[PR #7653] feat(questions): enhance questions TUI + add full descendants support #12468

Closed
opened 2026-02-16 18:17:22 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7653

State: closed
Merged: No


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)

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7653 **State:** closed **Merged:** No --- ## 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` <img width="1394" height="249" alt="Screenshot 2026-01-10 at 23 26 22" src="https://github.com/user-attachments/assets/f0dbd2f8-b1dc-4997-b550-5278819c097c" /> ### Short single with `from` <img width="1394" height="308" alt="Screenshot 2026-01-10 at 23 26 50" src="https://github.com/user-attachments/assets/2372f262-7b1a-4601-93af-8a5abda0916f" /> ### Simple Multi-select without `from` <img width="1394" height="350" alt="Screenshot 2026-01-10 at 23 27 30" src="https://github.com/user-attachments/assets/421cae97-22b5-4ce4-9020-d52ce9255136" /> ### Simple Multi-select with `from` <img width="1394" height="389" alt="Screenshot 2026-01-10 at 23 29 29" src="https://github.com/user-attachments/assets/5137dc01-81fa-4538-a85a-797f954349b1" /> ### Multi-Question <img width="1394" height="350" alt="Screenshot 2026-01-10 at 23 28 12" src="https://github.com/user-attachments/assets/975f8477-ff32-40c3-a769-856a88653786" /> ### Long Markdown question (dark zone is scrollable) <img width="1394" height="837" alt="Screenshot 2026-01-10 at 23 19 22" src="https://github.com/user-attachments/assets/d4393e19-f3ce-4f13-9999-5096b6a32046" /> ### Support for Markdown in the discussion answers <img width="1394" height="659" alt="Screenshot 2026-01-10 at 23 12 31" src="https://github.com/user-attachments/assets/6fe64de9-9645-4445-b4fe-25511fd3d9a3" /> (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)
yindo added the pull-request label 2026-02-16 18:17:22 -05:00
yindo closed this issue 2026-02-16 18:17:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12468