fix: prevent session creation loop without backend #42

Merged
shahondin1624 merged 1 commits from fix/session-creation-loop into main 2026-03-12 16:41:41 +01:00

Summary

  • Make getOrCreateSession idempotent: return existing active session when called with no ID instead of always creating a new one
  • Use untrack() in the $effect to sever SvelteMap dependency — effect now only re-runs on $page changes, not on every map mutation
  • Disable SSR on client-only routes, reduce preload aggressiveness from hover to tap, skip retries when already disconnected

Test plan

  • Clear localStorage, run npm run dev without backend → only ONE "New Chat" session appears
  • Refresh the page → no additional session created
  • Navigate away and back to /chat → still only one session
  • Click "+ New Chat" → second session IS created
  • Switch sessions via sidebar → messages sync correctly
  • npm run check, npm run lint, npm run build all pass

🤖 Generated with Claude Code

## Summary - Make `getOrCreateSession` idempotent: return existing active session when called with no ID instead of always creating a new one - Use `untrack()` in the `$effect` to sever SvelteMap dependency — effect now only re-runs on `$page` changes, not on every map mutation - Disable SSR on client-only routes, reduce preload aggressiveness from `hover` to `tap`, skip retries when already disconnected ## Test plan - [ ] Clear localStorage, run `npm run dev` without backend → only ONE "New Chat" session appears - [ ] Refresh the page → no additional session created - [ ] Navigate away and back to `/chat` → still only one session - [ ] Click "+ New Chat" → second session IS created - [ ] Switch sessions via sidebar → messages sync correctly - [ ] `npm run check`, `npm run lint`, `npm run build` all pass 🤖 Generated with [Claude Code](https://claude.com/claude-code)
shahondin1624 added 1 commit 2026-03-12 16:41:26 +01:00
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>
shahondin1624 merged commit cfd338028a into main 2026-03-12 16:41:41 +01:00
shahondin1624 deleted branch fix/session-creation-loop 2026-03-12 16:41:41 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: llm-multiverse/llm-multiverse-ui#42