Skip to content

[high] Session cache update writes a stale session list #378

Open

Description

@Interstellar-code

Location: src/screens/chat/chat-screen.tsx:1203

Severity: high · Confidence: high

When

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.


Bug-hunt id: bh:cb9b6b62 · run: sweep:screens / slice screens · source: ~/.bughunt-data/repos/hermes-switchui/reports/2026-10-27-screens.json

Filed automatically from the 2026-10-27 bug-hunt sweep (report only, not yet triaged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions