Repository navigation
fix(daemon): hand off slept v29 history to v30 - #11423
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between be729f214f3bc03857b50a3b5b2979524d06c6b5 and 30fa9e6. 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a history-handoff predicate for legacy and current daemon adapters. Updates 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/daemon/daemon-pty-adapter.test.ts (1)
2386-2410: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winRestore the warning spy on every test path.
If
spawn()or an assertion throws beforewarn.mockRestore(),console.warnstays mocked and can affect later tests; Vitest config has no suite-wide mock restoration. Wrap the spawn and assertions intry/finally.Proposed cleanup
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) - const result = await historyAdapter.spawn({ cols: 80, rows: 24, sessionId }) + try { + const result = await historyAdapter.spawn({ cols: 80, rows: 24, sessionId }) ... - warn.mockRestore() + } finally { + warn.mockRestore() + }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cf68fdec-8eab-40a6-9056-efef3359038a
📒 Files selected for processing (2)
src/main/daemon/daemon-pty-adapter.test.tssrc/main/daemon/daemon-pty-adapter.ts
Greptile SummaryThis PR implements history handoff from slept legacy v29 sessions to the v30 daemon, replacing a warn-only approach. When a session owned by a pre-v30 daemon is intentionally slept (
Confidence Score: 5/5Safe to merge — the change is gated behind a precise four-condition predicate and all prior keepHistory paths are provably unchanged. The migration path fires only when keepHistory is true, the owning adapter is a different object from current, and a strict version boundary is crossed in both directions. The identity guard on sessionAdapters.delete handles the concurrent-onExit edge case correctly. All existing keepHistory scenarios retain their original behaviour, verified by both the existing suite and two new unit tests. The integration regression test uses real daemon sockets and asserts the full chunk-protocol sequence and authoritative-buffer recovery end-to-end. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/daemon/daemon-history-handoff.ts | New pure helper that encapsulates the four-way version-boundary predicate for history migration; logic is correct and well-tested. |
| src/main/daemon/daemon-pty-router.ts | Shutdown now conditionally releases the legacy route and ackColdRestore on migration; identity guard handles concurrent onExit; all other keepHistory paths unchanged. |
| src/main/daemon/daemon-pty-router-history-handoff.test.ts | New integration test exercises the full sleep/wake handoff with real sockets and large history, verifying chunk protocol and authoritative buffer recovery. |
| src/main/daemon/daemon-pty-router.test.ts | Adds two unit tests for the migration (successful rerouting) and failure preservation (route kept on checkpoint error) paths; existing tests are unaffected. |
Reviews (2): Last reviewed commit: "fix(daemon): hand off slept legacy histo..." | Re-trigger Greptile
be729f2 to
30fa9e6
Compare
Co-authored-by: Orca <[email protected]>
Description
When a session owned by a preserved pre-v30 daemon is intentionally slept, wait for its final checkpoint and then release its legacy route. On wake, the current v30 daemon reads the shared checkpoint and transfers large history through the bounded chunk protocol.
This replaces the warning-only approach. Live legacy sessions remain on their original daemon and are not interrupted.
Why
Protocol v30 has not shipped yet, so no released build currently has this regression. The compatibility boundary still matters for the first v30 release because stable v29 daemons and their live sessions survive an Orca update.
#10647's bounded history-transfer protocol is the correct root fix for oversized NDJSON messages. The degradation came from a stale router assumption:
keepHistoryretained the old daemon route because history was once assumed to be adapter-specific. Current and legacy adapters now share the same history directory, so a successfully checkpointed sleeping session can safely wake on v30.Failure safety
User behavior
After sleep/wake, users see their restored scrollback above the fresh shell. Unlike the previous renderer-only fallback, that history is also present in the daemon's authoritative buffer and remains recoverable after another remount or reload.
Proof
The new two-daemon regression starts a real v29 server, writes a history seed over 1 MiB, sleeps the session, and wakes it through a real v30 server. It verifies:
startHistorySeedTransfer,appendHistorySeedTransfer, andfinishHistorySeedTransfer;Additional unit coverage verifies successful rerouting and failure preservation.
Validation:
Made with Orca 🐋