Repository navigation
fix(runtime): add opt-in agentWait to worktree ps agent rows - #24142
Conversation
|
There was a problem hiding this comment.
ℹ️ No critical issues — one minor, non-blocking suggestion.
Reviewed changes
A focused, well-scoped fix that threads the richer agentWait human-wait signal onto worktree ps agent rows.
terminalHandleretained on the row source —runtime-worktree-pty-agent-sources.tsnow carries the observed handle alongside the resolvedptyId, giving the assembly its lookup key.- New wait-threading pass —
runtime-worktree-agent-row-waits.tsresolvesgetTerminalInteractiveWaitonce per handle-ful source in parallel and leaves unresolved (undefined) sources untouched. - Wiring in
getWorktreePs—orca-runtime-get-worktree-ps.ts:102wraps the collected sources before row assembly. - Row builder + wire contract — the field is copied only when present, and
RuntimeWorktreeAgentRow.agentWaitis an additive optional field with the documented null-vs-absent semantics. - Tests — four new cases in
runtime-worktree-agent-rows-agent-wait.test.tsplus a structured-absence assertion inworktree-ps-structured-host.spec.ts.
I verified the getter's null/undefined semantics match the documented contract, that the conditional-poll snapshot id hashes the whole result (so agentWait participates in change detection), that structured rows genuinely have no terminalHandle, and that formatWorktreePs does not print agent rows.
ℹ️ No test drives a pty row's agentWait through the real getWorktreePs
The new unit tests compose attachRuntimeWorktreeAgentRowWaits and attachRuntimeWorktreeAgentRows by hand, and the one test that executes the production read (worktree-ps-structured-host.spec.ts) only covers the structured absence path. Because orca-runtime-get-worktree-ps.ts is @ts-nocheck, dropping the attachRuntimeWorktreeAgentRowWaits(...) wrapper at the call site would leave every test green while the feature silently reverts. Since the adjacent spec exists precisely to exercise that file, an end-to-end pty case would close the loop. Non-blocking.
Technical details
# Integration coverage for the pty happy path
## Affected sites
- `src/main/runtime/orca-runtime-get-worktree-ps.ts:102` — the only production call site; `@ts-nocheck` means a wiring regression is invisible to typecheck.
- `src/main/runtime/orca-runtime-tests/worktree-ps-structured-host.spec.ts:34` — exercises the real `getWorktreePs` but asserts only that structured rows lack `agentWait`.
## Required outcome
- A test that runs the real `getWorktreePs` with a pty-backed agent row whose handle resolves to a populated wait, and asserts the row carries `agentWait` (and, optionally, an explicit `null` when the getter evaluates to no wait).
- Such a test must fail if the `attachRuntimeWorktreeAgentRowWaits` call is removed.
## Suggested approach (optional)
- Extend the existing structured-host spec (or add a sibling) using a runtime test double that stubs `getTerminalInteractiveWait` to return a descriptor for the hook snapshot's `terminalHandle`.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
No actionable comments were generated in the recent review. ℹ️ Recent review info
Walkthrough
Priority: Severity of issue fixed: Medium Merge Risk:
|
|
Done in 138849be61 (see the detail in the greptile thread): three pty-path cases now run through the real |
There was a problem hiding this comment.
Caution
This PR breaks the aggregate runtime unit suite. A new top-level beforeEach in worktree-ps-structured-host.spec.ts clobbers the shared scan mock for every test in the aggregate orca-runtime.test.ts, so worktree-scan-cache-ttl.spec.ts fails. CI globs src/**/*.test.ts, which includes the aggregate, so this is red until scoped.
Reviewed changes
- Added pty end-to-end coverage — three cases in
worktree-ps-structured-host.spec.tsnow drive a handle-carrying hook row through the realgetWorktreePs(stubbed getter proves the wiring; the real getter resolves a populated{ source: 'hook' }; aworkingrow carries an explicitnull). This closes the prior review's@ts-nocheck-wiring gap. - Primed the shared scan mock — a top-level
beforeEachsetsscanLocalRepoWorktreesForResolutionMock.mockResolvedValue(...)so the spec's cases have a resolved worktree snapshot. - Pinned structured absence —
expect(worktree?.agents[0]).not.toHaveProperty('agentWait')for a host-held structured session.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The only delta since the prior review is the fix for the aggregate-suite regression, and it is correct.
- Scoped the scan-mock override — the
beforeEachthat primesscanLocalRepoWorktreesForResolutionMockmoved from module top level into an outerdescribe, so it registers only for this file's tests and the shared scan mock thatresetRuntimeTestMocksdelegates tolistWorktreessurvives for every other spec.
I verified the fix independently: pnpm vitest run src/main/runtime/orca-runtime.test.ts -t "keeps a scratch repo scan cached past the base TTL" (the case that previously failed at worktree-scan-cache-ttl.spec.ts:73) now passes, and both new specs are green (9/9). The pty end-to-end coverage added earlier still drives the real getWorktreePs through attachRuntimeWorktreeAgentRowWaits.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
a6ec30d to
8e39345
Compare
|
Rebased onto @nwparker gentle ping — happy to adjust anything. |
8e39345 to
3d46d70
Compare
|
Rebased onto current @nwparker gentle ping whenever you get a chance — happy to adjust anything. |
`orca worktree ps --agent-wait --json` now reports, on each terminal-backed agent row of the returned page, the same agentWait verdict `orca terminal show --json` gives for that terminal. The lookup is opt-in (RPC `includeAgentWait: true`) because it reads screens and may probe PTYs, which is too costly for default pollers. Hook rows use their terminal handle only when a connected PTY confirms it, and pane-only hook rows resolve the live terminal by pane key. Structured-worker rows and older hosts omit the field (absent = not evaluated; null = looked, no wait). Fixes stablyai#23921 Co-authored-by: Neil <[email protected]>
3d46d70 to
01ec475
Compare

