From 9fb82f6eceb11dd711efd9dc46772e6aef088d4b Mon Sep 17 00:00:00 2001 From: chengyongru Date: Tue, 29 Sep 2026 13:25:21 +0800 Subject: [PATCH] fix(tui): align composer with transcript --- tui/src/app.test.ts | 14 +++++++++----- tui/src/app.ts | 7 ++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tui/src/app.test.ts b/tui/src/app.test.ts index 77e6f04c3..563a6ff17 100644 --- a/tui/src/app.test.ts +++ b/tui/src/app.test.ts @@ -2381,15 +2381,19 @@ describe("NanobotTui layout", () => { await setup.renderOnce() const lines = setup.captureCharFrame().split("\n") - const column = (needle: string): number => { + const lineContaining = (needle: string): string => { const line = lines.find((candidate) => candidate.includes(needle)) if (!line) throw new Error(`${needle} was not rendered`) - return line.indexOf(needle) + return line } - const contentColumn = column("Aligned message") + const messageLine = lineContaining("Aligned message") + const composerLine = lineContaining("Ask nanobot anything") + const contentColumn = messageLine.indexOf("Aligned message") - expect(column("default ▾")).toBe(contentColumn) - expect(column("Ready")).toBe(contentColumn) + expect(lineContaining("default ▾").indexOf("default ▾")).toBe(contentColumn) + expect(lineContaining("Ready").indexOf("Ready")).toBe(contentColumn) + expect(composerLine.indexOf("│")).toBe(messageLine.indexOf("›")) + expect(composerLine.indexOf("Ask nanobot anything")).toBe(contentColumn) }) test("shows context usage in the idle footer", async () => { diff --git a/tui/src/app.ts b/tui/src/app.ts index 8807e7ba2..11220afea 100644 --- a/tui/src/app.ts +++ b/tui/src/app.ts @@ -214,8 +214,9 @@ const TERMINAL: Palette = { const COMPOSER_PLACEHOLDER = "Ask nanobot anything" const ACTIVE_COMPOSER_PLACEHOLDER = "Enter send now · Tab send next" const COMPACT_ACTIVE_COMPOSER_PLACEHOLDER = "Enter now · Tab next" -// Transcript text starts after one content-padding cell and a two-cell role marker. -const TRANSCRIPT_TEXT_INSET = 3 +// Transcript rows start one cell inside the shell; text follows their two-cell role marker. +const TRANSCRIPT_EDGE_INSET = 1 +const TRANSCRIPT_TEXT_INSET = TRANSCRIPT_EDGE_INSET + 2 const IMAGE_PLACEHOLDER_STYLE = "image.placeholder" const SHIMMER_PAUSE = 16 const SHIMMER_BAND = 4 @@ -799,9 +800,9 @@ export class NanobotTui { const composerSurface = this.composerSurface() this.composerFrame = new BoxRenderable(renderer, { id: "nanobot-tui-composer-frame", - width: "100%", minHeight: 1, flexShrink: 0, + marginLeft: TRANSCRIPT_EDGE_INSET, border: ["left"], borderColor: this.palette.accent, paddingLeft: 1,