Skip to content

Handle OpenCode question prompts in Discord flow#60

Open
nathansmetelak wants to merge 1 commit intobevibing:mainfrom
nathansmetelak:fix-question-asked-discord-flow
Open

Handle OpenCode question prompts in Discord flow#60
nathansmetelak wants to merge 1 commit intobevibing:mainfrom
nathansmetelak:fix-question-asked-discord-flow

Conversation

@nathansmetelak
Copy link
Copy Markdown

Summary

  • handle OpenCode question.asked SSE events instead of leaving Discord runs stuck in Running
  • render pending questions in Discord with option buttons plus a reject button
  • answer/reject questions through OpenCode's /question/{requestID}/reply and /reject endpoints
  • add regression coverage for SSE question events, question API helpers, and Discord button parsing for que_... IDs

Fixes #46.

Testing

  • npm test -- --run
  • npm run build
  • locally installed this branch and verified a real plan-approval flow in Discord no longer hangs

Copy link
Copy Markdown
Collaborator

@RoundTable02 RoundTable02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Session hangs indefinitely when OpenCode fires a question.asked event

2 participants