Handle OpenCode question prompts in Discord flow#60
Handle OpenCode question prompts in Discord flow#60nathansmetelak wants to merge 1 commit intobevibing:mainfrom
Conversation
RoundTable02
left a comment
There was a problem hiding this comment.
Thanks for putting this up. This is a great direction for fixing Discord runs that get stuck after OpenCode emits question.asked.
[HIGH] Preserve the full OpenCode question request when replying
The current implementation only supports the simplest case: one question with one selected option.
In executionService.ts, the UI renders only request.questions?.[0], and in buttonHandler.ts the reply is always sent as:
[[option.label]]OpenCode’s question contract supports multiple questions per request, and /question/{requestID}/reply expects answers to contain one answer array per question, in question order. For AskUserQuestion / plan-mode style flows, a single request may contain several questions, and this implementation would drop every question after the first and submit an incomplete answer set.
It would be better to render all questions in the request, track selections by requestId and questionIndex, and only submit once all required questions have an answer. For multiple: true, selections should be toggleable and submitted as multiple labels for that question.
Expected shape:
{
answers: request.questions.map((question, index) => selectedLabelsByQuestion[index])
}Discord component limits will need some care here: action rows support up to 5 buttons, and messages support up to 5 action rows. For multi-question or multi-select prompts, select menus may be a better fit than one button per option.
Summary
question.askedSSE events instead of leaving Discord runs stuck inRunning/question/{requestID}/replyand/rejectendpointsque_...IDsFixes #46.
Testing
npm test -- --runnpm run build