opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(tui): enable plugin tools to use Task component rendering

Open code-yeongyu opened this issue 1 week ago • 1 comments

Summary

This PR enables external plugin tools to use the built-in Task component's TUI rendering, providing a consistent visual experience for custom task implementations.

Changes

  • TUI Routing: Route plugin tools with sessionId metadata to Task/BlockTool component
  • Task Component: Support flexible input shapes from external tools (agentName fallback chain, conditional toolcalls display)
  • Registry: Preserve plugin tool metadata by wrapping context and capturing metadata() calls

How it works

Plugin tools can now call ctx.metadata({ metadata: { sessionId: "..." } }) to opt into BlockTool rendering. The TUI checks for metadata.sessionId presence and routes accordingly.

Technical Details

  • Removed as any type assertion in registry, replaced with explicit types
  • Added wrappedCtx to intercept and capture metadata from plugin tool execution
  • Task component now derives agentName from multiple sources: subagent_type → agent → category → tool

code-yeongyu avatar Jan 06 '26 18:01 code-yeongyu