Repository navigation
fix(terminal): hidden tabs reconnect to their still-running session after a restart - #30926
brennanb2025 wants to merge 11 commits into
Conversation
…ession After a restart, a hidden tab whose agent was still running in the terminal daemon stayed detached until shown: the hidden sleeping-agent deferral asked pty:hasPty, which answers from the set of sessions this app run attached, so every surviving session read as exited and was held until reveal. A hidden sleeping-agent restore is now an attach-only connect end to end (renderer transport, preload, main spawn options, early adoption and the stable-owner path). A live session attaches eagerly; absence or any other failure keeps the saved binding and arms the existing reveal hold, whose wake runs the ordinary restore. Nothing after an attach-only attempt can create a PTY or resume the agent while the pane is hidden. pty:hasPty keeps its fast attached answer and its guards, and resolves a miss from the host's liveness probe (only the in-process provider may answer false without one), sharing overlapping probes per provider and id.
|
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
fb7fa890-b482-44e6-84ce-512509d1d2cb
📒 Files selected for processing: 73
src/main/ipc/pty-spawn-codex-home-unavailable.test.tssrc/main/ipc/pty-startup-barrier-and-listing.test.tssrc/main/ipc/pty/ipc/inspect.tssrc/main/ipc/pty/ipc/spawn-commit.tssrc/main/ipc/pty/ipc/spawn-env-codex.tssrc/main/ipc/pty/ipc/spawn-env.tssrc/main/ipc/pty/ipc/spawn-execute.tssrc/main/ipc/pty/ipc/spawn-options.tssrc/main/ipc/pty/ipc/spawn-preflight.tssrc/main/ipc/pty/ipc/spawn-run.tssrc/main/ipc/pty/ipc/spawn-types.tssrc/main/ipc/pty/pane/adopt-stable.tssrc/main/ipc/pty/pane/stable-owner.tssrc/main/ipc/pty/pane/stable-pane-absence-respawn.test.tssrc/main/ipc/pty/provider/liveness.tssrc/main/ipc/pty/runtime/operations.tssrc/main/ipc/pty/spawn-options-assembly.tssrc/preload/api/pty-api.tssrc/preload/api/pty-bridge-session-control.tssrc/renderer/src/components/terminal-pane/TerminalErrorToast.tsxsrc/renderer/src/components/terminal-pane/TerminalPaneSurface.tsxsrc/renderer/src/components/terminal-pane/ipc-pty-opencode-model.test.tssrc/renderer/src/components/terminal-pane/ipc-pty-spawn-request.tssrc/renderer/src/components/terminal-pane/pty-connection-agent-session-resume.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-cold-restore-agent-resume.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-cold-restore-resume-command.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-command-finished-cleanup.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-deferred-reattach-live-output.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-hibernation-wake.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-hidden-sleeping-resume.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-pending-spawn.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-reattach-binding.test.tssrc/renderer/src/components/terminal-pane/pty-connection-remote-runtime-attach.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-sleeping-resume-banner.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-test-pane-fixtures.tssrc/renderer/src/components/terminal-pane/pty-connection-test-store-fixtures.tssrc/renderer/src/components/terminal-pane/pty-connection-test-store-state.tssrc/renderer/src/components/terminal-pane/pty-connection/agent-idle-working-handlers.tssrc/renderer/src/components/terminal-pane/pty-connection/apply-reattach-payload.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-cold-restore-and-snapshot.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-choice.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-connect.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-newer-daemon-hold.test.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-startup-snapshot.test.tssrc/renderer/src/components/terminal-pane/pty-connection/fresh-spawn-start.tssrc/renderer/src/components/terminal-pane/pty-connection/fresh-spawn-types.tssrc/renderer/src/components/terminal-pane/pty-connection/hibernated-agent-wake-completion.tssrc/renderer/src/components/terminal-pane/pty-connection/hidden-agent-resume-deferral.test.tssrc/renderer/src/components/terminal-pane/pty-connection/hidden-agent-resume-deferral.tssrc/renderer/src/components/terminal-pane/pty-connection/in-place-resume-hold-wiring.test.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-pty-binding.tssrc/renderer/src/components/terminal-pane/pty-connection/pty-connect-limits.tssrc/renderer/src/components/terminal-pane/pty-connection/pty-exit-hibernate.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-payload-context.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-payload-session.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler-park-reveal-verdict.test.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-success-settle.test.tssrc/renderer/src/components/terminal-pane/pty-connection/session-reconcile-dispose.tssrc/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.tssrc/renderer/src/components/terminal-pane/pty-connection/unbound-pane-spawn-recovery.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/terminal-error-accumulation.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-projection.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-title-state.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/sleeping-pane-record-selection.tssrc/renderer/src/runtime/sleeping-records-to-layout-owner.test.tssrc/renderer/src/store/slices/agent-status-recovery-actions.tssrc/renderer/src/store/slices/agent-status-runtime.tssrc/renderer/src/store/slices/agent-status-slice-contract.tstests/e2e/helpers/completed-worker-retirement-fixture.tstests/e2e/settled-worker-tab-survives-restart.spec.ts
💤 Files with no reviewable changes: 2
- src/renderer/src/components/terminal-pane/pty-connection/reattach-payload-session.ts
- src/main/ipc/pty/ipc/spawn-env-codex.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Superseded by #31254, which restores the intended behaviour with a minimal fix to the session liveness check. This larger version also made hidden reconnects attach-only end to end; it is not needed to fix the regression. |
ELI5
When Orca restarts, terminal tabs you aren't looking at should quietly reconnect to agents that are still running, so Orca keeps seeing their output (bells, titles, agent status). Since #29459 they don't: a hidden tab asks "is my session still running?", the answer comes from a list that only knows terminals reconnected since the restart, so a running session looks finished and the tab waits until you open it. This PR makes the hidden tab reconnect only to a session that's still running, and never start a new one, and makes that question ask the terminal background service directly.
What Changed
Before: after a restart, a hidden tab with a running agent stayed disconnected until you opened it. Output that arrived meanwhile wasn't seen. The daily full E2E run (
settled-worker-tab-survives-restart) has failed on this since 10-18.After:
Mechanism:
pty:hasPtykeeps its fast "yes, attached here" answer. When that list says no, it now asks the terminal background service (the existingprobePtyLiveness). Only the in-process local provider may still answer "no" without asking, as before. Overlapping questions about the same terminal share one request. This also fixes typing into a terminal that isn't reconnected yet, which asked the same question and read "no" as "the session ended".Why
Only checking liveness first, then reconnecting with the ability to create, would leave two ways for a hidden agent to restart in the background: the session ends between the check and the reconnect, or the terminal service doesn't answer during a restart. The common pattern keeps "is it alive" and "may I create one" separate, and adopts an existing session through an operation that cannot create. This follows that. Fixing only the reconnect would leave the liveness question wrong for its other callers, so both are in this PR.
Differences from the common pattern:
Linked Issue
N/A (maintainer). Daily E2E failure, for example https://github.com/stablyai/orca/actions/runs/39307965554 (settled-worker-tab-survives-restart, "liveness before reveal").
Visual Proof
Pending real QA on a QA machine: restart with a hidden tab running an agent, then with a hidden tab whose agent has ended.
Testing
Named vitest files pass (stable-owner no-create cases;
pty:hasPtytrue/false/unknown/failure and shared overlapping probes; the hidden sleeping-resume renderer spec). The E2E "liveness before reveal" check now asserts the pane is actually bound to its session instead of askinghasPty.Agent skill upstream boundary
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)