fix(terminal): reconcile tabs with server sessions and keep shown terminals alive
The tab list lived only in per-tab sessionStorage, so a new browser tab, another device, or cleared storage showed an empty terminal sidebar while PTYs kept running server-side, and orphans leaked until the idle sweep. Add GET /api/terminal/sessions and adopt unknown server sessions into the local tab projection (additive only; a failed listing changes nothing). The idle sweep also reaped terminals in background tabs because only the active tab holds a WebSocket attachment. Add POST /api/terminal/touch and have open clients periodically refresh activity for every session their tabs reference.
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
||||
restartTerminalSession,
|
||||
forceKillTerminal,
|
||||
listTerminalShells,
|
||||
listTerminalSessions,
|
||||
touchTerminalSessions,
|
||||
} from '@openchamber/ui/lib/terminalApi';
|
||||
import type {
|
||||
TerminalAPI,
|
||||
@@ -23,6 +25,14 @@ export const createWebTerminalAPI = (): TerminalAPI => ({
|
||||
return listTerminalShells();
|
||||
},
|
||||
|
||||
async listSessions(cwd: string) {
|
||||
return listTerminalSessions(cwd);
|
||||
},
|
||||
|
||||
async touchSessions(sessionIds: string[]) {
|
||||
await touchTerminalSessions(sessionIds);
|
||||
},
|
||||
|
||||
async createSession(options: CreateTerminalOptions): Promise<TerminalSession> {
|
||||
return createTerminalSession(options);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user