fix(tui): preserve inline tool left edge

This commit is contained in:
Kit Langton 2026-05-21 15:00:52 -04:00
parent 939426828d
commit eb5d30257a
3 changed files with 23 additions and 12 deletions

View file

@ -1810,7 +1810,7 @@ function InlineTool(props: {
}
when={props.complete}
>
<box flexDirection="row" paddingLeft={3}>
<box flexDirection="row">
<text
width={props.icon.length + 1}
fg={props.iconColor ?? fg()}
@ -1826,7 +1826,9 @@ function InlineTool(props: {
</Match>
</Switch>
<Show when={error() && !denied()}>
<text fg={theme.error}>{error()}</text>
<box paddingLeft={props.icon.length + 1}>
<text fg={theme.error}>{error()}</text>
</box>
</Show>
</box>
)

View file

@ -1,11 +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.
*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]
* Grep "export const OPENCODE_DB|OPENCODE_DB|OPENCODE_DEV|Global\\.
Path\\.data|data =" in packages/opencode/src (115 matches)"
" * 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\\.
Path\\.data|data =" in packages/opencode/src (115 matches)"
`;

View file

@ -9,7 +9,9 @@ afterEach(() => {
testSetup = undefined
})
const tools = [
type ToolFixture = { icon: string; label: string; error?: string }
const tools: readonly ToolFixture[] = [
{
icon: "*",
label:
@ -26,6 +28,7 @@ const tools = [
{
icon: "->",
label: "Read packages/opencode/src/index.ts [offset=1, limit=100]",
error: "No LSP server available for this file type.",
},
{
icon: "*",
@ -34,13 +37,18 @@ const tools = [
},
] as const
function InlineToolRow(props: { item: (typeof tools)[number] }) {
function InlineToolRow(props: { item: ToolFixture }) {
return (
<box paddingLeft={3}>
<box paddingLeft={3} flexDirection="row">
<box flexDirection="row">
<text width={props.item.icon.length + 1}>{props.item.icon}</text>
<text flexGrow={1}>{props.item.label}</text>
</box>
{props.item.error && (
<box paddingLeft={props.item.icon.length + 1}>
<text>{props.item.error}</text>
</box>
)}
</box>
)
}