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
askquestion tool with valid questions
- Tool state shows
status: "running" with metadata.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
-
State synchronization:
- Part updates flow via
message.part.updated events
- Web:
packages/app/src/context/global-sync.tsx:330-349
- TUI:
packages/opencode/src/cli/cmd/tui/context/sync.tsx:213+
-
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
-
UI rendering:
- Web:
packages/app/src/pages/session.tsx:858-865 - AskQuestionWizard in Switch/Match
- TUI:
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx:1572-1608 - DialogAskQuestion in Switch/Match
Potential Root Causes
- Reactivity issue: The
createMemo detecting pending questions may not be reactive to state changes
- Event propagation:
message.part.updated events may not be reaching the UI layer
- Sync timing: Part metadata may not be populated when the memo evaluates
- Switch/Match ordering: SolidJS
Switch/Match may 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
Investigation Steps
-
Verify event propagation:
- Add console logs to
global-sync.tsx:330 to confirm message.part.updated events arrive
- Check if part metadata contains
status: "waiting" and questions array
-
Check memo reactivity:
- Add debug logging inside
pendingAskQuestion() memo
- Verify sync.data.message and sync.data.part are populated
-
Test Switch/Match rendering:
- Temporarily replace
<Match when={pendingAskQuestion()}> with a hardcoded condition
- Check if the wizard component renders at all
-
Compare TUI vs Web:
- TUI may have different sync timing - check if TUI has same issue
- If only Web is broken, focus on
packages/app context
Related Files
packages/opencode/src/tool/askquestion.ts - Tool definition
packages/opencode/src/askquestion/index.ts - Core module with bus events and pending request management
packages/app/src/pages/session.tsx - Web session page with wizard rendering
packages/app/src/components/askquestion-wizard.tsx - Web wizard component
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx - TUI session with dialog rendering
packages/opencode/src/cli/cmd/tui/ui/dialog-askquestion.tsx - TUI dialog component
packages/app/src/context/global-sync.tsx - Web event handling
packages/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.
Problem
The
askquestiontool 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 withstatus: "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
askquestiontool with valid questionsstatus: "running"withmetadata.status: "waiting"DialogAskQuestion)AskQuestionWizard)Technical Context
How AskQuestion Works
Tool invocation (
packages/opencode/src/tool/askquestion.ts:19-46):status: "waiting"and questions arrayAskQuestion.register()State synchronization:
message.part.updatedeventspackages/app/src/context/global-sync.tsx:330-349packages/opencode/src/cli/cmd/tui/context/sync.tsx:213+UI detection logic:
packages/app/src/pages/session.tsx:162-198-pendingAskQuestion()memopackages/opencode/src/cli/cmd/tui/routes/session/index.tsx:402-429-pendingAskQuestionFromSync()memoUI rendering:
packages/app/src/pages/session.tsx:858-865-AskQuestionWizardinSwitch/Matchpackages/opencode/src/cli/cmd/tui/routes/session/index.tsx:1572-1608-DialogAskQuestioninSwitch/MatchPotential Root Causes
createMemodetecting pending questions may not be reactive to state changesmessage.part.updatedevents may not be reaching the UI layerSwitch/Matchmay be evaluating conditions incorrectlyDetection Logic (Web)
Acceptance Criteria
/askquestion/respondInvestigation Steps
Verify event propagation:
global-sync.tsx:330to confirmmessage.part.updatedevents arrivestatus: "waiting"andquestionsarrayCheck memo reactivity:
pendingAskQuestion()memoTest Switch/Match rendering:
<Match when={pendingAskQuestion()}>with a hardcoded conditionCompare TUI vs Web:
packages/appcontextRelated 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 handlingConfiguration Note
The askquestion tool is behind an experimental flag:
Ensure
experimental.askquestion_tool: trueis set in config when testing.