From 1499daf15f19055e9cc260038550809fc4c43ad3 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Thu, 21 May 2026 11:00:35 -0400 Subject: [PATCH] test(tui): focus inline tool wrap snapshot --- .../inline-tool-wrap-snapshot.test.tsx.snap | 51 +------- .../tui/inline-tool-wrap-snapshot.test.tsx | 111 +----------------- 2 files changed, 6 insertions(+), 156 deletions(-) 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 664fa4e3f5..653935e088 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,58 +1,11 @@ // 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`] = ` -"CURRENT: measured height adds top margin after wrapped rows - - * 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) - - -STABLE WRAP: no height-coupled margin - * 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) - - -HANGING INDENT: wrap aligns with tool text - * 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] * Grep "export const OPENCODE_DB|OPENCODE_DB|OPENCODE_DEV|Global\\. - Path\\.data|data =" in packages/opencode/src (115 matches) - - -DETAIL ROWS: split identity from metadata - * Grep "OPENCODE.*DB|database|sqlite|drizzle|dev.*db|data. - *dir|xdg|APPDATA" - packages/opencode/src - 151 matches - * Glob "**/*db*" - 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 =" - packages/opencode/src - 115 matches - - -COMPACT: truncate middle, never wrap - * Grep "OPENCODE.*DB|d...dir|xdg|APPDATA" - packages/openc...c - 151 - * Glob "**/*db*" - packages/opencode - 6 matches - -> Read packages/openco...rc/storage/db.ts - offset=1, limit=130 - -> Read packages/opencode/src/index.ts - offset=1, limit=100 - * Grep "export const O...th\\.data|data =" - packages/openc...c - 115" + 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 0497fc462e..e5aa72d6fb 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 @@ -1,5 +1,5 @@ import { afterEach, describe, expect, test } from "bun:test" -import { createSignal, For } from "solid-js" +import { For } from "solid-js" import { testRender } from "@opentui/solid" let testSetup: Awaited> | undefined @@ -11,85 +11,30 @@ afterEach(() => { const tools = [ { - kind: "grep", icon: "*", label: 'Grep "OPENCODE.*DB|database|sqlite|drizzle|dev.*db|data.*dir|xdg|APPDATA" in packages/opencode/src (151 matches)', - target: '"OPENCODE.*DB|database|sqlite|drizzle|dev.*db|data.*dir|xdg|APPDATA"', - meta: "packages/opencode/src - 151 matches", }, { - kind: "glob", icon: "*", label: 'Glob "**/*db*" in packages/opencode (6 matches)', - target: '"**/*db*"', - meta: "packages/opencode - 6 matches", }, { - kind: "read", icon: "->", label: "Read packages/opencode/src/storage/db.ts [offset=1, limit=130]", - target: "packages/opencode/src/storage/db.ts", - meta: "offset=1, limit=130", }, { - kind: "read", icon: "->", label: "Read packages/opencode/src/index.ts [offset=1, limit=100]", - target: "packages/opencode/src/index.ts", - meta: "offset=1, limit=100", }, { - kind: "grep", icon: "*", label: 'Grep "export const OPENCODE_DB|OPENCODE_DB|OPENCODE_DEV|Global\\.Path\\.data|data =" in packages/opencode/src (115 matches)', - target: '"export const OPENCODE_DB|OPENCODE_DB|OPENCODE_DEV|Global\\.Path\\.data|data ="', - meta: "packages/opencode/src - 115 matches", }, ] as const -function CurrentInlineRow(props: { item: (typeof tools)[number]; index: number }) { - const [margin, setMargin] = createSignal(0) - - return ( - 1) { - setMargin(1) - return - } - const previous = parent.getChildren()[parent.getChildren().indexOf(this) - 1] - if (!previous) { - setMargin(0) - return - } - if (previous.height > 1 || previous.id.startsWith("text-")) setMargin(1) - }} - > - - {props.item.icon} {props.item.label} - - - ) -} - -function StableInlineRow(props: { item: (typeof tools)[number] }) { - return ( - - - {props.item.icon} {props.item.label} - - - ) -} - -function HangingIndentRow(props: { item: (typeof tools)[number] }) { +function InlineToolRow(props: { item: (typeof tools)[number] }) { return ( {props.item.icon} @@ -98,50 +43,11 @@ function HangingIndentRow(props: { item: (typeof tools)[number] }) { ) } -function DetailRow(props: { item: (typeof tools)[number] }) { - return ( - - - {props.item.icon} {titlecase(props.item.kind)} {props.item.target} - - {props.item.meta} - - ) -} - -function CompactRow(props: { item: (typeof tools)[number] }) { - return ( - - - {props.item.icon} {titlecase(props.item.kind)} {truncateMiddle(props.item.target, 34)} -{" "} - {truncateMiddle(props.item.meta, 32)} - - - ) -} - function Fixture() { return ( - CURRENT: measured height adds top margin after wrapped rows - {(item, index) => } - - STABLE WRAP: no height-coupled margin - - {(item) => } - - HANGING INDENT: wrap aligns with tool text - - {(item) => } - - DETAIL ROWS: split identity from metadata - - {(item) => } - - COMPACT: truncate middle, never wrap - - {(item) => } + {(item) => } ) @@ -149,7 +55,7 @@ function Fixture() { describe("TUI inline tool wrapping", () => { test("snapshots consecutive grep, glob, and read rows at a narrow width", async () => { - testSetup = await testRender(() => , { width: 72, height: 60 }) + testSetup = await testRender(() => , { width: 72, height: 12 }) await testSetup.renderOnce() await testSetup.renderOnce() @@ -163,12 +69,3 @@ describe("TUI inline tool wrapping", () => { ).toMatchSnapshot() }) }) - -function titlecase(value: string) { - return value.slice(0, 1).toUpperCase() + value.slice(1) -} - -function truncateMiddle(value: string, max: number) { - if (value.length <= max) return value - return value.slice(0, Math.floor((max - 3) / 2)) + "..." + value.slice(value.length - Math.ceil((max - 3) / 2)) -}