Repository navigation
chore: implement caching for session lists, details, and chat history with react query - #1479
Merged
harshil-2096 merged 15 commits intoDec 3, 2026
Conversation
… with react query
…ession-listing-and-chat-page-to Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # packages/trueforge-ui/src/containers/ThreadContainer.tsx # packages/trueforge-ui/src/containers/ThreadListContainer.tsx
…ectors load The gate and warning waited on the aggregate catalog flags, so a slow skills or MCP request left Send enabled for a saved chat whose model was dropped. Gate on the models query alone via modelsSettled. Co-authored-by: Cursor <cursoragent@cursor.com>
harshil-2096
marked this pull request as ready for review
November 30, 2026 12:27
harshil-2096
requested review from
govindavashishtha,
qaifi-tf and
sajal-truefoundry
as code owners
November 30, 2026 12:27
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7a9e65b. Configure here.
…and useShareSessionDialog
…to' of github.com:truefoundry/trueforge into harshil/age-2926-migrate-session-listing-and-chat-page-to
sajal-truefoundry
approved these changes
Dec 2, 2026
harshil-2096
enabled auto-merge (squash)
December 3, 2026 03:55
harshil-2096
deleted the
harshil/age-2926-migrate-session-listing-and-chat-page-to
branch
December 3, 2026 04:01
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.

Summary
Moves the Sessions list, session detail, session history, and share-dialog grants onto React Query. Session caches are scoped per server, so a server swap can't leak another account's data.
What changed
packages/trueforge-ui/src/server/sessionQueries.tswraps the session server port. Detail uses a 30sstaleTime, or 0 while the last turn is running. History is cached byupdatedAtversion.updatedAtthan the cached detail.src/server/queryClient.tshashes keys with the server scope and rescopes on server swap. AisCurrentScopeguard stops a swapped-out server's list result from being cached.src/atoms/agent-details/AgentSessions.tsxusesuseInfiniteQuerywith keyset pagination. It polls every 30s while any session isrunningorpaused(src/atoms/lib/sessionListPoll.ts).ThreadListContainer.tsxpolls only the first page and skips the open thread, whose status comes from the live stream.src/hooks/useShareSessionDialog.tsreads grants withuseQuery. Permission, invite, and remove are mutations with optimistic updates. Invite responses are merged, not replaced, so a concurrent tenant grant isn't overwritten. Grants are revalidated once no other grant mutation is in flight.packages/assistant-ui-runtime/src/dedupeInflightBySession.tsshares in-flight session loads. It is used byloadSessionSnapshot.tsanduseTrueForgeAgentMessages.ts.src/server/sessionListCache.tsand its test.Closes AGE-2926
Changes
How was this tested?
Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,python/trueforge_sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
Medium Risk
Touches session loading, caching, and account-switch boundaries across chat, sessions browser, and sharing—incorrect scope handling could leak or stale data, but behavior is heavily covered by new tests.
Overview
Replaces ad-hoc session list caching and local React state with TanStack React Query on the server-scoped query client. Session lists (infinite pagination + live-turn polling), detail, event timelines, and share access grants are cached, invalidated on mutations, and scoped so data from a prior server/account cannot be served after a swap.
The runtime
withSessionListCachewrapper is removed in favor ofwithSessionQueries, which wraps list/detail/history reads and ties cache writes toserverQueryScope.AgentSessionsand related shells consume queries directly; failed background refetches keep the last good UI.Assistant-ui-runtime dedupes in-flight
getSession/ snapshot loads by server + sessionId (WeakMap), anduseTrueForgeAgentMessageskeeps the transcript when re-opening a thread but clears it on server change.Draft catalog exposes
modelsSettledso send/composer gating depends only on models (not skills/connectors). Share dialog uses query mutations with optimistic updates and targeted rollback.Reviewed by Cursor Bugbot for commit 958164e. Bugbot is set up for automated code reviews on this repo. Configure here.