Skip to content

feat(agent-status): show OSC 7501 program status from agents (part 2 of 2) - #30145

Closed
Regis-RCR wants to merge 32 commits into
stablyai:mainfrom
Regis-RCR:contrib/osc7501-part2
Closed

Regis-RCR wants to merge 32 commits into
stablyai:mainfrom
Regis-RCR:contrib/osc7501-part2

Conversation

@Regis-RCR

Copy link
Copy Markdown
Contributor

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 main includes 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 answers the probe, so agents that wait for it start reporting.
  • Their state shows on the sidebar dot and row, the worktree card, the dashboard (in window and pop-out), the tab bar, and orca worktree ps.
  • Where an agent also reports through hooks (for example Claude Code with Orca's hooks), the hook status still wins by default, so what you see there does not change. The program's report shows where no hook reports, or everywhere once you turn on Settings > Agents > Prefer status reported in the terminal (off by default).
  • Dismissing an agent's card dismisses both sources for that pane, and "Clear completed" also clears a finished program report (done, idle or error).
  • OSC 7501 ingestion and probe replies remain disabled on Linux, Windows, WSL, SSH panes, orca serve hosts and the Node orcad server. On Linux and Windows the setting and its search entry are hidden, since the switch could change nothing there.

Mechanism, commit by commit:

  1. A program-status slot in the hook server store (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.
  2. Publication to desktop readers. Slot rows travel on the existing agentStatus:set push and agentStatus:getSnapshot pull 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 of agentStatus: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.
  3. Composition in display readers (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 while programStatusEpoch is 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 ps composes on the host only for a caller that sends composeProgramStatus, which the CLI now does.
  4. Local ingestion (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 (done and error stay, working goes); 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.
  5. Daemon tracking, protocol 50 (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 new program-status kind inside the existing transientFact event, with the session incarnation and an ordering number; the createOrAttach reply carries a snapshot so the state survives an app restart.
  6. The setting agentProgramStatusPreferred, desktop-local, presentation policy only. It is declared as its own settings group in src/shared/global-settings-base.ts and added to the GlobalSettingsBase composition there. Main's settings write keeps it only as a strict boolean, in a new src/main/ipc/settings-program-status.ts, since settings.ts sits close to its line budget. Its test runs on the real-store fixture, so config/scripts/vitest-node-runtime-files.mjs gains one line beside its sibling.
  7. Ingestion on supported terminals. Spawns from the macOS desktop app (local, and daemon at protocol 50) ask the PTY owner to track reports through an optional programStatus field of the startup ingress intent. Agents that report without probing now show.
  8. The probe answer (src/shared/pty-startup-program-status-probe.ts). The PTY owner's startup ingress answers ESC ] 7501 ; ? ST in 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.
  9. Review fix: the setting shows only where ingestion can arm. One shared predicate, 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.
  10. Review fix: a retired pane reopens only when its restore binds. The restore handler lifted the slot's closure before main checked the pane and PTY pair. A stale restore naming a replaced PTY then let that PTY's next report show on the pane. The closure now lifts inside the accepted resync, at once or when a spawn commit or leaf move resolves the parked request; a restore that never binds leaves the pane closed.
  11. Review fix: an early report is published once its pane binds. A daemon reattach snapshot or a local fact can reach the ingress before the runtime records the PTY's pane. On each bind, after the parked resyncs, the ingress now writes every ledger that has no pane yet. A runtime-owned pane whose program reports nothing more therefore still reaches the store and worktree ps. A ledger already written, a detached PTY and a closed pane write nothing.
  12. Review fix: a pane-scoped drop closes only those panes. A drop given 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.
  13. Review fix: the worktree removal test checks behavior. It searched agent-hook-runtime-deps.ts as 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.
  14. Review fix: a scoped drop closes every named pane. A named pane with no slot record yet stayed open, so a delayed row could create a slot for a pane already retired. The closure is now recorded for every named pane of the tab; deletion still reaches only the records that exist.
  15. Review fix: early facts of a replacement incarnation are kept. A daemon session respawned under the same PTY id can relay its first fact before its createOrAttach reply. 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.mjs flagged the reports' base64 msg= values as opaque tokens. It now decodes OSC 7501 msg and title values 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.ts replays 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 in KNOWN_PREEXISTING_I2_FAILURES in 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.mjs records 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; clear removes a subtree; prompt start drops working and blocked; on process exit done and error survive; 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; done arrives twice (bare, then with a message about two seconds later); an interrupt reports idle; exit sends three root clear reports; subagent ids are flat hex ids, and a child ends with clear:id=....

Choices.

  • One store, one producer slot per pane. AGENTS.md asks 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.
  • Composition on the read side, as presentation policy. A pure, clock-free function. Hooks first by default, because hooks carry richer data (prompt, tool, permission details) that 7501 does not; the setting flips it.
  • Probe answered at the startup ingress, before DA1. Every DA1 answerer sits downstream of it.
  • Daemon tracking before thinning, with incarnation and ordering. Facts from an old incarnation or out of order are dropped; facts that overtake the control reply wait for it.
  • Lifecycle. Certified exit shows what survives exit; a lost link marks the state unverifiable and a reconnect restores it; a closed pane refuses writes while the ledger keeps tracking, and reopens and resyncs only once a restore of it binds; a report taken before its pane exists is written once the pane binds.
  • Dismissal as an operation bound to the PTY. It acknowledges one exact incarnation, view and generation. A new state shows again, a stale dismissal changes nothing, and a dismissal that can still be undone follows the PTY to another pane.
  • Two PRs. Part 1 adds the pure core and changes no behavior; this part is the integration.

Rejected alternatives.

  • A separate 7501 store and channel: every reader would need a second subscription and its own merge, against the one-store rule.
  • Writing both sources into the one hook row: the result depends on arrival order, the program's report would inherit the hook row's identity and permission data, and the hook row could not come back after a clear or a setting change.
  • Answering the probe in the renderer (the approach [Feature]: Support the Program Status Protocol (OSC 7501) as an agent status source #26809 suggests): hidden or parked panes may have no renderer receiving live bytes. While the daemon's shell-ready barrier holds, the daemon answers DA1 itself, so a renderer-only probe handler cannot guarantee the required reply order.
  • Answering in the headless terminal model: it answers only for dropped hidden chunks, hands over to a remote viewer, and sits after the owner, so it cannot guarantee the order.
  • Dismissing only the composed winner: the other source's state would appear the moment the winner went away, which is not what "remove this row" means.
  • Encoding the slot as an optional field on hook rows in the default snapshot: a pane with only a program report would still need a row of its own, and every non-opting client would start receiving new content. Slot rows plus an opt-in keep old clients byte-identical.

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.ps parameter an old host strips) plus a new transientFact kind, 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 serve and the Node orcad server, daemons below protocol 50, agents inside tmux. Only the state is shown, not msg, title or progress, 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 a working record 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 with ORCA_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), and hostProgramStatusIntent returns nothing in a process that never claimed it (src/main/program-status/program-status-spawn-intent.ts:18-20), with the --serve argv check kept as a second guard (:25). The spawn builders are shared by every PTY host, so the Node orcad server, 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 by orcad does not. On the store side, agentHookRuntimeDeps gives 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 by orcad (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's worktree ps reads empty slots and stays hook-only. A pane with a connectionId (SSH) maps to the relay owner, 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 through worktree.ps with composeProgramStatus (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 main and 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.

Before: Claude Code at a permission prompt, no agent row for the pane

After: the waiting icon on the tab and the workspace, and a claude - Agent row blocked on the prompt.

After: the waiting icon on the tab and the workspace, and a claude - Agent row blocked on the prompt

The new Prefer status reported in the terminal setting, off by default.

Settings, Agents: Prefer status reported in the terminal, off

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:

  • The end-to-end tests that replay the captured transcripts through the real ingestion path and assert the composed status a reader shows:
    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.ts
  • On a macOS dev build, in a terminal of a worktree with no agent running:
    • printf '\e]7501;state=working\a'; sleep 20 should show the worktree as working, and the status should go away when the prompt returns (a prompt start drops working, per spec);
    • printf '\e]7501;state=blocked:kind=permission\a'; sleep 20 should show it waiting for permission;
    • printf '\e]7501;state=done\a' should show it done until you dismiss the card or run printf '\e]7501;state=clear\a'.
  • Then run Claude Code 2.1.295 or later in a terminal and watch a turn go working, then done. With Orca's hooks installed, the hook status keeps winning unless Prefer status reported in the terminal is on.

I ran the app only in isolated builds to take the screenshots above; the manual printf steps are untested by me, and the automated tests above are what I ran.

Testing

  • Every commit passes pnpm tc and 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.ts modules, 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.ts modules, which run inside their hosts. pty-connection-spawn-and-startup.test.ts passes (80 tests). orca-runtime.test.ts has 1,431 passing, 1 skipped and 1 failing; that test fails the same way on the base (a /var versus /private/var temp path in preserves 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 running src/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) and src/main/sqlite/sync-database-portability.test.ts (1).

  • oxlint (default and config/oxlint-react-doctor.json), oxfmt --check, pnpm run check:code-quality:changed and check:max-lines-ratchet pass. No max-lines disable 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 orcad spawn that arms, an error slot 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, and tests/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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security. A report is untrusted text from a program that already controls the screen, so printing a file that contains one changes that pane's displayed state. The result is display-only and attributed to its own pane. The composed entry carries no agent type, tool or permission metadata; its required prompt field 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.
  • Cross-platform. Armed only in the macOS desktop app; elsewhere no ingestion is requested, the probe is not answered and the setting is hidden.
  • Remote SSH. Not armed: a pane with a connectionId never 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.
  • Mobile. Unchanged, hooks only.
  • Backward compatibility. See the compatibility paragraph above.
  • Performance. An untracked PTY costs one map miss per chunk; a tracked one an indexOf per active pattern. Store writes are throttled per PTY (burst of 8, then 20 per second) with the final state exact.
  • fix(agent-status): the execution host ends the agent a finished command ran #26495 (command end ends the agent a finished command ran) is still open. It cannot touch 7501 state, since the slot is never a hook row; if it lands first I will rebase and rerun both suites.
  • Pre-existing, out of scope. While reading the pop-out I noticed that its refresh deadline ignores structuredHostOwned, while the sidebar rows honour it (dashboard-popout/useDashboardSnapshot.ts against sidebar/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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
Copilot AI balanced review requested due to automatic review settings October 18, 2026 01:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ab6ddb98-6187-4c19-907f-22c34b45097d
📥 Commits

Reviewing files that changed from the base of the PR and between ce2d608 and 0c8d199.

📒 Files selected for processing: 197
  • .gitignore
  • config/scripts/pty-transcript-secret-scan.mjs
  • config/scripts/pty-transcript-secret-scan.test.mjs
  • config/scripts/vitest-node-runtime-files.mjs
  • docs/design/osc7501-program-status.md
  • src/cli/handlers/worktree.ts
  • src/cli/index-omitted-host-scope-selectors.test.ts
  • src/main/agent-hooks/agent-hook-runtime-deps.ts
  • src/main/agent-hooks/server-program-status-isolation.test.ts
  • src/main/agent-hooks/server-program-status.test.ts
  • src/main/agent-hooks/server/server-program-status.ts
  • src/main/agent-hooks/server/server-row-ownership.ts
  • src/main/daemon/daemon-create-or-attach-result.ts
  • src/main/daemon/daemon-foreground-confirmation-protocol.test.ts
  • src/main/daemon/daemon-program-status-compat.test.ts
  • src/main/daemon/daemon-program-status-relay.test.ts
  • src/main/daemon/daemon-program-status-relay.ts
  • src/main/daemon/daemon-protocol-version.ts
  • src/main/daemon/daemon-pty-adapter.ts
  • src/main/daemon/daemon-pty-runtime-state.ts
  • src/main/daemon/daemon-pty-spawn-request.ts
  • src/main/daemon/daemon-spawn-result-identity.ts
  • src/main/daemon/daemon-stream-events.ts
  • src/main/daemon/daemon-terminal-admission.ts
  • src/main/daemon/macos-daemon-launchd.test.ts
  • src/main/daemon/serialize-grid-transcript-replay.test.ts
  • src/main/daemon/session-output-plane.ts
  • src/main/daemon/session-startup-ingress.ts
  • src/main/daemon/session.ts
  • src/main/daemon/terminal-host-create-contract.ts
  • src/main/ipc/agent-hooks.test.ts
  • src/main/ipc/agent-hooks.ts
  • src/main/ipc/agent-pane-authority-ipc.ts
  • src/main/ipc/agent-pane-authority-ownership.test.ts
  • src/main/ipc/agent-pane-authority-ownership.ts
  • src/main/ipc/agent-status-row-teardown-ipc.ts
  • src/main/ipc/dashboard-payload-validation.ts
  • src/main/ipc/pty/ipc/leaf-move.ts
  • src/main/ipc/pty/ipc/spawn-options.ts
  • src/main/ipc/pty/pane/key-state.ts
  • src/main/ipc/pty/runtime/spawn-options.ts
  • src/main/ipc/pty/spawn-options-program-status.test.ts
  • src/main/ipc/register-core-handlers/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers/register-core-handlers.ts
  • src/main/ipc/settings-program-status.test.ts
  • src/main/ipc/settings-program-status.ts
  • src/main/ipc/settings.ts
  • src/main/ipc/terminal-startup-color-query-replies.ts
  • src/main/persistence/profile-state/profile-state-offline-settings.test.ts
  • src/main/program-status/program-status-clear-across-closure.test.ts
  • src/main/program-status/program-status-daemon-ingest.test.ts
  • src/main/program-status/program-status-daemon-ingest.ts
  • src/main/program-status/program-status-daemon-transcript-replay.test.ts
  • src/main/program-status/program-status-host-authority.ts
  • src/main/program-status/program-status-ingress.test.ts
  • src/main/program-status/program-status-ingress.ts
  • src/main/program-status/program-status-ledger.ts
  • src/main/program-status/program-status-local-ingest.ts
  • src/main/program-status/program-status-preference-isolation.test.ts
  • src/main/program-status/program-status-resync-order.test.ts
  • src/main/program-status/program-status-spawn-intent.ts
  • src/main/program-status/program-status-startup-batch.test.ts
  • src/main/program-status/program-status-transcript-replay.test.ts
  • src/main/providers/local-pty-session-activation.ts
  • src/main/providers/pty-provider-contract.ts
  • src/main/providers/pty-spawn-result.ts
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-interrupt.meta.json
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-interrupt.txt
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-permission.meta.json
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-permission.txt
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-question.meta.json
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-question.txt
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-startup.meta.json
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-startup.txt
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-subagent.meta.json
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-subagent.txt
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-turn.meta.json
  • src/main/runtime/__fixtures__/claude-program-status-2-1-295-turn.txt
  • src/main/runtime/construction/runtime-construction-dependencies.ts
  • src/main/runtime/construction/runtime-construction.ts
  • src/main/runtime/orca-runtime-tests/agent-status-and-waits-part-03.spec.ts
  • src/main/runtime/program-status-claude-transcripts.test.ts
  • src/main/runtime/program-status-composed-entry-terminal-status.test.ts
  • src/main/runtime/rpc/methods/worktree-catalog-methods.ts
  • src/main/runtime/rpc/methods/worktree-catalog-snapshot-method.test.ts
  • src/main/runtime/runtime-pty-pane-attribution.test.ts
  • src/main/runtime/runtime-pty-pane-attribution.ts
  • src/main/runtime/runtime-worktree-agent-rows.ts
  • src/main/runtime/runtime-worktree-agent-source.ts
  • src/main/runtime/runtime-worktree-ps-program-status.test.ts
  • src/main/runtime/runtime-worktree-pty-agent-sources.ts
  • src/main/runtime/terminal/lifecycle/floating-session-liveness.ts
  • src/main/runtime/terminal/lifecycle/pty-exit-lifecycle.ts
  • src/main/runtime/terminal/output/pty-output-ingestion.ts
  • src/main/runtime/terminal/output/terminal-derived-agent-facts.ts
  • src/main/runtime/workspaces/workspace-process-listing.ts
  • src/main/startup/main-process-runtime-launch-activation.test.ts
  • src/main/startup/main-process-runtime-launch.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/main/startup/main-window-agent-status.ts
  • src/main/startup/main-window-structured-status-filter.test.ts
  • src/main/startup/program-status-desktop-publication.test.ts
  • src/preload/api/agent-status-api.ts
  • src/preload/api/agent-status-bridge.ts
  • src/renderer/src/components/activity/activity-clear-completed.ts
  • src/renderer/src/components/dashboard-popout/dashboard-agent-status-patch.ts
  • src/renderer/src/components/dashboard-popout/useDashboardSnapshot.ts
  • src/renderer/src/components/dashboard/build-dashboard-bucket-counts.cache.test.ts
  • src/renderer/src/components/dashboard/build-dashboard-bucket-counts.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.rows-cache.test.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.ts
  • src/renderer/src/components/dashboard/useAgentBucketCounts.ts
  • src/renderer/src/components/dashboard/useDashboardPopoutBridge.test.tsx
  • src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts
  • src/renderer/src/components/dashboard/useLiveDashboardSnapshot.ts
  • src/renderer/src/components/dashboard/worktree-agent-rows-cache.ts
  • src/renderer/src/components/settings/AgentProgramStatusSetting.test.tsx
  • src/renderer/src/components/settings/AgentProgramStatusSetting.tsx
  • src/renderer/src/components/settings/AgentsPane.tsx
  • src/renderer/src/components/settings/agent-program-status-availability.ts
  • src/renderer/src/components/settings/agent-program-status-copy.ts
  • src/renderer/src/components/settings/agents-search.ts
  • src/renderer/src/components/sidebar/WorktreeCardAgents.tsx
  • src/renderer/src/components/sidebar/use-worktree-activity-statuses.test.ts
  • src/renderer/src/components/sidebar/use-worktree-activity-statuses.ts
  • src/renderer/src/components/sidebar/worktree-agent-activity-summary.test.ts
  • src/renderer/src/components/sidebar/worktree-agent-activity-summary.ts
  • src/renderer/src/components/sidebar/worktree-agent-freshness-selector.test.ts
  • src/renderer/src/components/sidebar/worktree-agent-freshness-selector.ts
  • src/renderer/src/components/sidebar/worktree-agent-row-selectors.ts
  • src/renderer/src/components/sidebar/worktree-agent-rows.ts
  • src/renderer/src/components/tab-bar/SortableTab.tsx
  • src/renderer/src/components/tab-bar/terminal-tab-activity-status.ts
  • src/renderer/src/components/terminal-pane/pty-connection-fresh-spawn-guards.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-reattach-binding.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-pty-visibility-bind.ts
  • src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.ts
  • src/renderer/src/hooks/ipc-events/agent-status-ipc-bridge.ts
  • src/renderer/src/hooks/ipc-events/agent-status-listeners.ts
  • src/renderer/src/hooks/settings-navigation-capability-sections.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/agent-pane-activity-flags.ts
  • src/renderer/src/lib/pane-agent-evidence.ts
  • src/renderer/src/lib/program-status-composed-entry-readers.test.ts
  • src/renderer/src/store/selectors/composed-agent-status-cache-invalidation.test.ts
  • src/renderer/src/store/selectors/composed-agent-status.test-support.ts
  • src/renderer/src/store/selectors/composed-agent-status.test.ts
  • src/renderer/src/store/selectors/composed-agent-status.ts
  • src/renderer/src/store/slices/agent-pane-authority.test.ts
  • src/renderer/src/store/slices/agent-status-authority-actions.ts
  • src/renderer/src/store/slices/agent-status-drop-actions.ts
  • src/renderer/src/store/slices/agent-status-drop-reducer.ts
  • src/renderer/src/store/slices/agent-status-runtime.ts
  • src/renderer/src/store/slices/agent-status-slice-contract.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/renderer/src/store/slices/program-status-hide-actions.ts
  • src/renderer/src/store/slices/program-status-pane-mirror.test.ts
  • src/renderer/src/store/slices/program-status-pane-mirror.ts
  • src/shared/agent-status-freshness.ts
  • src/shared/dashboard-snapshot.ts
  • src/shared/default-global-settings.ts
  • src/shared/global-settings-base.ts
  • src/shared/local-build-compatibility-contract.json
  • src/shared/local-build-compatibility-contract.ts
  • src/shared/program-status-intent.test.ts
  • src/shared/program-status-intent.ts
  • src/shared/program-status/compose-agent-status-entry.test.ts
  • src/shared/program-status/compose-agent-status-entry.ts
  • src/shared/program-status/program-status-entry-table.test-support.ts
  • src/shared/program-status/program-status-expiry.ts
  • src/shared/program-status/program-status-pane-payload.ts
  • src/shared/program-status/program-status-pending-hide.ts
  • src/shared/program-status/program-status-preference.ts
  • src/shared/program-status/program-status-projection.test.ts
  • src/shared/program-status/program-status-projection.ts
  • src/shared/program-status/program-status-record-store.test.ts
  • src/shared/program-status/program-status-record-store.ts
  • src/shared/program-status/program-status-report.test.ts
  • src/shared/program-status/program-status-report.ts
  • src/shared/program-status/program-status-scan-budget.test.ts
  • src/shared/program-status/program-status-slot-transition.test.ts
  • src/shared/program-status/program-status-slot-transition.ts
  • src/shared/program-status/program-status-slot.test.ts
  • src/shared/program-status/program-status-slot.ts
  • src/shared/program-status/program-status-stream-scanner.test.ts
  • src/shared/program-status/program-status-stream-scanner.ts
  • src/shared/program-status/program-status-tracker.test.ts
  • src/shared/program-status/program-status-tracker.ts
  • src/shared/pty-startup-ingress-intent.ts
  • src/shared/pty-startup-ingress-program-status-probe.test.ts
  • src/shared/pty-startup-ingress.ts
  • src/shared/pty-startup-program-status-probe.test.ts
  • src/shared/pty-startup-program-status-probe.ts
  • src/shared/pty-startup-query-answer.ts
  • src/shared/pty-startup-query.ts
  • src/shared/rpc-contract/worktree-params.ts
  • src/shared/terminal-reply-query-program-status.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The change adds OSC 7501 parsing, PTY tracking, daemon relay support, and a separate pane-level status store. It adds configurable composition of program status with hook status across worktree, dashboard, sidebar, and tab readers. It also adds startup probe handling, dismissal and restore flows, daemon protocol version 50 compatibility, and transcript-based tests.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 0c8d1

This change adds terminal-reported (OSC 7501) agent status for macOS desktop local and daemon terminals. It is gated by platform, provider, and daemon protocol, and hook status stays the default. No concrete defect was found, and earlier compatibility and ordering concerns were checked against the code and ruled out. It appears ready to merge with normal checks; the author did not run a full build or e2e tests.

Pre-merge checks: Passed 3 · Failed 1 · Inconclusive 1

Failed Failed checks: 1 warning · 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Warning Issue #26809 requires OSC 7501 to be the preferred status source when a pane has program-status records, with hooks and title heuristics as fallback. The PR adds probe replies, per-pane records, lifec… Make the OSC 7501 entry win by default whenever a visible program-status slot exists. Keep hook and title status as fallback when no program-status slot exists. Update the preference behavior and tests if the issue requirement is intentiona…
Docstring Coverage Inconclusive Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 72 functions across 50 files. (147 skippe… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: displaying OSC 7501 program status from agents. The part designation is relevant and does not obscure the feature.
Description check Passed The description covers all required template sections, including the user impact, implementation details, rationale, linked issue, visual proof, testing, AI disclosure, compatibility notes, and checkl…
Out of Scope Changes check Passed The changed files support the OSC 7501 feature in issue #26809. The daemon protocol changes, settings UI, CLI projection, transcript fixtures, secret scanning, design note, and tests cover ingestion, …
Full details: Description check

Explanation

The description covers all required template sections, including the user impact, implementation details, rationale, linked issue, visual proof, testing, AI disclosure, compatibility notes, and checklist. It also clearly documents unrun checks and known baseline failures.

Full details: Out of Scope Changes check

Explanation

The changed files support the OSC 7501 feature in issue #26809. The daemon protocol changes, settings UI, CLI projection, transcript fixtures, secret scanning, design note, and tests cover ingestion, display, lifecycle, compatibility, or validation. The PR also identifies the pop-out liveness behavior as pre-existing and does not change it. No demonstrated unrelated implementation change appears in the reviewed scope.

Full details: Linked Issues check

Explanation

Issue #26809 requires OSC 7501 to be the preferred status source when a pane has program-status records, with hooks and title heuristics as fallback. The PR adds probe replies, per-pane records, lifecycle handling, daemon support, composition, and tests. However, composeAgentStatusEntry returns the hook entry by default when the hook is valid because the default preference is hooks-first. OSC 7501 wins only when the user enables agentProgramStatusPreferred or when no valid hook entry exists. The PR description confirms this default behavior.

Resolution

Make the OSC 7501 entry win by default whenever a visible program-status slot exists. Keep hook and title status as fallback when no program-status slot exists. Update the preference behavior and tests if the issue requirement is intentionally changed.

Full details: Docstring Coverage

Explanation

Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 72 functions across 50 files. (147 skipped: 16 unsupported, 131 over the file limit.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@innocarpe

Copy link
Copy Markdown
Contributor

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.

@Regis-RCR

Copy link
Copy Markdown
Contributor Author

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 done twice: through its Stop hook and, in parallel, through OSC 7501, where a later idle still reads as done. Orca maps both to a completed row. Codex 0.163 has no state for "turn over, still waiting on another task", and it sends no blocked kind and no msg (support matrix in src/main/agent-hooks/README.md).

So the change belongs in Codex. If Codex kept its OSC 7501 root record at working or blocked while it waits on an external result, main would pick that up with no Orca change: after 2 minutes of hook silence the OSC 7501 state takes over the row. That is worth raising with the Codex team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support the Program Status Protocol (OSC 7501) as an agent status source

3 participants