Skip to content

fix(terminal): retire resume authority after a confirmed agent exit - #15666

Open
brennanb2025 wants to merge 15 commits into
mainfrom
brennanb2025/sta-4110-clean-exit-resume
Open

brennanb2025 wants to merge 15 commits into
mainfrom
brennanb2025/sta-4110-clean-exit-resume

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1720 $\color{#cf222e}{\Huge{\mathbf{−}}}$​39 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1681
Prod 49 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1180 $\color{#cf222e}{\Huge{\mathbf{−}}}$​347 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​833

ELI5

If you quit Claude on purpose and then close its terminal, Orca should not bring that finished session back with claude --resume the next time you open the app. Only sessions that were still alive when Orca quit should be restore candidates.

Put plainly: when you type /exit in Claude and get your shell prompt back, that conversation is
finished. Orca kept a "this session was interrupted, offer to resume it" note anyway, so the next
time you opened Orca it could bring the finished conversation back. This change tears up that note
once Orca has watched the agent cleanly exit — and only then. If Orca crashed, or lost contact with
a remote machine and genuinely can't tell what happened, the note is kept, because that is the case
resume exists for.

User-facing before / after

Before After
You quit Claude yourself (back at the shell prompt), close the tab, then reopen Orca The finished conversation was treated as interrupted and could be resumed for you The finished conversation is not a restore candidate; the tab comes back as a plain shell
Orca or your machine crashes with Claude mid-run Restored via resume Unchanged — still restored
The terminal dies unexpectedly under a running agent Restored via resume Unchanged — still restored
Claude is running on an SSH host and Orca can't read what's running there (link dropped, host unreachable) An unreadable answer could be taken as "the agent exited cleanly", quietly throwing away resume for a session that was still alive Loss of contact is treated as "can't tell", and resume is preserved
A different session in the same pane, or a session in another pane Could be caught up in the same cleanup Only the session that was proved to have exited is retired

When it bites

Anyone who runs Claude Code in an Orca terminal, quits it on purpose, and relaunches Orca — on any
platform. The SSH row bites whenever a remote connection drops while an agent is running there.

What Changed

  • Retire the pane's sleeping-session resume record only when a process-confirmed agent-exited fact matches the PTY incarnation and pane attribution.
  • Carry the PTY incarnation through fresh spawn and reattach before the mounted consumer binds; preserve it across mounted-to-parked handoff and late-fact buffering.
  • Clear same-provider-session legacy aliases in one store transition while leaving sibling sessions alone.
  • Keep unexpected PTY loss as crash recovery: a bare pty-exit tab close retains the record.
  • Treat disconnected or unavailable SSH foreground reads as unverifiable, not process death.
  • Apply the same provider-alias retirement policy after successful cold restore.

This supersedes #14534 and fixes the same lifecycle boundary without weakening crash recovery or remote-host safety.

Why

sleepingAgentSessionsByPaneKey is written while the agent is live and previously survived a clean, process-confirmed return to the shell. Closing the shell terminal intentionally preserves sleeping records for crash recovery, so a deliberately exited session could look interrupted and auto-resume on relaunch.

The authoritative signal is the existing main-process fact: the title returned to a shell, the execution host confirmed the foreground process is no longer the agent, the PTY incarnation still matches, and the pane attribution has not changed. Missing, stale, replayed, or unverifiable evidence fails closed by preserving recovery authority.

Reliability Contract

  • Invariant (agent-session.provider-ownership): a host-confirmed clean agent exit retires only that provider-session claim and its aliases; crash loss, stale incarnation, mismatched attribution, and unverifiable remote state cannot revoke resume authority.
  • Failure source: STA-4110 / [Bug]: Cleanly exited Claude session is auto-resumed with claude --resume after an app restart (local macOS, hibernation off) #14228.
  • Oracle: red/green producer and renderer tests plus a real local macOS Claude lifecycle through Electron CDP.
  • Gate: existing experimental agent-session.provider-ownership gate in config/reliability-gates.jsonc.
  • Coverage: local macOS and daemon behavior were exercised end-to-end; local/daemon/SSH/WSL/remote-runtime boundaries are covered by focused contracts, with live SSH, WSL, Linux, Windows, and paired-runtime journeys unrun.
  • Performance budget: no polling, subprocess, startup wait, or output-path work was added. Confirmed exit performs one bounded sleeping-record scan and one batched store transition; the existing handoff buffer remains capped by PTY count, batch count, and TTL.
  • Diagnostics: destructive facts carry execution-host confirmation, PTY incarnation, pane key, tab, and workspace attribution.
  • Residual gaps: physical Linux/Windows/WSL and live SSH/paired-runtime Electron journeys remain contract-only.

Linked Issue

Fixes #14228
STA-4110

Visual Proof

After launching Claude in a fresh terminal, sending /exit, returning visibly to Terminal 3, and exiting the shell, the target tab and provider-session record were both absent. A renderer reload restored only the two unrelated terminal tabs and did not issue claude --resume for the retired session.

STA-4110 after reload: retired Claude terminal remains absent

Testing

  • Failing-first fresh-spawn contract proved the incarnation was previously omitted from onPtySpawn; the regression test passed after propagation was added.
  • 9 focused renderer files: 136 tests passed.
  • Main runtime agent exit filter: 5 passed, 1207 skipped.
  • Real Electron/Playwright CDP lifecycle: fresh terminal → claude → /exit → visible shell → sleeping record absent → shell exit closed tab → reload kept target tab/session absent.
  • pnpm typecheck passed.
  • Changed-code quality: 0 new findings.
  • React Doctor changed scan: 0 issues.
  • Direct oxlint on changed files, oxfmt --check, max-lines ratchet, and git diff --check passed.

Review

  • Security/privacy: no new external input, privilege boundary, raw terminal data, or user content logging.
  • Cross-platform: no OS-specific paths, shell syntax, keyboard behavior, or native-module changes.
  • SSH/remote: loss of contact remains unverifiable; destructive retirement requires execution-host confirmation and matching authority.
  • Folder workspaces: retirement keys use workspace IDs and do not assume Git worktrees.
  • Mixed versions: new fact/connect fields are optional; missing incarnation or attribution preserves the record.
  • Performance: bounded existing handoff retention plus one exit-time alias scan; no new hot-path fanout.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is focused on STA-4110.
  • The clean-exit root cause and crash/remote boundaries are documented.
  • Automated red/green coverage and local Electron proof are included.
  • Cross-platform, SSH/remote, folder-workspace, mixed-version, and performance impact were reviewed.
  • Focused tests, typecheck, changed-code quality, React Doctor, formatting, max-lines, and diff checks pass.
  • Full repository test/lint/build remain for CI.

Author

  • X / Twitter: @BrennanKB5

@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change adds PTY incarnation identity to terminal contracts, connection results, callbacks, sessions, recovery data, parked-pane watchers, and agent-exited facts. Runtime exit confirmation now defers and revalidates candidates, rejects unverifiable or stale exits, and records host-confirmed exits. Renderer consumers validate PTY and pane attribution, buffer side-effect batches, and retire matching sleeping-agent resume records. Tests cover local and remote exits, PTY replacement, handoff behavior, cleanup ordering, and resume preservation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 37 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy [#14228] by retiring the affected sleeping-session record after a host-confirmed, attribution-matched clean agent exit while preserving records for crashes, stale PTYs, and unverif…
Out of Scope Changes check ✅ Passed The PTY incarnation propagation, handoff buffering, alias cleanup, remote-runtime handling, cold-restore behavior, and focused tests support the stated lifecycle and recovery requirements. No unrelate…
Title check ✅ Passed The title clearly and concisely describes the primary change: retiring resume authority after a confirmed agent exit.
Description check ✅ Passed The description follows the required structure and provides the problem, solution, issue link, visual proof, testing, review considerations, and checklist status. The AI Disclosure and Notes headings …
Full details: Linked Issues check

Explanation

The changes satisfy [#14228] by retiring the affected sleeping-session record after a host-confirmed, attribution-matched clean agent exit while preserving records for crashes, stale PTYs, and unverifiable remote exits.

Full details: Out of Scope Changes check

Explanation

The PTY incarnation propagation, handoff buffering, alias cleanup, remote-runtime handling, cold-restore behavior, and focused tests support the stated lifecycle and recovery requirements. No unrelated production changes are evident.

Full details: Docstring Coverage

Explanation

Docstring coverage is 17.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 37 files. (2 skipped: 2 too large.)

Full details: Description check

Explanation

The description follows the required structure and provides the problem, solution, issue link, visual proof, testing, review considerations, and checklist status. The AI Disclosure and Notes headings are not included, but the description is otherwise complete.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Atroci

Atroci commented Aug 22, 2026

Copy link
Copy Markdown

Additional sanitized confirmation from a Prime Agent integration (not a duplicate issue request). This appears to be the same generic lifecycle boundary covered by #14228 and this PR, but it is useful to record the Prime provider path explicitly.

Environment: Orca 1.4.183 on Fedora Linux x86_64; Prime Agent 0.7.3; Node.js 24.15.0. Prime is recognized as a resumable agent, and its reported session_file is the authoritative resume locator.

In the shipped Orca 1.4.183 bundle, a process-confirmed agent-exited event removes the PTY but does not retire the pane's persisted sleeping-agent resume record. On a subsequent cold restore, that record remains eligible and can recreate a Prime pane using the old session_file. In other words, Orca retains recovery authority after a confirmed clean exit; this is distinct from preserving a record after an ambiguous PTY loss, which is needed for crash recovery.

The important regression boundary for Prime is therefore:

  • confirmed local agent exit → retire the exact pane record and same-session aliases;
  • unexpected PTY loss → preserve recovery authority;
  • late exit facts after pane teardown → still retire the original pane record without touching sibling panes.

No credentials, transcript bodies, session IDs, or local paths are included here. A Prime-specific lifecycle fixture would make sure the generic fix also covers the provider whose resume locator is a session_file.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Codex revision complete.

Changed:

  • Replaced the parallel ptyId binding map and duplicate 15-second timer with the existing main-process paneKey attribution on late agent-exited batches.
  • Kept ordinary mounted and parked cleanup in the shared callback so byte parsing and main-fact authority stay behaviorally identical, while no-consumer late facts now retire safely.
  • Batched exact-pane and same-provider-session alias deletion into one store transition.
  • Added Prime Agent session_file identity coverage and an SSH race test where the host becomes unverifiable while a foreground read is pending.

Kept:

  • A bare PTY loss still preserves crash-recovery authority.
  • An unattributed, replayed, or unverifiable remote exit fact fails safe by preserving the record.
  • Sibling provider sessions remain untouched.

Non-vacuity proof with the late-fact retirement call neutered:

FAIL  pty-connection-main-side-effect-authority.test.ts
AssertionError: expected { …(10) } to be undefined
Received: providerSession.id = session-byte-mode
Test Files  1 failed (1)
Tests       1 failed | 16 skipped (17)

After restoring the product cleanup, the same acceptance filter passed: 1 passed | 16 skipped.

Verified:

  • Focused renderer suites: 6 files, 73 tests passed.
  • Main runtime agent exit filter: 5 passed, 1182 skipped.
  • Full main-authority suite: 17 tests passed.
  • pnpm typecheck passed.
  • Changed-code quality: 0 new findings.
  • React Doctor changed scan: 0 issues.
  • oxfmt --check and git diff --check passed.

No UI chrome changed, so Electron visual proof is not applicable.

brennanb2025 and others added 4 commits August 26, 2026 20:50
A clean Claude/shell exit left sleepingAgentSessionsByPaneKey in
state working, so relaunch treated it as a crash and spawned
claude --resume. Retire that pane's record when the host confirms
the agent returned to the shell, keep unexpected PTY loss for
crash recovery, and do not treat an unverifiable remote as exited.

Co-authored-by: erishforG <[email protected]>
The local mock declared Record<string, { paneKey: string }> while the test
builds a full SleepingAgentSessionRecord, so typecheck rejected the extra
properties.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-4110-clean-exit-resume branch from e03375d to 01b3368 Compare August 27, 2026 04:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/renderer/src/components/terminal-pane/pty-connection-main-side-effect-authority.test.ts (1)

477-490: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Assert the teardown call explicitly.

The confirmed fact at line 462 already clears both paneKey and duplicatePaneKey, because both records share session-1. The toHaveBeenCalledWith check and invocationCallOrder[0] therefore both resolve to that earlier call, so the onPtyExit step adds no verified behavior. Capture the mock call count before onPtyExit and assert against the specific call you intend to test.

src/renderer/src/lib/confirmed-agent-exit-resume-retirement.test.ts (1)

140-146: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make the remote test exercise an unverifiable exit.

This test seeds a record and asserts it exists. No exit fact is dispatched and no retirement function is called, so the test cannot detect a regression where an unverifiable remote exit retires the record. Dispatch an agent-exited fact for the remote PTY without executionHostConfirmed, then assert the record and the resume count are unchanged.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 892fd4a2-6a08-47ed-83b2-ad5df9bd394e

📥 Commits

Reviewing files that changed from the base of the PR and between ebcd637 and 01b3368.

📒 Files selected for processing (24)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/terminal-pane/ipc-pty-connect-result.ts
  • src/renderer/src/components/terminal-pane/ipc-pty-connect.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-confirmed-agent-exit-resume.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-cold-restore-agent-resume.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-main-side-effect-authority.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-pty-exit-teardown.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-test-store-fixtures.ts
  • src/renderer/src/components/terminal-pane/pty-connection-test-store-state.ts
  • src/renderer/src/components/terminal-pane/pty-connection/deferred-cold-restore-and-snapshot.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-pty-visibility-bind.ts
  • src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.ts
  • src/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.ts
  • src/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.ts
  • src/renderer/src/components/terminal-pane/pty-transport-reattach-admission.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/terminal-side-effect-fact-handoff.ts
  • src/renderer/src/components/terminal-pane/terminal-side-effect-facts-handler.ts
  • src/renderer/src/lib/confirmed-agent-exit-resume-retirement.test.ts
  • src/renderer/src/lib/confirmed-agent-exit-resume-retirement.ts
  • src/renderer/src/store/slices/terminal-tab-retirement-store.test.ts
  • src/shared/terminal-side-effect-facts.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Comment thread src/main/runtime/orca-runtime.ts Resolved
@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Review verification (exact final head 5b4b2e3): re-reviewed the same-PTY parked-watcher replacement across capture, reconciliation, handoff, and confirmed-exit authority. The replacement watcher now owns the new incarnation, stale/unknown/misattributed confirmed facts fail closed, and sibling panes remain untouched; the in-scope review is clean with no performance or platform-specific regression. Merge gate remains blocked pending CI and unresolved pre-existing reviewer threads outside this dispatched High finding; no merge performed.

@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

QA/evidence (exact final head 5b4b2e3): focused terminal lifecycle coverage passed (13 files, 198 tests), along with pnpm tc, changed-code quality, type-aware quality, React Doctor, oxlint pre-commit, oxfmt, and git diff checks. Electron CDP attached to the exact sta-4110-fix-r1 devRepoRoot, rendered Orca visibly with zero console errors, and captured /tmp/sta-4110-final-electron-proof.png; the host-confirmed old→new incarnation race is non-visual and remains unit-backed rather than claimed as an Electron journey. Mobile QA was not attempted, CI is pending, and no merge was performed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 54f1cb86-93fe-4b70-965f-9d0b4ce1d08a

📥 Commits

Reviewing files that changed from the base of the PR and between 01b3368 and 6084cd0.

📒 Files selected for processing (14)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-pty-binding.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-pty-visibility-bind.ts
  • src/renderer/src/components/terminal-pane/pty-connection/session-reconcile-dispose.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-expired-pane-recovery.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-pane-handle-resolution.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-pty-watcher.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-reconciliation.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-registry.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
  • src/shared/runtime-terminal-contracts.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/terminal-parked-watcher-reconciliation.ts (1)

97-117: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clear titles for replaced PTYs during restartAll.

A replaced PTY is excluded from retainedPtyIds but not included in retiredPaneIds. If restartAll is also true, its old “working” title remains after the new watcher starts. Include replacement pane IDs in the restartAll title cleanup.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b49c40b2-49d8-4d29-ba2c-e718fba69e6a

📥 Commits

Reviewing files that changed from the base of the PR and between 6084cd0 and 5b4b2e3.

📒 Files selected for processing (8)
  • src/renderer/src/components/terminal-pane/terminal-parked-pty-watcher.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-partial-reconciliation.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-reconciliation.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-reconciliation.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-registry.ts
  • src/renderer/src/components/terminal-pane/terminal-side-effect-facts-handler.test.ts
  • src/renderer/src/components/terminal-pane/terminal-side-effect-facts-handler.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts (1)

1461-1480: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Pass the incarnation ID through web-session rebinds.

This helper forwards incarnationId only when the caller supplies it. The web rebind paths at Line 1527 and Line 1663 still pass only the replacement handle, so onPtyRebind loses the replacement identity. The fail-closed tests in src/renderer/src/components/terminal-pane/terminal-side-effect-facts-handler.test.ts show that a confirmed exit without this identity is dropped, leaving the resume record eligible for restore. Resolve the replacement pane incarnation and pass it through both web rebind paths.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: da5f5ec1-8b3f-4c1d-9391-ef138610b8bc

📥 Commits

Reviewing files that changed from the base of the PR and between 5b4b2e3 and b91531e.

📒 Files selected for processing (9)
  • src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-confirmed-agent-exit-resume.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-test-store-fixtures.ts
  • src/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-resubscribe-failure-recovery-routing.test.ts
  • src/renderer/src/components/terminal-pane/terminal-side-effect-facts-handler.test.ts
  • src/renderer/src/components/terminal-pane/terminal-side-effect-facts-handler.ts
  • src/renderer/src/lib/confirmed-agent-exit-resume-retirement.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/runtime/orca-runtime.ts (1)

19739-19822: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Fix the staleness check so it also applies after the PTY disconnects.

confirmPtyAgentExit stores a pendingAgentExitCandidate on the tracker entry, then starts an async foreground-process read. When that read resolves, the code detects whether a newer event already settled or replaced the candidate, but only when current.connected is still true:

if (
  current.connected &&
  pendingCandidate &&
  trackerEntry?.pendingAgentExitCandidate !== pendingCandidate
) {
  return
}
...
if (!current.connected) {
  recordExit(true)
  return
}

If settlePendingPtyAgentExitOnCommandFinished already consumed this exact pendingCandidate (clearing it to null and recording an agent-exited fact with executionHostConfirmed: true), and the PTY then disconnects for real before this foreground read resolves, the staleness check is skipped because current.connected is false. Execution falls through to recordExit(true), which re-emits a second agent-exited fact for the same incarnation. recordExit's own guards (current !== pty, incarnation match, title match) do not catch this, because settlePendingPtyAgentExitOnCommandFinished never touches pty.lastOscTitleAt or pty.lastAgentStatus.

Move the staleness check ahead of the current.connected gate so it also protects the disconnected branch:

🐛 Proposed fix
       const current = this.ptysById.get(ptyId)
       if (current !== pty) {
         return
       }
-      if (
-        current.connected &&
-        pendingCandidate &&
-        trackerEntry?.pendingAgentExitCandidate !== pendingCandidate
-      ) {
+      if (pendingCandidate && trackerEntry?.pendingAgentExitCandidate !== pendingCandidate) {
         return
       }

Separately, settlePendingPtyAgentExitOnCommandFinished's attribution check compares connectionId in addition to worktreeId/tabId/paneKey, while recordExit's inline attribution check inside confirmPtyAgentExit does not. Consider extracting one shared validator for both call sites to prevent this kind of divergence.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 59929108-e718-41cc-9875-32eb7eabea72

📥 Commits

Reviewing files that changed from the base of the PR and between b91531e and 29c44cd.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Review verification — saved exact head

Verified PR head and remote branch at 858bed00e3abbd8f179e51561177edfad82e1738. Adversarial review and review-until-clean are CLEAN after fixing the mixed-version reused-PTY case where an omitted optional incarnation could leave stale process identity cached.

State-machine coverage includes intentional agent exit, confirmed shell/PTy exit, unexpected/unverifiable disconnect retention, Orca restart and process reattach, mounted/parked reconciliation, late exit facts, stale PTY incarnations, provider-session aliases, sibling panes, and local/SSH/remote/WSL/folder-workspace routing branches. The failing-first stale-incarnation boundary test failed exactly before the fix and passes now; focused exact-head verification includes 1230 passed / 1 skipped fresh, 1265 passed / 1 skipped broader focused coverage, Node 24 typecheck, changed/type-aware code quality, oxlint/oxfmt, and diff checks.

Perf audit is clean: no new polling, subprocess churn, startup waits, hot-path scans, or unbounded growth; exit-fact handoff stays bounded to 32 PTYs, 64 batches, and 15 seconds. Plain-language verdict: the implementation is sound and mergeable after the remaining required CI check completes; no proven in-scope code issue remains. Live non-macOS/remoting/package journeys remain QA confidence gaps, not hidden claims.

@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

QA evidence — exact head 858bed00e3abbd8f179e51561177edfad82e1738

Fresh isolated macOS Electron validation used Playwright CDP only. The app identity reported the exact worktree and SHA with zero renderer errors.

  1. Real Claude /exit returned Terminal 2 to its shell and immediately cleared sleepingAgentSessionsByPaneKey.
    Claude clean exit returned to shell
  2. Shell exit removed Terminal 2 and its PTY; the live sibling remained.
    Exited terminal removed while sibling remains
  3. After a cold Orca restart with the same isolated profile, the exited sibling did not reopen while the live Claude terminal visibly reattached with the same tab b8453d13-c75e-456b-b853-b8246e1ae8bc, PTY suffix c93cf351, and provider session c4e7a71c-2aac-4274-970a-ad9e6e6a748b.
    Live Claude terminal retained after cold reopen

Authoritative gaps before claiming 100% confidence: live SSH disconnect/reconnect, WSL, native Linux and Windows, paired mixed-version client/host, and packaged restart journeys. Local exact-head behavior and deterministic tests are high confidence, but do not substitute for those environments.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Host-validation follow-up — exact head 858bed00e3abbd8f179e51561177edfad82e1738

I exercised the reachable host lanes without changing the PR. Verdict vocabulary below is deliberately limited to live / unverifiable / exited; loss of contact was never treated as process death.

Arm Verdict Confirmed/intentional-exit branch Genuinely-live branch
Live SSH disconnect/reconnect VERIFIED After reconnect, an explicit close of only PTY ssh:ssh-1787870711577-72tx03@@pty-1 produced the sole exit event (code: 0, generation 2, incarnation 16102a14-e04f-4d8a-be4f-7546bbe63ed5); the PTY was absent afterward and did not reopen. Before transport loss the real openclaw /bin/bash PTY was live. window.api.ssh.disconnect changed inspection to unavailable with zero exit events (unverifiable, not exited); reconnect advanced the provider generation and restored the same PTY ID/incarnation as live, still with zero exit events. Rendered reconnect proof.
WSL2 (Ubuntu-24.04) UNREACHABLE Not covered end to end. The real-Windows WSL contract suite passed, including buildWslExecArgs using --exec and captured login-shell exit propagation, but no isolated WSL agent lifecycle journey was completed. Not covered end to end. Real-distro banner fencing and argv round trips passed, but no isolated live-at-shutdown reopen journey was completed. Follow-up access failed with orca terminal read --terminal term_0652b8b1-4131-4f53-bfbf-8b4ea4bf1dcd --limit 500 --json → terminal_handle_stale.
Native Linux (openclaw, Ubuntu 24.04) UNREACHABLE Exact-head build and six focused lifecycle cases passed, including confirmed local/SSH exit retirement, but the built app's supposedly unique profile rendered pre-existing workspaces, so the visible close/restart result was contaminated and rejected. Same isolation failure prevented trustworthy live-at-shutdown reopen proof. Launch was ORCA_USER_DATA_PATH=<unique profile> <exact-head built Electron> --remote-debugging-port=9452 --no-sandbox; without --no-sandbox the exact error was chrome-sandbox ... must be owned by root and mode 4755, and with it CDP rendered but ignored the requested isolation boundary.
Native Windows (physical high-spec host, Windows 10.0.26200.9168) UNREACHABLE Exact-head build and the six focused lifecycle cases passed, but the unique-profile/CDP launch displayed pre-existing workspaces, so the confirmed-exit restart result could not be attributed to this worker's session. Same profile contamination invalidated the live-at-shutdown branch. The exact-head app was launched with a unique ORCA_USER_DATA_PATH and --user-data-dir on CDP 9453; both were behaviorally rejected by the observed pre-existing profile. Follow-up capture command orca terminal read --terminal term_3d541b31-2162-4215-8baa-765e71c11313 --limit 500 --json returned terminal_handle_stale.
Paired mixed-version client/host UNREACHABLE Not covered. The available builds were exact-head client 858bed00e3, openclaw runtime 1.4.178-rc.2, and Windows runtime 1.4.190, but a new isolated paired host journey could not be established. Not covered. Attempt: orca terminal create --worktree 'id:6556cb39-27ad-41af-81d9-e8251f0158dc::/home/brennan/orca/workspaces/orca/qa-15666-host-worker-linux-858bed' --title 'qa15666-mixed-probe' --command 'orca --version; orca serve --help' --json → selector_not_found; therefore neither side's mixed-version retire/reopen interpretation was exercised.
Actual packaged restart UNREACHABLE Not covered: the signed exact-head arm64 package completed and codesign --verify --deep --strict passed, but it exited before CDP, so an intentionally closed session could not be restarted visibly. Not covered for the same reason. Exact attempt: env HOME=/private/tmp/orca-15666-packaged-profile.KZH6Sq/home ORCA_E2E_HOME_DIR=/private/tmp/orca-15666-packaged-profile.KZH6Sq/home ORCA_E2E_USER_DATA_DIR=/private/tmp/orca-15666-packaged-profile.KZH6Sq/user-data ORCA_USER_DATA_PATH=/private/tmp/orca-15666-packaged-profile.KZH6Sq/user-data dist/mac-arm64/Orca.app/Contents/MacOS/Orca --remote-debugging-port=9455 → process exit 1, and curl http://127.0.0.1:9455/json → connection refused. /usr/bin/open -n -a "$PWD/dist/mac-arm64/Orca.app" --args --remote-debugging-port=9455 also produced ERROR: packaged Orca launched with open -n did not expose CDP 9455.

Backing checks that passed

  • Exact HEAD was proved locally and in detached Linux/Windows worktrees.
  • Linux and Windows: pnpm build:desktop passed.
  • Linux and Windows: pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/confirmed-agent-exit-resume-retirement.test.ts src/renderer/src/components/terminal-pane/parked-terminal-confirmed-agent-exit-resume.test.ts src/renderer/src/components/terminal-pane/pty-connection-main-side-effect-authority.test.ts src/main/runtime/orca-runtime.test.ts -t "retires a clean-exit record|still offers resume|does not retire an unverifiable|becomes unverifiable|host-certified SSH exit|confirms a local agent exit" passed all 6 selected cases.
  • Real Windows/WSL2: pnpm exec vitest run --config config/vitest.config.ts src/shared/wsl-login-shell-command.test.ts passed 21 with 1 skip, including real-distro --exec, login-banner fencing, $/awk/positional-argument preservation, and fenced exit status propagation.
  • Packaged macOS: pnpm build:mac completed both slices and produced the signed arm64 package.

Merge verdict

DO NOT MERGE on this evidence. The live SSH loss-of-contact boundary is verified, but WSL lifecycle, native Linux/Windows visible restart journeys, mixed-version pairing, and the actual packaged restart remain authoritative gaps. No code defect was proven and no PR code was changed.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

STA-4110 blocking fix is now at bc72ee5.

Contract boundary: completion-sensitive local PTY inspection now preserves resolver availability and live-child evidence through LocalPtyProvider.inspectProcess and OrcaRuntimeService. Legacy foreground reads remain non-throwing for status/UI callers; exit confirmation only becomes executionHostConfirmed when inspection is available and explicitly sees no children. This avoids changing every non-authoritative caller while preventing a swallowed provider failure from being laundered into an exit.

Failing-first production-shaped regression: does not certify an adapter-swallowed foreground query failure as an agent exit failed at 858bed0 because the emitted fact contained executionHostConfirmed: true for inc-unverifiable-exit. It now emits only an unconfirmed agent-exited fact, while separate tests prove a live child also retains resume authority and an authoritative no-child inspection still emits executionHostConfirmed: true.

Verification:

  • 5 focused suites: 1286 passed, 1 skipped, including the six sibling renderer retain-branch lifecycle tests
  • pnpm tc passed
  • oxlint on all four changed files, oxfmt, git diff --check, and pre-commit hooks passed
  • pnpm build:mac passed for x64 and arm64; packaged daemon/plugin verification passed
  • same-model review-until-clean result: CLEAN
  • readiness END: zero P0/P1/P2 candidates; no mobile-facing persisted or wire surface changed; no polling, subprocess fanout, retry loop, or unbounded state added

The changed-code-quality wrapper itself remains affected by the existing Node 26 engine-warning JSON pollution (package expects Node 24); direct lint and pre-commit quality checks passed. Residual empirical gap is live native Windows/Linux/WSL restart travel; provider/runtime tests cover degraded local and fail-closed remote contract behavior.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Empirical restart evidence for bc72ee5:

Dev, isolated profile and CDP ports 28460/28461: identity was Orca: bc72ee5, isDev true, devRepoRoot exactly this PR worktree. Tab 30b05750-c8ac-423b-875b-84606edf33b4 reattached PTY 42e6c2e9-2b94-4cd9-a9bd-6470c269bb18::/Users/brennanbenson/orca/workspaces/orca/pr-15666-adapter-fix-r1@@072af635, and the visible shell PID stayed 14115 before and after restart.

dev restart proof

Packaged arm64 build 1.4.178-rc.2.local.1787874677190.bc72ee52190a, isolated profile and CDP port 28462: identity was Orca, isDev false, and the renderer loaded from this worktree packaged app. PTY 09e7ba75-5ff3-4a47-b529-c1258a9d7ad9::/Users/brennanbenson/orca/workspaces/orca/pr-15666-adapter-fix-r1@@eeadb812 reattached, and the visible shell PID stayed 80191 before and after restart.

packaged restart proof

Both journeys exercised the rendered terminal through Playwright CDP, not store-only inspection, desktop automation, or the users running Orca. Merge verdict: mergeable once required CI is green; no known in-scope correctness, performance, platform, remoting, or lifecycle blocker remains.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Host-validation retry — exact commit bc72ee5219

This supersedes the earlier 1-of-6 result for the fixed code at exact commit bc72ee52190a065bfd92ee4cd5d5836e99ade5b3. All five previously open arms exercised both decisions: an explicit user close stayed closed, while a genuinely live or inspection-unverifiable session survived restart and reattached.

Important

The PR advanced to dadeeca765 after this validation completed. The three newer commits materially change process inspection, so the table below is exact-commit evidence for bc72ee5219, not current-head certification; dadeeca765 needs a fresh validation pass before landing.

Arm Verdict Exact evidence at bc72ee5219
WSL2 (Ubuntu-24.04) VERIFIED On the isolated physical-Windows client, explicit-close tab 3aa715be… stayed absent after restart; live tab 1f73ddf2… returned with the same …@@3126b018 PTY and inspectProcess={foregroundProcess:"wsl.exe",hasChildProcesses:true}. The real-distro contract suite passed 21/21 executed tests (1 capability-dependent skip), including buildWslExecArgs routing through --exec and buildWslCapturedLoginShellCommand dropping login-banner stdout. closed branch · live branch · post-restart
Native Linux (openclaw) VERIFIED Clean profile /tmp/orca-qa-15666-linux/profile, renderer 29522, dedicated CDP 29521/29523, and identity Orca: bc72ee5219 were checked before captures. User-closed tab b705d064… stayed absent; live tab 95e58546… survived a consumed one-shot fake-ps failure and false exit-shaped title, retained {foregroundProcess:"codex",hasChildProcesses:true}, and reattached with the same …@@89e3eed0 PTY. transient live · post-restart · explicit close
Native Windows VERIFIED Uniquely named detached worktree and clean profile …\\orca-qa-15666-win-dfd0\\profile, renderer 29602, dedicated CDP 29601/29603/29604, with identity Orca: bc72ee5219. Closed tab 997dd44c… / PTY …@@5debdf63 stayed absent; survivor 2f1e06f9… returned with the same tab ID and …@@f03a18b2 PTY and live-child inspection. both branches · post-restart
Mixed-version client/host VERIFIED Packaged PR client 1.4.178-rc.2.local.1787878435974.bc72ee52190a paired to stable physical-Windows host 1.4.190. The old b61c… repo prefix reproduced selector_not_found; the correct stable-host selector was id:a0a2b4a4…::C:/Users/neil/orca/workspaces/orca/qa-15666-retry-bc72-dfd0. Explicit-close tab qa15666-mixed-close-tab / handle term_cc7… became exited and stayed absent. A visibly live Codex 0.149.1 tab survived with the same qa15666-mixed-survivor-tab, handle term_c9bc…, and PTY …@@253034dd even though the old host returned the misleading {foregroundProcess:"bash.exe",hasChildProcesses:false}—the fixed PR client correctly treated the mixed-version evidence as unverifiable rather than retiring it. Remote tabs were intentionally background-only, so this arm's decisive evidence is the paired-host RPC/session snapshot and terminal screen read; packaged client after restart.
Signed packaged restart (macOS arm64) VERIFIED Built package dist/mac-arm64/Orca.app, version 1.4.178-rc.2.local.1787878435974.bc72ee52190a, identity Orca, isDev:false. The original no-CDP startup was diagnosed from a process sample: the main thread was blocked in SecItemAdd → AuthorizationCopyRights on a Keychain prompt; relaunching the same package non-interactively with --use-mock-keychain exposed CDP. Rendered close + Stop Agent removed tab 8ce45790… / PTY …@@a6b9665f; live tab 395998b5… returned after real window.api.app.restart() with the same PTY …@@8f5493ae, incarnation c62b30cb…, and {foregroundProcess:"node",hasChildProcesses:true}. before restart · after restart

This also incorporates and supersedes the earlier exact-commit packaged-only note. No source files were changed during validation.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Verification evidence for head 08f68fd304a9a3390fe5e356878cc246e38b23d6

This comment supersedes the evidence for bc72ee5219 (#15666 comment 5447277396) and the earlier 858bed00e3 evidence. Those verdicts no longer certify the head: four commits landed after bc72ee5219 — ebd61242c2 (close process inspection contract), 344b1205c4 (protocol contract version), dadeeca765 (safe process runner for relay inspection), 08f68fd304 (packaged daemon protocol metadata) — totalling +875/−146 across 32 files, including the relay process-inspection path (src/relay/pty-child-process-inspection.ts, src/relay/pty-handler.ts) and src/shared/local-build-compatibility-contract.json. The verification below was run against 08f68fd304a9a3390fe5e356878cc246e38b23d6 exactly.

Challenge results (1–4 PASS)

  1. Contract closure, not a special case — PASS. Adversarial failure shapes at the completion-sensitive PTY inspection seam — a rejected promise, a thrown error, a timeout, an undefined return, and a partially-populated result — all classify as unverifiable; none reach a fact with executionHostConfirmed: true. Only an available inspection reporting no children can produce a host-confirmed exit. No bypass path was found through a different adapter or failure shape.
  2. Failing-first, production-shaped test — PASS. With the fix reverted, src/main/runtime/orca-runtime.test.ts › does not certify an adapter-swallowed foreground query failure as an agent exit goes red exactly as the original defect predicts: the fact channel emits { kind: 'agent-exited', executionHostConfirmed: true } for the swallowed-null query failure. The test models the real adapter swallowing the failure into a resolved null (not a throwing controller — the wrong shape that let the original bug ship). With the fix in place it passes.
  3. Both branches, adversarially — PASS. No over-correction: a genuine execution-host-confirmed exit (available inspection, no children) still retires resume authority, and intentionally-closed sessions stay closed — user-closed tabs remained absent across restart while confirmed-exit retirement tests pass. The original STA-4110 bug does not resurface.
  4. Packaged evidence on this head — PASS. A packaged arm64 build stamped with this exact head (1.4.178-rc.2.local.1787881233862.08f68fd304a9) was put through a real application restart: live terminal PIDs 8670, 24082, and 24253 survived the restart and reattached. This is a packaged-app run, not a dev-mode CDP run.

Challenge 5 — class remains OPEN (deliberately out of scope here)

This PR closes the completion-sensitive process-inspection contract only. It does not close the other acting coercion sites from the systemic sweep: fresh confirmation, the generic and raw fallbacks, legacy coercions, the null-hasPty demotion, restored-ownership deletion, and Windows host pruning. Those are separate PRs — #16900, #16908, #16926 (SSH relay completion evidence), #16932 (null-hasPty demotion) — plus sites still open, not gaps in this PR. A reader should not mistake this narrow contract fix for the class fix.

PR state at this head

  • 0 unresolved review threads.
  • CI settled at 08f68fd304: 32 success, 10 skipped, 0 failed.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Host re-validation at current head 08f68fd304a9

This re-runs all five host arms at exact commit 08f68fd304a9a3390fe5e356878cc246e38b23d6 and supersedes the bc72ee5219 evidence, which predated the four process-inspection/protocol commits (ebd61242c2…08f68fd304). Every arm ran against a build fingerprinted to this head (daemonProtocolVersion: 37 in the built bundle, or the SHA embedded in the packaged version string). The head did not move during validation. Each arm exercised both decisions: an explicitly closed session must not reopen; a live or inspection-unverifiable session must survive restart and reattach to the same PTY.

Arm Verdict Exact evidence at 08f68fd304a9
WSL2 (Ubuntu-24.04, physical Windows) VERIFIED Dev build in qa-15666-retry-bc72-dfd0 (clean profile orca-qa-15666-r2-win/profile, CDP 29701/29711). Explicitly closed WSL tab / PTY …@@a61f63ec (confirmed through the rendered "Stop running command?" dialog) stayed absent after restart. WSL survivor …@@8c0ea339 reattached with the same PTY and full scrollback (wsl.exe -d Ubuntu-24.04 history intact) and answered a post-restart echo qa15666r2-wsl-alive-42 interactively. Real-distro contract suites at this head: runner + UNC-delete + approved-root-race pass; the banner suite passes 5/5 run in isolation (one 30s timeout appears only when all four files share a run — the runner suite's ~/.profile sleep 60 fixture bleeding into the banner suite on this loaded shared box, not a product defect). four tabs live · after closes · post-restart survivor interactive
Native Linux (openclaw) VERIFIED Built at head in qa-15666-host-worker-linux-858bed (now checked out to 08f68fd304), clean profile /tmp/orca-qa-15666-r2-linux/profile, CDP 29621/29622, daemon launched with a one-shot failing ps on PATH. The consumed failure made inspectProcess return {foregroundProcess:"node", hasChildProcesses:false, unavailable:true} — the degraded read stayed unverifiable instead of confirming an exit — and the next read recovered {codex, hasChildProcesses:true}. Explicit-close tab …@@002ffe36 (Stop Agent dialog) stayed absent across two app restarts; survivor …@@5136d5b9 reattached both times with the same PTY and live codex. both live · Stop Agent dialog · post-restart
Native Windows VERIFIED Same dev build/profile as the WSL arm. Explicitly closed codex tab / PTY …@@3f4810a8 stayed absent after restart. Survivor …@@973e3458 reattached with the same PTY, codex TUI interactive at its update prompt, inspection {foregroundProcess:"codex"} (codex.exe reports no children on Windows — live foreground either way). before restart · post-restart tabs · codex survivor
Mixed-version client/host VERIFIED Packaged PR client 1.4.178-rc.2.local.1787881233862.08f68fd304a9 (this head's daemonProtocolVersion 37 + new inspection contract) paired via pairing code to stable host orca-ide 1.4.190 on openclaw (this round's stable host; the Windows low-spec runtime was unreachable). In remote workspace qa-15666-host-worker-linux-858bed: client-side explicit close of codex tab …@@fc28ccb3 / handle term_ca11a4a3… propagated to the old host and stayed closed after client restart (host terminal list confirms absence). Survivor …@@0df3fc88 / term_8afbc4d8… reattached in the client with the same tab, and the 1.4.190 host independently reports it connected/writable with the codex TUI live. Four pre-existing host sessions in the same workspace were left untouched and all survived. survivor-to-close marked · after close · post-restart reattach
Packaged restart (macOS arm64) VERIFIED Fresh pnpm build:mac at this head → dist/mac-arm64/Orca.app, isDev:false, version string embeds the SHA; launched non-interactively with --use-mock-keychain and an isolated E2E profile. Explicit close (rendered "Stop running command?" → Stop and Close) removed tab / PTY …@@0e6d69a8; after a real window.api.app.restart() the closed tab stayed absent and survivor …@@af5b28de reattached with the same PTY and live codex ({codex, hasChildProcesses:true}); the survivor then also held across a second restart during the mixed-version pass. both live · after close · post-restart

Observation outside this PR's diff (dev-only surface, noting for completeness): on Linux and Windows dev builds launched with --remote-debugging-port, the daemon and PTY children inherit the DevTools listener socket, so after window.api.app.restart() the relaunched app cannot rebind the port (Linux came back CDP-less; Windows' relaunched instance, a child of the harness shell, later exited). Verification restarts were completed by quitting and relaunching the same build on a fresh port; the retire/reopen decisions held identically across every restart cycle, including the double-restart cases. The macOS packaged app does not exhibit this — app.restart() reattached CDP on the same port.

No source files were changed during validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cleanly exited Claude session is auto-resumed with claude --resume after an app restart (local macOS, hibernation off)

2 participants