Skip to content

Commit 0d433e3

Browse files
Gustav-SimonssonTheGreatAxios
authored andcommitted
refactor(tui): deepen comment compression in the theme module
1 parent 0223b97 commit 0d433e3

2 files changed

Lines changed: 27 additions & 28 deletions

File tree

‎src/tui/theme-contrast.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Light-palette legibility: every `corbitsLight` role holds >=4.5:1 against
3-
* the cream ground, and warm roles keep the lightness/hue structure the
4-
* palette header promises. Assertions compare computed values, never pinned
5-
* hex, so the palette can be re-tuned without rewriting the contract.
3+
* the cream ground, and warm roles separate by lightness first, hue and
4+
* saturation second. Assertions compare computed values, never pinned hex,
5+
* so the palette can be re-tuned without rewriting the contract.
66
*/
77

88
import { describe, expect, test } from "bun:test";
@@ -60,7 +60,7 @@ function hue(hex: string): number {
6060
return h;
6161
}
6262

63-
/** Every painted role: all Theme keys except the ground it sits on and its name. */
63+
/** Painted roles: every Theme key except the ground and the name. */
6464
function paintedRoles(theme: Theme): readonly [string, string][] {
6565
return (Object.entries(theme) as [string, string][]).filter(
6666
([key, value]) =>

‎src/tui/theme.ts‎

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
/**
2-
* Corbits terminal palette — the single source of truth for every color the
3-
* shell paints. Three rules the TUI depends on:
2+
* Corbits terminal palette — the single source of every color the shell
3+
* paints. Three rules the TUI depends on:
44
*
55
* 1. No neutral gray: dimmed text is a dimmed cream.
6-
* 2. Orange is spent once per screen — the session mark and pending human
7-
* decisions only (diff removals excepted).
6+
* 2. Orange is spent once per screen (diff removals excepted).
87
* 3. The chrome ramp is warm but never saturated: every bronze stays below
98
* the action orange's saturation, so full orange reads as an event.
109
*
1110
* Summit Blue is absent on purpose: cool reads foreign against cream, black
1211
* and orange chrome.
1312
*/
1413

15-
/** Palette values a theme supplies. Call sites paint through `UI`, never a
16-
* theme directly, so a second theme is a data change here. */
14+
/** Call sites paint through `UI`, never a theme directly, so a second
15+
* theme is a data change here. */
1716
export interface Theme {
1817
readonly name: string;
19-
/** Terminal ground. Foreground-only discipline means almost nothing fills it. */
18+
/** Terminal ground. Foreground-only discipline: almost nothing fills it. */
2019
readonly ground: string;
2120
/** All body text. Never white, never gray. */
2221
readonly text: string;
@@ -27,9 +26,9 @@ export interface Theme {
2726
/** The session mark and anything awaiting a human decision. */
2827
readonly action: string;
2928
readonly actionDim: string;
30-
/** Work in progress: ramps, tool verbs, machine output threaded into prose. */
29+
/** Work in progress: ramps, tool verbs, machine output in prose. */
3130
readonly inFlight: string;
32-
/** The tier above body text that still reads as machine: keywords, links, args. */
31+
/** Above body text but still machine: keywords, links, args. */
3332
readonly inFlightBright: string;
3433
/** Document structure: markdown headings and section rules. */
3534
readonly heading: string;
@@ -41,9 +40,9 @@ export interface Theme {
4140
readonly error: string;
4241
}
4342

44-
/** Brand hues, plus the warm ramp that replaced Summit Blue. Lowercase: the
45-
* renderer normalizes hex that way and tests compare a painted span's `fg`
46-
* against these constants directly. */
43+
/** Brand hues and the warm ramp. Lowercase: the renderer normalizes hex
44+
* that way and tests compare a painted span's `fg` against these constants
45+
* directly. */
4746
export const BRAND = {
4847
// Charcoal, not pure black: lifts the interface off the host terminal
4948
// and keeps `textFaint` readable against the cream.
@@ -84,14 +83,14 @@ export const corbitsDark: Theme = {
8483

8584
/**
8685
* Light companion to `corbitsDark`: the same roles on a warm light ground.
87-
* Data-only — no interface change, no new roles, no per-theme branches.
86+
* Data-only: no per-theme branches.
8887
*
89-
* Values follow relative luminance against the cream ground, not eye: body
90-
* text ~14:1 (dark ~15:1), every essential role >=4.5:1. The dark rules
91-
* carry over: action stays a one-per-screen decision marker (darkened;
92-
* Breakthrough Orange is ~2.3:1 on cream), dimmed text is dimmed ink, and
93-
* the bronze ramp is darkened. Caution moves to a muted plum so a bronze
94-
* warning does not collapse into the machine ramp on cream.
88+
* Values follow relative luminance, not eye: body text ~14:1 (dark ~15:1),
89+
* every essential role >=4.5:1. Dark rules carry over: action stays a
90+
* one-per-screen decision marker (darkened; Breakthrough Orange is ~2.3:1
91+
* on cream), dimmed text is dimmed ink, and the bronze ramp is darkened.
92+
* Caution moves to a muted plum so a bronze warning does not collapse into
93+
* the machine ramp on cream.
9594
*/
9695
export const corbitsLight: Theme = {
9796
name: "corbits-light",
@@ -123,9 +122,9 @@ export function resolveThemeName(name: string): Theme {
123122

124123
let activeTheme: Theme = corbitsDark;
125124

126-
/** Paint state derived from the palette registers a reset here; `setTheme`
127-
* runs every hook after swapping `UI`, so no stale palette survives a pin
128-
* change and call sites never reset caches themselves. */
125+
/** Palette-derived paint state registers a reset here; `setTheme` runs
126+
* every hook after swapping `UI`, so no stale palette survives a pin change
127+
* and call sites never reset caches themselves. */
129128
type ThemeCacheReset = () => void;
130129

131130
const themeCacheResets = new Set<ThemeCacheReset>();
@@ -148,6 +147,6 @@ export function setTheme(name: ThemeName | string): Theme {
148147
}
149148

150149
/** Semantic roles everything outside this file paints through. `setTheme`
151-
* copies the active palette onto this live binding; default dark, startup
152-
* detection picks the final theme before renderables are built. */
150+
* copies the active palette onto this live binding; startup detection picks
151+
* the final theme before renderables are built. */
153152
export const UI: Theme = { ...corbitsDark };

0 commit comments

Comments
 (0)