Skip to content

fix: replace hardcoded sessionId with persistent per-conversation ID - #20

Merged
elijahgjacob merged 5 commits into
mainfrom
fix/bug4-session-id-persistence
Mar 12, 2026
Merged

fix: replace hardcoded sessionId with persistent per-conversation ID#20
elijahgjacob merged 5 commits into
mainfrom
fix/bug4-session-id-persistence

Conversation

@elijahgjacob

Copy link
Copy Markdown
Contributor

Summary

  • All 4 client templates now use useRef(crypto.randomUUID()) instead of hardcoded 'session-123'
  • Added useRef to the React import in all templates
  • Updated gravity://docs/js-sdk resource to show crypto.randomUUID() with reuse guidance
  • Added new troubleshoot KB entry for "hardcoded or rotating sessionId" with React and vanilla JS fixes
  • Updated prompt checklist: gravityContext() note now mentions sessionId stability
  • Narrowed gravity_context KB keywords (removed bare "session") to avoid false-positive collisions

Test plan

  • 61 unit tests pass (including test_all_entries_reachable with the new KB entry)
  • 22 smoke tests pass against local Docker
  • Verified FastAPI streaming client code has useRef, sessionRef.current, no session-123
  • Verified Next.js non-streaming client code has same fix
  • Verified troubleshoot("hardcoded session id") returns the new entry with useRef fix
  • Verified gravity://docs/js-sdk shows crypto.randomUUID(), no session-123

Made with Cursor

elijahgjacob and others added 5 commits March 12, 2026 14:15
All 4 client templates now use useRef(crypto.randomUUID()) for a
stable sessionId per conversation instead of hardcoded 'session-123'.
Added troubleshoot KB entry for hardcoded/rotating sessionIds.
Updated js-sdk docs and prompt checklist.

Made-with: Cursor
Templates now use currentUser.id instead of hardcoded 'user-456',
with a comment guiding publishers to plug in their own conversation
session ID and authenticated user ID. Updated docs and KB to match.

Made-with: Cursor
Templates now declare SESSION_ID and USER_ID as null! typed
constants so TypeScript will error at runtime if publishers
don't replace them. No more silent crypto.randomUUID() fallback
that masks missing identity wiring. Updated KB to match.

Made-with: Cursor
The gravity_context entry had generic keywords (session, sessionId,
422) that intercepted lookups meant for the new hardcoded-sessionId
entry. Narrowed to context-missing-specific keywords only.

Made-with: Cursor
@elijahgjacob
elijahgjacob merged commit 111c13e into main Mar 12, 2026
2 checks passed
@elijahgjacob
elijahgjacob deleted the fix/bug4-session-id-persistence branch March 12, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant