Repository navigation
Conversation
… tool call
Every invocation of the question tool now ends with a final free-form text
question ("Any comments?", header "Comments", textOnly: true). The auto-append
guarantees the runtime always collects feedback regardless of whether the
caller's own questions already used a confirmation step.
Schema additions:
- schema/question.ts (V2) and schema/v1/question.ts: add optional
textOnly?: boolean to QuestionV2.Info / QuestionInfo. The field stays
optional so existing prompts decode unchanged; consumers that branch on
textOnly treat absence as the existing select behavior.
Tool layer:
- core/tool/question.ts: withComments appends a constant COMMENTS_INFO to
the questions array before the QuestionV2.Service.ask call, and the
toModelOutput formatter reads the same wrapped list so the model also
sees the auto-appended question in its reply (with whatever answer the
user typed, empty string included).
- opencode/tool/question.ts (V1 mirror): same withComments wrap applied to
the opencode CLI's V1 tool. Both the V1 and V2 runtime paths now behave
identically.
- Tool description strings updated in both layers to advertise the new
textOnly flag and the always-on Comments question.
UI rendering:
- tui/routes/session/question.tsx: textOnly memo drives an unconditional
edit-mode (textarea only, no option list) for those tabs, with the
editing memo derived as textOnly() || store.editing. Edit-mode bindings
gain tab navigation so users can still skip to the next question, and
escape rejects instead of cancelling the edit on a text-only tab.
- opencode/cli/cmd/run/question.shared.ts + footer.question.tsx: the pure
state machine gains questionTextOnly() and routes questionSelect to
questionSave on text-only tabs; questionSetTab now takes the request
and flips editing on when landing on a text-only tab. The footer UI
renders the textarea directly (no scrollbox) when textOnly is active.
Tests:
- core/test/tool-question.test.ts: existing assertions extended to reflect
the auto-appended Comments entry; new case asserts the trailing shape.
- opencode/test/cli/run/question.shared.test.ts: three new cases cover
text-only submit, empty input handling, and the multi-question advance
path.
- opencode/test/tool/question.test.ts: V1 tool expectations updated for
the auto-append (2 questions instead of 1).
SDK regenerated via bun run generate (packages/client) and
./packages/sdk/js/script/build.ts.
The auto-appended Comments text question added by `withComments` (see b77c8ce8f) was invisible in the UI summary views: the scrollback titles, structured snapshots, transcript JSON, and the timeline's question list all iterated the original `input.questions` (N items) but matched against `metadata.answers` (N+1 items), so the trailing entry and its answer fell off the rendered list. Three coordinated changes: 1. V1 tool now stores the full list (including Comments) in `metadata.questions` alongside `metadata.answers`, so consumers have a single source of truth without re-deriving it. 2. Extracted the synthetic Comments literal into a browser-safe `COMMENTS_QUESTION_INFO` constant in `packages/core/src/tool/question-shared.ts`, re-exported by the V1 and V2 tool modules. UI packages (session-ui, tui) and the opencode CLI import this constant directly — no more literal duplication across the four render paths. 3. Each render path now prefers `metadata.questions` when present and falls back to a synthetic Comments entry derived from the constant when only `metadata.answers` is available (V2 sessions and older V1 sessions persisted before the new metadata field).
1 task done
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.
Auto-append “Comments” text question after every
questiontool callCloses anomalyco#39410
What
Every invocation of the
questiontool now ends with a trailing free-form text question —"Any comments?"(headerComments,textOnly: true). The auto-append is unconditional: it fires for single-question prompts, multi-question prompts, and prompts that never reach a Confirm tab. The model sees one extra answer in the reply, so it has a free-text feedback channel without having to request it itself.Why this approach over the issue's proposal
The original issue proposes a dedicated
Commentstab before Confirm plus a newcomments?: stringfield onQuestion.Reply. This PR ships a different—and I think cleaner—shape:comments?: stringonReplyAnswerarray (one extra entry)textOnlyquestioncustomdefault is unchanged; textOnly tabs use a textarea-only render)The shape change was deliberately avoided: the new field would require coordinated SDK regenerations, an HTTP API change (
POST /:requestID/replypayload), and a migration window for any third-party integration. ReusingAnswermeans the change is purely runtime + UI—schemas, SDKs, and HTTP APIs are all untouched.Changes
packages/schema/src/question.ts(+ V1 mirror): add optionaltextOnly?: booleantoQuestionV2.Info/QuestionInfo. Default behavior unchanged.packages/core/src/tool/question.ts:withComments()helper appends a constantCOMMENTS_INFOto the questions array before theQuestionV2.Service.askcall.toModelOutputreads the same wrapped list so the auto-appended question and its answer round-trip back to the model.packages/opencode/src/tool/question.ts(V1 mirror): samewithCommentswrap applied to the OpenCode CLI's V1 tool.textOnlybranch renders a textarea-only view (no option list), withenterto commit andescto reject. Tab navigation still works between questions.fix(core): surface appended Comments question in tool summary— second commit fixes the four render paths (CLI scrollback, structured snapshots, transcript JSON, session-ui timeline) that were iteratinginput.questions(N) againstmetadata.answers(N+1) and silently dropping the trailing entry.Screenshots & demo
9 PNGs (5 CLI/TUI + 4 Web) are attached to the release
assets/comments-screenshots-2026-07-29in the fork (asset bucket only—no code or branch changes).TUI / CLI (
bun dev)tabenter nextesc dismissComments:entry is included alongside the per-question answersAsked N questions, with the trailing comment entry visible)Web / Desktop (
localhost:4444)Any comments?withSelecciona una respuestaplaceholderTerminal recording
Tests
packages/core/test/tool-question.test.ts: existing assertions extended for the auto-append; new case asserts the trailingCommentsshape.packages/opencode/test/cli/run/question.shared.test.ts: three new cases (single text-only submit, empty-input commit, multi-question advance).packages/opencode/test/tool/question.test.ts: V1 tool expectations updated for the auto-append.fix(core): surface appended Comments question in tool summarycommit addspackages/opencode/test/cli/run/scrollback.surface.test.ts,packages/tui/test/util/transcript.test.ts,packages/session-ui/src/components/message-part.test.tsfor the summary-view fix.All passing locally:
bun typecheckis clean acrosscore,opencode,tui,schema,protocol,server,client,sdk/js,app.Notes for the maintainer
assets/comments-screenshots-2026-07-29is asset-only (no code commits, no branch). It's a CDN bucket for the screenshots referenced above. Happy to delete it after the PR is reviewed if you prefer.withCommentswrap; no schema migration is required.comments?: stringfield + dedicated tab), I can rework on top of this branch—the fixup commit would then become a clean revert.