Skip to content

fix(agent-status): keep Pi's background subagent rows on paired clients after the reply ends - #44375

Merged
AmoabaKelvin merged 1 commit into
mainfrom
fix-39120-async-subagent-rows
Nov 19, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
fix-39120-async-subagent-rows

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When Pi starts background subagents and then finishes its own reply, the host still knows the work is running. A paired desktop or phone could still show the parent as Done with no child rows. Now the paired client shows the parent as working, with its child rows, until the children finish.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​85 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15

What Changed

Before: on a paired client, a Pi pane that ended its reply while async subagents (plain async runs or workflow children) were still running showed a green Done with no child rows. On the host, orca worktree ps showed the pane working with every child listed.

The cause is in the host's session-tab projection, the status paired clients receive. When Pi ends its reply it writes its OSC 7501 root record as done, so the PTY's activity becomes idle. Orca's Pi status extension holds agent_end back while children run, so the hook row stays working and lists the subagents. The projection (workingHookOwnsIdleTitleInterval) kept a working row under an idle title only if the row was observed after the title went idle. Pi's last hook post and its 7501 done arrive within a millisecond of each other. When the hook landed first (1 ms earlier in the reporter's Linux host data), the projection decided the idle title had ended the turn. It then published a title-only done that carries no subagents.

After: an idle lead no longer retires a fresh, non-restored working row whose own subagent roster still has live work. It uses the same lead/child fold the hook server already applies (foldMainAgentWithRowChildWork), and the generation fence the Codex exception next to it uses. Shell titles (the agent exited), restored rows and stale rows (30 min) still demote as before. Both routes are covered: the headless-serve builder (resolveRuntimeHookLiveAgentRow) and the renderer-published tab (renewRuntimeMobileAgentStatusFromPtyTitle). Both call this one predicate.

Why

The reporter's first theory, a missing subagent:child-status subscription in the roster source, was ruled out by their own live trace: the host's hook store had every child. I checked the client side too. Pi sends no OSC 9999, so a paired renderer never takes ownership of the row and only mirrors what the host sends. The loss is entirely in the host projection, and only that route compares a hook row against the title.

Alternatives considered:

  • Make the OSC 7501 activity lane report working while child records live (the reporter's first suggestion). That changes the PTY's idle fact for every consumer: mailbox delivery, tui-idle waits, idle notifications. The lead really is at rest. It would also only cover children that pi-subagents reports over 7501, not the other producers in Orca's roster.
  • Have the Pi extension mark held turns explicitly (mainAgent: done). That post would land at the same moment as the 7501 done and hit the same race.

Folding the row's own roster at the one place that compares hook against title fixes every producer and both routes. The client still shows only what the host says.

Closed PR #39564 was about native chat background workers and was replaced by #42448. It does not touch this terminal path, so nothing was reused from it.

Linked Issue

Fixes #39120

Visual Proof

N/A for a screen recording: the bug depends on which of two reports reaches the host first. Locally on macOS the hook landed after the PTY's done, so the client looked right even before the fix. Payload evidence instead:

  • Real-runtime regression test (captured Pi 1.5.2 + pi-subagents 0.89.0 bytes, hook 1 ms before the PTY's done), session.tabs agentStatus for the pane:
    • before: { state: 'done', prompt: '', ... } (no subagents), on both the headless and the published route
    • after: { state: 'working', subagents: [child-a, child-b], ... }
  • Live run on a worktree-built orca serve with real Pi + pi-subagents (async workers, fake local model). session.tabs.list and worktree.ps agreed throughout: working with both children while they ran, then done with no children once they finished.

Testing

  • Reproduced first with a real Pi 1.5.2 + pi-subagents 0.89.0 run in a headless orca serve built from this branch. I captured the exact OSC 7501 sequence (state=working:app=pi, two app=pi-subagents child records, state=done:app=pi) and the Pi hook row (working + subagents, no mainAgent).

  • Added a regression test on the real OrcaRuntimeService session-tab projection (headless and renderer-published routes). Both fail on main with the title-only done and pass with the fix.

  • After the fix, ran a live end-to-end check on the same serve: rows stayed working with children while they ran, then settled to done.

  • Ran the dependent test files (session-tab projection, terminal waits, process listing, hook-server presence/interrupt tests): 17 files, 85 tests, all pass. pnpm tc:node passes; pnpm check:changed passes all 27 checks on the rebased head.

  • Platform: macOS host. Linux behaves the same; this path has no platform branches.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

Risk

The riskiest part is a working row being held under an idle title when its roster is stale. For example, a child that died without reporting would keep the row working on paired clients. That matches what the host's hook store and orca worktree ps already show, and it still ends at the 30-minute stale window, a shell title, a restore or a PTY generation reset. No wire, schema or persistence change, so older clients and hosts are unaffected. A plain revert backs it out.

Performance: the check runs on the session-tab projection, the status-sync hot path. It is evaluated only after the cheaper conditions have already failed: a working row, an idle PTY, no shell title, and an observed-at check that came out false. It then walks the row's existing subagent array once. No new polling, timers, RPCs or extra publishes. The published payload is the host's own row, the same one sent today whenever the hook wins the race.

Level: Low

AI Disclosure

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

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Mobile and paired desktop clients both read this projection, so both get the fix. SSH and local panes go through the same projection. Folder workspaces are unaffected.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a4ad7fbe-6d32-4a52-a1c9-9bc9638ff543
Commits

Reviewing files that changed from the base of the PR and between c9476fa and 95722f0.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The status projection now considers live row-child work when deciding whether a working lead remains open during an idle-title interval. Tests cover Pi sessions through headless and published-status routes, including the case where the lead reports completion while two subagents remain working.

Merge Risk: Minimal · previous review c9476

This change keeps Pi parent rows shown as working, with their child rows, when the reply ends before its subagents finish. The change is small and its guards are retained. Both projection routes have regression tests. I found no merge-blocking risk.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Linked issue #39120 reports that async pi-subagents workflow workers are missing from sidebar child rows while running. The issue names a missing subscription in src/main/pi/agent-status-subagent-rost… Provide evidence that, at the reviewed head, the roster source (src/main/pi/managed-extensions/agent-status/agent-status-subagent-roster-source.ts) consumes subagent:child-status for workflow children, associates the actual worker with its …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the fix (keeping Pi's background subagent rows on paired clients after the reply ends), which matches the changeset: the projection change in runtime-mobile-agent-status-evidence.ts ke…
Description check Passed The description follows the repository template and fills in most sections: ELI5, What Changed (before and after, with mechanism), Why (alternatives considered), Linked Issue (Fixes #39120), Visual Pr…
Out of Scope Changes check Passed The changed files are src/main/runtime/session-lifecycle/projection/runtime-mobile-agent-status-evidence.ts (adds subagents to HookTurnFacts and a rowChildWorkHoldsIdleLead guard in workingHookOwnsIdl…
Full details: Title check

Explanation

The title names the fix (keeping Pi's background subagent rows on paired clients after the reply ends), which matches the changeset: the projection change in runtime-mobile-agent-status-evidence.ts keeps a working row with live subagents from being demoted to a title-only done. It is specific and descriptive, and it is a single sentence. The title is 92 characters, slightly long but still readable.

Full details: Description check

Explanation

The description follows the repository template and fills in most sections: ELI5, What Changed (before and after, with mechanism), Why (alternatives considered), Linked Issue (Fixes #39120), Visual Proof (N/A with a reason and payload evidence), Testing, Risk (Level: Low with revert path), and the checklist. Several template sections are empty or unfilled: the AI Disclosure section has no content, the Review section is blank, and the Level line is filled but the template's Agent skill boundary and Checklist items are marked. The Visual Proof section gives a reason for N/A and supplies payload evidence, which the template allows. The gaps are minor and non-critical.

Full details: Out of Scope Changes check

Explanation

The changed files are src/main/runtime/session-lifecycle/projection/runtime-mobile-agent-status-evidence.ts (adds subagents to HookTurnFacts and a rowChildWorkHoldsIdleLead guard in workingHookOwnsIdleTitleInterval) and src/main/runtime/session-lifecycle/projection/orca-runtime-mobile-agent-status-title-truthfulness.test.ts (regression tests for Pi headless and published routes). Both match the PR's stated fix for the title-versus-hook race. The test changes support the source change. No unrelated file changes appear in the summary. Scope check is based on the summary; I did not read the full diff.

Full details: Linked Issues check

Explanation

Linked issue #39120 reports that async pi-subagents workflow workers are missing from sidebar child rows while running. The issue names a missing subscription in src/main/pi/agent-status-subagent-roster-source.ts (no subscription to subagent:child-status). The PR changes only the session-tab projection (runtime-mobile-agent-status-evidence.ts, the title-truthfulness test). It does not change the roster source. The PR description says the missing-subscription theory was ruled out by the author's live trace, where the host hook store held every child. The PR fixes a different symptom: a working Pi hook row is demoted to a title-only done with no subagents when the PTY done arrives first. The reporter's symptom (worker absent from the status snapshot) is not shown to be fixed. The roster source exists at src/main/pi/managed-extensions/agent-status/agent-status-subagent-roster-source.ts. I did not read its content at head, so I could not confirm whether the workflow-child lifecycle subscription is present. The requirement to consume workflow-child lifecycle events and clear them on completion is therefore not established either way.

Resolution

Provide evidence that, at the reviewed head, the roster source (src/main/pi/managed-extensions/agent-status/agent-status-subagent-roster-source.ts) consumes subagent:child-status for workflow children, associates the actual worker with its parent, and clears it on completion, failure, or cancellation. Alternatively, show a test that reproduces the issue's reported case (worker missing from the status snapshot while the parent is running) and passes at head. Either result decides this check.

  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df50b506-fe0f-4a41-b000-34ebad7864c0
Commits

Reviewing files that changed from the base of the PR and between cdf90d9 and c9476fa.

Files selected for processing: 2

  • src/main/runtime/session-lifecycle/projection/orca-runtime-mobile-agent-status-title-truthfulness.test.ts
  • src/main/runtime/session-lifecycle/projection/runtime-mobile-agent-status-evidence.ts

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

…n the lead's done lands after its hook

Pi ends its reply (OSC 7501 root done) while async subagents still run, and
the Pi extension withholds agent_end until they finish. The session-tab
projection read that idle activity as a newer turn end whenever the last
hook post landed first, and published a title-only Done with no subagents,
so paired clients lost the children. An idle lead no longer retires a row
whose own live children hold the turn open.

Fixes #39120
@AmoabaKelvin
AmoabaKelvin force-pushed the fix-39120-async-subagent-rows branch from c9476fa to 95722f0 Compare November 19, 2026 00:53
@AmoabaKelvin
AmoabaKelvin merged commit a7108b2 into main Nov 19, 2026
46 checks passed
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.

[Bug]: Async workflow workers are missing from sidebar child rows

1 participant