From 757d04828befd4bd0a19dbdac54c7e633cb91a54 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Sat, 4 Apr 2026 03:53:39 -0700 Subject: [PATCH] =?UTF-8?q?feat(errors-error):=20=E2=9C=A8=20Introduce=20s?= =?UTF-8?q?ession=20recovery=20mechanism=20to=20detect=20and=20handle=20ex?= =?UTF-8?q?pired/invalid=20sessions=20with=20graceful=20user=20flow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- @applications/web/src/features/errors/sessionRecovery.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/@applications/web/src/features/errors/sessionRecovery.ts b/@applications/web/src/features/errors/sessionRecovery.ts index 9ec186c..87fe7d1 100644 --- a/@applications/web/src/features/errors/sessionRecovery.ts +++ b/@applications/web/src/features/errors/sessionRecovery.ts @@ -5,9 +5,14 @@ const SESSION_STORAGE_KEY = 'companion_session_id'; /** Module-level lock to prevent concurrent recovery attempts. */ let recoveryPromise: Promise | null = null; -export async function createSession(apiBaseUrl: string): Promise { +export async function createSession(apiBaseUrl: string, personaId?: string): Promise { try { - const res = await fetch(`${apiBaseUrl}/session`, { method: 'POST' }); + const body = personaId ? JSON.stringify({ persona_id: personaId }) : undefined; + const res = await fetch(`${apiBaseUrl}/session`, { + method: 'POST', + headers: body ? { 'Content-Type': 'application/json' } : undefined, + body, + }); if (!res.ok) throw new Error(`POST /session failed: ${res.status}`); const { session_id } = (await res.json()) as { session_id: string }; sessionStorage.setItem(SESSION_STORAGE_KEY, session_id);