Repository navigation
fix(terminal): hidden tabs reconnect to sessions that survived a restart - #31254
Conversation
pty:hasPty answered from the provider's attached-this-run set, so right after a restart every surviving session read as exited and #29459's hidden-agent hold kept live hidden tabs disconnected until shown. On an attached-set miss, ask the host through the provider's existing liveness probe; providers without one (the in-process provider, its own sole owner) keep their answer.
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
🧹 Nitpick comments: 1
tests/e2e/settled-worker-tab-survives-restart.spec.ts: 1
347-350: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a DOM assertion for the revealed terminal pane.
Keep the pre-reveal PTY binding check. After reveal, assert the reattached pane with a DOM locator.
ensureTerminalVisiblechecks only store state, andvisibleTab.toBeVisible()verifies the tab, not the rendered pane. This DOM assertion is required by the E2E test boundary and is not duplicative.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
9b3473b3-08b7-41fb-af22-5238b433f677
📒 Files selected for processing: 3
src/main/ipc/pty-startup-barrier-and-listing.test.tssrc/main/ipc/pty/ipc/inspect.tstests/e2e/settled-worker-tab-survives-restart.spec.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.
There was a problem hiding this comment.
🧹 Nitpick comments: 1
tests/e2e/settled-worker-tab-survives-restart.spec.ts: 1
343-355: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert reattachment completion, not only the PTY binding.
data-pty-idis written before replay and payload application. A non-throwingfalseresult can leave that binding intact because the caller only clears the pending serializer on that path. The later assertions check pane presence and host PTY liveness, not replay completion. Add an assertion or synchronization for completed reattachment before reveal.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d9964b7b-43e9-4df9-bb0c-ee4bb3d30bf4
📒 Files selected for processing: 1
src/main/ipc/pty-startup-barrier-and-listing.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
|
After restarting Orca, a hidden terminal tab could stay disconnected from an agent that was still running. The liveness check mistook this run's empty attachment list for proof that the host session had ended, so output-driven updates did not reach the tab until it was opened. This change asks the existing host liveness probe when attachment membership misses. Eligible hidden tabs reconnect to surviving sessions before reveal. A confirmed ended session still waits until reveal; visible restores and new terminals retain their existing paths. The full review completed one correctness and architecture round, plus dedicated performance and readiness checks. No production correction was needed. The loop removed a test-fixture type assertion that blocked CI; all 22 targeted PTY tests passed. Existing compatibility fallbacks and all three renderer liveness callers were traced. A current host normally answers a single-session size request; older hosts and multi-generation ownership can use inventory. Individual RPC timeouts do not guarantee an end-to-end two-second bound. Intended inherited limits: the liveness check and reconnect are separate, and unknown liveness reconnects. Only mounted eligible panes participate; other workspaces keep their existing lazy mounting. STA-11356 and STA-11405 remain outside this fix. Separate main-side uses of provider attachment membership are unchanged; their full user-facing impact was not reproduced in this review. Review complete on Real QA on the M4Air used Claude 2.1.304 and a hidden app through the Chrome DevTools Protocol. Main ( The requested one-launch main control reproduced the same startup failure: branch The automated settled-worker-tab-survives-restart run passed both cases (2/2): hidden live-session reconnect before reveal, and the exited-session hold/reveal recovery path. The latter checks that the tab survives and allows at most one resume launch with the saved session ID; it does not require a launch or prove a real agent reply. The final-head full workflow also passed the changed restart tests. Under the explicit ruling, this automated evidence is accepted for the recovery flows the real QA setup could not reach. Not exercised in real QA: the ended-session no-hidden-launch / exactly-one-resume flow with real replies, a visible restored agent replying, and a new terminal rendering command output. The branch and the requested main comparison both stalled at the same 60-second workspace-restoration readiness wait before those flows could run. No real-QA success is claimed for them. This exception accepts the passing end-to-end coverage with these remaining limits disclosed. The one main launch was shut down through the unchanged helper. The final audit found no surviving recorded process identities and all assigned ports clear. The QA worktree was restored clean to For Brennan's review Partial live-session comparison, before opening the hidden agent tab:
After reveal:
No ended-session or final-control screenshot is claimed.
|





