Close only this WebCRT window's sessions on leave; require manual reconnect.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-06 10:20:08 +08:00
parent 938cd39c06
commit 4ea3b737f2
2 changed files with 77 additions and 118 deletions

View file

@ -665,6 +665,21 @@ export const closeWebcrtSession = (sessionId: string) =>
`/v1/webcrt/sessions/${encodeURIComponent(sessionId)}`,
);
/** Best-effort close during tab/window unload (fetch keepalive survives navigation). */
export function closeWebcrtSessionsKeepalive(sessionIds: string[]): void {
const ids = [...new Set(sessionIds.map((id) => String(id || "").trim()).filter(Boolean))];
if (!ids.length) return;
const headers = authHeaders();
for (const id of ids) {
const path = `/v1/webcrt/sessions/${encodeURIComponent(id)}`;
try {
void fetch(path, { method: "DELETE", headers, keepalive: true });
} catch {
/* ignore unload failures */
}
}
}
export type WebcrtSftpItem = {
name: string;
size: number;