Repository navigation
perf(terminal): let main's model rest for agents that read no screen - #27185
outof-place wants to merge 12 commits into
Conversation
…renderers can't pace agents A hidden pane whose PTY a raw-byte sidecar watches (background-launched and automation agents) kept the hidden-delivery gate off for the whole PTY, so its hidden xterm parsed every byte and main paced the producer to that parse. The parse runs on renderer timers, which Chromium throttles for hidden pages (one wake-up a minute after ~5 minutes), so a flooding agent slowed to tens of KB/s and blocked on its own writes. Delivery interest now only decides who receives the bytes, not whether the view is gated. For a hidden PTY with interest, main sends chunks flagged sidecarOnly. The renderer hands them to sidecars only and credits them on receipt. The view skips them like a gated drop and restores from the model on reveal, and main answers the PTY's terminal queries meanwhile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…flip Main decides who answers a terminal query when it ingests the chunk: the pane's view while the view parses, main's model while the view is gated. Delivery decided again at send time, so a flip while the chunk was still queued broke that: - Queued while visible, then hidden before the flush: the gate dropped the bytes (or sent them to sidecars only), the view never parsed them, and main had not answered. The program waited for a reply that never came. - Queued while gated, then revealed before the flush: main had answered, and the now-visible view parsed the bytes and answered again. Each pending entry now carries the gate state it was ingested under, and an entry never mixes states. Bytes the view was to answer but will skip have their queries handed to the view the way a pending-cap drop already does. Bytes ingested gated go to sidecars only even after a reveal, and the view restores from main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rendererPtyViewDelivery now owns how main delivers a PTY's bytes to the
renderer ('parse', 'sidecarsOnly' or 'drop'). The drop and sidecar-only
predicates and the query responder read it, and every pending entry
records the mode it was ingested under instead of a gated bit. Main's
model owns the replies of any mode other than 'parse', so a later mode
such as parse-once's native-view skip slots into the same function and
the same stamp without another ownership rule.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The e2e holds the renderer's delivery credit while it fills main's window. Under heavy load the old 8 KB pacing could stretch the hold past main's 10 s ack-silence heal, which writes the window off and drains the queue the test needs. The filler now writes 16 KB per tick, still far below the queue size at which main pauses the PTY, and the probe writes its reply counts atomically. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main fed every PTY byte into its own HeadlessEmulator, even for a visible pane whose renderer and daemon already parse the same bytes. For a visible local daemon terminal with no viewer, agent or gate drop, main now drops that emulator after 5 s without demand. A hide, a viewer, a screen read or a snapshot rebuilds it from the daemon's settled snapshot (protocol v36+), skipping live bytes the snapshot covers. The hidden-delivery gate stays open until the rebuilt model catches up, so main never owes a query reply for a byte it skipped. Restores of such terminals read the daemon at full depth. Phase 1 of #27023. Kill switch: terminalMainModelDormancy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An in-process consumer that reads main's emulator, or relies on main
answering a PTY's queries, can now hold the model live with
acquireTerminalOutputReader(ptyId, { kind: 'model' }) and release it when
done. A pin holds across a PTY respawn and releasing it restarts the
dormancy grace period. The reader kind leaves room for a later bytes-only
reader that does not need main's emulator.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main hands a chunk to the view only when the view answers its queries; main answers none of them. The renderer still discarded such bytes without replies in several places: - a hidden view with a restore latched; - backlog bytes a restored snapshot already covers, fully or in part, both on arrival and in the restore queue's drain; - a seq gap that forces a fresh restore; - an unmappable hidden filter; - unparsed writes a snapshot apply or a backlog cap discards. A program that sent CPR or DA there waited forever. This mostly hits the dormancy handoff, where a hidden view answers until main's rebuilt model catches up, and the reveal restore after it. Every discard path now salvages the bytes' queries, the way the pending-cap and restore-queue overflow drops already do. As there, CPR reports the cursor where the view is, which keeps the program alive rather than being exact. The E2E test runs rounds of CPR, DA1 and DSR 5n across hiding and revealing a dormant pane, quiet and with output in flight. It checks for exactly one reply each, with the right cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
which keeps that model parsing every hidden pane. A v45 daemon now answers them instead: main delegates with setSessionQueryResponder, the daemon flags its emulator writes and queues an in-order sessionQueryResponderMarker on the client stream, and main flips the delivery gate only at that marker. resolveTerminalQueryResponder picks exactly one of view, main or daemon per live chunk. Until the daemon confirms, main's live model keeps answering (the view does only when main's model is already dormant); after a take-back the view stays gated, and its reveal restore is deferred, until the daemon's false marker. Main takes the role back (and wakes its model) for agents, remote viewers, model readers, the kill switch, unconfirmed requests and daemon reattaches. Main pushes the renderer's view attributes so OSC 4/12, ?996n and cursor replies match. Old daemons, degraded routes, SSH, relay and agent panes keep main as the responder. Kill switch: terminalDaemonQueryAuthority. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… caught up When a hidden, delegated PTY stops qualifying (an agent starts, a reader registers, the kill switch flips), main takes its queries back. If main's model was dormant, the take-back used to land before the rebuilt model had caught up. The hidden view then had to answer in between, and a view with a latched restore does not parse. Main now wakes its model first and sends the take-back only once that model has caught up. The daemon keeps answering until then, so main answers from an exact model the moment the daemon lets go. A remote viewer still takes over at once, since main will not answer for it. The handoff E2E now runs with the daemon answering and with main answering. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to The protocol version update is consistent, but daemon reattachment can leave hidden terminal queries unanswered, and repeated backlog drops can lose query bytes. These remaining failure paths should be fixed or explicitly accepted before merging. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6651e2cb-79be-469f-af11-3cd8bc80452c
📥 Commits
Reviewing files that changed from the base of the PR and between f4c4eae and 2a3d70a0c83aa9013683a231d49e1d81e627c93d.
📒 Files selected for processing (103)
src/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-query-responder.test.tssrc/main/daemon/daemon-pty-adapter.tssrc/main/daemon/daemon-pty-connection-lifecycle.tssrc/main/daemon/daemon-pty-owner-query-protocol.tssrc/main/daemon/daemon-pty-router-test-fixture.tssrc/main/daemon/daemon-pty-router.test.tssrc/main/daemon/daemon-pty-router.tssrc/main/daemon/daemon-pty-runtime-state.tssrc/main/daemon/daemon-query-responder-routing.test.tssrc/main/daemon/daemon-request-router.tssrc/main/daemon/daemon-session-background-routing.tssrc/main/daemon/daemon-stream-events.tssrc/main/daemon/daemon-view-attributes.tssrc/main/daemon/degraded-daemon-pty-provider.test.tssrc/main/daemon/degraded-daemon-pty-provider.tssrc/main/daemon/headless-emulator.tssrc/main/daemon/session-output-pipeline.tssrc/main/daemon/session-output-plane.tssrc/main/daemon/session-query-responder.test.tssrc/main/daemon/session.tssrc/main/daemon/terminal-host-session-inspection-operations.tssrc/main/daemon/terminal-host.tssrc/main/daemon/types.tssrc/main/ipc/pty-buffer-snapshot-dispatch.test.tssrc/main/ipc/pty-hidden-delivery-gate.test.tssrc/main/ipc/pty-hidden-delivery-gate.tssrc/main/ipc/pty-ipc-daemon-query-responder.test.tssrc/main/ipc/pty-ipc-hidden-delivery-flip-replies.test.tssrc/main/ipc/pty-ipc-hidden-delivery-gate.test.tssrc/main/ipc/pty-ipc-provider-fixtures.tssrc/main/ipc/pty-pending-data-drain-contract.tssrc/main/ipc/pty/delivery/accept.tssrc/main/ipc/pty/delivery/debug.tssrc/main/ipc/pty/delivery/exit.tssrc/main/ipc/pty/delivery/flush.tssrc/main/ipc/pty/delivery/payload.tssrc/main/ipc/pty/delivery/pending-delivery-stamp.tssrc/main/ipc/pty/delivery/pending.tssrc/main/ipc/pty/delivery/wire-session.tssrc/main/ipc/pty/ipc/resize-visibility.tssrc/main/ipc/pty/ipc/snapshot.tssrc/main/ipc/pty/ipc/terminal-view-attributes-ipc.test.tssrc/main/ipc/pty/ipc/terminal-view-attributes-ipc.tssrc/main/ipc/pty/provider/bind-listeners.tssrc/main/ipc/pty/provider/registry.tssrc/main/ipc/pty/runtime/controller.tssrc/main/ipc/pty/session.tssrc/main/providers/pty-provider-contract.tssrc/main/providers/pty-provider-events.tssrc/main/runtime/agent-state-rules/agent-state-rules-engine.tssrc/main/runtime/agent-transcript-pane-test-harness.tssrc/main/runtime/claude-trust-dialog-transcript.test.tssrc/main/runtime/daemon-query-responder-delegation.test.tssrc/main/runtime/daemon-query-responder-delegation.tssrc/main/runtime/fake-daemon-terminal-model.test-fixture.tssrc/main/runtime/main-terminal-model-agent-dormancy.test.tssrc/main/runtime/main-terminal-model-agent-rest.tssrc/main/runtime/main-terminal-model-dormancy.test.tssrc/main/runtime/main-terminal-model-dormancy.tssrc/main/runtime/orca-runtime-activate-managed-worktree.tssrc/main/runtime/orca-runtime-attach-remote-terminal-source-range-consumer.tssrc/main/runtime/orca-runtime-fit-override-listeners.tssrc/main/runtime/orca-runtime-main-terminal-model-dormancy.tssrc/main/runtime/orca-runtime-maybe-hydrate-headless-from-renderer.tssrc/main/runtime/orca-runtime-on-pty-data.tssrc/main/runtime/orca-runtime-on-pty-exit.tssrc/main/runtime/orca-runtime-runtime-id.tssrc/main/runtime/orca-runtime-serialize-headless-terminal-buffer.tssrc/main/runtime/orca-runtime-serialize-main-terminal-buffer.tssrc/main/runtime/orca-runtime-tests/main-terminal-model-dormancy.spec.tssrc/main/runtime/orca-runtime-verify-orchestration-compatibility-caller.tssrc/main/runtime/orca-runtime-visible-snapshot-preview.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/runtime-pty-controller-contract.tssrc/main/runtime/runtime-store-contract.tssrc/main/runtime/runtime-terminal-state-records.tssrc/main/runtime/screen-input-veto.tssrc/main/runtime/terminal-model-query-authority.test.tssrc/main/runtime/terminal-model-query-authority.tssrc/main/runtime/terminal-query-responder.test.tssrc/preload/api/pty-api.tssrc/preload/api/pty-bridge-session-control.tssrc/preload/api/pty-bridge-stream-and-serialization.tssrc/renderer/src/components/terminal-pane/pty-connection-hidden-backlog-reconciliation.test.tssrc/renderer/src/components/terminal-pane/pty-connection/hidden-output-restore-drain.tssrc/renderer/src/components/terminal-pane/pty-connection/hidden-output-restore-snapshot.tssrc/renderer/src/components/terminal-pane/pty-connection/live-data-callback.tssrc/renderer/src/components/terminal-pane/pty-connection/write-pty-output-to-xterm.tssrc/renderer/src/components/terminal-pane/pty-dispatcher-sidecar-only.test.tssrc/renderer/src/components/terminal-pane/pty-dispatcher.tssrc/renderer/src/components/terminal-pane/pty-sidecar-only-delivery.tssrc/renderer/src/lib/pane-manager/pane-terminal-output-queue-backlog.tssrc/renderer/src/lib/pane-manager/pane-terminal-output-queue-registry.tssrc/renderer/src/lib/pane-manager/pane-terminal-output-scheduler-discarded-queries.test.tssrc/renderer/src/web/preload-api/web-terminal-api.tssrc/shared/default-global-settings.tssrc/shared/global-settings-types.tstests/e2e/terminal-hidden-sidecar-pacing.spec.tstests/e2e/terminal-main-model-dormancy.spec.tstests/e2e/terminal-query-reply-visibility-flip.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| // Why: a delegation outlives a quit main; the attaching one starts as responder and delegates again. | ||
| this.answersQueries = false |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C4 '\battachClient\s*\(' src/main/daemon
rg -nP -C3 'sessionQueryResponderMarker' src/main/daemon
rg -nP -C3 'releaseQueryResponderSessions|queryResponderSessionIds' src/main/daemonRepository: stablyai/orca
Length of output: 30503
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- daemon-pty-connection-lifecycle.ts ---'
nl -ba src/main/daemon/daemon-pty-connection-lifecycle.ts | sed -n '1,125p'
printf '%s\n' '--- terminal-host-session-create.ts ---'
nl -ba src/main/daemon/terminal-host-session-create.ts | sed -n '1,220p'
printf '%s\n' '--- setSessionQueryResponder references ---'
rg -n -F -- 'setSessionQueryResponder' src/main/daemon src/main/ipc src/shared || test "$?" -eq 1
printf '%s\n' '--- create/attach session routing references ---'
rg -n -P -C4 'createOrAttach|createSession|attachClient|streamClient' src/main/daemon/daemon-pty-adapter.ts src/main/daemon/daemon-pty-connection-lifecycle.ts src/main/daemon/daemon-session-background-routing.ts src/main/daemon || test "$?" -eq 1Repository: stablyai/orca
Length of output: 45657
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- session-output-plane.ts ---'
nl -ba src/main/daemon/session-output-plane.ts | sed -n '1,205p'
printf '%s\n' '--- session.ts query delegation ---'
nl -ba src/main/daemon/session.ts | sed -n '175,225p'
printf '%s\n' '--- background routing ---'
nl -ba src/main/daemon/daemon-session-background-routing.ts | sed -n '1,115p'
printf '%s\n' '--- query responder tests ---'
nl -ba src/main/daemon/session-query-responder.test.ts | sed -n '1,240p'
printf '%s\n' '--- adapter responder tests ---'
nl -ba src/main/daemon/daemon-pty-adapter-query-responder.test.ts | sed -n '1,125p'Repository: stablyai/orca
Length of output: 25696
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- adapter spawn/attach path ---'
rg -n -P -C8 'async spawn|spawn\(|createOrAttach|createSession' src/main/daemon/daemon-pty-adapter.ts src/main/daemon/daemon-pty-router.ts src/main/daemon/daemon-request-router.ts src/main/daemon/daemon-server.ts src/main/daemon/daemon-session-attachments.ts || test "$?" -eq 1
printf '%s\n' '--- adapter implementation block ---'
nl -ba src/main/daemon/daemon-pty-adapter.ts | sed -n '1,260p'Repository: stablyai/orca
Length of output: 10075
Emit a take-back marker when reattaching an existing session.
When createOrAttachTerminalSession reuses a live session, attachClient clears the daemon's answersQueries flag. The adapter still considers the session delegated because releaseQueryResponderSessions runs only for a fresh connection. If main still gates the hidden PTY, its model does not answer and the daemon no longer answers. Terminal queries can then time out.
Emit an in-order sessionQueryResponderMarker with responder: false for the affected session whenever an existing session is reattached. Clear the adapter's delegated-session tracking in the same transition. SessionOutputPlane.attachClient alone cannot emit this marker because it does not have the stream-routing context.
| @@ -58,6 +59,7 @@ export function replaceBacklogWithWarning( | |||
| break | |||
| } | |||
| } | |||
| const droppedData = shouldNotify ? queuedTerminalOutputData(entry) : '' | |||
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C4 'backgroundBacklogDropped\s*=|replaceBacklogWithWarning\s*\(' src/renderer/src/lib/pane-managerRepository: stablyai/orca
Length of output: 5955
🏁 Script executed:
set -e
printf '%s\n' '--- backlog helper ---'
nl -ba src/renderer/src/lib/pane-manager/pane-terminal-output-queue-backlog.ts
printf '%s\n' '--- queue entry and callback references ---'
rg -n -F --glob '*.ts' -- 'onBackgroundBacklogDropped' src/renderer/src/lib/pane-manager src/renderer/src | head -80
printf '%s\n' '--- helper diff against merge base ---'
git diff -- src/renderer/src/lib/pane-manager/pane-terminal-output-queue-backlog.ts 9d94a20f84d10641f217b9539b0aefeff8d9b1ed 2a3d70a0c83aa9013683a231d49e1d81e627c93dRepository: stablyai/orca
Length of output: 7613
🏁 Script executed:
set -e
printf '%s\n' '--- backlog helper ---'
nl -ba src/renderer/src/lib/pane-manager/pane-terminal-output-queue-backlog.ts
printf '%s\n' '--- callback references ---'
rg -n -F --glob '*.ts' -- 'onBackgroundBacklogDropped' src/renderer/src/lib/pane-manager src/renderer/src | head -80
printf '%s\n' '--- helper diff against merge base ---'
git diff 9d94a20f84d10641f217b9539b0aefeff8d9b1ed 2a3d70a0c83aa9013683a231d49e1d81e627c93d -- src/renderer/src/lib/pane-manager/pane-terminal-output-queue-backlog.tsRepository: stablyai/orca
Length of output: 8689
🏁 Script executed:
set -e
printf '%s\n' '--- callback consumer ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/write-pty-output-to-xterm.ts | sed -n '90,125p'
printf '%s\n' '--- queued data helper and QueueEntry ---'
nl -ba src/renderer/src/lib/pane-manager/pane-terminal-output-queue-registry.ts | sed -n '1,95p'
rg -n -F --glob '*.ts' -- 'queuedTerminalOutputData' src/renderer/src/lib/pane-manager
printf '%s\n' '--- discarded-query test ---'
nl -ba src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler-discarded-queries.test.ts | sed -n '1,110p'Repository: stablyai/orca
Length of output: 10192
Preserve query bytes on every backlog drop.
backgroundBacklogDropped remains true after the first drop. A later overflow can therefore clear queued data without calling onBackgroundBacklogDropped, so query bytes in that data can miss the salvage path and leave the program waiting for a reply.
Suggested fix
- const droppedData = shouldNotify ? queuedTerminalOutputData(entry) : ''
+ // Why always: every discard can carry queries the view still owes replies for.
+ const droppedData = queuedTerminalOutputData(entry)
...
- if (shouldNotify) {
- entry.onBackgroundBacklogDropped?.(droppedData)
- }
+ entry.onBackgroundBacklogDropped?.(droppedData)…tract This PR raises PROTOCOL_VERSION to 45, so the packaged local-build contract has to name 45 as the daemon protocol and list it as attachable. local-build-compatibility-contract.test.ts failed without it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Agent panes kept main's terminal model live, because some agents' readiness rules read main's screen. Only those agents need it: Codex, Cline, Antigravity, Prime Agent and unidentified agent panes (screen rules), Qoder (composer screen), OMP (screen input veto) and Freebuff (per-chunk screen status). Every other agent now rests like a plain terminal, and a hidden one is handed to the daemon's query responder. Two readers treated a missing model as an empty screen; both now wait for the rebuilt model: the tui-idle poll's dialog check, and a fresh worker's composer check before the brief is pasted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2a3d70a to
ee5a177
Compare
|
Closing as not planned. This extends the declined dormant-model/responder stack to selected agents and depends on its rebuild latency, history and query-ownership changes. Maintaining a policy of every screen consumer adds another correctness dependency, while the first screen read now waits for reconstruction. No independent small material performance fix remains after removing those trade-offs. |
ELI5
Orca's main process keeps its own copy of every terminal's screen. #27086 and #27123 let main drop that copy for plain terminals when nothing needs it, and rebuild it from the terminal daemon when something does. Agent panes were left out, because some agents' readiness checks read main's copy of the screen. This PR lets main drop the copy for the agents whose checks never read it, Claude Code among them. Background agents produce most of the terminal output, so that is where the saving is.
What Changed
Before: main parsed every byte of every agent pane, visible or hidden, even when no reader needed its screen.
After: an agent pane is treated like a plain terminal unless its agent reads main's screen. These agents still keep main's model, as today:
Every other agent (Claude Code, Gemini, OpenCode and the rest) gets its readiness from hooks, titles and the text tail, which main keeps without its model. The rule reads the agent's rule files, so a rule that starts reading the screen keeps its agent live without a change here.
Two readers could still read an agent's screen and treated a missing model as an empty screen. Both now wait for the rebuilt model instead:
tui-idlepoll's dialog check. Claude Code's workspace-trust dialog parks the cursor above its options, so only the screen shows them. With the model gone, the read returned nothing, and a weak-ready wait could settle on the trust dialog. The poll now asks for the model first, and the read waits for the daemon seed.Freebuff identification also takes the foreground agent, so a model rebuilt after dormancy still recognizes a Freebuff started by hand, after the title that identified it has passed.
For a hidden agent pane, #27123's daemon delegation now applies too: the daemon answers the pane's terminal queries and main's model rests.
Why
Most of the terminal bytes in an agent-heavy workspace come from hidden agent panes. Main parsed all of them, synchronously on the main thread, for a screen nothing read.
Alternatives considered:
Stacked on #27123
This branch sits on #27123 (the daemon answers hidden queries), which sits on #27086 and #27129. The diff here includes their commits until they land.
Linked Issue
Part of #27023 (phase 2b: agent panes)
Visual Proof
N/A: no UI or behavior change. Agent readiness, dialogs and query replies stay the same, which the tests below check.
Testing
Captured transcript: Claude Code's workspace-trust dialog, replayed into a pane whose main model then went dormant. A
tui-idlewait must still report the dialog. Without the poll fix the wait times out instead.Per agent: after 5 s of quiet, main's model rests for Claude Code, Gemini and OpenCode panes, and stays live for Codex, Cline, Antigravity, Qoder, OMP and Freebuff. The rest cases fail on the previous rule.
Settled screen read: for a dormant Claude pane, the synchronous read reports no screen while the model is rebuilt, and the settled read returns the rebuilt screen with its dialog text.
In-app A/B: headless E2E on minified builds; nobody used the app by hand. A stand-in Claude Code process (a small compiled launcher whose foreground process reads as
claude, running a shell script as its child)cats 16 MiB of agent-TUI frames into a hidden pane. Main'sprocess.cpuUsage()is recorded until main goes quiet; the daemon's CPU time and RSS come fromps; main's heap is read after a forced GC. Runs alternated between a build of perf(terminal): let the daemon answer hidden local terminals' queries #27123's head and a build of this branch, n=10 each, with host load between 5 and 12 on 16 cores (medians, p25–p75):The delivery debug snapshot showed the daemon answering the pane's queries in every run of this branch and in none of perf(terminal): let the daemon answer hidden local terminals' queries #27123's. Before this PR, an agent pane kept main as its responder. An earlier batch of the same A/B, without the daemon and memory sampling, gave main CPU 46.9 → 32.5 ms/MB (−31%).
No committed agent-pane E2E. A headless E2E can mark a tab as a Claude launch through the renderer store (
queueTabStartupCommandwithlaunchAgent, also with a launch token or launch config), but that path never gives main's PTY record alaunchAgent: such a test passed on perf(terminal): let the daemon answer hidden local terminals' queries #27123's build too, so it proved nothing and was dropped. The runtime tests above register the launch identity the way a real launch does, and the in-app A/B uses the foreground-process path.Unit suites for
src/main/runtime,src/main/ipcandsrc/shared: 29,792 pass (pnpm test src/main/runtime src/main/ipc src/shared). The 2 failures inrun-terminal-shell-alone.node-pty.test.tsfail the same way on the base commit in this environment. Four built-CLI subprocess tests failed against a staleout/clifrom another branch and pass against this branch's build.pnpm tcand the changed-code quality gate (ORCA_CODE_QUALITY_BASE=upstream/main pnpm run check:code-quality:changed) pass. The fullpnpm test,pnpm lintandpnpm buildwere left to CI.I manually tested these changes locally (not done: only the headless E2E runs and tests listed above ran)
Automated tests added/updated, or explained why not below
AI Disclosure
Implemented with Claude Opus 5.5 via Claude Code: design, code, tests and measurements. A human (outof-place) directed the work.
Review
Suggested reading order:
main-terminal-model-agent-rest.ts, the per-agent rule.canMainTerminalModelRestinorca-runtime-main-terminal-model-dormancy.ts.readVisibleScreeninorca-runtime-runtime-id.tsand the composeracceptinorca-runtime-activate-managed-worktree.ts.Agent skill upstream boundary
Trade-offs
terminalMainModelDormancy: falsekeeps every pane's model live, as before perf(terminal): let main skip parsing visible local daemon terminals #27086;terminalDaemonQueryAuthority: falsekeeps main as the responder.--expose-gc, heap plus array buffers). In the app, one hidden flood left main's RSS 23 MiB lower. The daemon's RSS was also 60 MiB lower after the flood; a likely reason is that the daemon buffers less output while main keeps up, and RSS is a high-water mark. The daemon holds no new state per pane beyond the responder flag.main-terminal-model-agent-rest.ts; the per-agent tests sit next to it.Notes
terminalMainModelDormancyandterminalDaemonQueryAuthoritycover agent panes too.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code