Skip to content

fix(tui): propagate permissions from nested subagents and show full subtask tree#24638

Open
michalsalat wants to merge 2 commits into
anomalyco:devfrom
michalsalat:fix/nested-subagent-permissions
Open

fix(tui): propagate permissions from nested subagents and show full subtask tree#24638
michalsalat wants to merge 2 commits into
anomalyco:devfrom
michalsalat:fix/nested-subagent-permissions

Conversation

@michalsalat
Copy link
Copy Markdown

@michalsalat michalsalat commented Apr 27, 2026

Issue for this PR

Fixes #13715
Fixes #7654

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The permissions and questions memos in the TUI session view only collect from direct children via children() — any grandchild or deeper descendant is excluded. When a subagent spawns its own subagent that needs permission (e.g. bash), the prompt never appears and the session hangs forever.

The fix adds a descendants memo that does a BFS traversal to collect all descendant session IDs, matching what the web/desktop app already does via sessionTreeRequest(). Both permissions and questions now use descendants() instead of children(). The existing children() memo is unchanged since it's still needed for sibling navigation.

Additionally, the Task component now recursively renders nested subtasks inline with indentation, status indicators, and per-session stats (duration, tool count, tokens, cost) so you can see what all levels of subagents are doing without clicking into each one.

Permission prompts now show the requesting session's description (e.g. "in Research macOS notification methods") and display tool parameters for MCP/generic tools, addressing the "from parameter" suggestion in #7654.

How did you verify your code works?

  • bun typecheck passes (only pre-existing unrelated error)
  • bun test test/session/retry.test.ts — 28/28 pass
  • bun test test/session/prompt.test.ts — same pass/fail as dev (pre-existing flaky tests)
  • bun test test/permission/ — 85/85 pass
  • Manually tested with dev TUI against a session with 5 levels of nested subagents that was stuck due to this bug — permissions now surface correctly

Screenshots / recordings

Subtask tree rendering:

│ General Task — Research content sources
  ✓ Research RSS and Twitter (8s · 3 tools · 4,521 tk · $0.0234)
    ✓ Research Python RSS libraries (5s · 5 tools · 2,100 tk · $0.0098)
    ✓ Research Twitter/X API (6s · 4 tools · 1,800 tk · $0.0087)
  ● Research LinkedIn and Reddit
    ✓ Research Reddit API (4s · 3 tools · 1,230 tk · $0.0052)
    ● Research LinkedIn API
└ 45s · 12 tools · 18,432 tk · $0.0891

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…ubtask tree

When a subagent spawns its own subagents (depth > 1), permission and
question requests from those nested sessions were never displayed in
the root session's TUI. This caused nested subagents to block forever
waiting for approval that no user could see or grant.

The root cause was the children memo only collecting direct children
(depth 1), then using that list to gather permissions and questions.

Changes:

1. Add a descendants memo that performs a full BFS traversal of the
   session tree to collect all descendant session IDs. Use this for
   permission and question collection while keeping the existing
   children memo unchanged for sibling navigation.

2. Show the full subtask tree inline in the conversation view. When a
   Task tool call has nested sub-tasks, recursively render them with
   indentation, status indicators, and per-session statistics (tool
   count, duration, tokens, cost). Child sessions are lazily synced
   as they appear in the tree.

3. Improve the permission prompt UX for nested subagents:
   - Show the session description (e.g. 'in Research macOS notification
     methods') instead of just the agent type
   - Display tool parameters for MCP/generic tool permission requests

The web/desktop app already handles descendant traversal correctly via
sessionTreeRequest() in session-request-tree.ts — this aligns the TUI
with that behavior.
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Apr 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

Permission asks from nested subagent sessions silently hang [BUG] Questions from nested sub-agents don't appear in TUI

1 participant