xonecas.io
64875
Mc

mini-coder / commit 9eb207e

feat(ui): simplify status bar pills and prep taller input

xonecas2026-04-07 9eb207e5bfe8cea506b0e337942ebb39d8f44196 parent b5609f8

5 files changed

spec.md+33−23
@@ -407,9 +407,7 @@ Three zones, top to bottom:
407407 ────══════─────────────────────────────────────────── animated divider
408408 fix the remaining lint warnings │ input: no prefix
409409 in the utils file too_ │
410-───────────────────────────────────────────────────── static divider
411- ~/src/mini-coder main +3 ~1 A 2 │ status line 1
412- anthropic/sonnet-4 · med in:1.2k out:0.8k 42% $0.03│ status line 2
410+ [ anthropic/sonnet-4 · med ] [ ~/src/mini-coder ] [ main +3 ~1 ▲ 2 ] [ in:1.2k out:0.8k · 42%/200k · $0.03 ] │ status pills
413411 ```
414412
415413 cel-tui structure:
@@ -420,14 +418,17 @@ VStack({ height: "100%" }, [
420418 VStack({ flex: 1, overflow: "scroll" }),
421419 // Top divider — animated scanning pulse when agent is working
422420 Divider(),
423- // Input area — intrinsic height, no prompt prefix
424- VStack({ padding: { x: 1 } }, [TextInput({ flex: 1, maxHeight: 10 })]),
425- // Bottom divider — always static
426- Divider(),
427- // Status bar — fixed 2 lines
428- VStack({ height: 2, padding: { x: 1 } }, [
429- HStack([Text(cwd), Spacer(), Text(gitStatus)]),
430- HStack([Text(modelInfo), Spacer(), Text(usage)]),
421+ // Input area — intrinsic height, no prompt prefix; starts at 2 lines
422+ VStack({ padding: { x: 1 } }, [
423+ TextInput({ flex: 1, minHeight: 2, maxHeight: 10 }),
424+ ]),
425+ // Status pills — fixed 1 line, backgrounds only behind the text
426+ HStack({ height: 1, padding: { x: 1 } }, [
427+ statusPill(modelInfo, theme.statusPrimaryBg),
428+ statusPill(cwd, theme.statusSecondaryBg),
429+ Spacer(),
430+ gitStatus && statusPill(gitStatus, theme.statusSecondaryBg),
431+ statusPill(usage, theme.statusPrimaryBg),
431432 ]),
432433 ]);
433434 ```
@@ -456,8 +457,12 @@ interface Theme {
456457 divider: Color | undefined;
457458 /** Divider scanning pulse highlight color (active state). */
458459 dividerPulse: Color | undefined;
459- /** Status bar foreground. Uses the terminal default when undefined. */
460+ /** Status pill foreground. */
460461 statusText: Color | undefined;
462+ /** Primary status pill background (outer pills: model/effort + usage/context/cost). */
463+ statusPrimaryBg: Color | undefined;
464+ /** Secondary status pill background (inner pills: CWD + git). */
465+ statusSecondaryBg: Color | undefined;
461466 /** Error text. */
462467 error: Color | undefined;
463468 /** Overlay modal background. */
@@ -465,26 +470,31 @@ interface Theme {
465470 }
466471 ```
467472
468-The default theme uses terminal palette colors where semantic accents help (`color08` for muted text, `color04`/`color05` for accents, `color02` for green, `color01` for red) and leaves shared foreground text on the terminal default where that gives better contrast. Theme values are cel-tui colors; `undefined` means "use the terminal default".
473+The default theme uses the full ANSI 16-color terminal palette where semantic accents or pill styling benefit from it, including bright variants (`color08`-`color15`) rather than restricting itself to the base 8 colors. Semantic colors should still map sensibly (for example, greens for additions/success and reds for removals/errors), but status pill styling may draw from the wider ANSI 16 range to create restrained outer/inner separation. Status pill backgrounds are applied only behind the text …
469474
470475 ### Status bar
471476
472-Two lines, four corners:
477+One line, two-sided, rendered as compact padded pills rather than a full-width footer band:
473478
474479 ```
475-~/src/mini-coder main +3 ~1 ▲ 2
476-anthropic/sonnet-4 · med in:1.2k out:0.8k · 42.0%/200k · $0.03
480+[ anthropic/sonnet-4 · med ] [ ~/src/mini-coder ] [ main +3 ~1 ▲ 2 ] [ in:1.2k out:0.8k · 42.0%/200k · $0.03 ]
477481 ```
478482
479-**Line 1 — location:**
483+- Background is applied only behind each pill's text + padding; there is no bottom divider below the input and no full-width colored block.
484+- The outer pills (`model/effort` on the left, `usage/context/cost` on the right) use `statusPrimaryBg`.
485+- The inner pills (`cwd` on the left, `git` on the right) use `statusSecondaryBg`.
486+- All status pill text uses `statusText`, chosen to remain legible against both pill backgrounds on light and dark terminals.
487+- The git pill is omitted outside a repo, preserving the current omission behavior.
488+
489+**Left side:**
480490
481-- Left: CWD, abbreviated with `~` for home. Truncated from the left (`…/mini-coder`) on narrow terminals.
482-- Right: git branch, working tree counts (+ staged, ~ modified, ? untracked), ahead of remote (▲ N). Omitted outside a repo.
491+- Outer-left: `provider/model · effort`. Effort shown as `low`, `med`, `high`, `xhigh`.
492+- Inner-left: CWD, abbreviated with `~` for home. Truncated from the left (`…/mini-coder`) on narrow terminals.
483493
484-**Line 2 — session:**
494+**Right side:**
485495
486-- Left: `provider/model · effort`. Effort shown as `low`, `med`, `high`, `xhigh`.
487-- Right: `in:input out:output · context%/window · $cost`. `in`, `out`, and `$cost` are **cumulative for the session**. `context%/window` shows the **estimated current context usage for the next model request** as a percentage of the active model's context window.
496+- Inner-right: git branch, working tree counts (+ staged, ~ modified, ? untracked), ahead of remote (▲ N). Omitted outside a repo.
497+- Outer-right: `in:input out:output · context%/window · $cost`. `in`, `out`, and `$cost` are **cumulative for the session**. `context%/window` shows the **estimated current context usage for the next model request** as a percentage of the active model's context window.
488498
489499 Token counts use human-friendly units (1.2k, 45k, 1.2M). Context usage is estimated from the current model-visible conversation, not just the last assistant message. Use the most recent valid assistant `usage` as an anchor (`totalTokens` when present, otherwise `input + output + cacheRead + cacheWrite`) and add heuristic estimates for any later messages. If no assistant `usage` exists yet, estimate the full current model-visible history heuristically. UI-only messages are excluded from this esti …
490500
@@ -506,7 +516,7 @@ While the agent is working, the top divider (above the input area) animates with
506516
507517 ### Input area
508518
509-Multi-line text input with no prompt prefix — the blinking cursor is the affordance. Intrinsic height (1 line when empty, grows with content) up to `maxHeight: 10`, then scrolls internally. Enter submits, Shift+Enter adds newlines (via cel-tui's `TextInput` `onKeyPress` pattern).
519+Multi-line text input with no prompt prefix — the blinking cursor is the affordance. Intrinsic height starts at 2 lines when empty (`minHeight: 2`), grows with content up to `maxHeight: 10`, then scrolls internally. Enter submits, Shift+Enter adds newlines (via cel-tui's `TextInput` `onKeyPress` pattern).
510520
511521 Supports:
512522
src/theme.test.ts+6−2
@@ -13,6 +13,8 @@ const THEME_KEYS = [
1313 "divider",
1414 "dividerPulse",
1515 "statusText",
16+ "statusPrimaryBg",
17+ "statusSecondaryBg",
1618 "error",
1719 "overlayBg",
1820 ] as const;
@@ -22,8 +24,10 @@ describe("theme", () => {
2224 expect(Object.keys(DEFAULT_THEME).sort()).toEqual([...THEME_KEYS].sort());
2325 });
2426
25- test("DEFAULT_THEME uses the terminal default foreground for shared status text", () => {
26- expect(DEFAULT_THEME.statusText).toBeUndefined();
27+ test("DEFAULT_THEME uses explicit ANSI16 colors for status pills", () => {
28+ expect(DEFAULT_THEME.statusText).toBe("color15");
29+ expect(DEFAULT_THEME.statusPrimaryBg).toBe("color04");
30+ expect(DEFAULT_THEME.statusSecondaryBg).toBe("color08");
2731 });
2832
2933 test("mergeThemes with no overrides returns base unchanged", () => {
src/theme.ts+14−4
@@ -5,7 +5,9 @@
55 * never hardcodes colors. Plugins can return a `Partial<Theme>` in their
66 * result to override any color. Multiple overrides are merged left-to-right.
77 *
8- * Theme values are cel-tui {@link Color} palette references.
8+ * Theme values are cel-tui {@link Color} palette references. The default
9+ * theme prefers ANSI 16-color palette entries so it adapts cleanly to the
10+ * user's terminal theme while still allowing restrained pill styling.
911 *
1012 * @module
1113 */
@@ -46,8 +48,12 @@ export interface Theme {
4648 divider: ThemeColor;
4749 /** Divider scanning pulse highlight color (active state). */
4850 dividerPulse: ThemeColor;
49- /** Status bar foreground. */
51+ /** Status pill foreground. */
5052 statusText: ThemeColor;
53+ /** Primary status pill background (outer pills: model/effort + usage/context/cost). */
54+ statusPrimaryBg: ThemeColor;
55+ /** Secondary status pill background (inner pills: CWD + git). */
56+ statusSecondaryBg: ThemeColor;
5157 /** Error text. */
5258 error: ThemeColor;
5359 /** Overlay modal background. */
@@ -62,7 +68,9 @@ export interface Theme {
6268 * The default theme.
6369 *
6470 * Uses terminal palette colors so it looks reasonable across light and
65- * dark terminal themes without any configuration.
71+ * dark terminal themes without any configuration. The outer status pills
72+ * use a blue primary background, the inner pills use a dim gray secondary
73+ * background, and bright text keeps the badges readable.
6674 */
6775 export const DEFAULT_THEME: Theme = {
6876 userMsgBg: "color08",
@@ -75,7 +83,9 @@ export const DEFAULT_THEME: Theme = {
7583 diffRemoved: "color01",
7684 divider: "color08",
7785 dividerPulse: "color04",
78- statusText: undefined,
86+ statusText: "color15",
87+ statusPrimaryBg: "color04",
88+ statusSecondaryBg: "color08",
7989 error: "color01",
8090 overlayBg: "color08",
8191 };
src/ui.test.ts+85−16
@@ -35,9 +35,11 @@ import {
3535 createInputController,
3636 type HelpRenderState,
3737 handleInput,
38+ type InputController,
3839 type PendingToolCall,
3940 previewToolRenderLines,
4041 renderAssistantMessage,
42+ renderBaseLayout,
4143 renderInputArea,
4244 renderStatusBar,
4345 renderStreamingResponse,
@@ -748,10 +750,14 @@ describe("ui rendering", () => {
748750 expect(firstInput.props.placeholder?.props.fgColor).toBe(
749751 state.theme.mutedText,
750752 );
753+ expect(firstInput.props.minHeight).toBe(2);
754+ expect(firstInput.props.maxHeight).toBe(10);
751755 expect(firstInput.props.onChange).toBe(controller.onChange);
752756 expect(firstInput.props.onFocus).toBe(controller.onFocus);
753757 expect(firstInput.props.onBlur).toBe(controller.onBlur);
754758 expect(firstInput.props.onKeyPress).toBe(controller.onKeyPress);
759+ expect(secondInput.props.minHeight).toBe(firstInput.props.minHeight);
760+ expect(secondInput.props.maxHeight).toBe(firstInput.props.maxHeight);
755761 expect(secondInput.props.onChange).toBe(firstInput.props.onChange);
756762 expect(secondInput.props.onFocus).toBe(firstInput.props.onFocus);
757763 expect(secondInput.props.onBlur).toBe(firstInput.props.onBlur);
@@ -794,7 +800,7 @@ describe("ui rendering", () => {
794800 expect(pluginHeader.props.fgColor).toBe(theme.secondaryAccentText);
795801 });
796802
797- test("renderStatusBar uses themed accent colors for git and model info", () => {
803+ test("renderStatusBar renders a one-line status bar with outer primary pills and inner secondary pills", () => {
798804 const faux = registerFauxProvider();
799805 const state = createTestState();
800806 state.model = faux.getModel();
@@ -809,41 +815,104 @@ describe("ui rendering", () => {
809815 };
810816 state.theme = {
811817 ...DEFAULT_THEME,
812- accentText: "color04",
813- secondaryAccentText: "color05",
814- statusText: undefined,
818+ statusText: "color15",
819+ statusPrimaryBg: "color04",
820+ statusSecondaryBg: "color08",
815821 } satisfies Theme;
816822
817823 try {
818824 const node = renderStatusBar(state);
819825
820- expect(node.type).toBe("vstack");
821- if (node.type !== "vstack") {
822- throw new Error("Expected status bar to be a VStack");
826+ expect(node.type).toBe("hstack");
827+ if (node.type !== "hstack") {
828+ throw new Error("Expected status bar to be an HStack");
829+ }
830+ expect(node.props.height).toBe(1);
831+ expect(node.props.padding).toEqual({ x: 1 });
832+
833+ const [modelPill, cwdPill, spacer, gitPill, usagePill] = node.children;
834+ expect(modelPill?.type).toBe("hstack");
835+ expect(cwdPill?.type).toBe("hstack");
836+ expect(gitPill?.type).toBe("hstack");
837+ expect(usagePill?.type).toBe("hstack");
838+ if (
839+ !modelPill ||
840+ !cwdPill ||
841+ !spacer ||
842+ !gitPill ||
843+ !usagePill ||
844+ modelPill.type !== "hstack" ||
845+ cwdPill.type !== "hstack" ||
846+ gitPill.type !== "hstack" ||
847+ usagePill.type !== "hstack"
848+ ) {
849+ throw new Error("Expected status pills around a spacer in one row");
823850 }
824- expect(node.props.fgColor).toBeUndefined();
825851
826- const gitNode = findTextNode(node, "main +1 ~2 ?3 ▲ 4");
852+ expect(modelPill.props.bgColor).toBe(state.theme.statusPrimaryBg);
853+ expect(cwdPill.props.bgColor).toBe(state.theme.statusSecondaryBg);
854+ expect(gitPill.props.bgColor).toBe(state.theme.statusSecondaryBg);
855+ expect(usagePill.props.bgColor).toBe(state.theme.statusPrimaryBg);
856+ expect(modelPill.props.padding).toEqual({ x: 1 });
857+ expect(cwdPill.props.padding).toEqual({ x: 1 });
858+ expect(gitPill.props.padding).toEqual({ x: 1 });
859+ expect(usagePill.props.padding).toEqual({ x: 1 });
860+
861+ const cwdNode = findTextNode(cwdPill, state.cwd);
862+ const gitNode = findTextNode(gitPill, "main +1 ~2 ?3 ▲ 4");
827863 const modelNode = findTextNode(
828- node,
864+ modelPill,
829865 `${state.model.provider}/${state.model.id} · med`,
830866 );
867+ expect(cwdNode).not.toBeNull();
831868 expect(gitNode).not.toBeNull();
832869 expect(modelNode).not.toBeNull();
833- if (!gitNode || !modelNode) {
834- throw new Error("Expected git and model text nodes");
870+ if (!cwdNode || !gitNode || !modelNode) {
871+ throw new Error("Expected status pill text nodes");
835872 }
836- if (gitNode.type !== "text" || modelNode.type !== "text") {
837- throw new Error("Expected git and model nodes to be text");
873+ if (
874+ cwdNode.type !== "text" ||
875+ gitNode.type !== "text" ||
876+ modelNode.type !== "text"
877+ ) {
878+ throw new Error("Expected status pill content to be text nodes");
838879 }
839- expect(gitNode.props.fgColor).toBe(state.theme.secondaryAccentText);
840- expect(modelNode.props.fgColor).toBe(state.theme.accentText);
880+ expect(cwdNode.props.fgColor).toBe(state.theme.statusText);
881+ expect(gitNode.props.fgColor).toBe(state.theme.statusText);
882+ expect(modelNode.props.fgColor).toBe(state.theme.statusText);
883+ expect(collectText(usagePill).join("")).toContain("in:0 out:0 ·");
841884 } finally {
842885 faux.unregister();
843886 state.db.close();
844887 }
845888 });
846889
890+ test("renderBaseLayout keeps a single divider between the log and input", () => {
891+ const state = createTestState();
892+ const controller: InputController = {
893+ onChange: () => {},
894+ onFocus: () => {},
895+ onBlur: () => {},
896+ onKeyPress: () => undefined,
897+ };
898+
899+ try {
900+ const node = renderBaseLayout(state, 80, controller);
901+
902+ expect(node.type).toBe("vstack");
903+ if (node.type !== "vstack") {
904+ throw new Error("Expected app layout to be a VStack");
905+ }
906+ expect(node.children).toHaveLength(4);
907+ expect(node.children[0]?.type).toBe("vstack");
908+ expect(node.children[1]?.type).toBe("text");
909+ expect(node.children[2]?.type).toBe("vstack");
910+ expect(node.children[3]?.type).toBe("hstack");
911+ } finally {
912+ state.db.close();
913+ }
914+ });
915+
847916 test("renderStatusBar estimates context usage from the latest valid assistant usage plus trailing model-visible messages", () => {
848917 const faux = registerFauxProvider();
849918 const state = createTestState();
src/ui.ts+107−71
@@ -11,7 +11,7 @@
1111 import { exec } from "node:child_process";
1212 import { homedir, platform } from "node:os";
1313 import type { SelectInstance } from "@cel-tui/components";
14-import { Divider, Markdown, Select, Spacer } from "@cel-tui/components";
14+import { Markdown, Select, Spacer } from "@cel-tui/components";
1515 import {
1616 cel,
1717 HStack,
@@ -1012,35 +1012,51 @@ function renderOverlay(state: AppState): Node {
10121012 // Status bar
10131013 // ---------------------------------------------------------------------------
10141014
1015+function renderStatusPill(
1016+ text: string,
1017+ bgColor: Theme["statusPrimaryBg"] | Theme["statusSecondaryBg"],
1018+ theme: Theme,
1019+): Node {
1020+ return HStack({ bgColor, padding: { x: 1 } }, [
1021+ Text(text, { fgColor: theme.statusText }),
1022+ ]);
1023+}
1024+
10151025 /**
1016- * Render the two-line status bar.
1026+ * Render the one-line status bar as compact padded pills.
1027+ *
1028+ * Outer pills use the primary background and inner pills use the secondary
1029+ * background. The git pill is omitted outside repositories.
10171030 *
10181031 * @param state - Application state.
10191032 * @returns The status bar node.
10201033 */
10211034 export function renderStatusBar(state: AppState): Node {
1022- return VStack(
1035+ const cwd = abbreviatePath(state.cwd);
1036+ const gitStatus = formatGitStatus(state);
1037+ const modelInfo = formatModelInfo(state);
1038+ const usage = formatUsage(state);
1039+
1040+ const children: Node[] = [
1041+ renderStatusPill(modelInfo, state.theme.statusPrimaryBg, state.theme),
1042+ renderStatusPill(cwd, state.theme.statusSecondaryBg, state.theme),
1043+ Spacer(),
1044+ ];
1045+ if (gitStatus) {
1046+ children.push(
1047+ renderStatusPill(gitStatus, state.theme.statusSecondaryBg, state.theme),
1048+ );
1049+ }
1050+ children.push(
1051+ renderStatusPill(usage, state.theme.statusPrimaryBg, state.theme),
1052+ );
1053+
1054+ return HStack(
10231055 {
1024- height: 2,
1056+ height: 1,
10251057 padding: { x: 1 },
1026- fgColor: state.theme.statusText,
10271058 },
1028- [
1029- HStack({}, [
1030- Text(abbreviatePath(state.cwd)),
1031- Spacer(),
1032- Text(formatGitStatus(state), {
1033- fgColor: state.theme.secondaryAccentText,
1034- }),
1035- ]),
1036- HStack({}, [
1037- Text(formatModelInfo(state), {
1038- fgColor: state.theme.accentText,
1039- }),
1040- Spacer(),
1041- Text(formatUsage(state)),
1042- ]),
1043- ],
1059+ children,
10441060 );
10451061 }
10461062
@@ -1114,6 +1130,7 @@ export function renderInputArea(
11141130 return VStack({ padding: { x: 1 } }, [
11151131 TextInput({
11161132 flex: 1,
1133+ minHeight: 2,
11171134 maxHeight: 10,
11181135 value: inputValue,
11191136 onChange: controller.onChange,
@@ -1926,6 +1943,74 @@ async function gracefulExit(state: AppState): Promise<void> {
19261943 // Main
19271944 // ---------------------------------------------------------------------------
19281945
1946+function renderConversationLog(state: AppState): Node {
1947+ return VStack(
1948+ {
1949+ flex: 1,
1950+ overflow: "scroll",
1951+ scrollbar: true,
1952+ scrollOffset: stickToBottom ? Infinity : scrollOffset,
1953+ onScroll: (offset, maxOffset) => {
1954+ scrollOffset = offset;
1955+ stickToBottom = offset >= maxOffset;
1956+ cel.render();
1957+ },
1958+ },
1959+ buildConversationLog(state),
1960+ );
1961+}
1962+
1963+/**
1964+ * Render the base application layout without overlays.
1965+ *
1966+ * The layout contains the conversation log, the animated divider, the input
1967+ * area, and the two-line pill-based status bar.
1968+ *
1969+ * @param state - Application state.
1970+ * @param cols - Current terminal width in columns.
1971+ * @param inputController - Stable callbacks for the controlled TextInput.
1972+ * @returns The base layout node.
1973+ */
1974+export function renderBaseLayout(
1975+ state: AppState,
1976+ cols: number,
1977+ inputController: InputController,
1978+): Node {
1979+ return VStack(
1980+ {
1981+ height: "100%",
1982+ onKeyPress: (key) => {
1983+ if (key === "ctrl+c") {
1984+ gracefulExit(state).catch(() => process.exit(1));
1985+ return;
1986+ }
1987+ if (key === "ctrl+d" && inputValue === "") {
1988+ gracefulExit(state).catch(() => process.exit(1));
1989+ return;
1990+ }
1991+ if (key === "escape" && state.running) {
1992+ if (state.abortController) state.abortController.abort();
1993+ return;
1994+ }
1995+ return false;
1996+ },
1997+ },
1998+ [
1999+ // ── Conversation log ──
2000+ renderConversationLog(state),
2001+
2002+ // ── Animated divider (pulse when agent is working) ──
2003+ renderDivider(state, cols),
2004+
2005+ // ── Input area ──
2006+ renderInputArea(state.theme, inputController),
2007+
2008+ // ── Status bar (2 lines) ──
2009+ renderStatusBar(state),
2010+ ],
2011+ );
2012+}
2013+
19292014 /**
19302015 * Start the terminal UI.
19312016 *
@@ -1941,56 +2026,7 @@ export function startUI(state: AppState): void {
19412026
19422027 cel.viewport(() => {
19432028 const cols = terminal.columns;
1944-
1945- const base = VStack(
1946- {
1947- height: "100%",
1948- onKeyPress: (key) => {
1949- if (key === "ctrl+c") {
1950- gracefulExit(state).catch(() => process.exit(1));
1951- return;
1952- }
1953- if (key === "ctrl+d" && inputValue === "") {
1954- gracefulExit(state).catch(() => process.exit(1));
1955- return;
1956- }
1957- if (key === "escape" && state.running) {
1958- if (state.abortController) state.abortController.abort();
1959- return;
1960- }
1961- return false;
1962- },
1963- },
1964- [
1965- // ── Conversation log ──
1966- VStack(
1967- {
1968- flex: 1,
1969- overflow: "scroll",
1970- scrollbar: true,
1971- scrollOffset: stickToBottom ? Infinity : scrollOffset,
1972- onScroll: (offset, maxOffset) => {
1973- scrollOffset = offset;
1974- stickToBottom = offset >= maxOffset;
1975- cel.render();
1976- },
1977- },
1978- buildConversationLog(state),
1979- ),
1980-
1981- // ── Animated divider (pulse when agent is working) ──
1982- renderDivider(state, cols),
1983-
1984- // ── Input area ──
1985- renderInputArea(state.theme, inputController),
1986-
1987- // ── Static divider ──
1988- Divider({ fgColor: state.theme.divider }),
1989-
1990- // ── Status bar (2 lines) ──
1991- renderStatusBar(state),
1992- ],
1993- );
2029+ const base = renderBaseLayout(state, cols, inputController);
19942030
19952031 if (activeOverlay) {
19962032 return [base, renderOverlay(state)];