fix(api): persist final heartbeat state after execution settlement - #6594
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🤖 The AI agent says: @coderabbitai review Please review e3cecf0 for heartbeat completion correctness and preserved takeover/watchdog fences. Eight real Postgres regressions pass, including the blocked-on-sweep race. Live local browser verification confirms the session list now agrees with the idle snapshot and the observer activity indicator clears. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe session stream mirror now recognizes terminal executions only when ChangesSession stream settlement persistence
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change allows a session’s final idle heartbeat to persist after execution settlement while continuing to prevent late active updates from reviving settled, replaced, or watchdog-collapsed sessions. The covered persistence cases show no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 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 |
|
✅ Action performedReview finished.
|
Railway Preview Environment
Updated at 2026-09-06T02:48:55.189Z |
Context
After an agent finished, another browser could keep showing activity dots because the project session list still reported it as running. The individual session snapshot already said idle. The heartbeat database guard treated every execution row as terminal, although approval continuations create active rows upfront, and rejected the final idle update after settlement.
Changes
Treat only execution rows with a terminal outcome as settled. Allow the final non-running heartbeat to mirror completion after settlement, while retaining the same-turn and previously-live row checks. Late running heartbeats still cannot revive a settled execution or a row collapsed by the watchdog.
Tests
All eight real Postgres tests in the affected persistence suite pass. New cases cover active continuation rows, final idle updates, late running updates, replaced turns, and collapsed rows. The existing blocked-on-watchdog race also passes. Ruff format and lint pass.
A live local browser turn completed a read tool and returned its exact final answer once. The session detail, project list, and snapshot agreed it was idle, and the observer's activity dots disappeared with the frontend unchanged.
What to QA
Open the same session in two browsers, run a tool and let it finish, and verify both clients settle. Repeat after an approval continuation. Stop and a later turn must still preserve session ownership.