You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supersedes #2272 with the same bounded outcome rebuilt and re-reviewed from the latest stable release, v0.2.5 (6fc491e6220fba6543bbbe4bf1b1f58cfe59228b). The old PR remains unchanged so its discussion and evidence stay readable.
Type of change
Bug fix
New feature
Enhancement
Refactor
Docs
What does this PR do
The OpenCode adapter can lose the terminal portion of a turn when the global event stream ends before the provider session has finished. This change reconciles the active turn from persisted provider state instead of treating stream EOF alone as terminal truth.
The focused replacement:
keeps turn ownership explicit while reconciling persisted provider messages;
recovers multi-step turns without accepting ambiguous or unrelated assistant output;
preserves completed usage and cost, including failed and canceled terminal turns;
isolates persisted terminal errors from later turns;
keeps the normal live event stream as the primary path; and
preserves current upstream autonomous-turn behavior: idle persisted user content does not start a turn, while busy status and permission-first live activity do.
It contains no Plexer policy, host topology, fleet routing, release bump, or machine-local behavior.
How did you verify it
The current head is a69c283a4bff686834df67e62cc0c2721c0298ca. It retains the stable-derived change and merges current upstream main at 70ed70d36e2eabd3876a22931954319ec202c902 without force.
114 focused OpenCode adapter tests passed on Node 24.
Full server and CLI dependency build passed.
Server/CLI/protocol dependency typecheck passed.
Targeted lint and formatting passed.
The all-workspace pre-commit lint, format, and typecheck passed.
Greptile reviewed the exact current head and reported 5/5 confidence with no blocking defect.
GitHub reports the PR mergeable with no content conflict.
The focused tests cover disconnected completion, missing suffix recovery, pending permission/question states, provider turn ownership, multi-step persisted messages, failure/cancel outcomes, usage and cost, ambiguous-state rejection, idle persisted user content, busy autonomous activity, and permission-first activity.
No UI or desktop bundle is changed. This branch has not been installed or activated on either live daemon.
Checklist
One focused change
npm run typecheck passes
npm run lint passes
npm run format passes
QA evidence
Tests added or updated where it made sense
This contribution was developed with AI assistance; every verification claim above comes from an actual run against the submitted branch.
The PR makes OpenCode turn startup and EOF handling cancellation-aware.
Reconciles owned foreground and autonomous turns from persisted provider messages when the event stream ends prematurely.
Captures a pre-dispatch message baseline for slash commands and aborts that read on interrupt or close.
Preserves terminal outcomes, usage, cost, and turn ownership while rejecting ambiguous persisted history.
Adds focused harness support and tests for EOF recovery, cancellation races, multi-step turns, and terminal-state isolation.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains; the previously reported slash-command startup issue is addressed by passing the active turn’s abort signal into the baseline history request, checking cancellation before dispatch, and covering both interrupt and close paths.
Extends the OpenCode test client with injectable message-history request behavior for cancellation and race tests.
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[startTurn] --> B{Slash command?}
B -- Yes --> C[Read persisted-message baseline]
C --> D{Interrupted or closed?}
D -- Yes --> E[Abort baseline request]
D -- No --> F[Dispatch command]
B -- No --> G[Dispatch prompt]
F --> H[Consume live event stream]
G --> H
H --> I{Terminal event received?}
I -- Yes --> J[Finish turn from live event]
I -- No, stream EOF --> K[Read persisted messages]
K --> L{Owned terminal state unambiguous?}
L -- Yes --> M[Restore usage and emit terminal event]
L -- No --> N[Fail turn at EOF]
Fixed in 2238d3b416417124fc59af2a526779c250efd661. The pre-dispatch history lookup now uses the active turn AbortSignal, and the continuation checks cancellation before dispatch. Added interrupt and close regressions proving the pending lookup, startTurn, and close all settle without dispatching the slash command. Verification: 92 focused OpenCode tests, full server build, repository-wide typecheck, and pre-commit lint/format/typecheck all pass.
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
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.
Linked issue
Closes #2271
Supersedes #2272 with the same bounded outcome rebuilt and re-reviewed from the latest stable release,
v0.2.5(6fc491e6220fba6543bbbe4bf1b1f58cfe59228b). The old PR remains unchanged so its discussion and evidence stay readable.Type of change
What does this PR do
The OpenCode adapter can lose the terminal portion of a turn when the global event stream ends before the provider session has finished. This change reconciles the active turn from persisted provider state instead of treating stream EOF alone as terminal truth.
The focused replacement:
It contains no Plexer policy, host topology, fleet routing, release bump, or machine-local behavior.
How did you verify it
The current head is
a69c283a4bff686834df67e62cc0c2721c0298ca. It retains the stable-derived change and merges current upstreammainat70ed70d36e2eabd3876a22931954319ec202c902without force.The focused tests cover disconnected completion, missing suffix recovery, pending permission/question states, provider turn ownership, multi-step persisted messages, failure/cancel outcomes, usage and cost, ambiguous-state rejection, idle persisted user content, busy autonomous activity, and permission-first activity.
No UI or desktop bundle is changed. This branch has not been installed or activated on either live daemon.
Checklist
npm run typecheckpassesnpm run lintpassesnpm run formatpassesThis contribution was developed with AI assistance; every verification claim above comes from an actual run against the submitted branch.