[fix] Fetch remote-run records immediately and once more when the run ends [#5624] - #5629
[fix] Fetch remote-run records immediately and once more when the run ends [#5624]#5629mmabrouk wants to merge 1 commit into
Conversation
…n the run ends Claude-Session: https://claude.ai/code/session_01R1ExBrpDc3rFVeuwKw4ucs
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe session hydration hook now fetches remote-run data immediately. When ChangesRemote transcript hydration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web/oss/src/components/AgentChatSlice/hooks/useSessionHydration.ts (1)
237-240: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftAdd regression coverage for the new timing and cancellation paths.
Cover these cases:
runningElsewherestarts astrue: the first fetch starts without a 15-second delay.runningElsewherechanges fromtruetofalse: one final fetch adopts with{armJump: false}.sessionIdchanges: the falling-edge effect does not fetch the previous session.- Cleanup runs before
loadSessionMessagesresolves: neither callback adopts a transcript.Also verify that the poll timer is canceled and that a new session starts its own polling cycle.
Also applies to: 249-268
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e7b23556-6eba-4eec-86cb-cee3de010296
📒 Files selected for processing (1)
web/oss/src/components/AgentChatSlice/hooks/useSessionHydration.ts
Railway Preview Environment
|
Stopgap for #5624, per the triage decision: close the reported reproduction now with the two smallest possible changes; the real fix (a records-count endpoint, option A on the issue) is scheduled separately and retires both this patch's polling cost and #5609.
Context
Open the same session in two tabs, send a message in tab 1, switch to tab 2: tab 2 shows neither the message nor the answer, indefinitely. Archiving and unarchiving was the only workaround, because it remounts the conversation.
The watermark adoption guard from #5589 is correct. The gap is the triggers around the remote-run poll in
useSessionHydration.ts:setTimeout(poll, delay)at 15 seconds. Most turns finish sooner.runningElsewhereflips false. A run ending between ticks discards the pending fetch.Together: short runs were often fetched zero times. Full analysis and the backend fix ladder are on #5624.
Changes
Two changes in one file, both feeding the existing guarded adoption:
runningElsewhereflips from true to false, so records written between the last tick and the run's end still land. The previous-state ref also trackssessionId, so switching sessions cannot fire a spurious edge for the wrong session; and since adoption is guarded by the record watermark, an extra read is harmless by construction.Before: tab notices run at t=0, first fetch scheduled t=15s, run ends t=8s, fetch cancelled, transcript stale until remount.
After: fetch at t=0 (user message appears), ticks while running, one final fetch at t=8s (answer appears).
Tests
useSessionHydrationnor this poll has unit coverage (noted in A second open tab misses short runs: no refetch on focus, first poll tick at 15s, no final fetch when the run ends #5624). Verified by reading against the [fix] Rebase #5589 onto #5569 and fix the two blocking review findings #5608 review analysis of this exact effect; the deliberate non-dependency onadoptServerTranscriptis preserved.tsc/eslintcould not be run in this environment (no node_modules on the box); the PR CI TypeScript jobs cover both. The change uses only symbols already imported in the file.What to QA
Closes nothing; #5624 stays open for the scheduled records-count endpoint.
https://claude.ai/code/session_01R1ExBrpDc3rFVeuwKw4ucs