Repository navigation
fix(pi): keep re-posting a child-held turn so async children never look stale - #48146
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
A Pi turn held open by async child agents posted nothing until the last child settled. After the host's 30-minute freshness window, a paired server fell back to the PTY title, published a title-only done, and dropped the live child rows. While children hold the turn, re-post the held status through the existing subagents_update path every 10 minutes (a third of the freshness window). The unref'd timer lives on the shared subagent roster so a Pi reload keeps a single timer, re-arms on session_start, and clears on child settle, run close-out, and session shutdown. It stops after a day without child lifecycle events so a child that never reports again cannot keep the pane working forever. Fixes stablyai#46585 Co-authored-by: Neil <[email protected]>
b516f6f to
2748e75
Compare
* local(ci): clear the three red fork checks after the 2026-11-24 sync Issue #463. Every red reproduced locally on f55ccb8 and is fallout from upstream 7daf01d (PR stablyai#46786 retired ~93% of the test files and several workflows) plus four collisions between long-standing fork patches and upstream's new tests. check-actions-enablement: macos-updater-tests.yml left REQUIRED and EXPECTED_TRIGGERS. Upstream deleted the workflow with the updater suites it ran, so the contract named a path no commit carries. Recorded in LOCAL-PATCHES.md § local(ci); the two fork tests that pin contract-against-tree went green from the removal. fork-main-gates: max-lines pruned two dead rows and gained the upstream-owned orca-runtime-bots.ts exemption its own header already claimed; focus-read, main-blocking-helper and workspace-path-sync-fs pruned; two orphan ko.json keys retired; the upstream-file-comments baseline re-based at the new sync base (4752 lines against 5113, a 361-line shrink) with the growth reason recorded in `accepted`. Nightly: the e2e verdict contract follows upstream's unsharded job and its report path; the two dead ledgers lost entries naming retired files; the tab focus harness passes `fromKeyboard` as stablyai#46611 defined it; the webhook refusal assertion follows the shipped copy; and the rate-limits isWatched patch is split so the timer keeps the fork's gate while an owner return keeps upstream's. The pi lane's cancel latch is the one real defect the nightly found. This fork publishes one `subagent_async_state` snapshot per post instead of upstream's `agent_start:subagent`, so a child starting right after Esc was held as late work for the whole 15s window (stablyai#47627). The latch gained a marked LOCAL(nplez1) rule for that shape and upstream's suite is kept and green. The held-turn repost suite (stablyai#48146) needs the two `subagent:async-*` bindings this fork deliberately removed, so it is a recorded fork-refactor deletion with its coverage owed. * local(sync): point the retired repost suite at the commit that deleted it * local(agents): mark the cancel latch's snapshot rule and keep its comment budget The latch hunk needs a rationale in an upstream file, so it carries the fork-comment-ok marker the ratchet asks for rather than growing the baseline, and LOCAL-PATCHES.md § local(agents) now says why the rule is not "any snapshot is a start". * local(agents): say which check holds the OMP start, and warn against widening the event check * local(sync): name the issue that owns the retired repost suite's coverage * local(lint): record the eight blocking-helper rows the sync left over baseline check:main-blocking-helper-ratchet fails on the PR revision and on f55ccb8 itself: eight upstream-owned files now reach a sync fs/SQLite helper through upstream's own call chains (its SQLite storage layer, and the project-folder-placement split that put a readdirSync behind getWorktreePathSettings). None has a fork hunk, so they are recorded in the fork overlay with a why rather than diverged, which is the ratchet's documented escape for a call the fork cannot move. The earlier reading that this was this machine only was wrong: the same eight rows reproduce on the merge revision GitHub tests, so the runner sees them too. * fix(mobile): give the shared photon connector row a mobile case Upstream's shared connector list adds a photon entry for every bot, and the fork's photon connector rides it. Mobile's typecheck has been red since the sync because its words object lacked the field and needPage had no case for the kind: TS2741 in connector-entry-rows.tsx and TS2366 in phone-connector-needs.ts. The row is now listed with its mark and no press — the phone has no Photon surface yet and the connector asks nothing of the owner, so listing it is the honest half of parity rather than dropping it, which is what a switch with no case for the kind was doing. --------- Co-authored-by: Nathan Plesnicher <[email protected]>
ELI5
When a Pi agent hands work to background child agents, Orca correctly keeps its turn marked "working" until those children finish. But the lead agent goes quiet while it waits, and after 30 minutes of silence Orca treats the turn as stale. On a paired server that meant the row could flip to a false "Done" and the running children disappeared from the list. Now the Pi status extension re-sends "still working, these children are running" every 10 minutes while children hold the turn, so the status never goes stale.
What Changed
Before:
postAgentEndOnce()held backagent_endwhile children were running but posted nothing in its place. The extension only posts on events, so a turn whose reply ended with long-running children was silent until the last child settled. After the host's 30-minute freshness window (AGENT_STATUS_STALE_AFTER_MS), a paired server fell back to the PTY title, published a title-onlydonewith nosubagents, and re-pulling the workspace dropped the live child rows (#46585).After: while
isHeldByChildren()is true, the extension re-posts the held status through the existingpostSubagentsUpdate()path everyAGENT_STATUS_STALE_AFTER_MS / 3(10 minutes). The provider normalizer restates the previousworkingpayload and merges the live roster, so each repost is fresh evidence of exactly the held state.Mechanism:
unref()'d timer (heldTurnRepostCheck) lives on the sharedSubagentRoster, next torunnerExitCheck. It only exists while children hold a turn.session_start. It is cleared byresetSubagentRoster()and bysession_shutdown. On a Pi reload the old registration clears its timer at shutdown and the new one re-arms onsession_start, so there is only ever one timer.lastChildEventAt. If a day passes with no child event, the reposts stop and normal host freshness decay takes over. That way a child that never reports again cannot pin the pane as working forever. The day bound matches pi-subagents' abandoned-slot release window (MAX_ABANDONED_SLOT_RELEASE_AFTER_MS = 24h, checked in pi-subagents origin/main).Dateinto the VM context so the generated extension can read the clock.Why
#46585 suggests two fixes. This PR does the first one, where the status is produced: it keeps the status fresh while a turn is legitimately held open. The second one, how a server handles stale evidence, is covered separately by #46903 and #46968. This PR does not touch the 30-minute freshness constant, the desktop decay rule, or the server projection. Each repost is a real hook delivery stamped at receipt, not a re-dated old row. The post queue is latest-only, so repeated posts cannot make it grow.
Linked Issue
Fixes #46585
Visual Proof
N/A. Nothing visible changes in Orca's own UI. The change repeats an existing background status post while children hold a turn. The user-visible symptom (a false "Done" after 30 silent minutes on a paired server) needs a real Pi chat and 30 minutes of wall-clock silence, so the scripted fake-timer extension tests below verify it instead.
Testing
agent-status-extension-held-turn-repost.test.tsruns the generated Pi extension in the existing VM harness with fake timers:agent_endis posted. After two intervals there are twosubagents_updateposts carryingchild-1. When the child completes, the realagent_endposts and the reposts stop.agent_endis invented.Red/green: with only the three source files reverted to main, all 3 new tests fail. With the change, all of
src/main/pi/managed-extensions/agent-status/passes (23/23). Platform: macOS (vitest). CI gates were run on the touched files and are clean: anti-slop oxlint, code-quality native oxlint, ast-grep, the changed-code quality gate, oxlint, and oxfmt.Performance
None, because the change runs inside the Pi extension process, not in Orca's main process or renderer. At most one
unref()'d timer exists, and only while children hold a turn. It makes one small, existing hook post every 10 minutes, and there is no timer when idle. Microbenchmark of the work added to each child event (Date.now()plus the O(1)active.size/ timer-null check): about 35 ns typical, and about 253 ns in the adversarial case where the timer is armed and cleared on every event.Risk
Level: Low
The riskiest part is a timer that outlives its turn. It is cleared on every teardown path (child settle, run close-out, roster reset, session shutdown), it is never created while idle, and it stops on its own after a day with no child events. If it misfired, the worst case is one extra
subagents_updatethat restates the live state. It can never post a completion. Older hosts already acceptsubagents_update. Back out with a plain revert.Review
Agent skill upstream boundary
Notes
Security: no new inputs, paths, or network endpoints; it reuses the existing local hook post. Cross-platform: plain timers, no platform-specific code. Remote/SSH: posts go through the existing hook path, so local and remote hosts both work. Mobile: consumes the same host status evidence, which now stays fresh. Backwards compatibility:
subagents_updateis an existing event.Original fix by @Pr1p in #48146. Maintainer follow-ups: a single timer per registration across reloads, and a 24h quiet bound in place of sweeping runner PIDs.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)