Skip to content

fix(opencode): retire a rolled-up subagent blocker on unknown-lineage idle - #22615

Open
pullfrog[bot] wants to merge 2 commits into
mainfrom
pullfrog/22604-root-idle-unknown-lineage-blocker
Open

pullfrog[bot] wants to merge 2 commits into
mainfrom
pullfrog/22604-root-idle-unknown-lineage-blocker

Conversation

@pullfrog

@pullfrog pullfrog Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​37
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

Follow-up to #22604 (merged), closing the one remaining path from its review.

ELI5

When a subagent asks a question, Orca shows "needs input" on the pane. The merged fix retires that indicator when the root turn ends — but only if Orca still remembers which pane the subagent belongs to. In a long-lived session Orca can forget, and if the lookup is also failing at that moment, the indicator could stay stuck. This closes that gap.

What Changed

clearAttentionForTurnEnd (added in #22604) matches a blocker by its source session or the root session it is displayed on. #22604 wired it into the normal idle branch, but the childState === null fallback idle branch still used clearAttentionForSession, which matches by source only.

Before: root's cached lineage is evicted and its idle lookup fails → the fallback branch cannot match a child's rolled-up blocker → the pane stays on "needs input" after the turn.
After: the fallback branch retires it and the pane goes idle.

The childState === null && Busy branch keeps the source-only clear, so a live blocker still outranks the root going Busy (the scope #22604 deliberately chose).

Why

The branch is reachable, contrary to the review thread's initial conclusion. The reasoning there was that a root-displayed blocker implies a successful lookup, and success is cached, so the root's idle resolves from cache. That holds until the cache drops the entry: rootSessionById is capped at 128 and rememberSessionRoot evicts the oldest key — a live blocker does not pin its root. Once evicted, the root's idle re-looks up; during the SDK outage this branch exists to handle, that lookup fails, childState is null, and control reaches the fallback.

Demonstrated by the new regression test: it resolves the child's ancestry (so the blocker is displayed on ROOT), inserts 130 session.created events to evict ROOT from the 128-entry cache, then fails the ROOT lookup at idle. With clearAttentionForSession the final post stays SessionStart (the blocker survives); the swap makes it SessionIdle, for both plugin families.

Linked Issue

Fixes #22371

Follow-up to #22604.

Visual Proof

N/A — the change is a status-lifecycle branch, no layout or interaction change. The proof is the hook-post sequence pinned by the new test: without the swap the last post is SessionStart; with it, SessionIdle { sessionID: ROOT }.

Testing

  • New: retires a root displayed child blocker when the root idle cannot resolve lineage. Mutation-checked — reverting the swap fails it with expected 'SessionStart' to be 'SessionIdle' for both opencode and opencode2.

  • pnpm test src/main/opencode src/main/opencode2 src/main/agent-hooks src/main/mimo → 114 files passed

  • pnpm tc:node clean; pnpm run check:code-quality:changed → 0 findings

  • Both pinned plugin digests move (the ownership source is shared with mimo-code), same as fix(opencode): retire a subagent's blocker when the root turn ends #22604.

  • I manually tested these changes locally

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

AI Disclosure

Authored by pullfrog/opencode while investigating the review thread on #22604.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH/remote and WSL: no wire change; the plugin runs on the execution host and keeps owning agent status per docs/reference/agent-status-store.md.
  • The 130 filler sessions model a long-lived OpenCode process that has resolved more than 128 sessions — the condition under which the root mapping is evicted.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • 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 pass locally

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

clearAttentionForSession retires a blocker only by sourceSessionID, so a
descendant's question displayed on the root it rolled up to survives when
the root's idle lands on the unknown-lineage branch. That branch is
reachable: rootSessionById is bounded at 128 and a live blocker does not
pin its root, so a long-lived process evicts the mapping and a failing
re-lookup sends the idle to the fallback. Use clearAttentionForTurnEnd
there too, matching the source or the rolled-up root; the Busy branch
keeps the source-only clear so a live blocker still outranks Busy.

Regression test evicts the root's cached ancestry with 130
session.created events, then fails the root lookup at idle; without the
swap the last post stays SessionStart instead of SessionIdle.
@pullfrog

pullfrog Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

The only real failure was a flaky test unrelated to this PR's opencode change: src/main/ssh/ssh-relay-reset.test.ts > uses the command-line fallback when lsof cannot match the socket, which asserted killCalls === ['-TERM 11111', '-KILL 11111'] but got [] while pgrep was still called.

Root cause: the reset script's pgrep fallback filters its own shell PIDs (awk -v self="$$" -v parent="$PPID"). The test hardcoded TARGET_PID = '11111', so whenever the CI process happened to be assigned PID 11111, the target was dropped as a false self-match. The sibling match test passed because it takes the lsof path, which bypasses that filter.

Fix: raise the test's target PID above any real pid_max (999999999), so the self/parent filter can never drop it. Verified pnpm test src/main/ssh/ssh-relay-reset.test.ts passes repeatedly, and pnpm run check:code-quality:changed reports 0 findings. Pushed as b588dff227.

Task list (6/6 completed)

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

This branch has not been deployed

No deployments
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] Orca incorrectly categorizes opencode2's subagent menu as a "question"

0 participants