feat(questions): enhance questions TUI + add full descendants support
Summary
This PR fixes nested agent questions not appearing in the TUI and improves question tool UX. Fixes #7654
Problem
When using ohmyopencode (or similar setups) with sub-agents spawning other agents via background_task, questions from deeply nested agents don't show up in the main session's TUI. The old code only looked at direct children sessions, missing questions from grandchildren and beyond.
To reproduce (without this PR):
Do the following:
- spawn one subagent
- from this subagent spawn 3 background_task and give them a name (one, two and three)
- in each background_task ask 3 questions (ask if I prefer python or typescript). Include both the background_task name and the question number.
Once all is done, give me a summary of all answers
The questions never appear in the TUI.
Solution
Core Fix: Nested Agent Questions
- Changed from direct children lookup to BFS traversal of all session descendants
- Questions from any depth now surface to the root session
- Added
fromparameter so users know which agent is asking ("Question from explorer-agent")
QoL Improvements
The remaining changes are quality-of-life tweaks to improve the interview workflow:
- Answer display: Table layout with borders, word wrapping, multi-select answers on separate lines
-
Multi-select UX: Checkbox prefixes (
☐/■),spaceto toggle,enterto confirm - Question type indicator: "Single"/"Multiple" tag in bottom bar
- State reset: Fix stale selections bleeding into new questions
Test Infrastructure
-
OPENCODE_TEST_SKIP_GITenv var to skip git init (for commit signing setups) - Print
OPENCODE_TEST_*vars at test start for visibility
Verification
- Tested the reproduction prompt above - questions now appear
- Manually verified single/multi-select flows
- Added tests for
fromfield
Screenshots
Short single without from
Short single with from
Simple Multi-select without from
Simple Multi-select with from
Multi-Question
Long Markdown question (dark zone is scrollable)
Support for Markdown in the discussion answers
(this PR was mainly done by opencode with my supervision, I've been using the question workflow heavily lately with the https://github.com/paulp-o/ask-user-questions-mcp MCP. It's so great that we have questions natively in opencode now, but there descendant issue was preventing my old workflows from working properly as questions weren't bubbling up from lower than direct child agents. Also added some TUI improvements)