diff options
| author | Adam <[email protected]> | 2026-03-05 07:46:31 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2026-03-05 08:00:42 -0600 |
| commit | 1a420a1a710e94bedfedbe61946f86265a347790 (patch) | |
| tree | a622d1a7d81a0b40925695309b8b70847cf86bce /packages/ui/src/components/basic-tool.tsx | |
| parent | 4c185c70f22f93a3a467a4cc4a28934e4384e393 (diff) | |
| download | opencode-1a420a1a710e94bedfedbe61946f86265a347790.tar.gz opencode-1a420a1a710e94bedfedbe61946f86265a347790.zip | |
fix(app): websearch and codesearch tool rendering
Diffstat (limited to 'packages/ui/src/components/basic-tool.tsx')
| -rw-r--r-- | packages/ui/src/components/basic-tool.tsx | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/packages/ui/src/components/basic-tool.tsx b/packages/ui/src/components/basic-tool.tsx index fff6e92f1..4ad91824d 100644 --- a/packages/ui/src/components/basic-tool.tsx +++ b/packages/ui/src/components/basic-tool.tsx @@ -203,6 +203,41 @@ export function BasicTool(props: BasicToolProps) { ) } -export function GenericTool(props: { tool: string; status?: string; hideDetails?: boolean }) { - return <BasicTool icon="mcp" status={props.status} trigger={{ title: props.tool }} hideDetails={props.hideDetails} /> +function label(input: Record<string, unknown> | undefined) { + const keys = ["description", "query", "url", "filePath", "path", "pattern", "name"] + return keys.map((key) => input?.[key]).find((value): value is string => typeof value === "string" && value.length > 0) +} + +function args(input: Record<string, unknown> | undefined) { + if (!input) return [] + const skip = new Set(["description", "query", "url", "filePath", "path", "pattern", "name"]) + return Object.entries(input) + .filter(([key]) => !skip.has(key)) + .flatMap(([key, value]) => { + if (typeof value === "string") return [`${key}=${value}`] + if (typeof value === "number") return [`${key}=${value}`] + if (typeof value === "boolean") return [`${key}=${value}`] + return [] + }) + .slice(0, 3) +} + +export function GenericTool(props: { + tool: string + status?: string + hideDetails?: boolean + input?: Record<string, unknown> +}) { + return ( + <BasicTool + icon="mcp" + status={props.status} + trigger={{ + title: `Called \`${props.tool}\``, + subtitle: label(props.input), + args: args(props.input), + }} + hideDetails={props.hideDetails} + /> + ) } |
