From e03ffb9ed4fd2daa32a3c415886a45aee5c37a34 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Thu, 21 May 2026 15:53:49 -0400 Subject: [PATCH] refactor(tui): use fixed inline tool icon cell --- .../src/cli/cmd/tui/routes/session/index.tsx | 6 ++++-- .../inline-tool-wrap-snapshot.test.tsx.snap | 12 ++++++------ .../cli/tui/inline-tool-wrap-snapshot.test.tsx | 16 +++++++++------- 3 files changed, 19 insertions(+), 15 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 de7395f109..bbd5eac1a2 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -1497,6 +1497,8 @@ const PART_MAPPING = { reasoning: ReasoningPart, } +const INLINE_TOOL_ICON_WIDTH = 2 + function ReasoningPart(props: { last: boolean; part: ReasoningPart; message: AssistantMessage }) { const { theme, subtleSyntax } = useTheme() const ctx = use() @@ -1801,7 +1803,7 @@ function InlineTool(props: { > @@ -1815,7 +1817,7 @@ function InlineTool(props: { - + {error()} diff --git a/packages/opencode/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap b/packages/opencode/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap index e2f5d53037..89987234dd 100644 --- a/packages/opencode/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap +++ b/packages/opencode/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap @@ -1,12 +1,12 @@ // Bun Snapshot v1, https://bun.sh/docs/test/snapshots exports[`TUI inline tool wrapping snapshots consecutive grep, glob, and read rows at a narrow width 1`] = ` -" * Grep "OPENCODE.*DB|database|sqlite|drizzle|dev.*db|data. +" ✱ Grep "OPENCODE.*DB|database|sqlite|drizzle|dev.*db|data. *dir|xdg|APPDATA" in packages/opencode/src (151 matches) - * Glob "**/*db*" in packages/opencode (6 matches) - -> Read packages/opencode/src/storage/db.ts [offset=1, limit=130] - -> Read packages/opencode/src/index.ts [offset=1, limit=100] - No LSP server available for this file type. - * Grep "export const OPENCODE_DB|OPENCODE_DB|OPENCODE_DEV|Global\\. + ✱ Glob "**/*db*" in packages/opencode (6 matches) + → Read packages/opencode/src/storage/db.ts [offset=1, limit=130] + → Read packages/opencode/src/index.ts [offset=1, limit=100] + No LSP server available for this file type. + ✱ Grep "export const OPENCODE_DB|OPENCODE_DB|OPENCODE_DEV|Global\\. Path\\.data|data =" in packages/opencode/src (115 matches)" `; diff --git a/packages/opencode/test/cli/tui/inline-tool-wrap-snapshot.test.tsx b/packages/opencode/test/cli/tui/inline-tool-wrap-snapshot.test.tsx index 8e968bc6a5..318847e946 100644 --- a/packages/opencode/test/cli/tui/inline-tool-wrap-snapshot.test.tsx +++ b/packages/opencode/test/cli/tui/inline-tool-wrap-snapshot.test.tsx @@ -11,27 +11,29 @@ afterEach(() => { type ToolFixture = { icon: string; label: string; error?: string } +const INLINE_TOOL_ICON_WIDTH = 2 + const tools: readonly ToolFixture[] = [ { - icon: "*", + icon: "✱", label: 'Grep "OPENCODE.*DB|database|sqlite|drizzle|dev.*db|data.*dir|xdg|APPDATA" in packages/opencode/src (151 matches)', }, { - icon: "*", + icon: "✱", label: 'Glob "**/*db*" in packages/opencode (6 matches)', }, { - icon: "->", + icon: "→", label: "Read packages/opencode/src/storage/db.ts [offset=1, limit=130]", }, { - icon: "->", + icon: "→", label: "Read packages/opencode/src/index.ts [offset=1, limit=100]", error: "No LSP server available for this file type.", }, { - icon: "*", + icon: "✱", label: 'Grep "export const OPENCODE_DB|OPENCODE_DB|OPENCODE_DEV|Global\\.Path\\.data|data =" in packages/opencode/src (115 matches)', }, @@ -51,11 +53,11 @@ function InlineToolRow(props: { item: ToolFixture }) { }} > - {props.item.icon} + {props.item.icon} {props.item.label} {props.item.error && ( - + {props.item.error} )}