feat(cli): print session id at the end of run#17229
Open
phall1 wants to merge 1 commit intoanomalyco:devfrom
Open
feat(cli): print session id at the end of run#17229phall1 wants to merge 1 commit intoanomalyco:devfrom
phall1 wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing 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.
Issue for this PR
[FEATURE]: output session_id after a cli run #17221
Closes #17221
Type of change
What does this PR do?
opencode runalready creates or resolves a session ID internally, but before this change it did not surface that ID at the end of the run in a reliable way for follow-up commands or shell scripts.Updates
packages/opencode/src/cli/cmd/run.tssosession.completeevent andsession: <id>at the end of the command. In the default CLI format, that final line is printed withUI.println, which goes to stderr, so it stays visible to the user without polluting stdout pipelines.In
--format json, the newsession.completeevent gives scripts a clean final event containing thesessionID.This works because (1) the session ID is already known before the prompt/command is dispatched, and (2) awaiting the run loop guarantees the final output happens after all prior run events have been flushed.
How did you verify your code works?
packages/opencode/src/cli/cmd/run.tsand confirmed there were no errors in the modified fileruncommand behaviorUI.println/stderr, while JSON mode emits structured events to stdoutbun typecheckinpackages/opencode, which currently reports unrelated pre-existing type errors in test and fixture files outside this changeScripting patterns:
Screenshots / recordings
default
--json
stderr redirect:
Checklist