Add interactive session switcher for navigating between subagent sessions #3874

Open
opened 2026-02-16 17:41:47 -05:00 by yindo · 2 comments
Owner

Originally created by @rmk40 on GitHub (Dec 26, 2025).

Originally assigned to: @rekram1-node on GitHub.

Problem

When working with subagent sessions (e.g., tasks spawned by the task tool), navigation currently requires cycling through sessions one-by-one using <leader>right / <leader>left. This becomes inefficient when:

  • Multiple subagents are spawned from a single parent session
  • Subagents spawn their own subagents (nested hierarchy)
  • You need to jump directly to a specific session (e.g., one awaiting permission input)

There's no way to see all related sessions at once or jump directly to a specific one.

Proposed Solution

Add an interactive session switcher dialog that:

  1. Shows hierarchical view of parent and all descendant sessions (up to 3 levels deep)
  2. Displays session status - busy spinner for active sessions, permission indicator for sessions awaiting user input
  3. Allows direct navigation - select any session from the list instead of cycling through sequentially
  4. Integrates with command palette - appears in suggested commands when subagents exist

Keybind

<leader>s (configurable via session_child_list)

UI Example

Switch Session
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Parent
  ● Main session title                              2m ago

Subagents
    explore task                                    1m ago
    code-review task                               45s ago

Subagents › explore
  ◉ nested-search task                             30s ago
  • indicates current session
  • (warning color) indicates session awaiting permission
  • Spinner shown for busy/active sessions

Why This Is Useful

Direct selection is significantly more efficient than sequential cycling when you have 5+ subagent sessions and need to:

  • Check on a specific task's progress
  • Respond to a permission prompt in a nested subagent
  • Return to the parent session after reviewing children

Implementation Approach

The implementation reuses existing patterns from the codebase:

  • DialogSelect component for the selection UI (same as DialogSessionList, DialogTimeline)
  • sync.data.permission[sessionID] for pending permission detection
  • sync.data.session_status[sessionID] for busy state detection
  • Category grouping for hierarchical display (same pattern as date grouping in DialogSessionList)

Style note

The implementation uses a let statement when walking up the session tree to find the root parent:

let current = currentSession()
while (current?.parentID) {
  const parent = sync.session.get(current.parentID)
  if (!parent) break
  current = parent
}

This is a legitimate use case where let is appropriate - the variable must be reassigned during iterative traversal. Per the style guide, let should be avoided where possible, but not prohibited when it's the natural solution.

