@@ -0,0 +1,736 @@
1+# cel-tui Specification
2+
3+## Overview
4+
5+cel-tui is a TypeScript TUI framework built around a declarative functional API, ultra-fast rendering, and a concise developer experience. Layout is inspired by CSS Flexbox, using composable horizontal and vertical stacks as the core container primitives.
6+
7+---
8+
9+## API Surface
10+
11+### Entrypoint
12+
13+```ts
14+cel.viewport(render: () => Node | Node[])
15+cel.render()
16+```
17+
18+`cel.viewport` sets the render function that returns the UI tree. Accepts a single layer or an array of layers. Each layer is a container with full viewport dimensions, laid out independently. When multiple layers are provided, they are composited bottom-to-top (array index = z-order). Setting the viewport triggers the first render.
19+
20+`cel.render` requests a re-render. Batched via `process.nextTick()` — multiple calls within the same tick produce a single render. Call this after state changes.
21+
22+State is fully external to the framework. Use any state management approach — plain variables, classes, libraries. The framework just calls the render function and renders the returned tree.
23+
24+### Primitives
25+
26+| Category | Primitive | Description |
27+| --------- | ------------------------- | -------------------------------------------------- |
28+| Layout | `VStack(props, children)` | Vertical stack — children laid out top to bottom |
29+| Layout | `HStack(props, children)` | Horizontal stack — children laid out left to right |
30+| Content | `Text(content, props?)` | Styled text content |
31+| Container | `TextInput(props)` | Editable text container |
32+
33+### Systems
34+
35+| System | Description |
36+| -------------------------- | --------------------------------------------------------- |
37+| Flexbox layout engine | Sizing, alignment, gap |
38+| Overflow & scrolling | `overflow: "hidden" \| "scroll"`, scrollbar |
39+| Layering | Multiple viewport layers, composited bottom-to-top |
40+| Mouse/scroll hit detection | Pointer-driven, topmost layer first, innermost node wins |
41+| Focus management | Keyboard-driven, for `TextInput` and clickable containers |
42+
43+---
44+
45+## Layout Model
46+
47+### Core Containers
48+
49+- **VStack** — vertical stack, children laid out top to bottom (`flex-direction: column`)
50+- **HStack** — horizontal stack, children laid out left to right (`flex-direction: row`)
51+
52+Containers are arbitrarily nestable: `HStack > VStack > HStack > ...`
53+
54+### API Shape
55+
56+Declarative and functional:
57+
58+```ts
59+VStack(props, children);
60+HStack(props, children);
61+```
62+
63+### Container Props
64+
65+Shared by both VStack and HStack:
66+
67+| Prop | Type | Description |
68+| ---------------- | ---------------------------- | ----------------------------------------------- |
69+| `width` | `number \| string` | Fixed cells or percentage (`"50%"`) |
70+| `height` | `number \| string` | Fixed cells or percentage (`"100%"`) |
71+| `flex` | `number` | Flex grow factor, proportional to siblings |
72+| `minWidth` | `number` | Minimum width constraint |
73+| `maxWidth` | `number` | Maximum width constraint |
74+| `minHeight` | `number` | Minimum height constraint |
75+| `maxHeight` | `number` | Maximum height constraint |
76+| `padding` | `{ x?: number, y?: number }` | Internal padding (cells) |
77+| `gap` | `number` | Spacing between children (cells) |
78+| `justifyContent` | `string` | Distribute children along the main axis |
79+| `alignItems` | `string` | Align children along the cross axis |
80+| `overflow` | `"hidden" \| "scroll"` | Content overflow behavior (default: `"hidden"`) |
81+| `scrollbar` | `boolean` | Show scrollbar indicator |
82+| `scrollOffset` | `number` | Scroll position in cells (controlled) |
83+| `onScroll` | `(offset: number) => void` | Called on scroll input |
84+| `onClick` | `() => void` | Called on mouse click or Enter when focused |
85+| `focusable` | `boolean` | Opt out of focus (default: `true` if `onClick`) |
86+| `focused` | `boolean` | Whether this element is focused (controlled) |
87+| `onFocus` | `() => void` | Called when element receives focus |
88+| `onBlur` | `() => void` | Called when element loses focus |
89+| `onKeyPress` | `(key: string) => void` | Called on key event (bubbles up from focus) |
90+
91+### Sizing
92+
93+Four sizing strategies, inspired by CSS Flexbox:
94+
95+| Strategy | Example | Description |
96+| -------------- | -------------------------------- | ----------------------------- |
97+| **Intrinsic** | _(no sizing props set)_ | Size to fit content (default) |
98+| **Fixed** | `width: 30, height: 10` | Exact cell count |
99+| **Flex** | `flex: 1`, `flex: 2` | Proportional to siblings |
100+| **Percentage** | `width: "50%"`, `height: "100%"` | Relative to parent |
101+
102+Constraints via `minWidth`, `maxWidth`, `minHeight`, `maxHeight`.
103+
104+**Intrinsic sizing:** A container with no explicit `width`/`height`/`flex`/percentage sizes to fit its children. Leaf nodes (Text) and TextInput compute intrinsic height from content and wrapping at the given width.
105+
106+**Sizing priority:** Intrinsic and fixed sizes are allocated first, then remaining space is distributed among flex/percentage children.
107+
108+### Gap
109+
110+Cell-based spacing between children:
111+
112+```ts
113+HStack({ gap: 1 }, [...])
114+```
115+
116+### Alignment
117+
118+Inspired by Flexbox:
119+
120+- `justifyContent` — distribute children along the main axis
121+- `alignItems` — align children along the cross axis
122+
123+---
124+
125+## Rounding Strategy
126+
127+Terminals operate on integer cell coordinates. When dividing space among flex/percentage children produces fractional values, the **Largest Remainder Method** is used:
128+
129+1. Floor all computed sizes
130+2. Calculate the remaining cells (available space minus sum of floored values)
131+3. Distribute remaining cells one-by-one to children with the largest fractional remainders
132+
133+Example: 80 columns, three `flex: 1` children (80 ÷ 3 = 26.667 each):
134+
135+- Floor: 26, 26, 26 = 78
136+- Remaining: 2 cells
137+- All fractional parts are equal (0.667), first two children receive +1
138+- Result: 27, 27, 26
139+
140+This guarantees the total always sums exactly to the available space, with no order bias.
141+
142+---
143+
144+## Overflow & Scrolling
145+
146+### Overflow Modes
147+
148+```ts
149+VStack({ overflow: "hidden" }); // clip content (default)
150+VStack({ overflow: "scroll" }); // enable scrolling
151+```
152+
153+### Scrollbar
154+
155+Optional visual scrollbar indicator:
156+
157+```ts
158+VStack({ overflow: "scroll", scrollbar: true });
159+```
160+
161+### Scroll Direction
162+
163+Follows the container's main axis:
164+
165+- VStack with `overflow: "scroll"` → vertical scroll
166+- HStack with `overflow: "scroll"` → horizontal scroll
167+
168+### Scroll Position
169+
170+Scroll supports both **uncontrolled** and **controlled** modes, determined by whether `scrollOffset` is provided:
171+
172+**Uncontrolled** (default) — the framework manages scroll position internally. Mouse wheel just works:
173+
174+```ts
175+VStack({ overflow: "scroll" }, [...])
176+```
177+
178+**Controlled** — the app owns the scroll state. Enables patterns like auto-scroll to bottom on new content:
179+
180+```ts
181+VStack({
182+ overflow: "scroll",
183+ scrollOffset: offset,
184+ onScroll: (newOffset) => {
185+ offset = newOffset;
186+ },
187+}, [...])
188+```
189+
190+In controlled mode, mouse wheel events fire `onScroll` with the new offset; the UI only moves when the app passes the updated `scrollOffset` back.
191+
192+---
193+
194+## Scroll Input Model
195+
196+Scroll is **pointer-driven**, not focus-driven. Mouse wheel events are routed spatially based on cursor position.
197+
198+### Hit Detection
199+
200+1. Terminal reports mouse position via SGR mouse mode
201+2. Starting from the **topmost layer**, find the deepest node at `(x, y)`
202+3. If the layer has a node at that position, it handles the event. Otherwise, try the next layer down.
203+4. For scroll: walk up the ancestor chain to find the nearest scrollable node (container with `overflow: "scroll"`, or TextInput)
204+5. For click: walk up to find the nearest container with `onClick`
205+
206+### Nested Scrollable Containers
207+
208+**Innermost scrollable wins.** The deepest scrollable ancestor of the hit target handles the event.
209+
210+### Architecture Requirements
211+
212+- Each node stores its **absolute screen rect** after layout
213+- The layout tree supports **bottom-up traversal** (child → parent)
214+- Hit testing: given `(x, y)` → return the deepest node at that position
215+
216+### Click
217+
218+Click uses the same hit model as scroll: mouse click position is mapped to the deepest node, then walks up the ancestor chain to find the nearest container with `onClick`. **Innermost clickable container wins.**
219+
220+### Text Selection
221+
222+Native terminal text selection (click-drag to highlight/copy) is handled by the terminal emulator, not the framework. With SGR mouse mode enabled, most terminals support **Shift+click/drag** to bypass application mouse capture and use native selection. This is standard behavior across terminal applications (vim, tmux, etc.).
223+
224+---
225+
226+## Focus Model
227+
228+Focus is **keyboard-driven** and separate from scroll. Focus state is **controlled** — the app owns which element is focused.
229+
230+- Focus is for interactive widgets (TextInput) and clickable containers (with `onClick`)
231+- Scroll does not require focus
232+- A user can type in a focused widget while scrolling a different container with the mouse
233+
234+### Focusable Elements
235+
236+Focus is implicit — no `focusable` prop needed for the common case:
237+
238+- **TextInput** — always focusable
239+- **Container with `onClick`** — focusable by default, opt out with `focusable: false`
240+
241+### Traversal
242+
243+**Escape** unfocuses the current element. **Tab / Shift+Tab** moves focus to the next/previous focusable element in document order (depth-first tree traversal).
244+
245+When a TextInput is focused, text-editing keys (printable characters, arrows, backspace, Tab) go to the input. Modifier combos (e.g., `ctrl+s`) are not consumed by TextInput and bubble up. Press Escape to leave the input, then Tab to traverse.
246+
247+---
248+
249+## Key Handling
250+
251+Key events are routed through the focus and layer system, then bubble up the tree.
252+
253+### Key Event Flow
254+
255+1. **Topmost layer** receives the key event
256+2. If a **TextInput** is focused, it consumes text-editing keys (printable characters, arrows, backspace, Tab). Modifier combos pass through.
257+3. If a **clickable container** is focused, Enter fires `onClick`. Other keys pass through.
258+4. Unconsumed keys **bubble up** through ancestors — the nearest `onKeyPress` handler in the ancestor chain handles it.
259+5. The root container's `onKeyPress` acts as the global key handler.
260+
261+### Key Format
262+
263+All lowercase, modifiers joined by `+` in canonical order `ctrl+alt+shift+<key>`:
264+
265+```
266+"ctrl+s"
267+"ctrl+shift+n"
268+"escape"
269+"enter"
270+"alt+up"
271+"f1"
272+"ctrl+plus"
273+```
274+
275+**Modifiers:** `ctrl`, `alt`, `shift`
276+
277+**Named keys:** `escape`, `enter`, `tab`, `backspace`, `delete`, `space`, `plus`, `up`, `down`, `left`, `right`, `home`, `end`, `pageup`, `pagedown`, `f1`–`f12`
278+
279+**Printable characters:** lowercase letter or character itself — `"a"`, `"1"`, `"/"`
280+
281+The framework normalizes modifier order, so `"shift+ctrl+s"` and `"ctrl+shift+s"` both match.
282+
283+### Activation
284+
285+When a clickable container is focused, **Enter** fires its `onClick`.
286+
287+### Mouse Interaction
288+
289+Clicking a focusable element also focuses it. This bridges the keyboard and mouse models — click a TextInput to start typing, click a button to focus it.
290+
291+### Controlled Focus
292+
293+The app owns focus state via `focused`, `onFocus`, and `onBlur` props on focusable elements:
294+
295+```ts
296+TextInput({
297+ value: text,
298+ onChange: handleChange,
299+ focused: isFocused,
300+ onFocus: () => {
301+ isFocused = true;
302+ },
303+ onBlur: () => {
304+ isFocused = false;
305+ },
306+});
307+```
308+
309+Only one element can be focused at a time. The app is responsible for ensuring this — if multiple elements set `focused: true`, the first in document order wins.
310+
311+---
312+
313+## Layering
314+
315+Layering enables modals, dropdowns, and overlay UI. Each layer is an independent layout tree with full viewport dimensions.
316+
317+```ts
318+// Single layer — most apps
319+cel.viewport(() =>
320+ VStack({ height: "100%" }, [...])
321+)
322+
323+// Multiple layers — ordered bottom-to-top
324+cel.viewport(() => [
325+ VStack({ height: "100%" }, [...mainUI]),
326+ VStack({ height: "100%" }, [...modalUI]),
327+])
328+```
329+
330+**Compositing:** Layers are rendered bottom-to-top. Cells without content in a higher layer are transparent — the lower layer shows through.
331+
332+**Input:** Events target the topmost layer that has a node at the event position. This naturally blocks input to lower layers when a modal or overlay is present.
333+
334+**Modal backdrop pattern:** A full-viewport container on the top layer captures all input, preventing interaction with the base UI:
335+
336+```ts
337+cel.viewport(() => [
338+ VStack({ height: "100%" }, [...mainUI]),
339+ VStack(
340+ {
341+ height: "100%",
342+ justifyContent: "center",
343+ alignItems: "center",
344+ onClick: dismissModal,
345+ },
346+ [
347+ VStack({ width: 40, height: 15 }, [
348+ Text("Are you sure?"),
349+ HStack({ gap: 1 }, [
350+ HStack({ onClick: handleYes }, [Text("[Yes]")]),
351+ HStack({ onClick: handleNo }, [Text("[No]")]),
352+ ]),
353+ ]),
354+ ],
355+ ),
356+]);
357+```
358+
359+---
360+
361+## Primitives
362+
363+### Text
364+
365+Styled text leaf node. No children, no sizing props — the parent container controls the box.
366+
367+```ts
368+Text(content: string, props?: TextProps)
369+```
370+
371+**Sizing behavior:**
372+
373+- Width: always parent-assigned
374+- Height: intrinsic — computed from content, newlines, and word-wrapping at the given width
375+
376+#### Props
377+
378+| Prop | Type | Description |
379+| -------- | ------------------ | ------------------------------------ |
380+| `repeat` | `number \| "fill"` | Repeat content N times or fill width |
381+| `wrap` | `"none" \| "word"` | Wrapping mode (default: `"none"`) |
382+
383+Text also accepts the shared styling props (see Styling Props below).
384+
385+#### Repeat
386+
387+```ts
388+Text("─", { repeat: "fill" }); // repeat to fill available width
389+Text("─", { repeat: 20 }); // repeat exactly 20 times
390+```
391+
392+`repeat` takes a number or `"fill"`. When set, wrapping is ignored.
393+
394+#### Wrapping
395+
396+| Mode | Description |
397+| -------------- | --------------------------------------------------------------- |
398+| `wrap: "none"` | No wrapping (default). Content is hard-clipped at the box edge. |
399+| `wrap: "word"` | Word-wrap to fit available width. Affects computed height. |
400+
401+Whitespace is always preserved. `\n` in content produces explicit line breaks.
402+
403+---
404+
405+### TextInput
406+
407+Multi-line editable text container. Accepts all container props but has no children — its content is the editable `value`. Scroll is always uncontrolled (framework-managed: follows cursor and responds to mouse wheel).
408+
409+```ts
410+TextInput(props: TextInputProps)
411+```
412+
413+#### Props
414+
415+Container sizing props (`width`, `height`, `flex`, `min*`, `max*`, `padding`), focus props, and:
416+
417+| Prop | Type | Description |
418+| ------------- | ------------------------- | -------------------------------------------------- |
419+| `value` | `string` | Current text content (controlled) |
420+| `onChange` | `(value: string) => void` | Called on text change |
421+| `onSubmit` | `() => void` | Called on submit key |
422+| `submitKey` | `string` | Key combo that fires onSubmit (default: `"enter"`) |
423+| `placeholder` | `Text` | Text node shown when value is empty |
424+| `focused` | `boolean` | Whether this input is focused (controlled) |
425+| `onFocus` | `() => void` | Called when input receives focus |
426+| `onBlur` | `() => void` | Called when input loses focus |
427+
428+Word-wrap is always on. Cursor position is framework-managed.
429+
430+TextInput also accepts the shared styling props (see Styling Props below).
431+
432+#### Growing / Shrinking Pattern
433+
434+Without explicit height, TextInput uses intrinsic sizing (content height). Combined with `maxHeight`, this creates a naturally growing input:
435+
436+```ts
437+TextInput({
438+ maxHeight: 10,
439+ value,
440+ onChange,
441+ onSubmit,
442+ submitKey: "ctrl+enter",
443+});
444+```
445+
446+- 1 line of text → height is 1
447+- 5 lines → height is 5
448+- 15 lines → height is 10 (capped), internal scroll kicks in
449+
450+---
451+
452+### Styling Props
453+
454+Shared by Text and TextInput:
455+
456+| Prop | Type | Description |
457+| ----------- | --------- | ---------------- |
458+| `bold` | `boolean` | Bold weight |
459+| `italic` | `boolean` | Italic style |
460+| `underline` | `boolean` | Underlined text |
461+| `fgColor` | `Color` | Foreground color |
462+| `bgColor` | `Color` | Background color |
463+
464+**Colors:** ANSI base 16 — `"black"`, `"red"`, `"green"`, `"yellow"`, `"blue"`, `"magenta"`, `"cyan"`, `"white"`, and their bright variants (`"brightRed"`, `"brightGreen"`, etc.).
465+
466+---
467+
468+## Character Width
469+
470+Terminal cells are monospaced, but not all characters occupy one cell. Correct width measurement is critical for layout, wrapping, truncation, and cursor positioning.
471+
472+### Width Rules
473+
474+| Category | Width | Examples |
475+| --------------------------- | ----- | -------------------------------------------------- |
476+| Printable ASCII (0x20–0x7E) | 1 | `a`, `Z`, `#`, ` ` |
477+| East Asian wide (CJK) | 2 | `世`, `界`, `!` |
478+| Emoji (RGI) | 2 | `😀`, `👨👩👧` |
479+| Zero-width | 0 | Control chars, combining marks, default ignorables |
480+| ANSI escape sequences | 0 | `\x1b[31m`, `\x1b[0m` |
481+
482+### Measurement Strategy
483+
484+1. **Fast ASCII path** — if the entire string is printable ASCII, width = `string.length`. No segmentation needed. This is the hot path.
485+2. **Grapheme segmentation** — `Intl.Segmenter` with `granularity: "grapheme"` to handle multi-codepoint characters (emoji with ZWJ, skin tones, combining marks).
486+3. **East Asian width lookup** — per-codepoint lookup for CJK full-width characters (via `get-east-asian-width` or equivalent).
487+4. **ANSI stripping** — escape sequences (CSI, OSC, APC) are stripped before measuring.
488+5. **Caching** — LRU cache for non-ASCII width results.
489+
490+---
491+
492+## Rendering
493+
494+### Cell Buffer
495+
496+The rendering pipeline uses a 2D **cell buffer** — a grid matching the terminal dimensions where each cell stores:
497+
498+- Character (grapheme cluster)
499+- Foreground color
500+- Background color
501+- Style flags (bold, italic, underline)
502+
503+The layout engine writes styled cells into the buffer. This makes clipping trivial (don't write outside the rect), and layer compositing trivial (higher layers overwrite lower layers, empty cells are transparent).
504+
505+### Pipeline
506+
507+1. **Layout** — flexbox engine computes absolute screen rects for all nodes
508+2. **Paint** — each node writes styled cells into the buffer within its rect
509+3. **Composite** — layers are painted bottom-to-top into the final buffer
510+4. **Diff** — compare new buffer against previous buffer
511+5. **Emit** — generate ANSI sequences for changed cells, write in a single batched call
512+
513+### Reactive Rendering
514+
515+Rendering is **reactive**, not FPS-based. `cel.render()` batches via `process.nextTick()` — multiple calls within the same tick produce a single render. Terminal resize also triggers a re-render automatically. No fixed frame rate, no wasted renders.
516+
517+### Synchronized Output
518+
519+All screen updates are wrapped in **CSI 2026** (`\x1b[?2026h` to begin, `\x1b[?2026l` to end). The terminal holds display updates until the end marker, producing atomic flicker-free screen refreshes.
520+
521+### Differential Rendering
522+
523+Three strategies, selected automatically:
524+
525+| Strategy | When | Description |
526+| ------------------ | --------------- | ---------------------------------------------- |
527+| **Full + clear** | Terminal resize | Clear scrollback, re-render everything |
528+| **Full, no clear** | First render | Output everything to clean screen |
529+| **Differential** | Most renders | Compare buffers, only emit changed cells/lines |
530+
531+---
532+
533+## Reference Example: Agentic Chat UI
534+
535+```
536+┌──────────────────────────────────────────────┐
537+│ Agent Name model: gpt │
538+├──────────────────────────────────────────────┤
539+│ ▶ User: What files are in this dir? │
540+│ │
541+│ ▷ Agent: I'll check that for you. │
542+│ ┌──────────────────────────────┐ │
543+│ │ $ ls -la │ │
544+│ │ file1.ts │ │
545+│ │ file2.ts │ │
546+│ │ README.md │ │
547+│ └──────────────────────────────┘ │
548+│ Found 3 files. │
549+│ │
550+│ ▶ User: Delete file2.ts │
551+│ │
552+│ ▷ Agent: Running... ⠋ │
553+├──────────────────────────────────────────────┤
554+│ > type a message... [Send]│
555+└──────────────────────────────────────────────┘
556+```
557+
558+```ts
559+// State
560+let messages = [];
561+let input = "";
562+
563+function handleChange(value) {
564+ input = value;
565+ cel.render();
566+}
567+
568+function handleSend() {
569+ messages.push({ role: "user", content: input });
570+ input = "";
571+ cel.render();
572+}
573+
574+// UI
575+cel.viewport(() =>
576+ VStack(
577+ {
578+ height: "100%",
579+ onKeyPress: (key) => {
580+ if (key === "ctrl+q") process.exit();
581+ },
582+ },
583+ [
584+ // Header
585+ HStack({ height: 1, padding: { x: 1 } }, [
586+ Text("Agent Name", { bold: true }),
587+ VStack({ flex: 1 }),
588+ Text("model: gpt", { fgColor: "brightBlack" }),
589+ ]),
590+
591+ // Message history
592+ VStack(
593+ { flex: 1, overflow: "scroll", scrollbar: true, padding: { x: 1 } },
594+ [
595+ ...messages.map((msg) =>
596+ VStack({ gap: 0 }, [
597+ Text(`${msg.role === "user" ? "▶" : "▷"} ${msg.role}:`, {
598+ bold: msg.role === "user",
599+ fgColor: msg.role === "user" ? "blue" : "green",
600+ }),
601+ ...msg.blocks.map((block) => Text(` ${block.content}`)),
602+ ]),
603+ ),
604+ ],
605+ ),
606+
607+ // Input area
608+ HStack({ padding: { x: 1 }, gap: 1 }, [
609+ Text(">"),
610+ TextInput({
611+ flex: 1,
612+ maxHeight: 10,
613+ value: input,
614+ onChange: handleChange,
615+ placeholder: Text("type a message...", { fgColor: "brightBlack" }),
616+ onSubmit: handleSend,
617+ }),
618+ ]),
619+ ],
620+ ),
621+);
622+```
623+
624+---
625+
626+## Reference Example: Text Editor
627+
628+```
629+┌──────────────┬───────────────────────────────┐
630+│ files/ │ main.ts │
631+│ ▸ main.ts │ │
632+│ utils.ts │ import { foo } from "./utils";│
633+│ test.ts │ │
634+│ │ function main() { │
635+│ │ console.log(foo()); │
636+│ │ } │
637+│ │ │
638+│ │ │
639+├──────────────┴───────────────────────────────┤
640+│ main.ts Ln 3, Col 1 TypeScript ✓ │
641+└──────────────────────────────────────────────┘
642+```
643+
644+```ts
645+cel.viewport(() =>
646+ HStack(
647+ {
648+ height: "100%",
649+ onKeyPress: (key) => {
650+ if (key === "ctrl+q") process.exit();
651+ if (key === "ctrl+s") saveFile();
652+ },
653+ },
654+ [
655+ // Sidebar
656+ VStack(
657+ {
658+ width: 20,
659+ overflow: "scroll",
660+ scrollOffset: sidebarScroll,
661+ onScroll: (o) => {
662+ sidebarScroll = o;
663+ },
664+ },
665+ [
666+ Text("files/", { bold: true }),
667+ ...files.map((file) =>
668+ HStack(
669+ {
670+ onClick: () => selectFile(file),
671+ focusable: false,
672+ },
673+ [
674+ Text(
675+ `${file === activeFile ? "▸" : " "} ${file.name}`,
676+ file === activeFile
677+ ? { fgColor: "cyan", bgColor: "brightBlack" }
678+ : {},
679+ ),
680+ ],
681+ ),
682+ ),
683+ ],
684+ ),
685+
686+ // Main area
687+ VStack({ flex: 1 }, [
Cut short: this commit's diff is over 1000 lines.