Repository navigation
fix(opencode): preserve turn outcomes and avoid auto permission attention - #24612
Merged
Merged
Conversation
Adapt the root verdict proposal from brennanb2025 in PR #23105 to the current TUI-owned lifecycle, keeping hook-store authority and existing mainAgent semantics.
nwparker
force-pushed
the
nwparker/OpenCode-Agent-Status
branch
from
October 2, 2026 09:57
8796515 to
5fc4101
Compare
8 of 9 tasks
nwparker
marked this pull request as ready for review
October 2, 2026 12:01
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
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. Comment |
Closed
7 of 9 tasks
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
An OpenCode turn that failed looked Done, and Auto mode could briefly look like it needed your input even while it continued by itself. Orca now distinguishes failed and stopped turns and lets immediately answered permissions settle before asking for attention.
What Changed
The OpenCode 2 terminal plugin reads the current root outcome and binds a captured failure or user interruption to that completed turn's timestamp. A later turn completed while the plugin was unloaded replaces the old verdict when the reporter returns. It includes that verdict in its existing hook posts. The execution host translates those optional fields into the existing agent outcome contract, which the tab already renders as Failed or Interrupted. A child still working keeps the aggregate Working; a child's failure does not become the root's failure.
Permission requests remain Working for up to 500 ms. A request still present after that interval becomes Needs input; a reply received during that interval never publishes waiting. Questions remain immediate. Permission posts now carry the existing approval-card envelope so native Chat can display the actual command awaiting approval. The reporter uses its existing session data and tick, with no extra timers or status store.
Why
OpenCode v2.0.16 exposes failed/interrupted lifecycle events, but its session status alone says only whether the turn is running. Reading the current session outcome and matching ending event timestamps preserves the root verdict without guessing from terminal text or process state. The optional hook fields keep older clients and plugins compatible and leave status authority on the execution host.
In a real Auto run, permission replies followed requests by 6–18 ms. Waiting briefly for an unanswered request avoids false attention while preserving real permission prompts, including when Auto is toggled inside the terminal. Upstream issue anomalyco/opencode#47545 documents the same ordering; warpdotdev/opencode-warp#26 uses a 500 ms notification grace.
Linked Issue
Fixes #18950. Adapts and credits brennanb2025's root outcome proposal in #23105 to the current terminal-owned lifecycle. This does not replace that PR's broader older-server and reader work.
Visual Proof
Real OpenCode v2.0.16 in an isolated, hidden Orca folder workspace on macOS. These are CDP screenshots; no window was shown or focused.
Before: the exact previous reporter displays Done beside a genuine rate-limit failure.
After: the same failure displays Failed.
A user-stopped real turn displays Interrupted.
A genuine unanswered permission still displays Needs input.
Testing
Real CLI
--standalonewith isolated HOME and all four XDG directories: a Muse free model returned a rate-limit error; a Fledge turn was interrupted with two Escape presses; Auto ran three harmlessprintftool calls without intervention; a manual permission waited, was approved, and finished. Baseline Auto status observations included waiting; candidate observations contained only working/done. Raw provider events confirmed requests and automatic replies rather than a run that bypassed permissions. Private PTY captures were scanned for secrets.The four lifecycle/store-publication suites passed 93 tests before the permission change; the final combined terminal ownership, permission, and host normalizer suites passed all 117 tests.
pnpm tc:node, changed-code quality checks, formatting, whitespace checks, and the Electron/relay/CLI build phases passed. The full build stopped at mobile web because this worktree lacks react-native-web/expo-router dependencies. Windows/WSL and live SSH validation are pending; those platforms are not claimed tested.Review
The invariant is that a completed root outcome belongs to its current turn, and only an unanswered provider permission needs input. Failure modes covered include stale session data inside the ending-event callback, a whole turn missed during plugin unload, child work continuing after root failure, and automatic permission replies. The execution host normalizer owns the result for native and relay consumers; optional payload fields preserve mixed-version compatibility. Existing 100 ms polling and bounded memory remain unchanged; permission settling adds no subprocess or timer. Windows/WSL and SSH remain pending real validation.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No renderer styling, remote stream opcode, platform-specific command, or reader-side status precedence changed. Older plugin payloads continue to normalize without an invented outcome. Auto replies taking longer than 500 ms can still require attention until answered; this is a bounded downstream workaround for the upstream event ordering.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)