Matthias Nott
2026-03-08 dbb6bf09b013937b5903844f8aa567ef4ee69555
refs
author Matthias Nott <mnott@mnsoft.org>
Sunday, March 8, 2026 06:45 +0100
committer Matthias Nott <mnott@mnsoft.org>
Sunday, March 8, 2026 06:45 +0100
commitdbb6bf09b013937b5903844f8aa567ef4ee69555
tree 4aecc20ddb7da98a69bf848745e115a991a32e64 tree | zip | gz
parent 3c02569a045aa5303f97142893f7cfef86eaf9b3 view | diff
fix: cross-session message routing — stale closure + autoplay bugs

Root cause: switchSession and syncActiveFromSessions captured stale
`messages` from React closure, then overwrote messagesMapRef (which
was already correct) with stale data on session switch. This caused
messages to appear in wrong sessions or disappear entirely.

Fix: replace all nested setActiveSessionId-as-getter patterns with
an activeSessionIdRef that's always current. All message mutators
now read the ref directly instead of relying on closure captures.

Also fixes:
- Voice autoplay now checks if message is for active session
- Eliminates 6 nested setActiveSessionId callbacks (cleaner code)
1 files modified
changed files
contexts/ChatContext.tsx diff | view | blame | history