Skip to content

Your lightweight open-source personal agent.

fix(tui): align footer labels with transcript

chengyongru594b2e130c6e
diff --git a/tui/src/app.test.ts b/tui/src/app.test.ts
index a715a3306..77e6f04c3 100644
--- a/tui/src/app.test.ts
+++ b/tui/src/app.test.ts
@@ -2371,6 +2371,27 @@ describe("NanobotTui layout", () => {
expect(assistantMarker?.renderable.fg.toInts().slice(0, 3)).toEqual([161, 161, 170])
})
+ test("aligns footer labels with transcript content", async () => {
+ setup = await createRenderer({ width: 72, height: 24, screenMode: "alternate-screen" })
+ const app = mount(setup)
+ app.accept({ event: "attached", chat_id: "chat" })
+ ;(app as unknown as { transcript: { user(content: string): void } })
+ .transcript.user("Aligned message")
+ await waitUntil(() => (app as unknown as { ready: boolean }).ready)
+ await setup.renderOnce()
+
+ const lines = setup.captureCharFrame().split("\n")
+ const column = (needle: string): number => {
+ const line = lines.find((candidate) => candidate.includes(needle))
+ if (!line) throw new Error(`${needle} was not rendered`)
+ return line.indexOf(needle)
+ }
+ const contentColumn = column("Aligned message")
+
+ expect(column("default ▾")).toBe(contentColumn)
+ expect(column("Ready")).toBe(contentColumn)
+ })
+
test("shows context usage in the idle footer", async () => {
setup = await createRenderer({ width: 88, height: 24, screenMode: "alternate-screen" })
const app = mount(setup)
diff --git a/tui/src/app.ts b/tui/src/app.ts
index ee4f1547c..8807e7ba2 100644
--- a/tui/src/app.ts
+++ b/tui/src/app.ts
@@ -214,6 +214,8 @@ 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
const IMAGE_PLACEHOLDER_STYLE = "image.placeholder"
const SHIMMER_PAUSE = 16
const SHIMMER_BAND = 4
@@ -756,6 +758,7 @@ export class NanobotTui {
flexShrink: 0,
flexDirection: "row",
alignItems: "center",
+ paddingLeft: TRANSCRIPT_TEXT_INSET,
backgroundColor: RGBA.defaultBackground(),
})
this.runtimeControls = new RuntimeControls(
@@ -877,6 +880,7 @@ export class NanobotTui {
flexDirection: "row",
justifyContent: "space-between",
gap: 2,
+ paddingLeft: TRANSCRIPT_TEXT_INSET,
})
this.composerFrame.add(this.composer)
statusRow.add(this.status)