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);