Repository navigation
fix(app): put new sessions in Recents right away - #229
Merged
Merged
Conversation
QueryProvider builds a fresh QueryClient on every render, and it was mounted twice: once in AppBaseProviders and again inside AppInterface's ServerShell. GlobalProvider sits above ServerShell, so ServerSync — and the home session index cache it owns — resolved the outer client, while everything under the router, the sidebar and home screen included, resolved the nested one. The index that session.created/session.updated write to therefore had no readers, and the list those events exist to keep fresh could only change when its own query refetched. In this fork that list is the persistent sidebar's Recents section, so a new session stayed missing from it until something remounted the observer — switching Code/Work and back reassigns the observer's key, which is why that looked like the fix. Work made it obvious because there is less incidental navigation there, but Code was affected the same way. Both AppInterface call sites already wrap it in AppBaseProviders, so the nested client was always redundant. Drop it: Recents now gains the row as the session is created, and picks up the generated title as soon as the model chooses one instead of waiting for the next reload. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Creating a session left the sidebar's Recents list unchanged. The session only turned up once something made that list reload — switching between Code and Work and back was the reliable way to do it.
Root cause
QueryProviderbuilds a newQueryClienton every render, and it was mounted twice:AppBaseProvidersinstalls one (client A)AppInterface'sServerShellinstalled a second one (client B), nested inside itGlobalProvidersits aboveServerShell, soServerSync— and the home session index cache it owns (context/global-sync/home-session-index.ts) — resolved A, while everything under the router, the sidebar and home screen included, resolved B.Confirmed live by tagging both clients in a dev build:
state=falseis the failure:homeSessions.apply()looks the index query up in A, where it does not exist, and returns early. Everysession.created/session.updatedevent was written into a cache with no readers, so the list those events exist to keep fresh could only change when its own query refetched. Switching Code/Work reassigns the sidebar observer's query key, which forces exactly that refetch — hence the workaround.Work made this obvious because there is less incidental navigation there to trigger a refetch, but Code was affected the same way.
refreshIndex()inhome-model.tsxkept working throughout because it runs on the reader's own client, which is why archive/rename/delete always refreshed.Change
ServerShellrendersSharedProvidersdirectly.QueryProvideritself is untouched and still installed once, byAppBaseProviders. BothAppInterfacecall sites (packages/app/src/entry.tsx,packages/desktop/src/renderer/index.tsx) already wrap it inAppBaseProviders, so the nested client was always redundant.Verification
Drove the real flow in a dev desktop build over CDP (sidebar "New session" → type → Enter) and read the sidebar DOM:
New sessionrow appears at the top of RecentsGreeting, the model-generated title, liveBefore the change the row never appeared. Titles now land in Recents as soon as the model picks one instead of waiting for the next reload.
bun typecheckclean inpackages/appandpackages/desktop;test:unit657 pass,test:browser69 pass. No automated regression test — the invariant is "ServerSyncand the components reading its queries resolve the sameQueryClient", which only a full-tree mount would catch, so this was verified by instrumenting the running app.Divergence recorded in
DIVERGENCES.md; user-facing note inCHANGELOG.md.🤖 Generated with Claude Code