feat(tui): show subagents in sidebar based on subagent_type property #310
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_typeproperty in the tool input.Why this is needed
Plugins like
oh-my-opencodeuse their own orchestration tools (e.g., delegate_task) rather than the defaulttasktool. 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.tsxHow did you verify your code works?
Default OpenCode Build agent with this code integrated.
oh-mh-opencodewithout this change DOES NOT SHOW agents.Here's what it shows with this change.
closes #306
Greptile Summary
Generalizes TUI sidebar subagent detection to support plugin tools beyond the default
tasktool.Key Changes:
part.tool === "task"topart.state.input?.subagent_typecheck onsidebar.tsx:64oh-my-opencodeusing custom orchestration tools (e.g.,delegate_task) to display subagents in the sidebartasktool includessubagent_typein its input parametersConfidence Score: 5/5
subagent_typeproperty rather than a specific tool name, which is more flexible and maintains backward compatibility. All tool states (pending, running, completed, error) include theinputfield with the same structure, so the optional chaining?.safely handles any edge cases.Important Files Changed
subagent_typeproperty check; fixed comment indentationSequence 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