opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(questions): enhance questions TUI + add full descendants support

Open mortimr opened this issue 5 days ago • 2 comments

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 from parameter 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 (/), space to toggle, enter to confirm
  • Question type indicator: "Single"/"Multiple" tag in bottom bar
  • State reset: Fix stale selections bleeding into new questions

Test Infrastructure

  • OPENCODE_TEST_SKIP_GIT env 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 from field

Screenshots

Short single without from

Screenshot 2026-01-10 at 23 26 22

Short single with from

Screenshot 2026-01-10 at 23 26 50

Simple Multi-select without from

Screenshot 2026-01-10 at 23 27 30

Simple Multi-select with from

Screenshot 2026-01-10 at 23 29 29

Multi-Question

Screenshot 2026-01-10 at 23 28 12

Long Markdown question (dark zone is scrollable)

Screenshot 2026-01-10 at 23 19 22

Support for Markdown in the discussion answers

Screenshot 2026-01-10 at 23 12 31

(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)

mortimr avatar Jan 10 '26 15:01 mortimr