Repository navigation
fix(pi): let background subagent starts right after Esc mark the row working - #47627
Conversation
…working The Pi status extension posts agent_start for a background subagent start with the cached prompt and no explicit prompt, so within 15 s of an interrupted turn the cancel-verdict latch held it as a late event of the cancelled run and dropped it. The row stayed Interrupted for the whole run. Mark the subagent:async-started post with subagent_started, restate it as agent_start:subagent in Pi-family normalization (hookEventName already crosses SSH/WSL relays), and let the latch apply it. OMP task:subagent:lifecycle starts are in-turn children aborted with the turn, so they stay held, as do replays and plain late same-prompt work. Older extensions or relays keep today's behavior. Fixes #47576 Co-authored-by: Claude <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
* 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
In Pi, if you press Esc and a background job starts within the next 15 seconds, the sidebar kept showing the grey Interrupted dot for the whole job. Orca mistook the new job for a leftover message from the turn you just cancelled. Now Orca can tell the two apart, so the row shows working while the background job runs.
What Changed
Before: After Esc on a Pi turn, a background subagent start (
subagent:async-started) arriving within 15 s left the row on Interrupted (done) for the whole run. The same start after 15 s showed working.After: That start shows the row as working right away, then returns to done when the job completes. Late events from the cancelled turn are still held.
Mechanism:
agent-status-subagent-roster-source.ts) now marks itsagent_startpost withsubagent_started: true, but only for pi-subagents async starts (forcedStatus === 'started'). OMPtask:subagent:lifecyclestarts are in-turn children that get aborted with the turn, so they are not marked.provider-dispatch.ts, via the new leaf modulepi-subagent-start-event.ts) restates that post asagent_start:subagent.hookEventNamealready crosses SSH/WSL relays, so the marker survives remote paths.agent-hook-cancel-verdict-latch.ts) no longer holds aworkingupdate whose event isagent_start:subagent. It still holds replays, tool-progress events, and plain same-prompt work inside the 15 s window.Why
The latch exists to drop late hooks from a cancelled turn. A background subagent start that isn't tied to a prompt looked the same as one of those hooks, so the latch dropped it and nothing posted it again. Of the options, an explicit marker from the extension is the narrowest: it changes nothing for other providers or other Pi events. Shortening the window or letting every no-prompt
agent_startthrough would bring back the late-hook flicker that the latch prevents.Linked Issue
Fixes #47576
Visual Proof
N/A. The only visible change is which existing status dot shows (working instead of Interrupted). Nothing new is rendered. The behavior was checked end to end through the real
AgentHookServerand the real generated Pi extension (probe below).Probe (real
AgentHookServer+ real generated Pi status extension, Esc then background start):done(interrupted)workingdone(interrupted)workingdone/doneworking/donedone(interrupted, held)done(interrupted, held)workingworkingTesting
Repro: the probe above follows the issue's steps (interrupt a Pi turn, emit
subagent:async-startedwithin 15 s, read the row state). It fails 3 of 5 cases on main and passes all 5 on this branch.New unit test
agent-hook-cancel-verdict-latch.test.tssends the real generated extension's posts throughnormalizeHookPayloadand the latch. A background start is applied. An OMP lifecycle start and a replayed start are still held. The test fails if the latch change is reverted.vitestonsrc/shared/agent-hook-listener,src/main/pi/managed-extensions/agent-status, andsrc/main/agent-hooks/serverall pass. Lint, oxfmt, anti-slop, ast-grep, and the changed-code quality gate are clean.Platform: macOS (unit and integration level). The change is platform-neutral, and the marker uses an existing relay field for SSH/WSL.
I manually tested these changes locally (verified via the real-server probe and unit tests, not a GUI run)
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None, because this only runs per agent hook event, which is not a hot path. It adds one string comparison in the latch and one in Pi normalization. Measured old vs new: latch about 9 ns/op on main vs about 14 ns/op on this branch. Pi
normalizeHookPayloadabout 1.0 µs/op on both. There is no new I/O, polling, or subprocess work.Risk
Level: Low
The riskiest part is letting a held
workingupdate through. That is limited to posts the managed extension marks explicitly, and only pi-subagents async starts get marked. Older extensions or relays that don't send the flag keep today's behavior. If it goes wrong, a Pi row could briefly show working after Esc. A plain revert backs it out.Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Reported by @mmarabel