fix(chat): resume sessions with cursor-based history catch-up - #23
andrebrait wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe session hook now reloads saved transcript state before classifying empty agent completions. It tracks entries from before each run, preserves provider errors, avoids reusing older answers, and keeps recovery active when transcript loading fails. ChangesAgent recovery
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Browser
participant useAgentSession
participant SessionTranscript
Browser->>useAgentSession: visibilitychange or agent_end
useAgentSession->>SessionTranscript: loadSession()
SessionTranscript-->>useAgentSession: saved assistant content or error
useAgentSession->>useAgentSession: finishPromptWithoutStream()
Suggested reviewers: Merge Risk: ⚪ Minimal · up to Saved-response recovery and its failure paths are covered by the updated tests. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🟡 Changes recommended
A critical race can associate a new prompt with the previous run’s saved response before transcript state refreshes.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Improves recovery of saved assistant responses when terminal events are missed.
Changes:
- Reloads transcripts before classifying empty responses.
- Tracks entry IDs and retries failed reloads.
- Adds regression tests and changelog documentation.
File summaries
| File | Summary |
|---|---|
hooks/useAgentSession.ts |
Implements saved-response recovery and entry tracking; a critical stale-entry race remains. |
hooks/useAgentSession.rpc.test.mjs |
Adds recovery and failure-path tests. |
CHANGELOG.md |
Documents the recovery behavior. |
Review details
Suppressed comments (1)
hooks/useAgentSession.ts:2396
- The same stale-
entryIdswindow affectsabort_and_prompt: the interrupted run may already have persisted entries while the ReactentryIdsstate still reflects the pre-run transcript. If the replacement prompt is not yet persisted, recovery can treat the interrupted run's assistant response as the replacement's answer. Capture committed transcript IDs rather than this potentially stale state snapshot.
runPreviousEntryIdsRef.current = entryIds;
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Upstream kahme247#94 merged its original recovery fixes. The incremental cursor catch-up work is being moved to a new follow-up PR on the current upstream base, including the now-merged kahme247#61 behavior. Closing this review-only mirror without merging it. |
Companion review-only PR for kahme247#94. Base remains pinned to upstream/main a0881e1 so bot reviews cover the same diff. Do not merge this mirror.
Summary
Persisted-entry cursor catch-up for active/idle resume, bounded pages and branch/compaction reset; current partial/tool snapshots with stream epochs and selective domain ordering. Completed history is fetch-since-only while SSE keeps live output flowing. Completions during a held read queue a reread from the advanced cursor; delayed persistence comes through the existing file watcher. Earlier false-warning and rapid-send/interrupt fixes are retained.
Verification
741 tests passed, 1 existing skip; typecheck and lint passed. Explicit concurrent-completion races (persistence before/after held reply) pass. Real Chromium mobile HTTP/SSE/native-fixture smoke closes the stream, recovers entries 4/5/6 after cursor 3 without resending the prefix, restores a quiet partial without token replay, and commits the final answer once. Internal condensed adversarial review found no blocking issues.
No new dependencies or native OMP changes. Matching frontend/API deployment required; not deployed by this change.