| 370 | * fresh PTY w/ scrollback restore in S5). |
| 371 | */ |
| 372 | export async function resumeSession( |
| 373 | wsId: string, |
| 374 | sessionId: string, |
| 375 | terminalTheme?: TerminalThemeVariant, |
| 376 | ): Promise<SpawnedSession | null> { |
| 377 | const body: Record<string, unknown> = {}; |
| 378 | if (terminalTheme !== undefined) body['terminalTheme'] = terminalTheme; |
| 379 | const res = await fetch( |
| 380 | `/api/workspaces/${encodeURIComponent(wsId)}/sessions/${encodeURIComponent(sessionId)}/resume`, |
| 381 | { |
| 382 | method: 'POST', |
| 383 | ...(Object.keys(body).length > 0 |
| 384 | ? { |
| 385 | headers: { 'content-type': 'application/json' }, |
| 386 | body: JSON.stringify(body), |
| 387 | } |
| 388 | : {}), |
| 389 | }, |
| 390 | ); |
| 391 | if (!res.ok) return null; |
| 392 | return (await res.json()) as SpawnedSession; |
| 393 | } |
| 394 | |
| 395 | /** Permanently remove a session record (kills PTY first if running). */ |
| 396 | export async function deleteSession(wsId: string, sessionId: string): Promise<boolean> { |