Repository navigation
Conversation
Non-interactive \ un\ prints text only on message.part.updated with time.end set, and exits the moment session.status turns idle. If idle wins the race against the final part update (typical for instant, short answers), the command exits 0 with empty output despite the backend having recorded it. Track mirrored part IDs; on idle, re-fetch the session timeline and mirror finished text/reasoning/tool parts the stream never delivered. Best-effort: fetch failures keep the previous behavior. Live-loop rendering is refactored into a shared outputPart() with no behavior change (covered by existing run-process subprocess tests).
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
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.
Problem
Non-interactive
opencode run --format jsonintermittently exits 0 with empty stdout even though the backend recorded output. Observed withrun --attach(also reproducible without it): a short assistant reply such asOKis stored server-side (verified in the session database), but the CLI prints nothing — downstream consumers see an empty turn.Root cause in
loop()(packages/opencode/src/cli/cmd/run.ts):message.part.updatedwithpart.time.endset.breaks the momentsession.statusturnsidle.If idle wins the race against the final part update (typical for instant, short answers — long streamed replies almost always win), the client exits before printing anything. The codebase already knows transports can drop status events (
stream.transport.ts: "some transports can miss status events"); this is the inverse direction with no mitigation at all.Fix
client.session.messages()and mirror finished text / reasoning (when--thinking) / completed-or-errored tool parts that were never streamed, reusing the exact same rendering path (outputPart()), so live and flushed output are identical.outputPart()with no behavior change.Verification
packages/opencode/test/cli/run/flush-missed-parts.test.ts(9 tests: missed finished parts, already-emitted skip, unfinished skip, thinking gate, tool statuses, user-message exclusion, synthetic-signal exclusion, empty timeline).test/cli/run/run-process.test.tssubprocess suite: 13/13 pass (covers the refactor).tsgo --noEmitclean;oxlintreports no new warnings on touched files.step_start+textJSON lines repeatedly with no duplication.Notes
session.messages()lookup is by session ID only (same as the existingsession.getusage), so this works for attach and local runs alike.