Skip to content

bug(tui): subagent navigation broken for nested sessions and imprecise for multiple concurrent tasks #15972

Closed as not planned

Description

@guazi04

Summary

After #15607 replaced BlockTool (with onClick) with InlineTool (keybind-only) for the Task component, subagent session navigation has two issues:

1. session_child_first does not work in nested subagent sessions

Steps to reproduce:

  1. Start a session that spawns a subagent (task tool)
  2. Press <leader>down (session_child_first) to enter the child session — works fine
  3. If that child session also spawns subagents, press <leader>down again — nothing happens

Root cause:

children() in session/index.tsx (line 125-130) computes siblings, not descendants:

const children = createMemo(() => {
  const parentID = session()?.parentID ?? session()?.id
  return sync.data.session
    .filter((x) => x.parentID === parentID || x.id === parentID)
    .toSorted(...)
})

When already inside a child session, session()?.parentID is set, so parentID resolves to the grandparent. children() then returns the current session's siblings, not its children. moveFirstChild() searches these siblings for one with parentID set — which finds a sibling, not a deeper child.

2. No way to navigate to a specific subagent when multiple tasks are concurrent

Previously, each BlockTool Task had an onClick handler that navigated directly to that specific subagent's session. Now the only option is:

  1. session_child_first → jumps to the first child
  2. left/right → cycle through siblings

When an agent spawns 3+ concurrent subagent tasks, there's no way to directly enter a specific one. You have to cycle blindly, which is significantly worse UX than the previous click-to-enter behavior.

Suggestion

Consider one or more of:

  • Restore onClick on Task items (re-add click-to-navigate via BlockTool or add onClick to InlineTool)
  • Fix children() / moveFirstChild() to support arbitrary nesting depth
  • Add a picker UI (e.g., a dialog listing child sessions) when session_child_first is pressed and multiple children exist

Environment

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Mar 4, 2026
  2. github-actions commented on Mar 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If these don't fully cover your report (particularly the nested subagent children() logic bug), please clarify what's new so maintainers can decide whether to keep this open or consolidate.

  3. guazi04 commented on Mar 4, 2026

    @guazi04
    Author

    Thanks for flagging the potential duplicates. After reviewing them:

    Re #15769 — covers the same click-to-navigate regression (Bug 2 in this issue). Our fix restores BlockTool with onClick directly on the Task component, rather than making the hint text clickable (which is the approach in PR #15770). Both address the same root cause from 90270c615.

    Re #10444 — related but distinct. That issue covers session_child_cycle / session_child_cycle_reverse not working at all (terminal key parsing + guard logic). Our Bug 1 is specifically about session_child_first / moveFirstChild() not drilling into nested subagents because children() computes siblings rather than the current session's own children. The fix adds a separate subagents memo scoped to direct children of the viewed session, leaving children() untouched.

    So this issue covers ground that partially overlaps with #15769 (Bug 2) but also includes the nested navigation logic bug (Bug 1) which is not reported there. Happy to consolidate if maintainers prefer.

  4. diegonix commented on Mar 4, 2026

    @diegonix

    Confirming this bug — regression from PR #14814 in v1.2.16

    I can confirm this issue. I've been using OpenCode daily and this is a clear regression introduced in v1.2.16. Navigation with Ctrl+X + Down Arrow into nested sub-agents (sub-sub-agents / grandchildren) is completely broken — it only traverses one level deep.

    What changed

    In v1.2.15, the old keybindings (Ctrl+X Left/Right) cycled through all agents flatly — the main agent and every sub-agent regardless of nesting depth. This worked correctly for multi-level sub-agent trees.

    In v1.2.16, PR #14814 ("Change keybindings to navigate between child sessions" by @jlongster) introduced a new hierarchical navigation model:

    Ctrl+X Down → enter the child session level
    Left/Right → cycle between sibling sub-agents
    Up → go back to the parent

    While the hierarchical approach is a great UX improvement in concept, the implementation only works for the first level of children. When a sub-agent spawns another sub-agent (which is common with tools like Task/background_task), pressing Down again from a child session does nothing — the grandchild sessions are unreachable.

    Steps to reproduce

    Install OpenCode v1.2.16
    Give the agent a task complex enough that it spawns a sub-agent via Task, and that sub-agent also spawns its own sub-agent (2+ levels deep)
    Press Ctrl+X Down to navigate into the first-level sub-agent ✅ works
    Press Ctrl+X Down again to navigate into the second-level sub-agent ❌ nothing happens

    Expected behavior

    Ctrl+X Down should recursively navigate deeper into the sub-agent hierarchy, allowing access to any nesting depth. The Up key should then walk back up through each parent level.

    Environment

    OpenCode version: v1.2.16
    OS: Ubuntu 24.04 (Linux x64)
    Previous version: v1.2.15 (worked correctly with the old flat navigation)

  5. diegonix commented on Mar 6, 2026

    @diegonix

    The behavior changed once again in the release 1.2.20!

    Now the subagents sessions are clicable, so we could click no navigate, and in the inner session we could click again, and/or press up to back to upper levels.

  6. doer-ee commented on Apr 19, 2026

    @doer-ee

    Still reproducing on my side with nested subagent navigation:

    1. enter first child with Ctrl+X, Down
    2. from there, create another child
    3. Ctrl+X, Down no longer descends into the sub-subagent

    The bug came from computing child navigation relative to the wrong session level
    once you were inside a child session, OpenCode was effectively looking at the parent level again
    so Ctrl+X, Down could no longer find the current child’s own children

    The fix:
    computes visible child navigation from the current session id
    picks the first direct child of the current session when descending
    keeps sibling cycling scoped to the current depth

    So after the fix:
    parent -> child still works
    child -> sub-child now also works
    sibling navigation stays at the right level instead of mixing levels

    I opened a fix here:
    #23365

  7. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on May 3, 2026
  8. github-actions commented on Jul 5, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions