Skip to content

[FEATURE]:TUI Bottom Bar Auto-Discovery of Sub-Sessions with Auto-Switch Management #15363

Description

@Eric-GoodBoy-Tech

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem Description

OpenCode currently has the following limitations when managing sub-agent sessions:

  1. No Auto-Discovery Mechanism - The bottom bar/status line does not automatically display sub-session count and status
  2. Inefficient Manual Switching - Requires <leader>right/left to cycle through sessions one by one
  3. No Auto-Switch Support - Focus does not automatically switch when sub-tasks are created or completed
  4. Poor Status Visibility - Cannot quickly identify which sub-session is awaiting permission or has completed

Current Status Analysis

Session Navigation Capabilities

Feature Status Issue/PR
Manual Cycle Switch ✅ Supported Built-in
Dialog Picker 🔄 In Progress #6183 / PR #6184
Sidebar Display 🔄 Partial #5242 / PR #4865
Tab Bar Navigation 🟢 Discussion #5826
Tree Manager 🟢 Discussion #6032

Auto-Switch Capabilities

Feature Status Issue
Auto-Switch on Sub-Task Create ❌ Not Supported #6282 (Closed)
Auto-Return on Sub-Task Complete ❌ Not Supported #6282 (Closed)
Auto-Focus on Permission Request ❌ Not Supported -

Status Display Capabilities

Feature Status Issue
Background Task Status 🔄 In Progress #8322
Running Tools & LLM Status 🔄 In Progress #9655
Sub-Agent Info (ACP) 🟢 Requested #11576

Proposed Solution

Option 1: Bottom Bar Auto-Discovery + Quick Switch (Recommended)

1. Bottom Bar Auto-Discovery of Sub-Sessions

Automatically display sub-session summary in the status line:

┌─────────────────────────────────────────────────┐
│  [conversation content]                         │
│  > prompt input                                 │
├─────────────────────────────────────────────────┤
│  build │ claude-sonnet │ 3 sub[1⏳ 2✓] │ $0.02 │
└─────────────────────────────────────────────────┘

Display Content:

  • Total sub-session count
  • Permission pending count (⏳)
  • Completed count (✓)
  • Active/busy count (⟳)

2. Click/Shortcut Quick Switch

// Configuration Example
{
  "tui": {
    "status_line": {
      "subsession": {
        "enabled": true,
        "click_action": "switch_next",
        "shortcuts": {
          "switch_next": "ctrl+]",
          "switch_prev": "ctrl+[",
          "switch_picker": "<leader>s",
          "auto_switch": true
        }
      }
    }
  }
}

3. Auto-Switch Rules

// Auto-Switch Configuration
{
  "subsession": {
    "auto_switch": {
      "on_create": true,       // Auto-switch when sub-session created
      "on_permission": true,   // Auto-focus when sub-session awaits permission
      "on_complete": true,     // Auto-return to parent when sub-session completes
      "on_error": false,       // Switch on sub-session error
      "exclude_agents": []     // Exclude specific agent types
    }
  }
}

4. Plugin API Extension

// Plugin Sub-Session Event Subscription
export type PluginInput = {
  // ... existing fields
  subsession: {
    // Get child sessions of current session
    list: () => Promise<SubSessionInfo[]>;
    
    // Switch to specific sub-session
    switch: (sessionID: string) => Promise<void>;
    
    // Get parent session
    getParent: () => Promise<SessionInfo | null>;
    
    // Subscribe to sub-session changes
    on: (event: 'created' | 'updated' | 'deleted' | 'permission', 
         handler: (info: SubSessionInfo) => void) => void;
  }
}

interface SubSessionInfo {
  sessionID: string;
  parentID: string;
  agent: string;
  status: 'idle' | 'busy' | 'permission_pending' | 'completed' | 'error';
  createdAt: number;
  updatedAt: number;
  title?: string;
}

Option 2: Complete Session Management System

Reference #6032 Nerdtree style, implement full tree session manager:

