@@ -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)];