Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughWorkspace session parsing now salvages valid fields and entries from partially corrupt data. Local and host-partitioned repairs are logged and persisted. Browser hydration creates a fallback page when persisted pages are empty. Tab hydration repairs missing group ownership and expands incomplete layouts. Tests cover parser salvage, persistence repair, browser fallback pages, and tab-group restoration. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/main/persistence.test.ts (1)
12249-12280: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for a wholly unsalvageable partition.
This test proves the write-back for partitions that salvage successfully. No test covers the branch where
parseWorkspaceSessionSalvagingreturnsok: falsefor a partition. That branch skips the partition without settingsalvaged, so the corrupt partition is never removed from disk. See the comment onsrc/main/persistence.tsLine 576 for the root cause.Add a case that writes a non-object partition value, then asserts the profile file no longer contains that host key after
loadAndAwaitScheduledSave().src/shared/zod-salvage.ts (1)
8-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMake collector state reentrant-safe.
collectSalvageDropssaves a single global collector/path and clears them infinally. If parsed schema combinators nested these combinators, saving and parsing nested state would disconnect later diagnostics from the outer parse. Save and restore the previousdropCollectoranddropPathstack around the inner parse instead.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a0e49f6c-4743-4875-8510-b4998c4d5a5d
📒 Files selected for processing (14)
src/main/persistence.test.tssrc/main/persistence.tssrc/renderer/src/store/slices/browser.tssrc/renderer/src/store/slices/store-session-cascades.test.tssrc/renderer/src/store/slices/tab-group-reference-repair.tssrc/renderer/src/store/slices/tabs-hydration-group-validation.test.tssrc/renderer/src/store/slices/tabs-hydration.tssrc/shared/workspace-session-browser-schema.tssrc/shared/workspace-session-salvage.test.tssrc/shared/workspace-session-salvage.tssrc/shared/workspace-session-schema.test.tssrc/shared/workspace-session-schema.tssrc/shared/workspace-session-terminal-schema.test.tssrc/shared/zod-salvage.ts
Electron restart E2E proofA headful Electron test launched Orca with an isolated profile, created two named terminal tabs, shut down gracefully, injected one truncated sibling tab into the persisted workspace session, and relaunched the same profile. After restart, both valid tabs remained visibly rendered, the active terminal was usable, the main process emitted the bounded salvage warning, and the corrupt record was durably removed while the unified tabs remained on disk. The scenario passed twice consecutively. Remaining gap: this uses a local Electron profile and deterministic corruption injection; it does not reproduce the unknown original writer or exercise a live SSH transport. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/workspace-session-corrupt-tab-salvage.spec.ts (1)
126-130: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCompare the survivor IDs without depending on array order.
toEqualonunifiedTabIdsrequires the persisted order to match creation order. Tab reordering or sort-order changes then fail the test without a real regression.♻️ Order-independent comparison
await expect .poll(() => persistedSessionEvidence(session.userDataDir, worktreeId), { timeout: 30_000 }) - .toEqual({ corruptLegacyTabPresent: false, unifiedTabIds: survivorIds }) + .toEqual({ + corruptLegacyTabPresent: false, + unifiedTabIds: [...survivorIds].sort() + })Sort inside
persistedSessionEvidenceas well so both sides use the same order.unifiedTabIds: unifiedTabs .map((tab) => tab.id) .filter((id): id is string => typeof id === 'string') + .sort()
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0b761b5e-c818-4ea6-a313-49325adce3b5
📒 Files selected for processing (1)
tests/e2e/workspace-session-corrupt-tab-salvage.spec.ts

Summary
Fixes #12918 / STA-3604.
A single malformed record in the persisted workspace session previously made startup discard the entire session, including unrelated worktrees, tabs, layouts, browser state, and sleeping-agent resume records. Workspace-session schemas now salvage invalid array/map entries independently, log bounded diagnostics, and schedule a write-back so the repaired profile does not need to be salvaged again.
Partial salvage can leave dangling references, so hydration also re-homes tabs whose group was dropped, lays out every surviving group, and synthesizes a browser page when its persisted page list was emptied.
The original producer of the reported seven-field tab remains unproven. Direct SSH relay snapshots are a demonstrated ingress path because individual remote tab records are not runtime-validated, but this PR deliberately fixes the persistence blast radius for every corruption source rather than assuming a specific writer.
Screenshots
No product visual change. Headful Electron restart proof: #13431 (comment)
Testing
pnpm lintpnpm typecheckpnpm test— repository-wide run completed with 48,919 passing and 12 failures in five unrelated, untouched macOS/PTY/IME/relay test files; affected suites are greenpnpm buildFocused verification:
main: one truncated terminal tab rejects the complete session. It passes here and preserves every valid sibling/worktree.AI Review Report
Two independent post-implementation audits found no actionable correctness or regression issues. Reviews explicitly checked the old failure on
main, per-entry recovery, host partition isolation, write-back scheduling, dangling-reference repair, bounded diagnostics, exception cleanup, and foreign-payload rejection.Cross-platform review found no shortcut, label, path, shell, native-module, or Electron platform behavior changes. The implementation is platform-neutral TypeScript and applies identically to local, folder-workspace, runtime-host, and SSH partitions.
Security Audit
The diff adds no command execution, network endpoint, authentication, secret, dependency, IPC/RPC, or filesystem-path behavior. Persisted input continues through Zod validation; invalid entries are dropped, record reconstruction uses a null-prototype accumulator to prevent
__proto__poisoning, validator exceptions are contained, and diagnostic paths are capped at 100 without logging persisted values.Notes
The corrupt entry itself is intentionally lost; this changes the failure mode from losing the complete session to losing only data that cannot satisfy its schema. Tolerant parsing can make the original writer less visible, so salvage emits bounded warning diagnostics.
No mobile-facing protocol, RPC, pairing, route, relay-wire, or persisted mobile state is changed. Validating Direct SSH tab entries before renderer hydration is useful defense-in-depth but is separate from this recovery fix and is not required for persisted-state safety.
Reliability Contract
workspace-session.valid-sibling-preservation): one malformed independent persisted record may remove only itself, never valid sibling records or host partitions; surviving tabs, groups, layouts, and browser pages remain reachable, and repaired state is written once.2beaf6af21fails under the old all-or-nothing parser. The final branch preserves valid sibling worktrees and partitions, repairs references after partial salvage, and proves the repaired file is stable on a second load.startup-upgrade.persisted-session-corpus(experimental, no protection or executable command on main). Accepted gap: the reported producer and immutable production-fixture provenance remain unknown, so the PR uses deterministic schema and persistence fixtures rather than claiming production-corpus coverage.