@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
22 import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
33 import { tmpdir } from "node:os";
44 import { join } from "node:path";
5-import { measureContentHeight, VStack } from "@cel-tui/core";
5+import { cel, MockTerminal, measureContentHeight, VStack } from "@cel-tui/core";
66 import type { ContainerNode, Node } from "@cel-tui/types";
77 import type { AssistantMessage, Model } from "@mariozechner/pi-ai";
88 import {
@@ -150,6 +150,38 @@ function createDeferred<T = void>() {
150150 return { promise, resolve, reject };
151151 }
152152
153+async function waitForCelRender(): Promise<void> {
154+ await new Promise((resolve) => setTimeout(resolve, 10));
155+}
156+
157+async function renderLayoutRows(
158+ node: Node,
159+ cols = 40,
160+ rows = 16,
161+): Promise<string[]> {
162+ const terminal = new MockTerminal(cols, rows);
163+ cel.init(terminal);
164+ cel.viewport(() => VStack({ width: cols, height: rows }, [node]));
165+ await waitForCelRender();
166+
167+ const buffer = cel._getBuffer();
168+ if (!buffer) {
169+ throw new Error("Expected cel-tui to produce a render buffer");
170+ }
171+
172+ const snapshot: string[] = [];
173+ for (let y = 0; y < rows; y++) {
174+ let text = "";
175+ for (let x = 0; x < cols; x++) {
176+ text += buffer.get(x, y).char;
177+ }
178+ snapshot.push(text);
179+ }
180+
181+ cel.stop();
182+ return snapshot;
183+}
184+
153185 const tempDirs: string[] = [];
154186
155187 function createTempDir(): string {
@@ -192,6 +224,7 @@ function createTestState(): AppState {
192224 activeTurnPromise: null,
193225 showReasoning: DEFAULT_SHOW_REASONING,
194226 verbose: DEFAULT_VERBOSE,
227+ versionLabel: "dev",
195228 customModels: [],
196229 startupWarnings: [],
197230 };
@@ -476,15 +509,26 @@ describe("ui rendering", () => {
476509 }
477510 });
478511
479- test("empty conversation log renders no splash banner", () => {
512+ test("empty conversation log renders a minimal app banner", () => {
480513 const faux = registerFauxProvider();
481514 const withoutModel = createTestState();
482515 const withModel = createTestState();
483516 withModel.model = faux.getModel();
484517
485518 try {
486- expect(buildConversationLog(withoutModel)).toEqual([]);
487- expect(buildConversationLog(withModel)).toEqual([]);
519+ const withoutModelText = collectText({
520+ type: "vstack",
521+ props: {},
522+ children: buildConversationLog(withoutModel),
523+ });
524+ const withModelText = collectText({
525+ type: "vstack",
526+ props: {},
527+ children: buildConversationLog(withModel),
528+ });
529+
530+ expect(withoutModelText).toEqual(["mini-coder", "dev"]);
531+ expect(withModelText).toEqual(["mini-coder", "dev"]);
488532 } finally {
489533 faux.unregister();
490534 withoutModel.db.close();
@@ -492,6 +536,25 @@ describe("ui rendering", () => {
492536 }
493537 });
494538
539+ test("empty conversation log centers the banner vertically above the input area", async () => {
540+ const state = createTestState();
541+
542+ try {
543+ const rows = await renderLayoutRows(
544+ renderBaseLayout(state, 40, createInputController(state)),
545+ 40,
546+ 16,
547+ );
548+ const bannerRow = rows.findIndex((row) => row.includes("mini-coder"));
549+ const dividerRow = rows.findIndex((row) => row.includes("────"));
550+
551+ expect(bannerRow).toBe(5);
552+ expect(dividerRow).toBe(12);
553+ } finally {
554+ state.db.close();
555+ }
556+ });
557+
495558 test("first user message creates the session lazily", async () => {
496559 const faux = registerFauxProvider();
497560 const state = createTestState();