Repository navigation
fix(pi): complete a run whose settle never comes, and re-open a late busy post - #63
Merged
Merged
Conversation
…busy post A pi pane could sit on "Working - <tool>" for hours after its turn was over: the last hook Orca ever received was a working `message_end`, and nothing later could take the row out of working. Confirmed live on two panes (`orca worktree ps` reported `state: working` with `stateStartedAt` = the dangling `agent_start` at 21:07:34 and 23:03:51 whose `agent_stop` never followed, while both sessions' transcripts ended on an assistant `stopReason: stop`). Two ways the completion went missing, both in the turn-end path: - `agent_settled` set a permanent `agentSettledSupported` flag, and `agent_end` returned early on it forever after. A run whose settle never arrived (or whose settle was reported for another run) could therefore not publish its own completion — the generation differed from the latch, so there was no fallback left. `agent_end` now arms the idle recheck for the run that just ended and is only skipped when THAT run already settled. - A working post published after the run's completion (a re-finalized `message_end`, a late `tool_execution_end`) re-opened the row with the latch already consumed at that generation, so no later event could answer it. A busy post that lands while no turn is in flight now republishes the completion. The pane's completion is otherwise unchanged: the latch still dedupes a settle against its own `agent_end`, and OMP's `willContinue`/approval contract is untouched (every change is `kind === 'pi'` or already runtime-gated). Pre-fix evidence, from the new tests: the second run posted nothing (`expected ['agent_start','agent_end'] to equal [... 'agent_start','agent_end']`), and both late-busy cases delivered 3 posts instead of 4, leaving the row working. Known and left alone (reported separately): a pi in-process task child runs this same extension, and its `session_start` writes the module-global `sessionMetadata`, so the pane's own posts carry the CHILD's session id — both wedged panes' posts currently name a child session that finished hours ago while their leads run. That is deliberate for the child lane's run attribution (`agent-status-async-subagent.test.ts`: "its child is reported, and reported for the session its own context named"), so it needs its own decision. `pnpm test src/main/pi` (362 passed), `pnpm test src/shared/agent-hook-listener src/main/agent-hooks` (1754 passed), `pnpm tc`, changed-code quality gate: clean.
nplez1
added a commit
that referenced
this pull request
Oct 9, 2026
…it options Merging a review-gated pull request with the admin bypass failed on every attempt from the right sidebar, and from every other surface that offers it: the confirmation appeared, the user accepted it, and the merge was refused with "This pull request requires review approval before it can be merged." The same merge succeeded on github.com. Confirmed on #63 and #64, both merged by hand in the end. `getGitHubLocalGitOptionArgs` returns `[]` when a repo has no local git options — the ordinary case for a local checkout with no WSL routing and no gh account bound to the repo. Both host entry points spread that array immediately before a trailing options object: ...getGitHubLocalGitOptionArgs(store, repo), { bypassBranchProtection: args.bypassBranchProtection === true } An empty array spreads to nothing, so the options object became the sixth argument (`localGitOptions`) and `mergePR`'s seventh parameter (`options`) took its default `{}`. `options.bypassBranchProtection === true` was therefore false, so the preflight refused to authorise the bypass it had just been asked for and returned the review-approval error. A WSL repo, whose options array is non-empty, was unaffected — which is why that suite passed while the SSH/local one asserted the shifted call as if it were the contract. Both call sites now materialise the argument with the `[0] ?? {}` idiom the neighbouring runtime commands already use (`runtime-github-repository-query-commands`, `runtime-github-review-query-commands`), so the trailing options object cannot be displaced. Nothing else moves. The running build carries the same shape (`out/main/index.js` in Orca NP 1.4.214-np.22), and the real preflight called against #63 while it was still open returned `{"error":null,"adminBypass":true}` — the permission was never the problem, only the lost flag. Verified: the new and corrected suites fail 4 of 7 with the production change stashed and pass with it; `github-wsl-runtime-routing`, `rpc/methods/github`, `client-pr-admin-merge-bypass` and `pr-mutation-review-invalidation` pass (68 tests); `pnpm tc` and `pnpm lint` clean; full `pnpm test` 112,892 passed / 56 failed, every failure in a class already recorded as red on this machine's base and none of them importing the changed modules.
8 of 9 tasks
nplez1
added a commit
that referenced
this pull request
Oct 9, 2026
…it options (#67) Merging a review-gated pull request with the admin bypass failed on every attempt from the right sidebar, and from every other surface that offers it: the confirmation appeared, the user accepted it, and the merge was refused with "This pull request requires review approval before it can be merged." The same merge succeeded on github.com. Confirmed on #63 and #64, both merged by hand in the end. `getGitHubLocalGitOptionArgs` returns `[]` when a repo has no local git options — the ordinary case for a local checkout with no WSL routing and no gh account bound to the repo. Both host entry points spread that array immediately before a trailing options object: ...getGitHubLocalGitOptionArgs(store, repo), { bypassBranchProtection: args.bypassBranchProtection === true } An empty array spreads to nothing, so the options object became the sixth argument (`localGitOptions`) and `mergePR`'s seventh parameter (`options`) took its default `{}`. `options.bypassBranchProtection === true` was therefore false, so the preflight refused to authorise the bypass it had just been asked for and returned the review-approval error. A WSL repo, whose options array is non-empty, was unaffected — which is why that suite passed while the SSH/local one asserted the shifted call as if it were the contract. Both call sites now materialise the argument with the `[0] ?? {}` idiom the neighbouring runtime commands already use (`runtime-github-repository-query-commands`, `runtime-github-review-query-commands`), so the trailing options object cannot be displaced. Nothing else moves. The running build carries the same shape (`out/main/index.js` in Orca NP 1.4.214-np.22), and the real preflight called against #63 while it was still open returned `{"error":null,"adminBypass":true}` — the permission was never the problem, only the lost flag. Verified: the new and corrected suites fail 4 of 7 with the production change stashed and pass with it; `github-wsl-runtime-routing`, `rpc/methods/github`, `client-pr-admin-merge-bypass` and `pr-mutation-review-invalidation` pass (68 tests); `pnpm tc` and `pnpm lint` clean; full `pnpm test` 112,892 passed / 56 failed, every failure in a class already recorded as red on this machine's base and none of them importing the changed modules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
The Agents list shows a word next to each agent: Working, Waiting, Idle. A Pi agent's row could get stuck on "Working — bash" for hours after that agent had finished its turn and gone quiet. Nothing the agent did afterwards could clear it, and only restarting the app would. Two separate gaps in the Pi status lane let a finished turn go unpublished; both are fixed here.
What Changed
Before: a Pi pane that finished its turn stayed on Working indefinitely. Confirmed live, not theorised:
orca worktree psreportedstate: workingwithstateStartedAtpointing at a danglingagent_start(21:07:34 on one pane, 23:03:51 on another) whoseagent_stopnever followed — while both sessions' own transcripts ended on an assistant message withstopReason: stop. The last hook Orca ever received was a working one, so the row had nothing left to answer it.After: a run publishes its own completion whether or not the runtime happens to send its settle event, and a later stray working event re-asserts the completion it displaced instead of re-opening the row for good.
Two failures in the turn-end path, each fixed at its own point:
1. One settle silenced every later run
agent_settledset a session-lifetime boolean (agentSettledSupported) that made theagent_endfallback return early forever after. That boolean conflates "this runtime knows how to send a settle" with "this run already settled". So a run whose settle never arrived — or whose settle had been reported for a different run — could not publish its own completion either: its generation differed from the latch, and the fallback that exists to cover exactly that case had been switched off.It is now the generation of the run that settled (
settledGeneration = lifecycleState.runGeneration), andagent_endre-arms the idle recheck for the run that just ended. It is skipped only when that run already settled.2. A working post after the completion re-opened the row for good
A working post that lands once the run is over — a re-finalized assistant
message_end, a latetool_execution_end— re-opens the row, but the completion latch for that generation had already been consumed by the first completion. No later event could answer it, so the stale re-open was permanent.republishLateBusyPostCompletion()now runs after those two posts: when no turn is in flight and a run has actually ended, it re-asserts the completion the working post displaced.The ordinary path is untouched: the latch still dedupes a settle against its own
agent_end, and a busy post that arrives while a turn is in flight still leaves the run in flight.Scope
Every change is either gated on
kind === 'pi'at source-generation time or (for the settle tracking) a strictly narrower replacement of the boolean it replaces. OMP'swillContinue/ approval contract is not touched.Why
Why track the settling run's generation rather than a "does this runtime settle?" flag. The existing flag was answering the wrong question. Its only purpose was to stop the fallback from double-posting a completion for a run that had already completed — and that is a question about a run, not about a runtime. Answering it per run fixes the under-reporting without weakening the dedupe, and a runtime that stops emitting settles simply falls back to the
agent_endrecheck, which is the behaviour that already existed for runtimes that never emitted them.Why republish rather than suppress the late busy post. The late post is not spurious — it is newer truth than the completion and the host is right to apply it. Suppressing it would trade one wrong row for another (a finished turn that still shows a tool running). Re-asserting the completion keeps the host's last-write-wins rule intact and makes the pair of posts self-correcting.
Why both in one commit. They are the two halves of one symptom: a completion the pane never gets, and a completion the pane loses again after getting it. Either alone leaves a way to wedge the row, so a reviewer cannot judge the fix from one of them.
Linked Issue
N/A — a fork PR against
nplez1/main, reported directly by the fork owner from a live stuck pane rather than filed as an issue first.Visual Proof
The change is to what the status row reads (Working → Idle on a finished turn), but the defect only appears when a runtime stops emitting its settle event at the right moment, which is not reproducible on demand — that is exactly why it went unnoticed. The proof is the hook-event stream rather than a screenshot, and it is pinned by tests:
agent_start, agent_end, agent_start(run 2 never completes; pane stays working)agent_start, agent_end, agent_start, agent_endmessage_endlands after the run completedagent_start, agent_end, message_end(row re-opened, permanently working)agent_start, agent_end, message_end, agent_endtool_execution_endlands after the run completedagent_start, agent_end, tool_execution_end— same wedgeagent_start, agent_end, tool_execution_end, agent_endmessage_endduring a run in flightagent_start, message_endagent_start, message_end— unchangedThe pre-fix failures were observed directly, not inferred: the second run posted nothing (
expected ['agent_start','agent_end'] to equal ['agent_start','agent_end', ...]) and both late-busy cases delivered 3 posts where 4 are required. Say the word if a screen recording of the before/after is wanted anyway and I will drive a live pane for it.Testing
pnpm tc— cleanpnpm lint— clean (full chain, including repo-wideoxlintand the max-lines ratchet)pnpm test— full suite from this worktree; see the failure classification belowpnpm test src/main/pi(362 passed) andpnpm test src/shared/agent-hook-listener src/main/agent-hooks(1754 passed)pnpm run check:code-quality:changed— cleanpnpm testresult: 112,889 passed, 57 failed, 14 files failed, 113,878 total. Every one of the 57 is in a class this machine'sLOCAL-PATCHES.mdalready records as red on the fork's base, and none of them is reachable from this change:agent-session-*,agent-launch-*,structured-agent-session-*807aa6062ccloud/is not installed on this host, so the suite dies importingpgbunproject onlybunruntime; passes under the node projectThe baseline this is measured against is on record as 113,874 tests with 57 failing across 14 files on this machine before this branch existed; this run is 113,878 (the four new tests) with the same 57 failures in the same 14 files — the failing set is unchanged.
Three further checks back "not ours" rather than assuming it:
src/main/runtime,src/main/native-chat,src/main/daemon,src/relayortests/e2eimportssrc/main/pi, so the changed module is not on any of the 14 files' import graph.src/main/piis green: 362 passed, including the four tests added here.src/relay/subprocess.test.ts, passes on its own —pnpm test src/relay/subprocess.test.ts→ 28 passed / 28. It timed out at the default 10s inside the fullbun-project run, which is the shared-resource shape the recordedbun-project class has. It is noted in theLOCAL-PATCHES.mdledger rather than fixed here.Platform: verified on macOS (this host). No platform-specific code path is touched — the change is in generated hook-handler source, which is platform-independent.
AI Disclosure
Written by Claude (Opus) in an agent session, reviewed by the fork owner. The live diagnosis was done against this machine's own stuck panes.
Review
Agent skill upstream boundary
Notes
agent_endandmessage_end; no new timers, and the new code paths run at most once per turn.session_startwrites the module-globalsessionMetadata. So the pane's own posts can carry the child's session id — both wedged panes' posts currently name a child session that finished hours ago while their leads run. That attribution is deliberate for the child lane (agent-status-async-subagent.test.ts: "its child is reported, and reported for the session its own context named"), so changing it is its own decision and is not smuggled into this fix.Checklist
pnpm tc,pnpm lintandpnpm testrun from this worktree; results and failure classification above