Repository navigation
fix(terminal): an app's own prompt markers no longer forget a live agent when its pane is hidden or shown - #31182
Conversation
…keeps the live agent's launch identity (red)
…ent when its pane is hidden or shown OMP closes each prompt bubble with OSC 133 B C D;0 while it keeps running. Read as "the command finished", that D retired the pane's launch and hook identity, so later hooks were refused and the phone lost the session. The uninterrupted case was already recognized, but scan authority moves between main and the daemon on every hide/show, and a fresh scanner that never saw B C read the lone D as a real exit. - A scanner that joins mid-stream holds an unseen D;0 and fires it only when the shell's next prompt (A) follows at once, as every Orca shell hook prints; OMP follows its zone close with output, which drops it. - A finished command retires launch identity only once the agent's process is gone: the hook process exited, or the host sees nothing but the shell in the PTY's process tree (a backgrounded agent still counts as alive). - Daemon protocol 51: older relays misread these zones, so they no longer get background scan authority and their queued command exits are dropped. Tracked in STA-11321.
|
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. Walkthrough
Merge Risk:
|
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:
2c085f7f-161d-4f36-a040-b4ce6306a163
📒 Files selected for processing: 27
src/main/daemon/daemon-background-transient-facts.test.tssrc/main/daemon/daemon-foreground-confirmation-protocol.test.tssrc/main/daemon/daemon-protocol-version.tssrc/main/daemon/daemon-pty-adapter-protocol-compatibility.test.tssrc/main/daemon/daemon-pty-adapter.tssrc/main/daemon/daemon-pty-runtime-state.tssrc/main/daemon/types.tssrc/main/runtime/omp-user-bubble-launch-authority.test.tssrc/main/runtime/opencode-finished-session-authority.test.tssrc/main/runtime/opencode-run-lifetime-runtime.test.tssrc/main/runtime/orca-runtime-agent-prompt-request-correlation.tssrc/main/runtime/orca-runtime-provider-reattach-launch-identity.test.tssrc/main/runtime/run-terminal-shell-alone.node-pty.test.tssrc/main/runtime/run-terminal-shell-alone.tssrc/main/runtime/terminal/lifecycle/pty-agent-launch-exit-retirement.tssrc/main/runtime/terminal/output/terminal-title-tracker.tssrc/main/runtime/terminal/output/terminal-transient-facts.tssrc/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.test.tssrc/renderer/src/components/terminal-pane/pty-connection-command-finished-cleanup.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-command-finished-late-done.test.tssrc/renderer/src/components/terminal-pane/pty-connection-hibernation-kill-shell-foreground.test.tssrc/renderer/src/components/terminal-pane/pty-connection-process-exit-row-retire.test.tssrc/renderer/src/components/terminal-pane/pty-connection-unanswered-command-finish.spec.tssrc/shared/local-build-compatibility-contract.jsonsrc/shared/local-build-compatibility-contract.tssrc/shared/terminal-osc133-command-finished.tssrc/shared/terminal-osc133-self-closed-zone.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
…or a mirror adopted mid-bubble, no longer reads as a finished command - Raw-byte readers (the daemon's background relay and recovery barrier, main's ownership mirror) now treat complete OSC 9999 status frames the way main's stripped stream does: not as output, so a B C <status> D;0 bubble close still reads as the app's own zone. - Main's ownership mirror joins the stream mid-flight (snapshot seed, data gap, reattach), so it holds an unseen D;0 until the shell's adjacent prompt, like the shared scanner. The daemon barrier reads from PTY birth and is unchanged. - The POSIX exit proof finds the shell under macOS's login wrapper and reads a fresh strict process table: a malformed capture proves nothing. Tracked in STA-11321.
…e, so a bubble whose B C was dropped doesn't end the turn The daemon keep-tail can drop a hidden pane's oldest output. Main already resets every other cross-chunk carry on that gap; its OSC 133 scanner kept its old context, so a D;0 whose B C was in the dropped span read as a finished command. Tracked in STA-11321.
…ms until the host admits mode writes Orca told programs that subscribed to mode 2031 about each theme flip from a client-side check alone. A flip queued while the program withdraws reaches the shell as typed ?997;Nn (#9993). Real color-scheme queries still get answers; unsolicited flips return once the host admits mode writes (STA-11321 slice 4). Tracked in STA-11321.
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:
39e9073a-e71f-42e1-9b09-b44eba8319d6
📒 Files selected for processing: 10
src/main/daemon/daemon-background-transient-facts.test.tssrc/main/daemon/terminal-shell-lifecycle-scanner-app-zone.test.tssrc/main/daemon/terminal-shell-lifecycle-scanner.tssrc/main/runtime/pty-shell-ownership-mirror.tssrc/main/runtime/run-terminal-shell-alone.test.tssrc/main/runtime/run-terminal-shell-alone.tssrc/shared/agent-status-osc.tssrc/shared/process-table-snapshot-reader.tssrc/shared/terminal-osc133-command-finished.tssrc/shared/terminal-osc133-self-closed-zone.test.ts
🚧 Files skipped from review as they are similar to previous changes: 1
- src/main/runtime/run-terminal-shell-alone.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
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:
052e7caf-56b2-40f2-8b41-17482c06daf6
📒 Files selected for processing: 7
src/main/daemon/macos-daemon-launchd.test.tssrc/main/runtime/omp-user-bubble-launch-authority.test.tssrc/main/runtime/terminal/output/terminal-transient-facts.tssrc/renderer/src/components/terminal-pane/pty-connection-foreground-agent-sampling.spec.tssrc/renderer/src/components/terminal-pane/terminal-appearance.test.tssrc/renderer/src/components/terminal-pane/terminal-mode-2031-replies.tssrc/shared/terminal-output-side-effects.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
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:
eb6992c2-bb8f-4b54-833f-af675284e97b
📒 Files selected for processing: 8
src/main/daemon/terminal-shell-lifecycle-scanner.tssrc/main/runtime/run-terminal-shell-alone.test.tssrc/main/runtime/run-terminal-shell-alone.tssrc/main/runtime/terminal/output/pty-output-ingestion.tssrc/shared/terminal-osc133-command-finished.tssrc/shared/terminal-osc133-self-closed-zone.test.tssrc/shared/terminal-output-side-effects.tssrc/shared/terminal-status-frame-cursor.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.
covered by a test fed a recorded real macOS login-wrapper tree; live run not possible under test-copy isolation
Resolve both beta.336 xterm patches, pnpm-lock.yaml, daemon transient facts and protocol version, typed agent identity, sleeping record access, and workspace cleanup preflight. Conflicted files: - config/patches/@[email protected] - config/patches/xterm-src/@[email protected] - pnpm-lock.yaml - src/main/daemon/daemon-background-transient-facts.test.ts - src/main/daemon/daemon-protocol-version.ts - src/renderer/src/components/terminal-pane/pty-connection-typed-agent-identity.spec.ts - src/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.ts - src/renderer/src/store/slices/workspace-cleanup-agent-stop-preflight.test.ts Retain protocol 55 foreground observation and previous versions 1-54 with the existing version-51 OSC 133 gate. Preserve host-owned remote agent status and pane-local notification arbitration. generated beta.336 patch and lock hash pending regeneration with the listener removal
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep appearance and reconnect reports with the pane reply owner. Restore the native color-scheme listener for standalone terminals and use the matching upstream patch hashes.
Allocate generation 56 and fix unseen-zone support at that introduction boundary. Keep generations 1-55 attached through the legacy raw-stream path, filter their queued completion facts, and align the packaged compatibility contract. Physical foreground observation remains available from generation 55. The protocol number must be re-checked against main at final merge; if main has consumed it, allocate an unused generation for both the current daemon and the fixed introduction boundary.
Resolve src/main/agent-hooks/server/server-lifecycle.ts and src/shared/electron-remote-runtime-client-capabilities.ts, preserving accepted hook ownership and main plugin delivery. Move launch-authority shutdown cleanup into src/main/agent-hooks/server/server-authority-state.ts without changing its statements or order. Validated with node_modules/.bin/lint-staged --diff=MERGE_HEAD --concurrent false under the main-merge hook exception.
Move composed notification delivery cases to the e2e unit project, retaining all assertions and the shared terminal fixture. Supply complete resident identities and use current layout, connection and PTY identity owners in regression fixtures. Tests only; no production behavior changes.
Carry the existing report payload through immediate pane notification dispatch without publishing a client status row. Keep quiet hydration and main-equivalent first-Done timing, with the source-cut stamp and replay checks intact.
Require live Working before testing delayed completion across a source cut. Keep remote hydration quiet and verify visible and hidden report delivery preserves the host row while retaining pause and reveal coverage.
Keep mirror retirement suppression through retention effects so a returning row uses its own source observation for session ordering. A current ready surface may retire an obsolete live row even when its terminal was replaced; separately retained PTY-end history keeps its existing identity boundary.
Declare the retained and suppression batch records, keep ownership decisions boolean, and expose the required status patch fields to retraction callers. Initialize both current state maps in the existing test fixtures.
Use satisfies for the existing partial app state fixture, preserving its values, test flow and assertions.
Complete the accepted session-tabs state shape in the retirement and title-fanout fixtures. Keep all existing test assertions and production types unchanged.
Keep automatic terminal replies out of command intent and both existing D-settlement input fences while forwarding them to the PTY. Preserve unclassified input and acknowledged interrupt handling. Cover deferred process reads and interrupt inference, driving-input successors, and carried pre-56 completion through replacement bytes.
Integrate c9845c5. Resolve agent-pre-ready-typed-draft.test.ts and pty-connection-spawn-deferred-sleep.test.ts by preserving main's test pruning and the branch's callback and fixture typing in surviving cases. No production conflict resolution or protocol behavior change. Merge validation: node_modules/.bin/lint-staged --diff=MERGE_HEAD --concurrent false.
Replace reflective reads with checked typed member access. Keep all provenance, retirement, interrupt and successor assertions unchanged.
Agent tracking and pending completion notifications could reset when a pane attached, closed or reconnected, even though its terminal kept running. This keeps one tracker with the running terminal and makes pane attachment presentation-only, so accepted work and completion handling continue through those transitions.
Agent identity comes from hooks and process observations. An honestly observed agent name can remain visible during contact uncertainty, while input routing, process presence, status and other actions continue to require their own current evidence. This removes typed-command identity guesses, the special one-shot OpenCode status producer and the FIFO/lease machinery. A shell completion marker alone cannot prove that an agent has exited; cleanup requires evidence from the execution host.
Tracked in STA-11321 and STA-9149. This PR includes the current foreground display/action boundary and lands before the separate canonical identity correction tracked in #35950. It works on its own; #35950 is not a landing dependency.
Intended compatibility behavior: old hosts keep main's existing 15-second handoff window for a bell that arrives before the terminal's lookup answers; hosts reporting the new capability deliver it unconditionally. The existing 64-batch/32-PTY limits and older hosts' launch path remain supported, with no minimum server version. Contact loss keeps the execution uncertain until actual evidence establishes its state.
Intended behavior: double-Escape detection stays per pane; Escapes from different panes do not combine into an interrupt. Acknowledgment accounting uses the execution captured when input was dispatched. Input dispatch never waits for bookkeeping.
Intended behavior. Kill-switch fallback only: when status authority is off and a reopened terminal's ID is a stale mapping from another workspace, a Ctrl+C sent before Orca has confirmed the terminal's process is delivered immediately but isn't inferred as an interrupt; the status updates at the agent's next event. Status should not be inferred from terminal keys at all.
Temporary: applications subscribed to terminal color-scheme changes no longer receive automatic light/dark reports when Orca's theme changes. Explicit color-scheme queries still receive current answers. Automatic subscribed reports return with host-admitted mode writes, tracked in STA-11321, slice 4.
Follow-up: recording interrupts at server write acceptance is out of scope for this PR.
Verification is in progress. Source review and finite integration acceptance are complete through
597fee3b70cb42388f2ebb0e39c85d63b4ac04df; the final main merge passed 208 named tests, with 31 tests independently rerun. The retained native protocol/artifact evidence has independent acceptance. Current CI is failing; compiler, static-test, smoke-parser and fixture repairs are in progress. Final changed-flow QA with real Claude and Codex, targeted OpenCode v1/v2 runs, and the remaining Command Code/Pi recorded-input contracts are pending. These test results are not an app QA pass, and this PR is not ready to merge.