Sessions (Sidebar)
├─ ● Main Session (build)
│  ├─ ◉ explore-task (waiting permission)
│  ├─ ✓ code-review (completed)
│  └─ ⟳ write-tests (busy)
└─ ○ Other Session (plan)

Option 3: Tab Bar Navigation

Reference #5826, implement horizontal tab bar:

[Main ●] [explore ◉] [review ✓] [tests ⟳]  [+ ]

Use Cases

Use Case 1: Parallel Multi-Task Development

User launches multiple sub-tasks:
1. Frontend development task
2. Backend API task
3. Test writing task

Bottom bar displays: 3 sub [1⏳ 1⟳ 1✓]
User can quickly switch to check each task's progress

Use Case 2: Permission Request Auto-Focus

When sub-session needs permission confirmation:
- Auto-switch to that sub-session
- Bottom bar highlights ⏳ icon
- Auto-return to original session after user confirmation

Use Case 3: Plugin Sub-Task Monitoring

export const SubSessionMonitor = async ({ client }) => {
  client.subsession.on('permission', (info) => {
    client.tui.showToast({
      message: `Sub-task "${info.title}" requires permission`,
      variant: 'warning'
    });
  });
  
  client.subsession.on('complete', (info) => {
    // Log sub-task completion metrics
    logSubSessionMetrics(info);
  });
};

Benefits

  1. Efficiency Improvement - Reduce session switching time by 70%+
  2. Status Visibility - Real-time awareness of all sub-session states
  3. Automation - Reduce manual operations, focus on core tasks
  4. Plugin-Friendly - Provide complete API for plugin extension
  5. Backward Compatible - Optional feature, does not affect existing workflows

Technical Implementation Suggestions

1. Status Line Integration

// packages/tui/src/status-line.ts
function renderSubSessionInfo() {
  const children = sync.session.getChildren(currentSessionID);
  const stats = {
    total: children.length,
    permission: children.filter(c => hasPermissionPending(c.id)).length,
    busy: children.filter(c => isBusy(c.id)).length,
    completed: children.filter(c => isCompleted(c.id)).length,
  };
  
  return `${stats.total} sub[${stats.permission}${stats.completed}✓]`;
}

2. Auto-Switch Logic

// packages/opencode/src/session/switch.ts
async function handleSubSessionEvent(event: SubSessionEvent) {
  const config = await getConfig();
  
  if (event.type === 'permission' && config.subsession.auto_switch.on_permission) {
    await switchToSession(event.sessionID);
  }
  
  if (event.type === 'complete' && config.subsession.auto_switch.on_complete) {
    const parent = await getSession(event.sessionID).parentID;
    if (parent) await switchToSession(parent);
  }
}

3. Plugin Event Subscription

// packages/plugin/src/hooks.ts
export const SessionHooks = {
  'subsession.created': async (info: SubSessionInfo) => { ... },
  'subsession.updated': async (info: SubSessionInfo) => { ... },
  'subsession.deleted': async (info: SubSessionInfo) => { ... },
  'subsession.permission': async (info: SubSessionInfo) => { ... },
};

Related Issues

Priority Recommendations

  1. High Priority: Bottom bar sub-session status display + shortcut switching
  2. Medium Priority: Auto-switch rules (create/permission/complete)
  3. Low Priority: Plugin API extension + complete tree manager

Configuration Example

{
  "$schema": "https://opencode.ai/config.json",
  "tui": {
    "status_line": {
      "enabled": true,
      "subsession": {
        "enabled": true,
        "format": "{total} sub[{permission}⏳ {completed}✓]",
        "auto_switch": {
          "on_create": false,
          "on_permission": true,
          "on_complete": true
        }
      }
    }
  }
}

References

  • Claude Code sub-task management
  • VS Code terminal tab management
  • tmux/screen session management
  • kitty terminal tab system

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussionneeds:complianceThis means the issue will auto-close after 2 hours.opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions