fix: prevent session creation loop when running without backend

Make getOrCreateSession idempotent by returning the existing active
session when called with no ID, instead of always creating a new one.
Use untrack() in the $effect to sever SvelteMap dependency so it only
re-runs on $page changes. Disable SSR on client-only routes, reduce
preload aggressiveness, and skip retries when already disconnected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shahondin1624
2026-03-12 16:41:08 +01:00
parent d7d1d9fd57
commit a5bc38cb65
6 changed files with 30 additions and 2 deletions

View File

@@ -67,6 +67,10 @@ function createSessionStore() {
saveActiveSessionId(id);
return sessions.get(id)!;
}
// No specific ID — prefer existing active session
if (!id && activeSessionId && sessions.has(activeSessionId)) {
return sessions.get(activeSessionId)!;
}
return createSession(id);
}