Repository navigation
fix(persistence): a session write cannot bring back a tab its partition recorded as closed - #27125
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to Closed tabs are now kept from reappearing. However, when the same tab ID exists in two worktrees, the surviving tab can lose its layout and session binding. Make that cleanup worktree-aware before merging. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2b74935f-f0d3-41d6-b2da-253befeb9547
📥 Commits
Reviewing files that changed from the base of the PR and between 4ec973f and 18dc3190fbaa80cd4a4f3f65bc78947d4b9e31a2.
📒 Files selected for processing (6)
src/main/persistence/closed-terminal-tab-write-fence.test.tssrc/main/persistence/closed-terminal-tab-write-fence.tssrc/main/persistence/loading-store/session-host-partitions.tssrc/main/persistence/loading-store/session-snapshot-operations.tssrc/main/persistence/loading-store/workspace-session-snapshot-publication.tssrc/main/runtime/orca-runtime-terminal-close-records.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| next = closeTerminalTabInWorkspaceSession(next, record.worktreeId, tabId, { | ||
| force: true | ||
| }).session |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Keep metadata for a same-ID tab in another worktree.
If a snapshot lists tabId in both worktrees, this call closes the recorded worktree's row. closeTerminalTabInWorkspaceSession also deletes the tab ID's global layout, remote-session binding, and sleeping records. The other worktree keeps its tab row but loses that metadata. Make the cleanup account for a surviving same-ID tab before applying the worktree-scoped fence.
…on recorded as closed Main records every terminal close, but only PTY bindings and orphan adoption honoured the record. A renderer save that still listed the tab (when no topology revision fenced it yet), a relay write, or a fast unified-tabs patch could write the closed tab back. Every full write and unified-tabs patch now removes tabs the same partition has a live close record for, scoped to the record's worktree. Rollback stays exempt.
…nal maps A host slice with no terminal rows omits tabsByWorktree, and the forced close transform indexed it, so a browser-only save to a partition with a live close record threw and never persisted. Close only tabs actually listed, with the terminal maps supplied.
8fb6e91 to
a9d9f99
Compare
ELI5
When you close a terminal tab, the app saves a note saying "this tab is closed". Some saves ignored that note and wrote the closed tab back, so it returned after a restart. Now every save checks the note first.
What Changed
closedTerminalTabTombstonesByTabId). Only two writers respected that record: PTY bindings and orphan adoption. Three kinds of write could put a closed tab back:unifiedTabs-only patch, which skips full normalization.unifiedTabspatch removes the terminal tabs the same partition has a live close record for. The removal is a full forced close of that tab: row, layout, unified tab, group order, active tab and sleeping records. It uses the same transform the close transaction uses.dropClosedTerminalTabs(session)insrc/main/persistence/closed-terminal-tab-write-fence.ts. It runs right afterpreserveRuntimeAuthoredWorkspaceSessionFieldsat that function's two call sites, and on theunifiedTabsfast patch lane.Why
unifiedTabspatch lane gets a filter instead of full normalization. Full normalization on every tab-activation patch would cost far more than this lookup.Linked Issue
Refs #12447: this is the residual write-side half. The leftover SSH lease and relay slot items in that issue belong to another cluster.
Visual Proof
N/A: persistence-only change with no UI change.
Testing
New
src/main/persistence/closed-terminal-tab-write-fence.test.ts, on a real SQLite store with reload. It covers a late local or SSH renderer save that still lists a closed tab, and aunifiedTabs-only patch: onorigin/mainall three fail. A same-id tab under another worktree is kept.One existing test in
orca-runtime-terminal-close-records.test.tsrelied on a listed tab sitting next to its own close record. That state is now impossible to write, so the test now checks that the write drops the tab and keeps the record.src/main/persistence(the 3 profile-state backup timeouts also fail onorigin/mainon this machine), the runtime close suites, andorca-runtime.test.ts.pnpm tc, oxlint, andpnpm run check:code-quality:changed.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Main-only and partition-local: a record in one partition never suppresses a row in another. No wire change. SSH partitions get the same rule. A client's own close records in its
ssh:partition already suppress host rows in the renderer merge, so this matches that rule.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)