Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1483,10 +1483,32 @@ type ToolProps<T extends Tool.Info> = {
part: ToolPart
}
function GenericTool(props: ToolProps<any>) {
const { theme } = useTheme()
const [expanded, setExpanded] = createSignal(false)

return (
<InlineTool icon="⚙" pending="Writing command..." complete={true} part={props.part}>
{props.tool} {input(props.input)}
</InlineTool>
<Switch>
<Match when={props.output !== undefined}>
<BlockTool title={"# " + props.tool} part={props.part} onClick={() => setExpanded((prev) => !prev)}>
<box gap={1}>
<Show when={Object.keys(props.input).length}>
<text fg={theme.textMuted}>{input(props.input)}</text>
</Show>
<Show when={expanded() && props.output}>
<text fg={theme.text}>{props.output}</text>
</Show>
<Show when={props.output}>
<text fg={theme.textMuted}>{expanded() ? "Click to collapse" : "Click to expand"}</text>
</Show>
</box>
</BlockTool>
</Match>
<Match when={true}>
<InlineTool icon="⚙" pending="Running..." complete={true} part={props.part}>
{props.tool} {input(props.input)}
</InlineTool>
</Match>
</Switch>
)
}

Expand Down
24 changes: 22 additions & 2 deletions packages/ui/src/components/basic-tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@ export function BasicTool(props: BasicToolProps) {
)
}

export function GenericTool(props: { tool: string; hideDetails?: boolean }) {
return <BasicTool icon="mcp" trigger={{ title: props.tool }} hideDetails={props.hideDetails} />
export function GenericTool(props: {
tool: string
output?: string
hideDetails?: boolean
defaultOpen?: boolean
forceOpen?: boolean
locked?: boolean
}) {
return (
<BasicTool
icon="mcp"
trigger={{ title: props.tool }}
hideDetails={props.hideDetails || !props.output}
defaultOpen={props.defaultOpen}
forceOpen={props.forceOpen}
locked={props.locked}
>
<div data-component="tool-output" data-scrollable>
<pre>{props.output}</pre>
</div>
</BasicTool>
)
}
Loading