Repository navigation
fix(terminal): a background tab whose process exits closes as a process exit, not a user close - #34083
Conversation
Walkthrough
Priority: Merge Risk:
|
This comment has been minimized.
This comment has been minimized.
e23e5fe to
d02ddb5
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

Minor · Use the resolved PTY-exit reason for last-tab deselection. · terminal-tab-actions.ts:228
src/renderer/src/components/terminal/terminal-tab-actions.ts:228
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUse the resolved PTY-exit reason for last-tab deselection.
The parked PTY watcher passes only
hostCloseReason: 'pty-exit'. The close function resolves that reason for local closure, but this branch checks onlyoptions.reason. For the last renderable tab, this can treat a process exit as a user clear and select the wrong worktree successor.🐛 Suggested fix
+ const resolvedCloseReason = + options?.reason ?? (options?.hostCloseReason === 'pty-exit' ? 'pty-exit' : undefined) closeLocalTerminalTabState(terminalTabId, { - reason: options?.reason ?? (options?.hostCloseReason === 'pty-exit' ? 'pty-exit' : undefined), + reason: resolvedCloseReason, ... - } else if (options?.reason === 'pty-exit') { + } else if (resolvedCloseReason === 'pty-exit') {

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d7648c99-120b-4292-a007-cc19ca71c2d1
Files selected for processing: 2-
src/renderer/src/components/terminal/terminal-tab-actions-unrouted-close.test.tssrc/renderer/src/components/terminal/terminal-tab-actions.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
…-exit, not a user close The parked watcher passes only hostCloseReason 'pty-exit' (so the pinned guard still applies), and the local branch then let closeTab default the reason to 'user': a process exit wrote a user tombstone and retired the session. The local close now carries the pty-exit reason. Co-Authored-By: Claude <[email protected]>
d02ddb5 to
be887d7
Compare
ELI5
When a terminal tab you weren't looking at had its program exit, for example because its WSL distro was shut down, Orca closed it as if you had clicked Close. That threw away the terminal's saved session, so it couldn't come back. Now that exit is recorded as what it is: a process exit.
What Changed
closeTerminalTab(tab, { hostCloseReason: 'pty-exit' }). For a local tab,closeTerminalTabpassed noreasontocloseTab, which defaults to'user'. So a process exit wrote a user-close tombstone, committedclose_tabin main and retired the tab's session. The same exit in a visible tab usesreason: 'pty-exit'and does none of that.closeTerminalTabuses'pty-exit'when the caller passed onlyhostCloseReason: 'pty-exit'. The background tab closes the same way a visible one does.closeTerminalTaband not the watcher: the watcher sends onlyhostCloseReasonon purpose. Passingreason: 'pty-exit'from the watcher would skip the pinned-tab confirmation thatcloseTerminalTabapplies to every other reason. A test (keeps the pinned confirmation guard for a hostCloseReason pty-exit close) holds that guard. Paired-host closes still carry no local reason, as before.Why
Found in verify-15a (5e):
wsl --terminatekilled a background bridge tab's shell. The tab was closed as a user close, its session was retired, and the next launch opened a new session even though the old checkpoint was still on disk. The follow-up PR keeps such tabs entirely when the distro itself is gone. This one makes any background process exit stop posing as a user close.Linked Issue
Internal: WSL via orcad, verify-15a 5e.
Visual Proof
N/A. This changes the close reason recorded for a background tab whose process exits, with no visible difference. Covered by unit tests.
Testing
terminal-tab-actions-unrouted-close.test.tschecks that a local tab closed withhostCloseReason: 'pty-exit'reachescloseTabwithreason: 'pty-exit'. It fails without the fix, and I ran it that way. The existing pinned-guard test still passes.pnpm tc:web, the touched terminal-tab suites (87 tests) andcheck:code-quality:changedpass.User risk: low. It affects any user whose background terminal's process exits. The tab still closes as before; only the recorded reason changes, from "user" to "process exit". A tab closed this way is no longer recorded as one the user chose to close.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Renderer-only. No SSH, wire or platform-specific change.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)