ELI5
orca worktree ps --jsongives an agent one call that shows every worktree and the agents running in it. It already told you an agent's rough state, but not the more precise "this agent is stuck waiting for a human" verdict thatorca terminal showgives. To get that, a watcher had to callterminal showonce for every terminal. Now you can pass--agent-waittoworktree psand each agent row includes that same verdict.What Changed
worktree ps --jsonnever hadagentWait. Getting it meant oneorca terminal show --terminal <handle> --jsoncall per terminal.orca worktree ps --agent-wait --jsonaddsagentWaitto every terminal-backed agent row on the returned page. It uses the same contract asterminal show: a{ source, reason?, since? }descriptor when the agent is waiting on a human,nullwhen it checked and found no wait, and no field at all when it couldn't evaluate (structured-worker rows, older hosts). Without the flag the output is unchanged.Mechanism:
worktree.psRPC accepts a new optionalincludeAgentWait: trueparam. The CLI sends it only for--json+--agent-wait.terminalHandlethey were observed under, not just the resolvedptyId.getWorktreePspaginates first. When the caller opts in,attachRuntimeWorktreeAgentRowWaits()then runsgetTerminalInteractiveWait()in parallel, only for the rows on the returned page. A hook row's handle is used only when a connected PTY confirms it. Rows that reported only a pane key (HTTP hook posts) find their live terminal by pane key, the same wayterminal showdoes.Why
worktree psis meant to cover the whole fleet in one call. Making the caller fan out toterminal showper terminal defeats that. The lookup reads screens and can probe PTYs, so it's opt-in and limited to the returned page. That keeps default pollers (desktop, mobile, scripts) at today's cost. Mixed versions are safe: a new CLI talking to an old host just doesn't get the field (absent means "not evaluated"), and an old CLI never sends the param.Linked Issue
Fixes #23921
Visual Proof
N/A: this changes CLI JSON output, not UI. Here's the before/after from a runtime probe that compares
terminal showwithworktree psfor the same waiting agent:Before (main)
After (this PR)
Testing
Reproduced on main:
terminal showreports a hook wait, but theworktree psrow for the same agent has noagentWait. Verified the branch reports the identical descriptor.New
worktree-ps-agent-wait.spec.tsruns through the realgetWorktreePs. It checks that the wait is reported only on request (and nothing is probed otherwise), that pane-only hook rows find their live terminal, and that a working agent getsnull.Updated
worktree-catalog-snapshot-method.test.tsfor the new RPC param.pnpm test src/main/runtime/rpc/methods/worktree-catalog-snapshot-method.test.ts src/main/runtime/orca-runtime.test.ts src/cli: 187 files, 3671 tests pass.oxlint (anti-slop, code-quality native plugins), ast-grep, the changed-code quality gate, and oxfmt are clean on the touched files.
Platforms: macOS. The change is platform-neutral runtime/CLI logic with no paths, shells, or native modules involved.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Agent skill upstream boundary
Notes
Security: read-only data that the authenticated
terminal showalready exposes. Remote/SSH: works per host, and older hosts omit the field. Mobile: default calls are unchanged. Folder workspaces: rows are keyed by pane/terminal, not git. Performance: opt-in, page-scoped, parallel, and reuses the existing deduplicated and timeout-bounded probe.Original fix by @ggbdpq in #24142 (authorship preserved; maintainer follow-ups made the lookup opt-in, limited it to the returned page, and added pane-only hook rows).