Repository navigation
fix(chat): cancel abandoned reads when a chat resumes - #2584
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Read scopes and deadlines src/lib/conversationRefresh.ts, src/lib/chatReadDeadline.ts, src/lib/chatReadDeadline.test.ts |
Replacing or stopping a ConversationRefresh reader aborts its active scope. withChatReadDeadline accepts an external signal and removes its abort listener during cleanup. Tests cover cancellation and listener cleanup. |
Signal-aware conversation API src/lib/api.ts, src/lib/machineContext.tsx, src/lib/conversationFetch.test.ts |
Transcript and conversation reads pass signals through bounded requests, adopted press reads, and session-change retries. Tests cover canceled requests, queued reads, and cache behavior after late responses. |
ChatView wiring and resume checks src/components/ChatView.tsx, scripts/chat-history-fixture.tsx, scripts/chat-history-browser-qa.ts, changelog.d/chat-resume-cancel-reads.md |
ChatView passes signals to conversation, gap-page, fallback, and older-page reads. Browser checks hide and restore the same mounted chat at 390px and 1440px and verify that fresh content appears. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- devswha/ovis#2562: Introduces press-prefetched conversation reads that this change makes cancelable by the adopting screen.
- devswha/ovis#1937: Invalidates in-flight older-page reads in ChatView, which this change also addresses through read-scope cancellation.
- devswha/ovis#2576: Binds conversation reads to pane sessions; this change adds cancellation to those same reads.
Suggested reviewers: devswha, kilhyeonjun
Merge Risk: 
Minimal · previous review d29cc
-
No actionable issue with the chat-read cancellation change remains identified. It is mergeable after normal checks.
Pre-merge checks: 
5
-
Full details: Description check
-
Explanation
The description includes the required Change and Validation sections. It explains the problem and behavior, lists executed checks and results, documents failures and skipped checks, and states that no HTTP/WS protocol changes were made.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 9 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
An older page still queued when its screen closes is now rejected before its callback runs, so the callback's finally never cleared loadingOlder and the loading state, and Load older stayed disabled until the history changed. The cancellation catch clears them while the page's generation is still current.
|
Thanks @bonecool999. Review (omo code reviewer + Codex) found no way for an abandoned read to write the cache or show another session, and the tests fail without the fix. One regression is fixed on your branch in 5e1f961 (main merged in first): an older page still queued when the screen closes is now rejected before its callback runs, so the callback's |
|
Merging after the 0.4.22 Release run with credit to @bonecool999. A chat tab that was hidden no longer waits up to 15 s (30 s remote) for an abandoned read when it comes back: newest-page, gap-fill, older-page and terminal-fallback reads are tied to the visible screen's lifetime and cancelled with it, even when the transport ignores abort, and a taken press read hands its cancellation to the one screen that adopts it. Merge-pass review: omo code reviewer (APPROVE) and Codex Terra xhigh. No path found for a cancelled read to write or purge the conversation cache, disturb the newest-read order or the session-bound cache, or show another session; the serial lane never runs two reads at once; the tests fail without the fix (six fail with the three fixed files reverted).
CodeRabbit did not review this head (its check shows skipping); the merge pass reviewed it. |
Change
Returning to a chat can wait for a request started before the chat was hidden. Recent tabs stay mounted, but
ConversationRefresh.stop()previously stopped timers without cancelling the active read, leaving the serial read lane occupied until the old request or its 15-second local / 30-second remote deadline settled.Tie newest-page, gap-fill, older-page and terminal-fallback reads to the visible screen's lifetime. Hiding or replacing the screen cancels that lifetime, including when the transport ignores abort, so the next visible read can start promptly. A pending press-read prefetch transfers its cancellation ownership to the one screen that takes it. Cancellation also reaches the existing single session-change retry.
Preserve #2576's pane/session cache ownership, stale-409 protection and bounded session retry. Signals are transport-only; there are no new HTTP/WS fields, settings, dependencies or server changes.
The lifecycle design follows the effect-owned fetch cancellation in Paseo's DocumentFrame, applied to Ovis's existing mounted-chat behavior from #1061. No code or visual assets were copied.
Validation
bun test src/lib/chatReadDeadline.test.ts src/lib/conversationFetch.test.ts src/lib/api.test.ts src/components/ChatFallback.test.ts: 80 passed, 0 failed. The same four files also passed inside the full-fast attempt.64ae5e72scheduler/deadline helpers, the controlled-clock regression fails because the replacement reader never starts while the obsolete request is held. The candidate passes that same case.bun scripts/chat-history-browser-qa.ts: the new same-mounted-key hide/return cases passed at 390px (83ms) and 1440px (69ms), with the obsolete HTTP request cancelled and fresh rows visible before it was released. These are controlled React/Chromium fixtures, not device or WAN timings. The whole existing script is not green: its later.chat-new-messageswait times out identically on the original64ae5e72source and the candidate; assertions and timeouts were not relaxed.bun run check fast: generated types/themes, typecheck and production build passed. The unit gate did not pass. There were failures in 15 files outside this patch; the finalserver/usage-login-private.test.tsprocess stalled for over five minutes and was interrupted through the check runner after the other 655 of 656 files completed. Owned recorded descendants were confirmed gone.64ae5e72source reproduced 22 of the 23 named failures from those 15 files. The additionalserver/remote-entry.test.tscase,reclaims a startup lock whose PID another process now holds, passed in the focused baseline and remains unexplained here. The original private-login file also exceeded a bounded 20-second comparison. These checks use the same Bun/dependencies butcheck runadds isolated XDG/config/state, whereasfastruns unit tests with the plain allowlisted environment; this is not an identical-environment full-suite comparison.check full, the full integration/browser lanes, WebKit/physical iPhone or native Windows checks.Files with local unit failures outside this patch
AI tools assisted implementation and static review.