From 86040b6d53a444e416bdb36020e3499663dba760 Mon Sep 17 00:00:00 2001 From: Yanosh Kunsh Date: Mon, 26 Jan 2026 10:57:15 +0200 Subject: [PATCH 1/2] feat(tui): add custom tool and mcp call responses visible and collapsable --- .../src/cli/cmd/tui/routes/session/index.tsx | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index 2a5a901a21e4..8e6cf5e1a7c9 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -1462,10 +1462,39 @@ type ToolProps = { part: ToolPart } function GenericTool(props: ToolProps) { + const { theme } = useTheme() + const output = createMemo(() => props.output?.trim() ?? "") + const [expanded, setExpanded] = createSignal(false) + const lines = createMemo(() => output().split("\n")) + const maxLines = 3 + const overflow = createMemo(() => lines().length > maxLines) + const limited = createMemo(() => { + if (expanded() || !overflow()) return output() + return [...lines().slice(0, maxLines), "…"].join("\n") + }) + return ( - - {props.tool} {input(props.input)} - + + {props.tool} {input(props.input)} + + } + > + setExpanded((prev) => !prev) : undefined} + > + + {limited()} + + {expanded() ? "Click to collapse" : "Click to expand"} + + + + ) } From 84d00acfa302fd46d4558412b34a67e80fbe903c Mon Sep 17 00:00:00 2001 From: Yanosh Kunsh Date: Wed, 28 Jan 2026 17:31:32 +0200 Subject: [PATCH 2/2] change the generic tool output to be toggable from the Commands menu and keep the toggle value in kv.json --- .../src/cli/cmd/tui/routes/session/index.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index ab1e33fffe66..75e5e73fdfcb 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -95,6 +95,7 @@ const context = createContext<{ showThinking: () => boolean showTimestamps: () => boolean showDetails: () => boolean + showGenericToolOutput: () => boolean diffWrapMode: () => "word" | "none" sync: ReturnType }>() @@ -148,6 +149,7 @@ export function Session() { const [showScrollbar, setShowScrollbar] = kv.signal("scrollbar_visible", false) const [diffWrapMode] = kv.signal<"word" | "none">("diff_wrap_mode", "word") const [animationsEnabled, setAnimationsEnabled] = kv.signal("animations_enabled", true) + const [showGenericToolOutput, setShowGenericToolOutput] = kv.signal("generic_tool_output_visibility", false) const wide = createMemo(() => dimensions().width > 120) const sidebarVisible = createMemo(() => { @@ -559,6 +561,15 @@ export function Session() { dialog.clear() }, }, + { + title: showGenericToolOutput() ? "Hide generic tool output" : "Show generic tool output", + value: "session.toggle.generic_tool_output", + category: "Session", + onSelect: (dialog) => { + setShowGenericToolOutput((prev) => !prev) + dialog.clear() + }, + }, { title: "Page up", value: "session.page.up", @@ -933,6 +944,7 @@ export function Session() { showThinking, showTimestamps, showDetails, + showGenericToolOutput, diffWrapMode, sync, }} @@ -1459,6 +1471,7 @@ type ToolProps = { } function GenericTool(props: ToolProps) { const { theme } = useTheme() + const ctx = use() const output = createMemo(() => props.output?.trim() ?? "") const [expanded, setExpanded] = createSignal(false) const lines = createMemo(() => output().split("\n")) @@ -1471,7 +1484,7 @@ function GenericTool(props: ToolProps) { return ( {props.tool} {input(props.input)}