ELI5
When Orca restarts, terminal tabs you aren't looking at should reconnect to agents that are still running, so Orca keeps seeing their bells, title changes and output. Since #29459 they don't: a background tab with a running agent stays disconnected until you click it. This makes the "is this session still running?" check tell the truth after a restart, which is what #29459 already relies on.
What Changed
Before: after a restart, a hidden tab whose agent was still running stayed disconnected until you opened it, and output that arrived meanwhile wasn't seen. Main's daily full E2E run (
settled-worker-tab-survives-restart, "liveness before reveal") has failed on this since 10-18.After: a hidden tab with a running agent reconnects right away. A hidden tab whose session has ended still waits until you open it and resumes there, exactly as #29459 designed.
Mechanism: #29459 holds a hidden tab only when
pty:hasPtysays its session is gone ("only the host's exited may hold it"). Butpty:hasPtyanswered from the provider's list of sessions attached in this run of Orca. Right after a restart that list is empty, so every session that survived the restart read as gone. Now, when that list says no, the handler asks the host through the provider's existing liveness probe (probePtyLiveness, the same one the runtime controller already uses). The fast "attached here" yes, the remote-id and swap-window guards, and the error-to-unknown handling are unchanged. A provider without a probe (the in-process provider, which is its own sole owner) keeps its answer.Why
This restores #29459's own design with the smallest change at the point that was wrong: the answer, not its callers. Answers can only move from "gone" to "running" or "unknown", never the other way, so nothing that acts on "gone" can act more often. Every renderer caller of
pty:hasPtymeans "does this session still exist on its host", so they all get a truthful answer. An attached-set miss consults the existing host probe. A current direct host normally answers one size lookup; older hosts and multi-generation ownership resolution can use inventory. Each daemon request has its existing 2-second timeout; this is not an end-to-end bound across startup, recovery and compatibility fallback.A larger version that also made hidden reconnects attach-only end to end was explored in #30926; it is not needed to restore the intended behaviour.
Intended scope and inherited choices
Linked Issue
N/A (maintainer). Daily E2E failure, for example https://github.com/stablyai/orca/actions/runs/39307965554.
Visual Proof
Partial real QA on M4Air, final head
f007ce61fed2fc3d26f2f148ae1d43df2bcb78a4, real Claude 2.1.304: current main6e973fa6d4b5640744453f416c6265b96fe7fefdreproduced the surviving hidden session staying unbound until reveal. The branch bound the same original PTY before reveal and received new output, title events and bells while hidden. The baseline app/renderer came from main but reused the branch CLI emission, so this remains a partial comparison.Review complete under Brennan's explicitly approved QA exception (2026-10-21). The requested one-launch main control reproduced the same startup failure: branch
f007ce61timed out at 02:58:28.977 UTC and main6e973fa6at 05:00:13.868 UTC on 2026-10-21, both waiting 60 seconds for workspace-restoration readiness (workspaceSessionReady). All 4,115 existing build artifacts matched the saved main build, so no rebuild was needed. The only controller changes were its Chrome DevTools Protocol and runtime port numbers, taken from fresh QA admission 1017; isolation, shutdown and the readiness wait were unchanged. This establishes that the timeout also occurs on main in this setup; it does not diagnose the timeout or prove the remaining feature flows.Real QA proved hidden live-session reconnect versus main, including output, title events and bells before reveal, as shown above. The passing settled-worker-tab-survives-restart run 39511560917 supplies the accepted automated evidence for the remaining recovery path: both live and exited cases passed (2/2). The exited case preserves the tab through hold/reveal and allows at most one resume with the saved session ID; it does not require a launch or prove a real reply. The full workflow on final head also passed the changed restart tests.
Not exercised in real QA: the ended-session no-hidden-launch / exactly-one-resume flow with real replies, a visible restored agent replying, and a new terminal rendering a command's output. Both the branch and requested main control timed out after the same 60-second workspace-restoration readiness wait before those flows. These gaps remain disclosed; the automated evidence is accepted under the explicit ruling. The one main launch was shut down through the unchanged helper. The final audit found no surviving recorded process identities and all assigned ports clear. The QA worktree was restored clean to
f007ce61; its ignored build artifacts remain the verified main build. The worker and evidence terminal are released, and admission 1017 is done. No product code, commits or pushes were added.Testing
Review path: full — terminal restart/recovery and IPC semantics require the full review and real-agent QA.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
pty-startup-barrier-and-listing.test.ts: a session the attached list doesn't know but the host reports live now reads true; attached and gone sessions unchanged. With the old handler this case returns false.pty-startup-swap-window-presence.test.tsandpty-session-liveness-and-ownership.test.tsstill pass (22 tests across the three files).settled-worker-tab-survives-restart.spec.ts: "liveness before reveal" now asserts the hidden pane is actually bound to its session, sincehasPtynow reads host liveness and would pass even if the tab never reconnected.Agent skill upstream boundary
Checklist