Repository navigation
Conversation
Parse the body of one Program Status report (protocol rev 0.4) into a report or a discard. Malformed pairs are skipped and counted; every well-formed occurrence is checked against the per-pair limits (key length, msg and title encoded and decoded size, strict base64 that decodes as UTF-8, control characters, app size, id size and grammar) before duplicates resolve, so an invalid earlier duplicate discards the report. A missing or unrecognized state discards it; an unrecognized kind, app or progress is treated as absent. Decoded msg and title are validated and not retained. Pure and not yet wired to any terminal.
Scan a PTY stream for OSC 7501 reports, OSC 133;A prompt starts and RIS, each with its source offsets, whatever the chunk boundaries. A report ends at BEL or ST, and a bare ESC also terminates it, as in Ghostty: the report is parsed up to that ESC and scanning resumes at the ESC, so it can begin the next sequence. The scanner carries at most a partial prefix or one open frame; a frame over 4096 UTF-8 bytes (skipped pairs and a BEL or ST terminator included) is discarded whole and skipped to its terminator without being buffered. The probe body is ignored. RIS and prompt starts are only scanned while the caller says they matter, re-read after every event so a report can arm the rest of the same chunk; DECSTR, alternate screen switches and erase display are not resets. Searches only move forward, and a chunk with nothing to report costs one indexOf per active pattern with no copy of the chunk.
Keep the per-terminal records the Program Status protocol describes: a report replaces its record completely, clear removes the addressed record and its subtree (no id is the root, so it empties the store), and past 256 records the least recently updated one is evicted. A prompt start drops working and blocked records and keeps idle, done and error; RIS drops everything. Summarize the records into the aggregate state a status dot shows (blocked and question above working above error above done above idle, ties to the most recent update), the root record's own state, and whether a child failed. A child error never becomes the aggregate error. The projection carries the current summary and the one that remains once the attached process exits (done and error only), computed without changing the store. Pure and not yet wired to any terminal.
…ations and budget Run the scanner and the record store for one PTY incarnation and number what they produce. After every applied event, in byte order and before any throttling, the tracker recomputes the projection and gives each of its two views (now, and what remains on exit) a new generation when that view's summary changed, drawn from one counter that clear, RIS and prompt starts never reset, so a generation is never reused. A changed view also records, on the owner's wall clock passed in by the caller, when its aggregate and its root last changed. Any change of either view takes the next reportSeq, so an equal reportSeq always means an identical observation, and a repeated state takes no number. Emission is throttled per PTY (a burst of 8, 20 per second) and the latest observation is always delivered, at worst by one 100 ms trailing timer. The budget and its timer read an injectable monotonic clock, never the wall clock, so a step of the owner's clock, backward or forward, neither credits time that did not pass nor delays delivery. An emission carries the reportSeq and the views recorded with it, so a coalesced done, working, done still shows a newer generation than the first done. snapshot() returns the current state without incrementing anything, and discarded reports are counted by reason. Pure and not yet wired to any terminal.
…mposition Define the program-status slot a pane will hold beside its hook row: the PTY and incarnation it belongs to, the tracker's reportSeq, a liveness (live, unverifiable, exited) with the instant it began, and the shown view (now, or what remains on exit) with its generation. A dismissal is an acknowledgement of one incarnation, view and generation. A strict codec parses the fact a PTY owner sends and the acknowledgement argument, rejecting an unknown state, a non-positive or fractional generation and a non-finite time. applyProgramStatusWrite is the pure acceptance rule: reports are ordered by reportSeq inside an incarnation and another incarnation replaces the slot; lifecycle writes are fenced by identity, exited is absorbing, and an empty view removes the slot. The liveness time is copied from the write and never stamped, so a re-created slot keeps the instant its producer was last verified. carryAckAcrossExit keeps a dismissal across the process exit only when it names exactly the pre-exit view and the remaining view shows the same summary; it reads the acknowledgement and the exit write alone, so it holds with no pane record. composeAgentStatusEntry applies the precedence setting as a pure input and reads no clock or timestamp: without a slot the hook entry is returned as is; by default a hook row wins unless it is absent, a seed Orca planted at launch or from process output, or restored and not yet confirmed. The display entry built from a slot maps the aggregate to the existing states, takes the main agent verdict from the root alone, and marks the idle state as resting. Tests run the existing sidebar row, dashboard, worktree card and worktree ps readers on that entry and on a hook entry of the same state and verdict, and expect the same result for every summary but idle. Pure and not yet wired to any reader.
Six transcripts of the agent CLI version 2.1.295 on macOS, captured with config/scripts/capture-agent-pty-transcript.mjs: idle at startup, one turn, a Bash permission dialog answered allow once, an AskUserQuestion answered with its first option, an Escape interrupt, and one subagent followed by /exit. The agent reports only once its OSC 7501 probe is answered ahead of DA1, so the capture script ran inside a test terminal that answers the probe the way the PTY owner's startup ingress does and the other startup queries the way the renderer's xterm.js does. Orca's own reply ordering is covered by the startup ingress tests. A run whose terminal leaves the probe unanswered carries the probe and no report. Each sidecar records the commit the capture ran on, the route and the scenario. Session link ids, the home path, the plan tier, the usage notice and the resume id are scrubbed at the same length, so the captured screens keep their wrapping. The replay reads the real bytes through the pure core: the scanner yields the same events at every read size and at every cut in and around each sequence, the parser accepts every report, the tracker yields each scenario's transitions with the descriptive second done folded into the first, and the subagent run drives a child record, its clear by id and the exit-time root clears.
Record the problem, the protocol and capture constraints, the architecture, compatibility, scope, rejected alternatives and known limits of OSC 7501 program status support.
A secret found inside the decoded msg or title of an OSC 7501 report was redacted by filling the encoded span with X. That fill is not valid base64 of UTF-8 text, so the parser discards the whole report and a scrubbed fixture silently stops carrying it on replay. Redact the decoded text instead and encode it again, keeping the original padding style. The placeholders are ASCII, so the encoding keeps its length whenever the secret was ASCII. The new test parses the scrubbed report, not only rescans it.
A lifecycle write that omits `shown` keeps the slot's view. On the move into `exited` that kept the pre-exit `now` view while the slot was relabelled `onExit`, so the pane went on showing working or blocked state after the exit, and an `onExit` dismissal was compared against a `now` generation. Refuse a lifecycle write that omits `shown` when it would change the view name. Only the move into `exited` does that, since `exited` is absorbing; an `exited` to `exited` write without `shown` is still a no-op. The ledger's exit write already carries the `onExit` view.
The parser checked the id grammar on every occurrence of `id`, so `state=done:id=a//b:id=a` was discarded although the spec says the last value of a repeated key wins and ignores only a report whose id does not match the grammar. Keep the id size limits (128 bytes, 32 per segment, 8 levels) on every occurrence, as the spec asks of every limit before any record is touched, and check the segment grammar once, on the value that wins. The msg and title checks are unchanged.
The scanner reported OSC 133;A as a prompt start as soon as a `;` followed the `A`, so a truncated `ESC]133;A;` dropped every working and blocked record although no complete prompt sequence arrived. A bare ESC right after the `A` counted too. Scan a prompt start like a report frame: through its parameters, across chunks, under the same 4096 byte bound, and report it only once BEL or ST ends it, which is how the shell lifecycle scanner reads OSC 133. A bare ESC ends the candidate without a prompt start and is scanned as the next sequence; an unterminated or oversized body reports nothing. The event's end now points past the terminator, like a report's.
Give the hook server a second producer slot per pane for OSC 7501 program status, beside the hook row and never inside it. The new store layer accepts report and lifecycle writes through the pure slot transition, carries a dismissal across a certified exit by PTY before the pane closure refusal, rekeys with a fallback to the current report, forgets with an identity check, records dismissals by PTY, and keeps its own pane closure record. The renderer's pane retirement, pane restore and tab close, and worktree removal now also close, reopen or forget slots. The slot is published only through its own listener and snapshot; it is never a hook row, never persisted, and never part of the default status snapshot or a hook event. Nothing writes a slot yet, so behavior is unchanged.
Publish the hook server's program-status slots to the desktop renderer as their own row type on the existing agent-status channel and snapshot pull. The renderer narrows these rows before the hook applicator and keeps them in a mirror beside the hook map, with its own closure record (pane retirement, tab close, pane removal, lifted by a pane restore), a mirrored preference and a composition epoch that is separate from the agent-status epoch. A dismissal now has a slot path: the renderer action hides the visible slot locally and sends an acknowledgement as an optional second argument of the drop channel, which main applies before, and instead of, any hook mutation. The one-argument drop is unchanged. For the pop-out, the main window marks cards whose pane has a visible slot and republishes them when that pane's inputs change; the pop-out ignores slot rows, never patches a marked card, and never derives an expiry for a card that carries one. The slot table is still always empty, so payloads, IPC and pop-out cards are unchanged.
Display readers now read one composed agent-status map: the hook map with each visible program-status slot composed in by the presentation policy (a valid hook row wins by default, the slot wins under the preference or when the hook row is absent, a seed or unconfirmed). With no visible slot the composed map is the hook map itself, so nothing changes until a slot arrives. The sidebar rows and dots, the worktree card, the bucket counts, the in-window dashboard, the pop-out snapshot and the tab bar read the composed map, and every cache on that path keys on its inputs: the slot mirror, the mirrored preference and a renderer-only composition epoch, carried by one composition token wherever a cache keyed on the agent-status epoch. The token is the agent-status epoch itself until a slot ever composed, and the runtime mobile sync key is left out of it. A second freshness scheduler expires every visible non-live slot, whoever wins its pane, and bumps only the composition epoch. A live slot never expires. The main window publishes the expiry of a card the slot wins, and an idle program reads as an idle row rather than a finished turn. Dismissing a row also acknowledges its slot, and clearing completed activity acknowledges a finished one. `worktree ps` composes the same way on the host only for a caller that sends `composeProgramStatus`, which the CLI now does; other callers get the hook-only listing.
Add the main-process ingress for OSC 7501 program status. A pure ledger per PTY keeps the registered incarnation, the tracker's report sequence, the latest observation and the lifecycle phase with the instant it began, and turns each event (a newer fact, a certified exit, an unconfirmed loss, a reconnect snapshot, a replaced incarnation) into at most one report write and one lifecycle write. It never mints a sequence or a generation, and facts that arrive before their incarnation registers wait for it. The ingress attributes each ledger to a pane with the rule OSC 9999 uses (mounted leaves, else the PTY record's pane), writes into the hook server store through a sink, rekeys when the pane moves, and forgets the slot with the PTY retired when the PTY record is pruned. It never reads the store. A certified exit shows what the program reported for after its exit, so done and error stay on an open pane while working goes away; an unconfirmed loss keeps the view and marks it unverifiable. A pane restore now carries the PTY the renderer bound. Main resyncs the pane's program status from the ledger only once its own maps name that pair on both sides: the PTY still holds its spawn key, that key and the pane are alias-equal, and no other PTY holds the canonical pane. Otherwise the request waits, and is read again when a spawn commit or a leaf move notifies, after a microtask; neither notification writes the pane or PTY maps. A resync republishes the last observation with its own sequence and phase instant, so a reopened pane shows a silent program again without restarting its expiry, and a dismissal stays hidden. A rekey now also finds a record still filed under a pane key that a leaf move has since aliased. Local PTYs get a tracker in main only when the spawn asks for one. No spawn does yet, so nothing is ingested and behavior is unchanged.
…l 50) A daemon session whose spawn intent asks for program status now runs its own OSC 7501 tracker on the startup ingress emissions, in byte order and before the stream's keep-tail thinning, so a backgrounded session under backlog never loses a report. Each change is relayed to the session's attached client as a new `program-status` kind inside the existing transientFact event, as a control entry that thinning never drops, and carries the session incarnation, the tracker's report sequence and both dated views. With no client attached nothing is sent; the createOrAttach reply instead carries the tracker's snapshot, read when the attach routes the stream to the new client, so the first state after an app restart is never lost. The throttled latest state is flushed before the exit event. Main reads facts and reply snapshots only from daemons at protocol 50, parses both with the strict codec, and feeds them to the program-status ingress: a fact that overtakes its control reply waits in the ledger and registration adopts the greater of the two, a replaced incarnation's late fact is dropped by its id, a dropped daemon link marks the session unverifiable, and a reattach of the same incarnation is a reconnect that applies a newer state first and then goes live again. The snapshot is consumed by the daemon provider and never reaches later spawn result readers. The daemon protocol moves to 50, with 49 kept attachable. A v49 or older session that survived an update has no tracker and stays hook-only until it ends, and an app downgraded below 50 does not discover a v50 daemon. Nothing builds the intent yet and the admission parser does not keep the field, so nothing is tracked or relayed and behavior is unchanged apart from the protocol version.
Adds the desktop setting agentProgramStatusPreferred, off by default, so hooks keep winning when a pane has both a hook row and an OSC 7501 report. Turning it on makes the display readers show the program's own report first. The switch lives in Settings > Agents beside the hook toggle, with its copy and a search entry. The setting is presentation policy only. It is read by the renderer's composition selector and by the host for `worktree ps`, and it is never sent to the hook server, the daemon, the relay or the PTY environment. It is not offered in paired web clients, because the client settings RPC rejects unknown keys and would drop the whole update; the search entry is hidden there too. The settings write coerces the value to a strict boolean. A test runs the same hook POSTs, OSC 9999 updates and OSC 7501 bytes in each mode, with the setting toggled and a clear report inserted at several points, and finds the hook-side state identical every time. Nothing ingests OSC 7501 yet, so the switch has no visible effect until the terminal ingestion lands.
Terminals now track OSC 7501 program status reports on macOS desktop
panes, for PTYs owned by main and by the persistent daemon. A program
that reports its state without first probing for support now shows that
state on the sidebar, dashboard, pop-out, worktree card, tabs and opted-in
`worktree ps`.
Both spawn paths (renderer panes and runtime-created terminals) ask for
it through one helper. The request rides the existing startup ingress
intent as `programStatus: { ingest: true }`, whose parser is widened so
an intent carrying only that field is valid; a plain shell therefore
gets a tracker even when it needs no colour or keyboard replies. Local
PTYs also get the spawn option that arms main's tracker. The request is
stripped for a daemon below protocol 50, which cannot relay facts, and
an older daemon parses a fresh object that drops the field anyway.
Out of scope and left unarmed: Linux, Windows and WSL, SSH panes (a pane
with a `connectionId` is never armed, and since stablyai#27215 there is no SSH
relay hop to carry the request), and headless `orca serve`. Answering the
support probe is a separate change, so programs that wait for the probe
reply still stay silent.
Programs that detect support before reporting, and send OSC 7501 reports only when the probe's reply arrives ahead of their DA1 reply, now start reporting in Orca on the panes where ingestion is on (macOS desktop, local and daemon at protocol 50). The PTY owner's startup ingress answers `ESC ] 7501 ; ? ST` with a spec rev 0.4 reply that spells out the default states and kinds, `ESC ] 7501 ; ? : states=idle,working,done,blocked,error : kinds=permission,question,auth ESC \`, in the same parse turn that reads the probe, and strips the probe from the stream. The spelled-out lists mean the same as a bare `?`, but keep the reply distinct from an ST probe: a later probe is never taken for the echo of an earlier reply, and an echoed reply is never answered as a probe. Every DA1 answerer (the renderer, and the daemon's own answer while the shell-ready barrier holds) sits downstream of that ingress, so the 7501 reply is written before the DA1 bytes even leave the owner, whether the probe and DA1 come in one read or are split across reads. The authority is session lived, like the colour replies, so an agent started long after the shell is answered too. It is armed by the new `answerProbe` flag of the startup intent, which the spawn sites now set beside ingestion. A pane with a `connectionId` still gets no intent at all: there is no SSH relay hop any more. A torn probe is held like a torn colour query, and one whose first fragment is 500 ms old or older is never answered: it is released raw, even when each later read renewed the hold. Recovery extractors, the stream replay scan and viewer colour responders do not recognize the probe, so nothing but the owner ever answers it. Tests replay a reporting agent's real startup write (XTVERSION, the Kitty keyboard query, the probe, then DA1) in one read, cut at every offset and one code unit per read, through a local owner with a real renderer emulator answering DA1, through a daemon session at protocol 50 with an attached renderer, and under the daemon's shell-ready barrier. Each asserts the 7501 reply precedes the DA1 reply, and the reports that follow reach the hook server store and the composed reader. Further tests answer every probe of a session, BEL or ST, in one read, cut at every offset or one code unit per read, while each echo shape of the reply is still swallowed.
The "Prefer status reported in the terminal" switch and its settings search entry showed on Linux and Windows, where no spawn arms OSC 7501 ingestion, so the switch could never change anything there. Pull the platform half of the ingestion scope into isProgramStatusPlatform, keep resolveProgramStatusIntent on it, and show the row and its search entry only where it holds for the app platform. Paired web clients still hide both.
The restore handler lifted the program-status closure before main had checked the renderer's pane and PTY pair. A restore naming an old PTY, such as a stale bind during a PTY replacement, parked as intended, but the pane was already open again. The replaced PTY's ingress entry still targeted that pane, so its next OSC 7501 report was published there while main bound the pane to another PTY. The closure now lifts inside the resync itself, once the binding proof passes: at once when main's maps already name the pair, or when a spawn commit or a leaf move resolves the parked request. A restore whose pair never binds, or that carries no PTY, leaves the pane closed; the next restore with the bound PTY reopens it and detaches the old one.
A daemon reattach snapshot or a local fact can reach the ingress before the runtime records the PTY's pane. The ledger keeps it with no target, and the spawn commit's bind notification only serviced parked renderer resyncs, so a runtime-owned pane whose program reported nothing more never reached the hook server store or `worktree ps`. On a bind, after the parked resyncs, re-run the lazy attribution for every registered ledger that has no pane yet. A ledger already published, a detached PTY and a closed pane write nothing, and the republished report keeps the ledger's own reportSeq.
…e panes A tab-prefix drop given `paneKeys` removes the hook rows of those panes only, but it still closed program status for the whole tab. A remote retirement of one pane therefore deleted its siblings' slot records and marked them closed, so their later slot rows were refused. Close only the records of the dropped panes when the drop is scoped, and keep the tab-wide closure for a full tab close. The new test drops one pane of a two-pane tab and checks that the sibling keeps its record, stays open and still takes a newer row, while the dropped pane refuses one.
The test for the worktree removal dependency read agent-hook-runtime-deps.ts as text and searched it for the two calls. A reformat or a helper extraction broke it while the behavior held, and a call on the wrong object still passed. Build the dependencies with agentHookRuntimeDeps, run dropAgentStatusForRemovedWorktree for one worktree, and check that its hook row and slot record are gone, that a later report for the pane is refused, and that another worktree's slot record stays. The test fails when either call is removed.
A tab-prefix drop given `paneKeys` recorded the program-status closure only for the named panes that already had a slot record. A named pane with no record yet stayed open, so a delayed slot row for it passed the closure check and created a slot for a pane that was already retired. Record the closure for every named pane of the tab. Deletion still reaches only the records that exist, so the siblings keep theirs. The new test drops a pane that has no slot, checks that a later row for it is refused, and that a sibling's newer row still applies.
…l it registers A daemon session respawned under the same PTY id can relay its first fact before its createOrAttach reply. The ledger still held the previous incarnation, and it buffered early facts only while no incarnation was registered, so it dropped that fact. Registration then adopted the reply's snapshot, and when that snapshot was empty and the program reported nothing more, the pane showed no status. Hold a fact of any unregistered incarnation in the bounded pending store, which registration already reads, and remember the latest replaced incarnations so their late facts are still dropped by id. A held fact is never published unless its incarnation registers.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
|
I would find accurate agent-reported status very useful when working with multiple agents. Here is a concrete use case from my current workflow. A Codex CLI session is waiting for a long verification run managed by another session. When Codex finishes its response turn, the sidebar shows a green completion check, even though the task is still waiting for that external result. This makes it easy to mistake the end of a turn for completion of the work. I welcome the terminal-reported status support in this PR. Being able to distinguish waiting for a human answer or approval from waiting for another task, and update the indicator when work actually resumes or finishes, would help a lot when managing several sessions. I have not yet verified whether this PR covers that specific Codex case; I wanted to share it as a real use case for accurate status reporting. |
|
Closing together with #30144: #30262 ships the display side on main. @innocarpe, thanks for the concrete case. I checked it, and neither this PR nor main changes the green check. A Codex row is owned by its hooks. When the turn ends, Codex reports So the change belongs in Codex. If Codex kept its OSC 7501 root record at |
ELI5
Some coding agents, such as Claude Code since 2.1.295, can tell the terminal what they are doing (working, waiting for permission, done). Some of them, Claude Code included, only start doing it if the terminal first says "I understand", and says it quickly. Orca never said it, so these agents stayed silent inside Orca. With this PR, on macOS, Orca answers in time, listens to the reports, and shows the state in the sidebar, the dashboard and the other places that already show agent status. Hooks still come first by default; a new setting lets the agent's own report win.
What Changed
Stacked on part 1 (#30144), which adds the pure parsing and tracking code, the captured transcripts and the design note. This PR's diff against
mainincludes part 1's commits. This part is the eight commits after part 1's last commit,docs(agent-status): say which part lands what in the design note, and seven review fixes.Before: inside Orca, an agent that waits for the OSC 7501 probe reply never reports, and an agent that reports without asking is ignored. A pane with no hooks and no recognizable title shows no status.
After, on the macOS desktop app, for local and daemon terminals:
orca worktree ps.done,idleorerror).orca servehosts and the Nodeorcadserver. On Linux and Windows the setting and its search entry are hidden, since the switch could change nothing there.Mechanism, commit by commit:
src/main/agent-hooks/server/server-program-status.ts). Each pane gets a second slot beside its hook row. The hook row is untouched, and neither slot ever writes the other. The slot has its own write rule, closure record (pane retire, tab close, worktree removal) and dismissal. It is never persisted and never part of the default status snapshot or status file.agentStatus:setpush andagentStatus:getSnapshotpull as their own row type. The renderer keeps them in a mirror beside the hook map. A dismissal sends an acknowledgement as an optional second argument ofagentStatus:drop, which main handles before, and instead of, any hook mutation; the one-argument call is unchanged. The pop-out receives cards the main window already composed.src/renderer/src/store/selectors/composed-agent-status.ts,src/shared/program-status/compose-agent-status-entry.ts). Readers read one composed map: by default a hook row wins unless it is absent, a seed Orca planted itself, or restored and not yet confirmed. The choice reads no timestamp, so it never depends on which source spoke last. With no visible slot, composition returns the original hook map. Cache tokens retain their legacy form whileprogramStatusEpochis zero; subsequent invalidations also track the program-status epoch. A live report never expires (the protocol has no heartbeat); one Orca can no longer verify decays on the usual 30 minute window.worktree pscomposes on the host only for a caller that sendscomposeProgramStatus, which the CLI now does.src/main/program-status/). Main keeps one ledger per PTY (incarnation, highest report number, latest observation, lifecycle phase) and writes into the store. On a certified exit the slot shows what remains (doneanderrorstay,workinggoes); an unconfirmed loss marks it unverifiable. A pane restore resyncs the slot, but only once main's own pane and PTY maps name that pair on both sides.src/main/daemon/daemon-program-status-relay.ts). A daemon session runs its own tracker before it thins a backgrounded stream, so no report is lost. Changes travel as a newprogram-statuskind inside the existingtransientFactevent, with the session incarnation and an ordering number; thecreateOrAttachreply carries a snapshot so the state survives an app restart.agentProgramStatusPreferred, desktop-local, presentation policy only. It is declared as its own settings group insrc/shared/global-settings-base.tsand added to theGlobalSettingsBasecomposition there. Main's settings write keeps it only as a strict boolean, in a newsrc/main/ipc/settings-program-status.ts, sincesettings.tssits close to its line budget. Its test runs on the real-store fixture, soconfig/scripts/vitest-node-runtime-files.mjsgains one line beside its sibling.programStatusfield of the startup ingress intent. Agents that report without probing now show.src/shared/pty-startup-program-status-probe.ts). The PTY owner's startup ingress answersESC ] 7501 ; ? STin the same parse turn, before any DA1 answer can leave the owner, whether the probe and DA1 arrive in one read or are split across reads. The reply is the spec's rev 0.4 form with the default lists spelled out,ESC ] 7501 ; ? : states=idle,working,done,blocked,error : kinds=permission,question,auth ESC \. It means the same as a bare?but can never be read as a probe, so an echoed reply is never answered and a later probe is never mistaken for an echo. It lasts the whole session, so an agent started long after the shell is answered too.isProgramStatusPlatform(src/shared/program-status-intent.ts), decides the platform half of the spawn scope and whether the settings row and its search entry render, so the two cannot drift apart.worktree ps. A ledger already written, a detached PTY and a closed pane write nothing.paneKeys(a remote retirement of one pane) closed program status for the whole tab, so its siblings lost their slot records and refused later rows. A scoped drop now closes only the named panes; a full tab close still closes the tab.agent-hook-runtime-deps.tsas text. It now builds the dependencies, removes one worktree, and checks that its hook row and slot record are gone, that a later report for its pane is refused, and that another worktree's slot record stays.createOrAttachreply. The ledger dropped that fact, and an empty reply snapshot then left the pane with no status. The ledger now holds a fact of any unregistered incarnation in its bounded pending store until that incarnation registers, and still drops late facts of the incarnations it replaced.Two existing CI checks changed with the transcripts (in part 1's transcript commit and one of its review fixes, both included in this branch):
config/scripts/pty-transcript-secret-scan.mjsflagged the reports' base64msg=values as opaque tokens. It now decodes OSC 7501msgandtitlevalues strictly and scans the decoded text with the same rules, reporting a hit at the encoded position. Its same-length redaction re-encodes the scrubbed text, so the report still decodes. A secret inside a message is still caught; a value that does not decode falls back to the existing rules.src/main/daemon/serialize-grid-transcript-replay.test.tsreplays every committed transcript through the snapshot serializer. Five of the new transcripts expose divergences the serializer already has (a true-colour background left on restored cells; in the subagent run, the cursor one column short after a shrink). This PR does not touch the serializer; the five are listed inKNOWN_PREEXISTING_I2_FAILURESin the file's existing "serializer untouched" style. The unscrubbed captures diverge identically. I can drop them if you would rather track them separately.How the transcripts were captured.
config/scripts/capture-agent-pty-transcript.mjsrecords and relays the agent's bytes; the replies to the agent's startup queries come from whatever terminal hosts it. To get reports, the script ran inside a small test terminal that answers the 7501 probe the way this PR's startup ingress does (immediately, before DA1) and answers the other startup queries the way xterm.js does. No Orca build hosted the captures. Orca's own reply order is proven by tests instead. They replay the captured startup write (XTVERSION, Kitty keyboard query, probe, DA1) through a local PTY owner with a real renderer emulator answering DA1, through a daemon session at protocol 50 with a renderer attached, and under the daemon's shell-ready barrier, in one read, cut at every offset, and one code unit per read. A run whose host leaves the probe unanswered produced the probe and no report.Why
Status from titles and per-agent hooks breaks when an agent changes its title, and agents without either show nothing (#26809). OSC 7501 is the agent telling Orca directly. Answering the probe is what turns it on. The captured agent decides support is absent if the DA1 reply comes first, and never asks again. So the answer has to come from the one place that sees the probe before anything answers DA1: the PTY owner.
Design memo
The full note is
docs/design/osc7501-program-status.md(added in part 1). It can be dropped if you prefer not to keep design docs in the repo (as with the cleanup in #26328); this section carries the same content in short.Problem. Agents without hooks or a recognizable title show no status, title parsers break when titles change, and agents that wait for feature detection, including the captured Claude Code version, send nothing because Orca never answers the probe.
Constraints. From the spec (rev 0.4): strict limits with a discard-whole rule;
clearremoves a subtree; prompt start dropsworkingandblocked; on process exitdoneanderrorsurvive; no heartbeat; reports are untrusted; the probe reply may spell out the default states and kinds. From a real capture of Claude Code 2.1.295: the probe must be answered before DA1 or the agent never reports;donearrives twice (bare, then with a message about two seconds later); an interrupt reportsidle; exit sends three rootclearreports; subagent ids are flat hex ids, and a child ends withclear:id=....Choices.
AGENTS.mdasks new producers to write into the hook server's store that every reader subscribes to. 7501 gets its own slot there, beside the hook row, with its own lifecycle, so neither source can erase the other.Rejected alternatives.
clearor a setting change.Compatibility. Daemon protocol 50 (the base of this branch is at 49), with 49 still attachable: a protocol 49 or older session that survived an update has no tracker and stays hook-only until it ends, and an app downgraded below 50 does not discover a 50 daemon (as with every bump). Wire changes are optional fields only (spawn intent field, IPC arguments, pop-out card fields, a
worktree.psparameter an old host strips) plus a newtransientFactkind, no new opcode. Old CLIs, mobile,session.tabs.*and paired clients see exactly what they see today, hooks only. The setting is not added to the client settings RPC, whose strict schema would make an old host reject a paired client's whole update.Scope and limits. macOS desktop app, local and daemon terminals. Not yet: Linux (expected to require a small enabling change, updates to the scope tests, and validation against a Linux capture), SSH panes, Windows ConPTY and WSL,
orca serveand the Nodeorcadserver, daemons below protocol 50, agents inside tmux. Only the state is shown, notmsg,titleorprogress, and subagents get no rows. An agent that reports only through 7501 raises no notification or unread mark, does not keep the computer awake and is not shown on mobile. Under hooks first, a hook row that only goes silent keeps winning until its own lifecycle ends it. If an agent leaves aworkingrecord without clearing it, and no shell prompt marker arrives, that record remains until the PTY process exits. One limit comes from a recent upstream path: in a build made withORCA_LAYOUT_OWNER=main(off in every shipped build; packaging refuses it), main can move a pane itself (src/main/runtime/orca-runtime.ts:233). That move rekeys the pane's owners but does not send the binding notification the IPC move sends (src/main/ipc/pty/ipc/leaf-move.ts:26). A pane restore waiting on that pane is then not re-read, and its program status can stay missing. The full list is in the note.Where the boundary sits in the code. Arming rests on a positive claim, not on recognizing headless launches. The desktop startup claims the role once it knows it is not serving, before any window or runtime RPC can spawn a PTY (
src/main/startup/main-process-runtime-launch.ts:268-272), andhostProgramStatusIntentreturns nothing in a process that never claimed it (src/main/program-status/program-status-spawn-intent.ts:18-20), with the--serveargv check kept as a second guard (:25). The spawn builders are shared by every PTY host, so the Nodeorcadserver, which never runs the desktop startup, and--serve, which takes the serve branch, neither request ingestion nor answer the probe. A daemon arms only from the intent sent with a spawn (src/main/daemon/daemon-program-status-relay.ts:92), so the desktop's local daemon tracks and a daemon started byorcaddoes not. On the store side,agentHookRuntimeDepsgives every runtime host the slot getter (src/main/agent-hooks/agent-hook-runtime-deps.ts:23), spread by desktop main (src/main/startup/main-process-runtime-service.ts:89) and byorcad(src/main/orcad/orcad-entry.ts:248), but nothing fills a slot unless an armed spawn feeds the ingress main installs (main-process-runtime-service.ts:152), so a headless host'sworktree psreads empty slots and stays hook-only. A pane with aconnectionId(SSH) maps to therelayowner, which never arms (program-status-spawn-intent.ts:23,src/shared/program-status-intent.ts:40). A paired server's panes are spawned by that server over runtime RPC (src/main/ipc/pty/provider/registry.ts:71), and slots reach a runtime RPC client only throughworktree.pswithcomposeProgramStatus(src/main/runtime/rpc/methods/worktree-catalog-methods.ts:33), which only the CLI sends (src/cli/handlers/worktree.ts:105), so those panes show hooks only.Linked Issue
Fixes #26809
Visual Proof
Before (base) and after (this branch), captured from isolated builds of each, with Claude Code 2.1.301 stopped at a file-write permission prompt. Both builds predate this branch's rebases onto the current
mainand its review fixes: they ran an earlier head of this branch and its base, Orca 1.4.214. Private and unrelated text is redacted with opaque boxes; image metadata is stripped.Before: no agent row for the pane.
After: the waiting icon on the tab and the workspace, and a
claude - Agentrow blocked on the prompt.The new Prefer status reported in the terminal setting, off by default.
These runs had no user settings, so no Orca hooks were installed for that agent, even though Orca's Agent status hooks setting is on by default (as the settings screenshot shows): this is the hook-less case that OSC 7501 fills. With hooks installed, the hook status keeps winning unless the setting is on.
What a reviewer can run instead:
pnpm test src/main/program-status/program-status-startup-batch.test.ts src/main/program-status/program-status-transcript-replay.test.ts src/main/program-status/program-status-daemon-transcript-replay.test.tsprintf '\e]7501;state=working\a'; sleep 20should show the worktree as working, and the status should go away when the prompt returns (a prompt start dropsworking, per spec);printf '\e]7501;state=blocked:kind=permission\a'; sleep 20should show it waiting for permission;printf '\e]7501;state=done\a'should show it done until you dismiss the card or runprintf '\e]7501;state=clear\a'.I ran the app only in isolated builds to take the screenshots above; the manual
printfsteps are untested by me, and the automated tests above are what I ran.Testing
Every commit passes
pnpm tcand the test files it touches, checked out on its own: 66, 73, 203, 108, 57, 42, 77 and 98 tests for the eight commits in order, then 37, 52, 57, 32, 23, 33 and 35 for the seven review fixes, all passing. Commit 4 also changes two.spec.tsmodules, which run only inside their host suites (next point).The 57 changed
.test.*files pass at the tip: 1,303 tests. The branch also changes two.spec.tsmodules, which run inside their hosts.pty-connection-spawn-and-startup.test.tspasses (80 tests).orca-runtime.test.tshas 1,431 passing, 1 skipped and 1 failing; that test fails the same way on the base (a/varversus/private/vartemp path inpreserves existing badgeColor on runtime cloneRepo folder->git dedupe upgrade).Full unit suite with CI's exclude list (
ORCA_BALANCE_UNIT_SHARDS=1 ORCA_BACKGROUND_LAUNCH=1 node config/scripts/run-vitest.mjs run --config config/vitest.config.ts) at the tip: 126,804 tests, 125,193 passed, 17 failed, 5 expected fail, 1,580 skipped, 6 todo. One test worker was killed by the OS (SIGKILL) while runningsrc/main/ipc/worktree-base-directory-poller.test.ts, a file this branch does not touch; that file passes alone on the base and at the tip (23 tests). The 17 failures sit in 8 files, none changed by this branch. Each file was then run alone on the base and at the tip, and all eight fail alone on both sides with the same tests:config/scripts/macos-terminal-host-bundle.test.mjs(1),config/scripts/main-entry-facade.test.ts(1),config/scripts/process-host-dev-rebuild.test.ts(6),src/main/cli/packaged-cli-assets.test.ts(1),src/main/orcad/orcad-forked-child-paths.test.ts(4),src/main/runtime/orca-runtime-structured-agent-session-create-intent.test.ts(2),src/main/runtime/orca-runtime.test.ts(1, the host above) andsrc/main/sqlite/sync-database-portability.test.ts(1).oxlint(default andconfig/oxlint-react-doctor.json),oxfmt --check,pnpm run check:code-quality:changedandcheck:max-lines-ratchetpass. Nomax-linesdisable was added.The new tests were checked to fail against deliberately broken implementations (for example: probe not answered or not recognized, no snapshot in the attach reply, no broadcast, a ledger that skips a fact, an exit that keeps the live view, an
orcadspawn that arms, anerrorslot that "Clear completed" leaves shown, a restore that reopens a pane before main binds its PTY, a report never written once its pane binds, a pane-scoped drop that closes the whole tab, an early fact of a respawned session dropped before its reply).Not run:
pnpm build, e2e, andtests/e2e/cross-version-wire, which this branch does not touch. The app was not launched at this tip; the screenshots above come from builds made before the rebases and the review fixes. macOS only; Linux, Windows and SSH are out of scope and left unarmed. Run under Node 26 (the repo pins 24, which I don't have on this machine).I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Assisted by Claude (Anthropic).
Review
Agent skill upstream boundary
Notes
promptfield is empty. Action readers (approve, auto-answer, stop, wait, hibernation, resume), notifications, unread marks, keep-awake and automations read hook rows only. The probe reply contains nothing from any report.connectionIdnever gets the request, and since refactor(relay): delete the SSH relay server, its build assets and tests #27215 there is no SSH relay hop to carry it, so SSH panes behave as before. Supporting it needs a remote-side tracker and reconnect snapshot of the same shape as the daemon's.indexOfper active pattern. Store writes are throttled per PTY (burst of 8, then 20 per second) with the final state exact.structuredHostOwned, while the sidebar rows honour it (dashboard-popout/useDashboardSnapshot.tsagainstsidebar/worktree-agent-rows.ts). A host-owned hook card silent past 30 minutes therefore looks like it would re-request a snapshot in a loop. I have not reproduced it. This PR leaves hook cards unchanged; cards a program report wins carry their own expiry and are not affected. I can open a separate issue for it.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)