forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
The askquestion tool is invoked correctly by the LLM, but the dialog/wizard UI does not appear in either the TUI or Web interface. The tool call registers and the metadata is set with status: "waiting", but users never see the question wizard.
This regression appears to have occurred during a recent upstream merge (likely v1.0.220-v1.0.222 sync).
Symptoms
- LLM calls
askquestiontool with valid questions - Tool state shows
status: "running"withmetadata.status: "waiting" - No dialog appears in TUI (
DialogAskQuestion) - No wizard appears in Web (
AskQuestionWizard) - Tool call eventually times out or hangs indefinitely
Technical Context
How AskQuestion Works
-
Tool invocation (
packages/opencode/src/tool/askquestion.ts:19-46):- Sets metadata with
status: "waiting"and questions array - Registers pending request with
AskQuestion.register() - Awaits promise resolution from user response
- Sets metadata with
-
State synchronization:
- Part updates flow via
message.part.updatedevents - Web:
packages/app/src/context/global-sync.tsx:330-349 - TUI:
packages/opencode/src/cli/cmd/tui/context/sync.tsx:213+
- Part updates flow via
-
UI detection logic:
- Web:
packages/app/src/pages/session.tsx:162-198-pendingAskQuestion()memo - TUI:
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx:402-429-pendingAskQuestionFromSync()memo
- Web:
-
UI rendering:
- Web:
packages/app/src/pages/session.tsx:858-865-AskQuestionWizardinSwitch/Match - TUI:
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx:1572-1608-DialogAskQuestioninSwitch/Match
- Web:
Potential Root Causes
- Reactivity issue: The
createMemodetecting pending questions may not be reactive to state changes - Event propagation:
message.part.updatedevents may not be reaching the UI layer - Sync timing: Part metadata may not be populated when the memo evaluates
- Switch/Match ordering: SolidJS
Switch/Matchmay be evaluating conditions incorrectly
Detection Logic (Web)
// packages/app/src/pages/session.tsx:162-198
const pendingAskQuestion = createMemo(() => {
const sessionID = params.id
if (!sessionID) return null
const sessionMessages = sync.data.message[sessionID] ?? []
for (const message of [...sessionMessages].reverse()) {
const parts = sync.data.part[message.id] ?? []
for (const part of [...parts].reverse()) {
if (part.type !== "tool") continue
const toolPart = part as ToolPart
if (toolPart.tool !== "askquestion") continue
if (toolPart.state.status !== "running") continue
const metadata = toolPart.state.metadata as { status?: string; questions?: AskQuestionQuestion[] } | undefined
if (metadata?.status !== "waiting") continue
const questions = (metadata.questions ?? []) as AskQuestionQuestion[]
if (questions.length === 0) continue
return { callID: toolPart.callID, messageID: toolPart.messageID, questions }
}
}
return null
})Acceptance Criteria
- AskQuestion dialog appears in TUI when tool is called
- AskQuestionWizard appears in Web when tool is called
- User can interact with the wizard (select options, submit, cancel)
- Answers are properly sent back to the tool via
/askquestion/respond - Tool completes with formatted user responses
Investigation Steps
-
Verify event propagation:
- Add console logs to
global-sync.tsx:330to confirmmessage.part.updatedevents arrive - Check if part metadata contains
status: "waiting"andquestionsarray
- Add console logs to
-
Check memo reactivity:
- Add debug logging inside
pendingAskQuestion()memo - Verify sync.data.message and sync.data.part are populated
- Add debug logging inside
-
Test Switch/Match rendering:
- Temporarily replace
<Match when={pendingAskQuestion()}>with a hardcoded condition - Check if the wizard component renders at all
- Temporarily replace
-
Compare TUI vs Web:
- TUI may have different sync timing - check if TUI has same issue
- If only Web is broken, focus on
packages/appcontext
Related Files
packages/opencode/src/tool/askquestion.ts- Tool definitionpackages/opencode/src/askquestion/index.ts- Core module with bus events and pending request managementpackages/app/src/pages/session.tsx- Web session page with wizard renderingpackages/app/src/components/askquestion-wizard.tsx- Web wizard componentpackages/opencode/src/cli/cmd/tui/routes/session/index.tsx- TUI session with dialog renderingpackages/opencode/src/cli/cmd/tui/ui/dialog-askquestion.tsx- TUI dialog componentpackages/app/src/context/global-sync.tsx- Web event handlingpackages/opencode/src/cli/cmd/tui/context/sync.tsx- TUI event handling
Configuration Note
The askquestion tool is behind an experimental flag:
// packages/opencode/src/tool/registry.ts:110
...(config.experimental?.askquestion_tool === true ? [AskQuestionTool] : [])Ensure experimental.askquestion_tool: true is set in config when testing.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working