You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[high] Session cache update writes a stale session list #378
A user sends a message in a chat screen that has stayed open while the chat list changed, for example new chats were created, chats were renamed, or the list was still loading when the screen opened.
Effect
The saved chat list is replaced with an old copy, so the sidebar can lose newer chats, show old names, or show only the current chat until the list is fetched again.
Evidence
Lines 1174-1215: the cache updater reads existing into cachedSessions but then returns [{...}, ...sessions] (line 1199) and sessions.map(...) (line 1203), using the render-time sessions variable. The callback's dependency list is [queryClient] (line 1214), so sessions is frozen at the value from the first render of the chat screen.
Skeptic note
Confirmed: upsertSessionInCache (chat-screen.tsx 1174-1215) reads the cache into cachedSessions but returns arrays built from the render-scope sessions (lines 1199, 1203), while useCallback deps are only [queryClient], so sessions is frozen at the first render (possibly an empty list while loading). It is called on every send from use-composer-send.ts:264. The array it writes is also the derived list from useChatSessions (sorted, tombstone-filtered, title-merged, with a possible made-up entry), not the raw cache.
Activity