Repository navigation
fix(site/src/api): abort chat history requests when the query is cancelled - #30542
Merged
Merged
Conversation
ibetitsmike
force-pushed
the
mike/chat-history-abort-signal
branch
from
October 9, 2026 11:32
cf99705 to
d51e219
Compare
ibetitsmike
marked this pull request as ready for review
October 9, 2026 11:32
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
DanielleMaywood
approved these changes
Oct 9, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Chat history requests now honor React Query's abort signal.
getChatMessagestakes an optionalsignal, andchatMessagesForInfiniteScrollpasses the query's signal to the first page request and to every turn fill request.Stack context
Stacked on #30524, which loads whole chat turns per history page by following the first page request with fill requests back to the turn's prompt.
Why
A review question on #30524 asked whether the fill loop bypasses React Query. It does not (the merged page is cached under
chatMessagesKeyand a refetch reruns the queryFn per page), but no history request received the abort signal, so a cancelled query kept its HTTP requests running. With this change, leaving a chat orcancelChatMessagesin the edit mutation aborts the in-flight page and fill requests. An aborted fill is caught by the existing catch/break, and React Query discards the result.Behavior change: because the queryFn now reads
signal, unmounting the last observer cancels and reverts an in-flight history fetch instead of letting it finish in the background.Testing
pnpm exec vitest run src/api/queries/chats.test.ts: 247 passed.aborts the page and fill requests when the query is cancelled; the existing first-request and per-page-cap assertions now expect the signal.pnpm lint:types,biome check --error-on-warnings,oxlint --deny-warningson touched files: clean. Pre-commit hook passed.Frontend review
frontend-reviewFE1 to FE10: all pass.coder-frontend-reviewround 1: SD1 (single-usehistorybinding in the new test) fixed. TN3 (wrap the factory ininfiniteQueryOptions) declined: the hand-typed queryFn context is pre-existing on main, and converting it would change the factory's type and every directqueryFncall in tests, which is outside this change. All other roles: no findings.