Originally created by @rmk40 on GitHub (Dec 26, 2025). Originally assigned to: @rekram1-node on GitHub. ### Problem When working with subagent sessions (e.g., tasks spawned by the `task` tool), navigation currently requires cycling through sessions one-by-one using `<leader>right` / `<leader>left`. This becomes inefficient when: - Multiple subagents are spawned from a single parent session - Subagents spawn their own subagents (nested hierarchy) - You need to jump directly to a specific session (e.g., one awaiting permission input) There's no way to see all related sessions at once or jump directly to a specific one. ### Proposed Solution Add an interactive session switcher dialog that: 1. **Shows hierarchical view** of parent and all descendant sessions (up to 3 levels deep) 2. **Displays session status** - busy spinner for active sessions, permission indicator for sessions awaiting user input 3. **Allows direct navigation** - select any session from the list instead of cycling through sequentially 4. **Integrates with command palette** - appears in suggested commands when subagents exist ### Keybind `<leader>s` (configurable via `session_child_list`) ### UI Example ``` Switch Session ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Parent ● Main session title 2m ago Subagents explore task 1m ago code-review task 45s ago Subagents › explore ◉ nested-search task 30s ago ``` - `●` indicates current session - `◉` (warning color) indicates session awaiting permission - Spinner shown for busy/active sessions ### Why This Is Useful Direct selection is significantly more efficient than sequential cycling when you have 5+ subagent sessions and need to: - Check on a specific task's progress - Respond to a permission prompt in a nested subagent - Return to the parent session after reviewing children ### Implementation Approach The implementation reuses existing patterns from the codebase: - **`DialogSelect`** component for the selection UI (same as `DialogSessionList`, `DialogTimeline`) - **`sync.data.permission[sessionID]`** for pending permission detection - **`sync.data.session_status[sessionID]`** for busy state detection - **Category grouping** for hierarchical display (same pattern as date grouping in `DialogSessionList`) #### Style note The implementation uses a `let` statement when walking up the session tree to find the root parent: ```typescript let current = currentSession() while (current?.parentID) { const parent = sync.session.get(current.parentID) if (!parent) break current = parent } ``` This is a legitimate use case where `let` is appropriate - the variable must be reassigned during iterative traversal. Per the style guide, `let` should be **avoided** where possible, but not prohibited when it's the natural solution.
yindo added the opentui label 2026-02-16 17:41:47 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 26, 2025):

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

  • #5826: Feature Request: Agent Session Tab Bar Navigation - Similar feature to add navigation UI for concurrent sessions
  • #6032: [FEATURE]: Nerdtree like session manager - Tree explorer interface for managing multiple sessions
  • #5578: [Feature] Custom command to cycle between child sessions - Alternative approach for session navigation
  • #4727: Subagent Switching - Buggy - Performance issues with current Ctrl+X left/right navigation
  • #4292: [feedback] make left / right navigation for subagents more clear - UX clarity for current navigation

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Dec 26, 2025): This issue might be a duplicate of existing issues. Please check: - #5826: Feature Request: Agent Session Tab Bar Navigation - Similar feature to add navigation UI for concurrent sessions - #6032: [FEATURE]: Nerdtree like session manager - Tree explorer interface for managing multiple sessions - #5578: [Feature] Custom command to cycle between child sessions - Alternative approach for session navigation - #4727: Subagent Switching - Buggy - Performance issues with current Ctrl+X left/right navigation - #4292: [feedback] make left / right navigation for subagents more clear - UX clarity for current navigation Feel free to ignore if none of these address your specific case.
Author
Owner

@rmk40 commented on GitHub (Dec 26, 2025):

After reviewing the related issues:

This PR (#6184) addresses the core problem shared across these issues:

  • #5826 (Tab Bar Navigation) and #6032 (Nerdtree session manager) - Both request visual session navigation. Our dialog provides a hierarchical view on-demand. A persistent tab bar or sidebar could complement this in the future.

  • #4727 (Subagent Switching - Buggy) - Users report lag when cycling through sessions. Our direct-selection approach bypasses cycling entirely, allowing users to jump directly to any session.

  • #5578 (Custom command to cycle) - Requests an alternative to keybinds that conflict with terminals. Our switcher is accessible via command palette (ctrl+p), providing a keyboard-friendly alternative.

The implementation is intentionally minimal - it reuses existing DialogSelect patterns and doesn't introduce new UI paradigms. It's designed to coexist with future enhancements like a persistent tab bar (#5826) or tree sidebar (#6032).

@rmk40 commented on GitHub (Dec 26, 2025): After reviewing the related issues: **This PR (#6184) addresses the core problem shared across these issues:** - **#5826** (Tab Bar Navigation) and **#6032** (Nerdtree session manager) - Both request visual session navigation. Our dialog provides a hierarchical view on-demand. A persistent tab bar or sidebar could complement this in the future. - **#4727** (Subagent Switching - Buggy) - Users report lag when cycling through sessions. Our direct-selection approach bypasses cycling entirely, allowing users to jump directly to any session. - **#5578** (Custom command to cycle) - Requests an alternative to keybinds that conflict with terminals. Our switcher is accessible via command palette (`ctrl+p`), providing a keyboard-friendly alternative. The implementation is intentionally minimal - it reuses existing `DialogSelect` patterns and doesn't introduce new UI paradigms. It's designed to coexist with future enhancements like a persistent tab bar (#5826) or tree sidebar (#6032).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3874