Skip to content

Conversation

@GollyJer
Copy link

@GollyJer GollyJer commented Jan 19, 2026

Description
This PR updates the TUI sidebar's Subagents section to be more agnostic about how subagents are invoked.

Previously, the sidebar logic relied on specific tool names or structures found in the default OpenCode implementation. This update generalizes the detection logic to check for the presence of the subagent_type property in the tool input.

Why this is needed
Plugins like oh-my-opencode use their own orchestration tools (e.g., delegate_task) rather than the default task tool. However, they still adhere to the convention of passing a subagent_type to identify the agent being called.

By keying off this property, we ensure that any future plugin can now trigger subagent UI elements simply by including subagent_type in their tool arguments.

Changes
One liner change to sidebar.tsx

How did you verify your code works?

Default OpenCode Build agent with this code integrated.

2026-01-18_17h42_29

oh-mh-opencode without this change DOES NOT SHOW agents.
Here's what it shows with this change.

2026-01-18_17h42_59

closes #306

Greptile Summary

Generalizes TUI sidebar subagent detection to support plugin tools beyond the default task tool.

Key Changes:

  • Changed filter from part.tool === "task" to part.state.input?.subagent_type check on sidebar.tsx:64
  • Enables plugins like oh-my-opencode using custom orchestration tools (e.g., delegate_task) to display subagents in the sidebar
  • Maintains backward compatibility since the default task tool includes subagent_type in its input parameters
  • Fixed comment indentation as minor cleanup

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a simple, well-scoped refactor that improves extensibility. The detection logic now checks for the presence of subagent_type property rather than a specific tool name, which is more flexible and maintains backward compatibility. All tool states (pending, running, completed, error) include the input field with the same structure, so the optional chaining ?. safely handles any edge cases.
  • No files require special attention

Important Files Changed

Filename Overview
packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx Generalized subagent detection from tool name to subagent_type property check; fixed comment indentation

Sequence Diagram

sequenceDiagram
    participant Plugin as Plugin (oh-my-opencode)
    participant TUI as TUI Sidebar
    participant Tool as Tool Invocation
    participant Filter as taskToolParts Filter
    
    Note over Plugin,Filter: Before PR: Only tools with name "task" are detected
    
    Plugin->>Tool: Invoke delegate_task<br/>(custom tool name)
    Tool->>Tool: Include subagent_type<br/>in input parameters
    Tool->>TUI: Create ToolPart with<br/>state.input.subagent_type
    TUI->>Filter: Filter parts where<br/>part.tool === "task"
    Filter-->>TUI: No match (delegate_task ≠ task)
    Note over TUI: Subagent not shown in sidebar
    
    Note over Plugin,Filter: After PR: Any tool with subagent_type is detected
    
    Plugin->>Tool: Invoke delegate_task<br/>(custom tool name)
    Tool->>Tool: Include subagent_type<br/>in input parameters
    Tool->>TUI: Create ToolPart with<br/>state.input.subagent_type
    TUI->>Filter: Filter parts where<br/>part.state.input?.subagent_type exists
    Filter-->>TUI: Match found (has subagent_type)
    TUI->>TUI: Display subagent in sidebar
Loading

@greptile-apps
Copy link

greptile-apps bot commented Jan 19, 2026

Greptile found no issues!

From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@shuv1337
Copy link
Collaborator

i like it, will merge tonight

@GollyJer
Copy link
Author

Awesome. Thanks @shuv1337

shuv1337 added a commit that referenced this pull request Jan 19, 2026
- fix(cli): rebrand command names from opencode to shuvcode in help output
- feat(tui): show subagents in sidebar based on subagent_type property (PR #310)
- Multiple upstream fixes and improvements

Closes #313
@shuv1337 shuv1337 merged commit 7623703 into Latitudes-Dev:integration Jan 19, 2026
1 check passed
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.

Background agents in sidebar?

2 participants