Repository navigation
perf(terminal): read background terminal screens from the daemon's model instead of re-parsing them on main - #46516
Conversation
Perf scan blockedP1 — One slow screen read can launch two snapshots for the same PTY. The format split in
Changed work by trigger and ownerR and C below are the addressed PTY's applied rows and columns. B is the encoded reply size. Counts are per acquisition unless a row specifies otherwise.
Visible gates and cache · Daemon output plane · Snapshot metadata · Projection · Cursor context · Request route · Cleanup Six questions and regression classes
The recurring classes matched here are re-reading unchanged input and overlapping pending work (P1), per-chunk rescans (one extra capture tracker in that P1 overlap), per-entity retention (one additional indexed slot, cleared as above), eager startup imports (the fixed one-time daemon graph above), and idle wakeups/hidden owner work (no new cadence at idle, with requests still gated by active callers). The request-scoped deadlines predate this change, and the idle-wait poll still reads the live main-side model. The changed test files add a daemon wire check, concurrent current-daemon replay and legacy parsing checks, an ownership assertion adjustment, and test import updates. They add no shipped work. Verification. 201 tests passed across four named files through the test gate on macOS. The daemon server test exercised the real local control socket with simulated PTY output, including alternate-screen rows with no ANSI fields and a separate legacy-form request. The runtime suite covered successful projection, replay, legacy ANSI, and stale or replaced terminal rejection. Row provenance and settled shell ownership tests passed. No app build, launch, live fleet profile, or captured cross-platform latency. The P1 is a source-proven request-count regression, with user-visible latency magnitude unmeasured. Reviewed |
Perf scan blockedP1 — The first screen read can still duplicate a zero-row replay on a compatible older daemon. In
Original 750 ms repro passed. The gated performance test starts provider-preferred screen reads, holds the first reply past 750 ms, and releases a sequence-current projection at 751 ms. It got 2 requests for 2 PTYs and 20 for 20, all projection requests, and every caller returned the projected screen. The fallback now joins the original acquisition under the existing 8 s caller budget. The tests also passed for ANSI-first sharing with a 50-row replay and visible-first sharing after legacy capability is learned. The remaining cold-overlap finding comes from the pinned source trace. Original input and count assertions · Screen fallback · Wait budgets Changed work by trigger and ownerR and C are the addressed PTY’s applied rows and columns. B is one encoded reply’s byte size.
Routing · Snapshot metadata · Projection · Rows · Cursor context · Provider adapter · Provider fallback · Visible cache · Generation cleanup Six scan questions and regression classes
Matched classes are repeated reads of unchanged input, pending-work multiplication and extra per-chunk scans (P1 above), per-entity retention (one additional indexed slot and one boolean, cleared with the PTY generation), eager startup imports (three small modules once per daemon process), and idle or hidden-owner work (zero added idle cadence, with requests admitted by demand). No newly bypassed feature gate, store churn, new process spawn, storage rewrite, or full-state publication was found in the changed paths. Verification. 205 tests passed across five named suites through the macOS test gate. The performance suite exercised the runtime controller/provider boundary with synthetic replies. The runtime suite covered concurrent current-daemon replay, legacy parsing, stale output and replacement generations. The daemon server suite exercised a real local control socket and validated both response formats with simulated PTY output. Row provenance and settled shell ownership tests passed. Source counts and the executed cases above are separate from estimates of fleet impact. No live fleet latency, CPU, or heap profile was collected. Reviewed |
Perf scan blockedP1 — Clipping bypasses the row string cache on Electron main, including grids that never shrank. In P1 — The daemon projection does width-dependent work for invisible cells after a shrink. The daemon call introduced in P1 — The version bump adds steady idle work while the previous daemon still owns live terminals. Protocol 62 selects a different endpoint and startup eagerly starts and leases a v62 daemon even with a healthy v61 daemon serving the old terminals. The base reused the v61 endpoint on that input. On default launched profiles, the new process schedules one host terminal-policy refresh every 3 s when the host policy path is available and there is no environment override (up to 1 KiB, guarded against overlapping reads), one host-ledger tick every 60 s, and one process-growth timer every 30 s at idle. Unix also runs one synchronous endpoint stat every 30 s. For those four timers, the v61 process stays at 25 callbacks/min on Unix or 23 on Windows, while v62 goes from absent to 25/min or 23/min. The added daemon goes from 0 to about 0.417 callbacks/s on Unix or 0.383/s on Windows. Totals grow from 25 to 50/min on Unix and from 23 to 46/min on Windows. The extra timer count on main and renderer is 0/s. With a policy override, subtract the policy's 20 ticks/min per process. The ledger tick writes only after that process has published its share. In ordinary observe mode the idle growth tick schedules its next run without reading the process table. In enforce mode two generations with live PTYs can each request one host process inventory per idle 30 s, where one generation made one request. The extra daemon and timers are per upgraded profile at both 300 and 3,000 terminals, with two generations retained while the old sessions stay live. This adds wakeups and duplicate host-policy I/O without a screen read. Verify with a healthy v61 owner kept alive across init, no new terminals or screen reads, and count daemon processes, timers and I/O before/after with a fake clock over 60 s. Separately exercise active v62 sessions and v61 retirement. The rates are source-derived. Protocol · Versioned endpoint · Provider init · Lease and legacy discovery · Policy · Ledger · Growth timer · Unix ownership timer Prior findings verified at this head
Work by trigger and ownerR and C are the addressed PTY's applied height and width. W is its stored row width and B is the encoded reply size.
Request routing · Existing fences · Proof and parser fence · Provider dispatch · Projection · Legacy discovery · Hold and ordinary snapshots · Chunk scanning · Separate mode boundaries · Close inventory · Host preflight Every production caller of the clipped row read
Live-model gates and raw-rule path · Wait tick gates · Lazy verdict read · Titleless permission read · Delivery dialog read · Launch-composer read · Tail caller bounds · Tail/visible passes Six scan questions
Regression classes screened. Re-reading unchanged input and hot-path rescans are findings on main and daemon. Fixed-cadence polling/steady-idle wakeups and newly reachable host I/O are findings during mixed-version operation. Per-entity acquisition retention is scoped to a live generation and teardown. Format-split fan-out shares matching requests and retains the base's supersession/deadline behavior, demonstrated for the two prior failures. Eager imports add the fixed source sizes above once per process. Wire replies stay demand-driven, one response per acquisition. Existing per-waiter screen polling and optional per-page fan-out predate this span. The clipping change increases their per-read work. Verification. 223 tests passed across nine named suites through the macOS test gate. They covered the two original inputs, concurrent current-daemon replay, freshness and generation handling, live wait polling, wrapped-row provenance and wide-glyph clipping, socket wire formats, shell ownership and protocol compatibility. The three findings above use source-proven operation counts. No fleet CPU, latency, heap or packaged startup measurements were collected. Reviewed local |
Perf scan blockedP1 — A one-column shrink still bypasses warm row-string caches on main and the renderer. The renderer's IME mask runs the same context reader on session start and on each render while composition is active. One warm 120×24 pane adds 2,880 decodes and 24 arrays/joins per call. At an illustrative 60 delivered renders/s, one active composition adds 172,800 decodes and 1,440 joins per second on the interaction thread, independent of 300 versus 3,000 resident terminals. Blank retained rows instead add up to 120 public cell loads per row to find the visible trim boundary, even if the result stays empty. These are source-derived operation counts for the shipped buffer implementations and production caller gates. The cost repeats after a single resize and competes with input, render and IPC work. A deterministic guard should count slow translations and trim probes after warming the same-width and 121→120 grids, then mutate one row and verify both fresh output and reuse for the unchanged rows. Exercise repeated active-composition renders and the live main projection at N/10N. Keep applied width, wide-cell behavior, wrapped provenance and cursor style evidence in the oracle. Main visible rows · Context translation · Clipped helper · Main projection · Wait admission · Wait screen gates · IME render gate Pass 3 inputs at this head
Work by trigger, owner and boundR/C are applied rows/columns for one PTY. W is retained row width. B is the encoded response size. Glyph strings may hold more than one code unit per cell.
Controller route · Host registry · Degraded dispatch · Degraded membership · Hello wire · Pair handshake · Request routing · Snapshot fence · Parser and ingress fences · Shell proof limits · Ordinary and projected serialization · Projection work · Adapter fallback and overlay · Acquisitions · Mode tracker lifetime · Output scan · Main tail bounds · Renderer draft cache · Draft pickup · Paste verification cadence Main live grid callers include the ordinary visible-state path, late mode-transition reconciliation, the waiter blocked-screen path, and lazy TUI evidence during wait entry/tick/resample, input delivery and launch readiness. A wait sample memoizes one lazy evidence read, and can also run a separate gated blocked-screen projection. Titleless eligibility, permission/delivery and launch-composer checks each address one PTY. Direct context calls also run on a guarded mailbox/delivery draft check, prompt-render arm or admitted output/settle callback (one proof read in flight per gate), and eligible prompt resubmission after the current screen has settled. A prompt proof can run both a visible projection and a second typed-context read. Ordinary key handling adds no new call to cursor context. Echo or key input can cause a render, and that render takes the IME path only while a composition is active. The moved readiness rule helper lazily reconstructs draft text once per admitted rule read with up to one reverse row search, one draft split and one output copy. Unchanged replay callers, bridge/type moves and test wiring add no shipped recurring work. Lazy wait evidence · Titleless read · Permission read · Launch composer · Delivery draft hold · Prompt render gate · Resubmit · Readiness probe Six scan questions and class dispositions
Verification. 89 tests passed across 11 named unit files, plus six targeted tests in the runtime aggregate through the macOS test gate. They covered the socket contract, handshake reset, provider acquisition counts, resize and cursor-context output, idle wait, wrapped-row metadata, shell-ownership snapshot and renderer composition behavior. The cache and fleet figures are source-derived operation counts. The exact 121→120 warm-grid cost has no executed counting contract. No packaged-app or native IME timing, live fleet CPU, heap, or startup measurements were collected. Reviewed local |
Perf scan pass 5 — blockedP1 — Retained-width rows still redo clipping work on every warm read. Width clipping introduced in the PR bypasses the warmed full-row string cache whenever retained columns contain text. The final repair in The final blank-overhang check also adds recurrent scanning even when canonical translation hits. On a warm 240→120×24 grid with 120 visible ASCII cells and 120 empty retained cells per row, the two main passes issue 5,808 edge/overhang cell loads per projection, including 5,760 off-grid loads. Subtracting 2,880 fewer style-cell visits and 120 fewer cursor-suffix visits leaves 2,808 additional public cell loads before cursor trim and encoding costs. The IME has one blank-proof pass of 2,904 loads. On that renderer input, most of those replace visits from the old full-width style scan. The main headless row pass alone adds 2,904 loads to what was a cache hit per row. Both shapes matter because repeated reads after repaint still encounter the same retained width and cells. Applied-column reader · Visible rows · Cursor context At one admitted live-grid projection per existing two-second sweep for 100/1,000 eligible waiters, the occupied case adds 288,000/2,880,000 full-row decodes and 2,400/24,000 joins per second on Electron main. The blank case adds 140,400/1,404,000 public cell loads per second after the style and suffix savings described above. Twelve CLI readers at one read every three seconds add 23,040 full-row decodes and 192 joins/s in the occupied case. At an illustrative 60 delivered renders/s, one composing renderer adds 172,800 full-row decodes and 1,440 joins/s in the occupied case, with 300 or 3,000 resident terminals. Main wait work is conditional on the existing evidence gates and can take a separate blocked-screen read. A fresh daemon projection also makes both row passes, with 5,760 uncached full-row decodes and 48 joins on the occupied sample. Daemon cache hits at the main caller avoid that request entirely. These are source-derived counts and assumed admission rates, with no measured interaction latency. The repeated work competes with main RPC and renderer composition work. Sweep admission · Sweep cadence · Wait runtime wiring · Daemon snapshot branches · Cached frame checks and late adoption · IME composition gate A deterministic guard should warm the same real buffer at base and head, then count translated cells, arrays/joins and clipping probes on repeated reads of an unchanged 120×24 grid and after 121→120 and 240→120 shrinks. Drive the live main projection and active IME context at N/10N, include occupied and blank overhangs, then mutate one visible row and verify changed output with reuse for the other rows. Preserve the applied width, wide-edge behavior, wrapped provenance and cursor styling. Reusing the clipped row result would require invalidation on the actual row mutation and applied width. Applied-column reader · Cursor context · Projection · Geometry and correctness controls Original pass-4 failing input
Work by production trigger, owner and boundR is applied screen rows, C is applied columns, W is retained row width, L is the requested tail limit and B is encoded control-reply bytes. A cell can contain multiple code units. Each request addresses one PTY.
Control hello · Client handshake · Daemon adoption · Versioned endpoint names · Protocol version and fallback generations · Controller lookup · Host registry · Daemon adapter route · Degraded provider route · Degraded lookup · Snapshot request · Shell-ownership and session admission · Ingress barrier · Proof queue and deadline Daemon snapshot branches · Projection · ANSI metadata and serializer · Wire selection and conversion · Acquisition slots · Capture and tracker lifetime · Per-output-chunk gate · Mode tracker limits · Replay request · Explicit screen fallback · Temporary replay grid · Rendered tail and compatibility branch · Raw rule grid and whole-model gate · Readiness probe · Draft revision cache · Paste verification · Process termination move Main callers of the shared grid code include explicit reads, late mode-transition reconciliation, live waiter screen/blocker checks, titleless agent evidence, permission/delivery and launch-composer checks. A waiter evaluation memoizes one lazy evidence read and can also run a gated blocked-screen pass. The prompt proof can read one screen and a separate typed context after its existing admission checks. Prompt resubmission and the delivery draft hold each address one terminal. Optional worktree listings can request agent-wait status for each eligible row on the requested page. Production cadence is demand plus the pre-existing waiter sweep/recheck, prompt settle/output and composition callbacks. Type moves, bridge forwarding and test fixtures introduce zero recurring work themselves. Main live-grid projection · Lazy evidence · Titleless agent evidence · Permission and delivery evidence · Launch composer evidence · Delivery draft hold · Prompt proof · Prompt resubmission · Optional agent-wait listing · Wait runtime wiring Six scan questions and matched classes
Verification. 85 tests passed through the named macOS unit-test gate. Ten files contributed 79 tests and the runtime aggregate contributed six targeted cases. The acquisition contracts made 2/20 requests for 2/20 delayed screens released at 751 ms and for 2/20 cold legacy screen-plus-replay pairs. The test suite also checked ANSI-first sharing, distinct formats when projection starts first, sequence/generation/handle rejection, snapshot ownership, resize semantics, wait and renderer composition behavior. Pass-5 fleet, byte-format and row counts above come from source, with no packaged-app CPU, heap, native IME or final-head timing measurement. Acquisition contracts · Staleness and replay controls · Socket controls · Geometry and correctness controls Reviewed |
Perf scan pass 6 — findingsP1 — A screen read followed by a concurrent zero-scrollback replay adds a daemon snapshot and a second main-process scan of live output. The base reused the outstanding zero-row ANSI capture for both consumers. The new format split starts a projected RPC for the first read and a zero-row ANSI RPC for the second. This order is reachable when an explicit screen read or a restored-terminal readiness probe overlaps a client snapshot request with zero or omitted scrollback for the same PTY. The capable-provider test holds the screen response open and checks that both formats are delivered. The count follows directly from the two slots and the old single-slot admission predicate. ANSI-first and legacy zero-row pairs still share one RPC. Format selection and sharing · Zero-row client snapshot · Production snapshot request handler · Screen-first control Each overlap adds one daemon ownership/write fence, ingress barrier, visible-grid projection, JSON encode and reply. Main gains one reply decode and one temporary capture-mode tracker, and saves the screen consumer's ANSI replay and projection. Both captures register trackers in the same PTY's set, and main sends every arriving chunk to each tracker. For the overlapping phase of a zero-row pair, main goes from one to two in-flight scans per chunk, in addition to the unchanged settled tracker when present. The extra scan checks the entire chunk for escape bytes and can run the mode parser over escape-bearing output. The duplicated coverage lasts until either capture settles. On a delayed daemon this window can outlive the screen caller's 750 ms wait, up to the existing control deadline for connected captures. This raises work on the shared daemon during concurrent screen and replay requests and on main's output-delivery path while the affected PTYs paint. Tracker registration and cleanup · Per-chunk scans · Control deadline A sensitivity check at 100/1,000 eligible PTYs with one overlapping pair per PTY every two seconds adds 50/500 RPCs and projected replies per second. At the slowest median below, the projection alone costs 6.3/63.2 ms/s on the daemon, before the extra fence and JSON work. With 100/1,000 pairs concurrently in flight and 10 output chunks/s per PTY, the extra main cost is 1,000/10,000 scan calls/s. At 4 KiB per chunk that is 3.9/39 MiB/s of input to the extra scanner. These conditional loads use the stated rates. Production overlap frequency and main-thread latency were unmeasured. The existing two-second wait sweep reads the main emulator. The provider overlaps require separate admitted screen and replay demand. A regression check should hold the screen-first, zero-row pair at 100 and 1,000 independent PTYs, deliver chunks while both requests are pending, and count daemon captures and main mode scans. Preserve ANSI replay, fresh screen rows, split escape handling and generation rejection. Sharing the underlying mode scan across captures would remove the per-chunk amplification even when the two formats need separate responses. Existing local-grid wait sweep · Mode scan fast path · Legacy and ANSI-first controls Pass-5 finding and daemon costThe pass-5 main and renderer cell-work regression is resolved. I compared the fallback reader bodies to the base byte for byte. Main's local screen and historical-tail projections enter the original row loop after one branch per reader call. Main's live cursor context and the renderer's IME and draft readers enter the original cursor loop after one branch. Those paths add zero clipped column visits, sliced translations or row-string cache misses per read. The renderer callers are unchanged. Direct ruled-screen and paste-check readers have the same path as the base. The daemon is the sole production caller that enables clipping. Main row reader · Shared cursor reader · Main screen caller · Renderer composition caller · Renderer draft caller · Daemon opt-in The completed Linux source probe measured microseconds per read, using the median of seven 2,000-read batches on warm alternate-screen fixtures. The base and final probe commits differ from their reviewed parents only by the probe. The live-reader arms run on a persistent grid. The daemon arm calls the clipped projection directly. These timings exclude ownership settling, socket/JSON, ANSI serialization, and main replay. The final 121→120 blank live arm ranged 45.7–89.8 µs within the run. The byte-for-byte comparison establishes the unchanged loop work. The timing arms do not isolate a change in live-reader latency.
Comparison with the actual ANSI route. Let R be applied height, C applied width, and B the string bytes including combining glyphs. A zero-row ANSI read serializes the last R normal rows and, when active, R alternate rows, at up to C cells each. At 120×24 that is 2,880 normal-screen or 5,760 alternate-screen serializer cell visits before wrap/cursor work and any enabled link-range scan. The daemon also constructs ANSI mode/frame state and encodes the reply. Main decodes it, creates and initializes a temporary grid, feeds the ANSI bytes to its parser, projects its rows and cursor context, and disposes it. The new route skips those ANSI operations and the temporary grid. It walks at most R viewport rows and R live cursor-context rows on the daemon, with one C-wide glyph/style scan per context row and an extra cursor suffix scan of at most C cells. It emits up to R nonblank lines and R metadata entries plus draft text, then main decodes and adopts those arrays. ANSI path and metadata · ANSI cursor work · ANSI link gate and scan · Temporary grid and parse · Projected rows and draft For each overwidth row in either daemon pass, classification examines one edge cell plus at most C retained cells. Widths above 2C skip the retained-suffix scan. For 24 retained rows at 121→120, classification costs at most 96 public cell loads across the two passes. At 240→120 with a blank retained suffix it costs up to 5,808 loads, before the up-to-2,880 style loads. The blank case can reuse the full-row translation. Occupied or split-wide edges can require bounded reverse trim scans and explicit range translations instead, including another translation for wrapped-row spacing. Each visible row has at most two translations, each cursor-context row one, and the cursor has two additional ranges. This is geometry and glyph-byte work independent of history length or retained pre-shrink width beyond 2C. It can exceed the old daemon's raw serializer visit count, so the projection timings alone leave the daemon CPU delta unmeasured. The removed main grid and parse are source-proven. A paired timing for the complete ANSI and projected RPCs was unavailable. Viewport loop · Cursor context scan · Width and trimming bounds Work inventory and six scan questions
Matched classes. Hot-path rescans and concurrent fan-out have the P1 above. Unchanged-input reads are skipped by the normal provider-visible cache. Further explicitly requested snapshots and legacy fallbacks remain demand-driven. The clipping re-scan is confined to the replacement daemon path and bounded as priced above. Per-entity state retires at the existing boundaries, subject to the outstanding RPC lifetime. Whole-snapshot publication covers one requested screen with zero new streaming or broadcast publications. Eager imports add the fixed startup work described above. No added timer, polling loop, hidden-pane capture, per-row mount work or bypassed visibility/admission gate was found. Verification. 91 named macOS unit tests passed, including 72 across nine files and 19 selected runtime, cursor and IME cases across three files. The remaining 198 cases in the selected aggregate were filtered out. The capable/legacy sharing and stale-frame controls ran. The overlap RPC and scanner counts are source-derived. The Linux timings are from the separate warm-grid probe, and its result excludes end-to-end daemon contention and main-process latency. No build or app launch was used. GitHub and the reviewed worktree both identified |
Perf scan pass 7 · CLEANNo P0 or P1 findings in The count test drives two chunks at 100 and 1,000 PTYs with both requests held open and no settled tracker. It observed 200 and 2,000 calls, respectively. Pass 6 would have made 400 and 4,000 calls. The corresponding counts at 300 and 3,000 PTYs are 600 and 6,000. The split-escape test confirms that a capture started after the escape began does not inherit that switch, while the earlier capture uses the post-switch live grid. The offset and last switch each occupy one scalar. The existing escape carry and mode stacks remain capped at 4,096 code units and 16 frames per screen. Each tracker still gates regex parsing on an escape introducer or an incomplete carry. The offset bookkeeping also runs in existing daemon-ingress and renderer trackers, adding constant work per gated chunk and recognized switch without another byte pass. Count contract · Split-switch test · Scanner Work and bounds
Regression classes. Hot-path rescans are bounded by the shared tracker and the geometry work above. Unchanged-input reads use the existing cache and in-flight sharing. Fan-out is one reply per demanded format, with the existing stronger-ANSI supersession noted above. Per-entity state ends on settlement or retirement. Whole-snapshot traffic is one response to a requested screen, with zero new streaming or broadcast frames. Eager imports are fixed-size startup work. No added polling loop, hidden or unobserved capture, per-row mount work, persistence write, or bypass of live-model and freshness gates was found. Evidence and limits. 102 named macOS unit cases passed, including the two overlap counts, capable and legacy sharing, slow responses, both formats, clipped wide glyph and draft, retained history, connection reset, split mode switches, and stale sequence, generation and handle rejection. The selected runtime aggregate skipped 177 unrelated cases. GitHub and the worktree both identified |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Status: ready for review at
|
QA screenshots (final head
|
…-parse-off-main # Conflicts: # src/main/daemon/emulation/testing/headless-emulator-shrink-snapshot.test.ts # src/main/daemon/server/testing/daemon-server.test.ts # src/main/daemon/terminal-host/testing/terminal-host-spawn-input-retention.test.ts # src/main/daemon/transport/client/daemon-client.ts # src/main/daemon/transport/client/testing/client.test.ts # src/main/runtime/terminal/query/terminal-creation-and-readiness-part-10.spec.ts # src/main/runtime/terminal/wait/agent-transcript-replay-test-harness.ts



ELI5
When Orca needs to see what's on the screen of a terminal it isn't showing (for example to check whether an agent is waiting at a prompt), it sometimes has to ask the background terminal service for it. Until now the service sent back the whole screen as raw terminal codes, and Orca's main process re-drew that screen from scratch just to read its text. Now the service, which already has the screen drawn, sends back the finished lines. The main process does less work, and nothing looks different.
What Changed
getSnapshotrequest accepts an optionalvisibleProjection: true. With it, the session returns the visible rows, row metadata and composer draft computed on its own emulator (projectTerminalVisibleLines), plus size, modes, title, terminal owner and output sequence, and skips ANSI serialization.projectTerminalVisibleLines/projectTerminalTailLinesmoved tosrc/main/daemon/emulation/terminal-screen-projection.tsso the daemon and the runtime share one implementation;RuntimeTerminalProjectionmoved to the shared runtime terminal contracts.visibleProjectionrequest option and response field. Only the provider-preferred visible screen read (captureProviderVisibleState) asks for it;adoptProviderVisibleSnapshotuses the returned rows and parses ANSI only when they are absent. All existing generation, sequence, mode-transition and retry checks are unchanged.captureProviderVisibleStateand thereadProviderTerminalTailLinesvisible-screen fallback, so a slow read and its fallback share one pending request.visibleProjectionSnapshots: truein its authenticated control hello (an optional field, like the existingresizeModel). The client records it per connection, replaces it on reconnect and clears it on disconnect, so the adapter knows before sending anything whether a projection can be asked for. A daemon without it (one that survived an app update) gets plain zero-scrollback ANSI requests in the single shared acquisition slot, exactly as today, so visible reads still share one request with an overlapping replay. Visible and ANSI acquisitions are tracked separately only for daemons that advertise projection, so replay readers never receive a projection-only snapshot. No protocol version change, so no second daemon is started on update.clipToGrid, used only bySessionOutputPlane.getVisibleProjection), through one shared rule (terminal-line-applied-columns.ts): a wide glyph split by the right edge reads as blank, matching the ANSI round trip it replaces, and rows whose overhang is blank reuse xterm's cached row text. Every other reader (main's live-model reads, waits, prompt checks, tail reads, the renderer's composer and IME reads) runs exactly the code and cost it runs today.terminateOwnedTreemoved fromsession.tstosession-process-inspection.tsunchanged, to keepsession.tsunder the 300-line limit.Why
This is the first step of moving terminal output parsing off Electron's main process: the daemon already parses every byte of a session, so screen reads should come from that model instead of being rebuilt on main. The capability is negotiated in the daemon hello: daemons that survive an app update don't advertise it and keep today's path, and an older app never sends the new option.
Linked Issue
N/A (maintainer change; part of the backend move).
Visual Proof
N/A: no visual or interaction change; screen text read for background terminals is identical.
Testing
provider-buffer-acquisition.performance.test.ts): a screen read held past its 750 ms wait plus its fallback, and an older daemon's screen read overlapping a zero-row replay, each make exactly one provider request per terminal at 2 and 20 terminals.abcdefghi(notabcdefghij) and its composer draftabcdefg(notabcdefgh); split and exactly-fitting wide glyphs; scrollback keeps its text.Performance
Less work: on Omarchy, main-thread time per provider-preferred screen read drops from 0.27-0.75 ms to about 0.01 ms (identical lines), and the daemon's side is 43-126 us per read including the post-shrink worst case. A provider-preferred visible screen read no longer serializes the screen to ANSI in the daemon, sends it over the socket, and re-parses it in a fresh emulator on main; the daemon reads rows from the emulator it already has. Nothing new runs per output chunk or on a timer. Measurements on the exact head are in the status comment.
Risk
Level: Medium. The riskiest part is screen text for background terminals coming from a different code path; if it were wrong, an agent-waiting or idle check could read the wrong screen. The rows come from the same projection function over the daemon's live model at the same read point a snapshot uses. Older daemons and other providers keep today's path. A plain revert backs it out.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)