From 27d6920d6033e2c84c637fabea75c3209b9da4bc Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Tue, 26 May 2026 11:53:33 -0400 Subject: [PATCH] fix(tui): preserve spacing after tool blocks --- .../src/cli/cmd/tui/routes/session/index.tsx | 3 +- .../inline-tool-wrap-snapshot.test.tsx.snap | 19 +++++++++++ .../tui/inline-tool-wrap-snapshot.test.tsx | 33 +++++++++++++++++-- 3 files changed, 52 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 6f18f02a9..8ca86209e 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -1793,7 +1793,7 @@ function InlineTool(props: { const children = parent.getChildren() const index = children.indexOf(el) const previous = children[index - 1] - setMargin(previous?.id.startsWith("text-") ? 1 : 0) + setMargin(previous?.id.startsWith("text-") || previous?.id.startsWith("tool-block-") ? 1 : 0) }} > @@ -1850,6 +1850,7 @@ function BlockTool(props: { const error = createMemo(() => (props.part?.state.status === "error" ? props.part.state.error : undefined)) return ( @@ -65,10 +66,23 @@ function InlineToolRow(props: { item: ToolFixture; errorExpanded?: boolean }) { ) } -function Fixture(props: { errorExpanded?: boolean }) { +function ShellOutput() { + return ( + + # List files + + $ ls + file.ts + + + ) +} + +function Fixture(props: { errorExpanded?: boolean; shellOutput?: boolean }) { return ( + {props.shellOutput && } {(item) => } @@ -105,4 +119,19 @@ describe("TUI inline tool wrapping", () => { .trimEnd(), ).toMatchSnapshot() }) + + test("keeps separation after a shell output block", async () => { + testSetup = await testRender(() => , { width: 72, height: 16 }) + await testSetup.renderOnce() + await testSetup.renderOnce() + + expect( + testSetup + .captureCharFrame() + .split("\n") + .map((line) => line.trimEnd()) + .join("\n") + .trimEnd(), + ).toMatchSnapshot() + }) })