forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
When using the ask tool with a freeform text prompt, submitting a response does not complete the tool - the active spinner continues indefinitely until the user aborts.
This appears to be caused by having two separate ask tool implementations with different response mechanisms:
asktool (packages/opencode/src/tool/ask.ts) - UsesTuiEvent.QuestionRequest/QuestionResponsebus eventsaskquestiontool (packages/opencode/src/tool/askquestion.ts) - UsesAskQuestion.register/respondwith HTTP endpoints
The TUI has handlers for both systems, but they're wired to different UI components and response flows.
Current State
Tool 1: ask (ask.ts:285-380)
- Schema: Supports
select,multi-select,confirm,textquestion types - Trigger: Publishes
TuiEvent.QuestionRequestviaBus.publish() - Response: Listens for
TuiEvent.QuestionResponseviaBus.subscribe() - UI: Uses
DialogQuestioncomponent (app.tsx:555) - opened as overlay dialog
Tool 2: askquestion (askquestion.ts:7-80)
- Schema: Uses
AskQuestion.QuestionSchemawithid,label,question,optionsfields - Trigger: Calls
AskQuestion.register() - Response: HTTP POST to
/askquestion/respondendpoint - UI: Uses
DialogAskQuestioncomponent (session/index.tsx:1428) - inline in session view
The Mismatch
DialogQuestion(forasktool) publishes response via SDK client:sdk.client.tui.publish()DialogAskQuestion(foraskquestiontool) posts to HTTP endpoint:fetch(\${sdk.url}/askquestion/respond`)`
When the ask tool's DialogQuestion is shown with a text question, the response is published via SDK events, but the tool is waiting for TuiEvent.QuestionResponse via the Bus - and these may not be connecting properly.
Acceptance Criteria
- Only one user-facing ask tool exists and works reliably
- Text/freeform input questions work correctly without spinner hang
- All question types (select, multi-select, confirm, text) function properly
- Response submission completes the tool and returns output to the LLM
- Cleanup of any dead code from the deprecated implementation
Investigation Tasks
- Trace why
TuiEvent.QuestionResponsedoesn't reach theasktool's Bus subscription - Determine which implementation is intended to be the "current" one (likely
askquestionbased on recent merges) - Check if
asktool should be removed or if both serve different purposes - Verify server-side event routing between SDK client and Bus
Relevant Files
| File | Purpose |
|---|---|
packages/opencode/src/tool/ask.ts |
Original ask tool using Bus events |
packages/opencode/src/tool/askquestion.ts |
New askquestion tool using HTTP endpoints |
packages/opencode/src/askquestion/index.ts |
AskQuestion namespace with register/respond |
packages/opencode/src/question/index.ts |
Question schemas for ask tool |
packages/opencode/src/cli/cmd/tui/app.tsx:550-597 |
QuestionRequest handler for ask tool |
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx:1426-1461 |
DialogAskQuestion for askquestion tool |
packages/opencode/src/cli/cmd/tui/ui/dialog-askquestion.tsx |
Wizard UI for askquestion |
packages/opencode/src/cli/cmd/tui/component/dialog-question/ |
Dialog UI for ask tool |
packages/opencode/src/tool/registry.ts:96,110 |
Both tools registered |
Git History Context
a1c9fec1c feat: merge upstream PR #5958 askquestion tool (replaces #5563)
3a23fec31 feat(askquestion): fix race condition and improve TUI UX
7ff537213 fix: ask tool schema validation and bash carriage return handling
36a1f210e feat: add Ask tool for collecting user input via dialogs
The commit message "replaces anomalyco#5563" suggests askquestion was intended to replace the original ask tool, but both remain registered.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working