Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

feat(picker): soften the SUB fill and chip `$` at the same width

Jack Rudenkof4b428b4c8ce
diff --git a/ai-docs/architecture/theming.md b/ai-docs/architecture/theming.md
index 6be3b799..da84ad25 100644
--- a/ai-docs/architecture/theming.md
+++ b/ai-docs/architecture/theming.md
@@ -142,3 +142,30 @@ Two related decisions in the same card, both about meaning rather than colour:
Prices are printed in body ink. Green is this palette's "ok", the figures are
facts rather than verdicts, and the FREE badge two rows above already says free
in colour.
+
+## The band an OWNED FILL may occupy is 1.26:1 wide, so the second axis is chroma
+
+Every chip claudish paints is measured against BOTH `CONTRAST_REFERENCE` pages
+(`#FAFAD2`, `#1C1C1E`) at 3:1, and carries white `C.ink` at 4.5:1. Those three
+constraints pin the fill's relative luminance into `L ∈ [0.1351, 0.1833]` — the
+floor is 3:1 on near-black, the ceiling is white ink at 4.5:1 — which is a total
+range of 1.26:1. Two consequences, both of which have now cost a round each:
+
+- **A fill cannot be made "softer" by darkening it.** `C.pillKeyBg` was `#15803d`
+ and the owner's verdict as an AREA was "not as bright… softer". Anything
+ visibly darker drops under 3:1 on a dark terminal, which is the same defect the
+ hex before it (`#2d6e3e`, 2.76:1) shipped. What IS free is saturation:
+ `#3f7752` is the same lightness class at CIELAB C* 31.2 instead of 52.5, and
+ its page ratios move 4.70/3.39 → 4.95/3.22. Softness is chroma here.
+- **Two fills cannot be told apart by contrast ratio.** The picker's billing
+ column now fills every row — `SUB`/`local` positive, `$` neutral — so the
+ design depends on the two reading as different. Inside that band they can
+ differ in WCAG terms by almost nothing (`#3f7752` vs `#6b7280` is 1.09:1), so
+ the assertion is perceptual: ΔE76 ≥ 20 and the neutral at under half the
+ positive's chroma, in `theme-contrast.test.ts` alongside a CIELAB helper
+ written out independently for the same reason the luminance formula is.
+
+A column of identical fills still fuses — that rule is unchanged, and is why a
+scoped flat-rate roster draws its repeated `SUB` as text (`priceVaries`). What
+changed is the finding that ALTERNATING fills do not, provided the alternation is
+measured rather than assumed.
diff --git a/packages/cli/src/picker/ModelPicker.test.tsx b/packages/cli/src/picker/ModelPicker.test.tsx
index d162f53b..fa9c927f 100644
--- a/packages/cli/src/picker/ModelPicker.test.tsx
+++ b/packages/cli/src/picker/ModelPicker.test.tsx
@@ -36,6 +36,7 @@ import type { DescriptionIndex } from "../providers/model-descriptions.js";
import { C } from "../tui/theme.js";
import { ModelPicker } from "./ModelPicker.js";
import { MAX_DIALOG_ROWS } from "./layout.js";
+import { CHIP_FILL_CELLS } from "./rows.js";
import type { PickerDataSource, PickerProviderChoice } from "./PickerDataSource.js";
// ── a scriptable source ──────────────────────────────────────────────────────────
@@ -340,21 +341,19 @@ describe("the billing and prefix CHIPS", () => {
provider({ value: "or", label: "OpenRouter", shortcut: "or@", billing: "metered" }),
];
- test("NO COLUMN IS A BAND: the prefix and `$` carry no fill at all", async () => {
- // THE REJECTED PASS CHIPPED BOTH, and `captureCharFrame` was blind to the
- // result: every one of the 17 provider rows had a fill in the prefix cell and a
- // fill in the billing cell, with no blank row between them, so the two columns
- // fused into a solid grey vertical band and a solid green one with the labels
- // floating inside. The owner's verdict was "that is super ugly". A fill marks
- // the NOTABLE member of a column; a column where every row qualifies has none.
+ test("THE PREFIX COLUMN IS NOT A BAND: a routing identifier carries no fill", async () => {
+ // THE REJECTED PASS CHIPPED IT, and `captureCharFrame` was blind to the result:
+ // every one of the 17 provider rows had a fill in the prefix cell, with no blank
+ // row between them, so the column fused into a solid grey vertical band with the
+ // labels floating inside. The owner's verdict was "that is super ugly". A fill
+ // marks a STATE; a prefix is an identifier with no states, so there is nothing
+ // in that column for a fill to mark. (The billing cell beside it is the opposite
+ // case and is chipped — see the two tests below.)
const d = await draw(<ModelPicker source={fakeSource({ roster })} onDone={() => {}} />);
try {
await d.until(providerListPainted);
const f = d.recapture().frame;
- for (const token of ["cx@", "or@", "$"]) {
- // `includes`, not an exact match: unfilled cells that share a foreground
- // MERGE into one span, and `or@` sharing the muted hue with the `$` beside
- // it is itself evidence that neither of them is carrying a fill.
+ for (const token of ["cx@", "or@"]) {
const spans = spansOf(f).filter((sp) => sp.text.includes(token));
expect({ token, found: spans.length > 0 }).toEqual({ token, found: true });
for (const sp of spans) {
@@ -371,6 +370,32 @@ describe("the billing and prefix CHIPS", () => {
}
});
+ test("`$` IS A CHIP TOO, ON ITS OWN QUIETER FILL — and the two are not one band", async () => {
+ // The owner's instruction, verbatim: "make sub badge not as bright, make it
+ // softer and make $$$ the same width and badge as well". So the billing column
+ // carries a fill on every row, which is only legible as a two-tone column if the
+ // two fills are different — and `captureCharFrame` reads `$` and `SUB` the same
+ // whatever colour they are, so the assertion has to be on the spans.
+ const d = await draw(<ModelPicker source={fakeSource({ roster })} onDone={() => {}} />);
+ try {
+ await d.until(providerListPainted);
+ const f = d.recapture().frame;
+ const dollars = labelled(f, "$");
+ expect(dollars.length).toBeGreaterThan(0);
+ for (const chip of dollars) {
+ expect(bgOf(chip)).toBe(rgb(C.pillMutedBg));
+ // Never the positive family's fill, and never a row background: a `$` that
+ // picked up `pillKeyBg` would claim the route costs nothing.
+ expect(bgOf(chip)).not.toBe(rgb(C.pillKeyBg));
+ expect(bgOf(chip)).not.toBe(rgb(C.bgAlt));
+ expect(chip.fg.toInts().slice(0, 3).join()).toBe(rgb(C.ink));
+ }
+ expect(rgb(C.pillMutedBg)).not.toBe(rgb(C.pillKeyBg));
+ } finally {
+ d.destroy();
+ }
+ });
+
test("`SUB` IS PAINTED ON THE POSITIVE FILL, AND NEVER ON THE FAILURE ONE", async () => {
// THE DEFECT THIS PINS SHIPPED, AND `captureCharFrame` IS BLIND TO IT. The frame
// reads `SUB` either way; only the FILL says whether the user is being told
@@ -392,27 +417,44 @@ describe("the billing and prefix CHIPS", () => {
}
});
- test("a chip's FILL is exactly `label + 2` cells — the padding is OUTSIDE it", async () => {
- // THE MEASURED FAILURE THIS GUARDS: `label={padTo("SUB", 6)}` looks identical and
- // is not — the padding lands inside `bg`, and 24 chips padded that way fused into
- // one solid rectangle running down the panel with the labels floating in it. An
- // earlier pass in this very project reverted chips to coloured text three times
- // over it. The column is aligned by a plain filler span AFTER the chip, so the
- // fill stays a chip however wide the cell is.
+ test("EVERY STATUS CHIP IS THE SAME WIDTH, and the cell's surplus stays unfilled", async () => {
+ // ONE COLUMN, ONE FILL WIDTH — the owner asked for `$` and `SUB` at the same
+ // width, and a 1-cell fill beside a 5-cell one is what he was looking at. The
+ // label is centred INSIDE the fill, which is the one sanctioned place for that
+ // (`rows.tsx` header): a column wants straight edges, and the rule it bends was
+ // measured on a ROW of 24 identical chips.
+ //
+ // WHAT IS STILL FORBIDDEN, AND WHAT THIS STILL GUARDS: padding the fill out to
+ // the CELL. `label={padTo("SUB", 9)}` looks like the same thing and is not — the
+ // price cell is 9 columns and the billing cell 7, so a fill sized to the cell
+ // would paint two different widths and, in a column of one repeated word, one
+ // unbroken rectangle. The surplus is a plain filler span outside `bg`.
const d = await draw(<ModelPicker source={fakeSource({ roster })} onDone={() => {}} />);
try {
await d.until(providerListPainted);
const f = d.recapture().frame;
- const filled = spansOf(f).filter(
- (sp) => bgOf(sp) === rgb(C.pillKeyBg) || bgOf(sp) === rgb(C.chipKeycapBg)
+ const status = spansOf(f).filter(
+ (sp) => bgOf(sp) === rgb(C.pillKeyBg) || bgOf(sp) === rgb(C.pillMutedBg)
);
- expect(filled.length).toBeGreaterThan(0);
- for (const sp of filled) {
- expect({ text: sp.text, cells: sp.text.length }).toEqual({
- text: ` ${sp.text.trim()} `,
- cells: sp.text.trim().length + 2,
+ expect(status.length).toBeGreaterThan(0);
+ // Every fill in the column is CHIP_FILL_CELLS wide, whatever its label…
+ expect([...new Set(status.map((sp) => sp.text.length))]).toEqual([CHIP_FILL_CELLS]);
+ // …and the label is centred in it rather than padded to one side.
+ for (const sp of status) {
+ const label = sp.text.trim();
+ const slack = CHIP_FILL_CELLS - 2 - label.length;
+ const left = Math.floor(slack / 2);
+ expect({ text: sp.text }).toEqual({
+ text: `${" ".repeat(left + 1)}${label}${" ".repeat(slack - left + 1)}`,
});
}
+ // A footer keycap is a DIFFERENT object with the original contract: its fill is
+ // exactly `label + 2`, because a row of keys is not a column of states.
+ const caps = spansOf(f).filter((sp) => bgOf(sp) === rgb(C.chipKeycapBg));
+ expect(caps.length).toBeGreaterThan(0);
+ for (const sp of caps) {
+ expect({ text: sp.text }).toEqual({ text: ` ${sp.text.trim()} ` });
+ }
} finally {
d.destroy();
}
diff --git a/packages/cli/src/picker/layout.ts b/packages/cli/src/picker/layout.ts
index a0345f4e..78480721 100644
--- a/packages/cli/src/picker/layout.ts
+++ b/packages/cli/src/picker/layout.ts
@@ -286,16 +286,17 @@ const PROVIDER_GLYPH_CELLS = 2;
*/
const PROVIDER_SHORTCUT_CELLS = 9;
/**
- * `local` is the longest billing word: 5 + 2 for the fill it may carry.
+ * `local` is the longest billing word: 5 + 2 for the fill every state now carries.
*
- * SIZED FOR THE CHIP EVEN THOUGH ONLY TWO OF THE THREE STATES TAKE ONE. A cell that
- * fitted the word and not the fill would clip `local`'s chip by exactly two cells,
- * and Yoga claws those out of a NEIGHBOURING cell rather than reporting anything —
- * `widgets.tsx` measured the result as a 1-column stub of background under the next
- * column's first letter, which `captureCharFrame` cannot see. The metered `$` is
- * drawn as text in the same cell and simply leaves it mostly empty. No separator
- * column: the chip carries one padded space of its own on each side, and the text
- * form indents by one to line up with it.
+ * SIZED FOR THE CHIP, AND ALL THREE STATES TAKE ONE. A cell that fitted the word and
+ * not the fill would clip `local`'s chip by exactly two cells, and Yoga claws those
+ * out of a NEIGHBOURING cell rather than reporting anything — `widgets.tsx` measured
+ * the result as a 1-column stub of background under the next column's first letter,
+ * which `captureCharFrame` cannot see. `$` is the same chip with its label centred in
+ * the same fill, which is what makes the column's edges straight (`rows.tsx`'s
+ * `CHIP_FILL_CELLS`, derived from this same longest word — `row-semantics.test.ts`
+ * pins that this cell never sits under it). No separator column: the chip carries one
+ * padded space of its own on each side.
*/
const PROVIDER_BILLING_CELLS = 7;
/**
diff --git a/packages/cli/src/picker/row-semantics.test.ts b/packages/cli/src/picker/row-semantics.test.ts
index 2dcc53c0..c77be32b 100644
--- a/packages/cli/src/picker/row-semantics.test.ts
+++ b/packages/cli/src/picker/row-semantics.test.ts
@@ -13,7 +13,7 @@ import type { ModelInfo, PickerDiscoveryOutcome } from "../model-selector.js";
import type { DiscoveryFailure } from "../providers/model-discovery.js";
import { resetThemeModeForTests, setThemeMode } from "../theme/theme-mode.js";
import { C } from "../tui/theme.js";
-import { truncate } from "../tui/viz/text.js";
+import { displayWidth, truncate } from "../tui/viz/text.js";
import { tokens } from "../tui/viz/tokens.js";
import {
discoveryNoticeContent,
@@ -23,8 +23,10 @@ import {
} from "./DiscoveryNotice.js";
import { capabilityWords, descriptionLines, detailText, providerFactsText } from "./detail.js";
import { type PickerRow, dedupeByModelId, dedupeByProviderModel } from "./hooks/usePickerModels.js";
-import { providerColumn } from "./layout.js";
+import { deriveProviderRowLayout, deriveRowLayout, providerColumn } from "./layout.js";
import {
+ CHIP_COLUMN_LABELS,
+ CHIP_FILL_CELLS,
billingLabel,
priceChipBg,
priceFg,
@@ -131,6 +133,49 @@ describe("priceFg / priceChipBg", () => {
});
});
+describe("CHIP_FILL_CELLS — one fill width for the whole status column", () => {
+ test("it fits the LONGEST label the column can print, and is never typed out", () => {
+ // The owner asked for one width across the column and the obvious number is 5 —
+ // `SUB` plus a space each side — which clips `FREE` by one cell and `local` by
+ // two. Yoga does not report a clipped cell; it takes the columns out of a
+ // NEIGHBOURING one and leaves a stub of background under its first letter, which
+ // a character frame cannot see. So the width is derived, and a fifth state added
+ // to the vocabulary widens the column instead of overflowing it.
+ expect(CHIP_FILL_CELLS).toBe(7);
+ for (const label of CHIP_COLUMN_LABELS) {
+ expect({ label, fits: displayWidth(label) + 2 <= CHIP_FILL_CELLS }).toEqual({
+ label,
+ fits: true,
+ });
+ }
+ });
+
+ test("the VOCABULARY is exactly what the two chipped columns answer", () => {
+ // A label outside this list would be sized by a constant that never saw it.
+ const words = new Set<string>(CHIP_COLUMN_LABELS);
+ for (const mode of ["sub", "local", "metered"] as const) {
+ expect(words.has(billingLabel(mode).text)).toBe(true);
+ }
+ for (const price of ["FREE", "SUB", "local"]) {
+ expect(priceChipBg(price)).not.toBeNull();
+ expect(words.has(price)).toBe(true);
+ }
+ });
+
+ test("BOTH columns that print a chip are at least that wide, at 80 and at 145", () => {
+ // The fill is the one cell count a chip owns; the CELL it sits in is a budget in
+ // `layout.ts`, and the two numbers drifting apart is how a chip comes to overflow
+ // its column. 76 and 141 are the dialog's inner widths at 80x24 and 145x45.
+ for (const inner of [76, 141]) {
+ expect({
+ inner,
+ billing: deriveProviderRowLayout(inner).billing >= CHIP_FILL_CELLS,
+ price: deriveRowLayout(inner).price >= CHIP_FILL_CELLS,
+ }).toEqual({ inner, billing: true, price: true });
+ }
+ });
+});
+
describe("priceVaries — which view earns chips", () => {
test("a flat-rate or local provider FIXES the column, so it gets no chips", () => {
// `resolveProviderDisplayPrice` answers `SUB` for every row of a subscription
@@ -149,19 +194,25 @@ describe("priceVaries — which view earns chips", () => {
});
describe("billingLabel / readinessGlyph", () => {
- test("each billing mode has its own WORD; only the two positive ones have a FILL", () => {
+ test("each billing mode has its own WORD, and ALL THREE carry a fill", () => {
const tags = (["sub", "local", "metered"] as const).map(billingLabel);
expect(tags.map((t) => t.text)).toEqual(["SUB", "local", "$"]);
- // THE `null` IS THE WHOLE FIX. Filling `$` too would put a fill on every row of
- // the column — metered and flat-rate partition the roster — and 17 adjacent
- // fills fuse into one vertical band, which is what the owner rejected.
- expect(tags.map((t) => t.bg)).toEqual([C.pillKeyBg, C.pillKeyBg, null]);
+ // `$` USED TO BE `bg: null` — drawn as text, on the grounds that a fill on every
+ // row of the column is the banding defect. The owner read the shipped screen and
+ // asked for the opposite: "make $$$ the same width and badge as well", because a
+ // filled `SUB` beside a bare `$` is a column with no edges. What stops the column
+ // banding is now the DISTANCE between the two fills (ΔE76 36.5, pinned in
+ // `theme-contrast.test.ts`) rather than the absence of one of them.
+ expect(tags.map((t) => t.bg)).toEqual([C.pillKeyBg, C.pillKeyBg, C.pillMutedBg]);
+ expect(C.pillMutedBg).not.toBe(C.pillKeyBg);
});
test("METERED IS NEUTRAL and SUB IS POSITIVE — neither is a warning", () => {
// `$` states that the route bills per token. That is information about the
// route, not a caution about it: the number that matters is on the model row.
- expect(billingLabel("metered").fg).toBe(tokens.subtle);
+ // Neutral is now carried by the FILL (a near-grey) rather than by the ink, which
+ // is white on every chip we paint.
+ expect(billingLabel("metered").fg).toBe(C.ink);
for (const mode of ["sub", "local", "metered"] as const) {
const tag = billingLabel(mode);
for (const colour of [tag.bg, tag.fg]) {
@@ -173,11 +224,13 @@ describe("billingLabel / readinessGlyph", () => {
test("A FILLED CHIP CARRIES WHITE INK, in both palettes", () => {
// We choose the fill, so we own the ink: `pickInk` would answer white on the
- // dark palette and BLACK on the light one for the same `#15803d` chip — one chip
- // with two inks, and the worse ratio (4.02 vs 5.02) on the lighter page.
+ // dark palette and BLACK on the light one for the same chip — one chip with two
+ // inks, and the worse ratio (4.02 vs 5.02) on the lighter page.
for (const mode of ["dark", "light"] as const) {
setThemeMode(mode);
- expect(billingLabel("sub").fg).toBe(C.ink);
+ for (const billing of ["sub", "local", "metered"] as const) {
+ expect(billingLabel(billing).fg).toBe(C.ink);
+ }
expect(C.ink).toBe("#ffffff");
}
resetThemeModeForTests();
diff --git a/packages/cli/src/picker/rows.tsx b/packages/cli/src/picker/rows.tsx
index 5d85cb53..f2b44b35 100644
--- a/packages/cli/src/picker/rows.tsx
+++ b/packages/cli/src/picker/rows.tsx
@@ -40,19 +40,42 @@
* block, the inactive one is plain muted text with no background at all.
*
* `or@` / `zengo@` subtle TEXT a routing IDENTIFIER, never a status
- * `$` subtle TEXT metered — information, not a warning
+ * `$` chip on `C.pillMutedBg` metered — the unremarkable default
* `FREE` / `SUB` chip on `C.pillKeyBg` no per-token charge — the SAME claim
* `local` chip on `C.pillKeyBg` no charge either, by another mechanism
* `catalog` warn text NOT the live roster — `DiscoveryNotice`
* `N/A` dead text the catalog does not say
* selection accent + `C.bgHighlight`, and a `▶` so it survives greyscale
*
- * THE PREFIX AND `$` ARE THE TWO THAT LOST THEIR FILL, and the reason is the same
- * for both: a column whose EVERY row carries the token cannot use a fill to mark it.
- * Every provider has a prefix, and `$` plus `SUB`/`local` partition the roster, so a
- * fill on the metered half plus a fill on the flat-rate half is a fill on all of it.
- * Leaving `$` as muted text makes `SUB` alternate down the column, which is what
- * stops it banding and is also the honest reading: metered is the default state.
+ * THE PREFIX KEEPS NO FILL AND `$` GOT ONE BACK — and the two are not the same
+ * question. A routing prefix is an IDENTIFIER: every row has one, they have no
+ * states, and a column with no notable member has nothing for a fill to mark. The
+ * billing cell is a STATUS with a closed vocabulary, and the owner's instruction
+ * after reading the shipped screen was *"make $$$ the same width and badge as
+ * well"*: `SUB` filled beside a bare `$` left the column ragged, one chip floating
+ * over a word with a different left edge. So the cell is now ALWAYS a chip, in one
+ * of two fills.
+ *
+ * WHICH MEANS THE BANDING RISK IS REAL AND IS ANSWERED BY THE PAIR, NOT BY A GAP.
+ * `$` and `SUB`/`local` partition the roster, so this is a fill on all 17 rows —
+ * exactly the shape that fused into one grey band when the PREFIX was chipped. What
+ * failed there was that all 17 fills were the SAME colour; here they alternate, and
+ * the two fills are held apart by measurement rather than by hope: `C.pillKeyBg`
+ * `#3f7752` is a green at CIELAB C* 31.2, `C.pillMutedBg` `#6b7280` a near-grey at
+ * C* 8.6, ΔE76 36.5 — thirty-odd times the just-noticeable difference, and pinned by
+ * `theme-contrast.test.ts` so a future tweak that collapses them fails a test rather
+ * than a screenshot. Verified on `dialog6-*` at 80x24 and 145x45, dark and light.
+ *
+ * ONE FILL WIDTH FOR THE WHOLE COLUMN, WHICH IS THE ONE PLACE PADDING GOES INSIDE A
+ * FILL. `aesthetics-and-color.md` forbids padding inside the label because 24 `UP`
+ * chips in a ROW fused into a rectangle; that rule is about a row of identical
+ * chips, and this is a single column whose whole point is a straight left and right
+ * edge. So `CHIP_FILL_CELLS` is derived from the LONGEST label the column can ever
+ * print (`local`, 5, + 2) and every chip paints exactly that, label centred inside —
+ * a hardcoded 5 would have clipped `local` and `FREE` by the two cells Yoga then
+ * steals from a neighbouring cell. Both columns that print these tokens use the same
+ * number, so `$`, `SUB`, `FREE` and `local` line up in the provider list and in the
+ * model list alike.
*
* `SUB` WAS `tokens.warn` UNTIL THIS PASS, AND THAT WAS A ONE-COLOUR-ONE-MEANING
* VIOLATION IN THE SHIPPED BUILD, not in a prototype. `warn` is `C.orange` —
@@ -102,6 +125,28 @@ import { GAPS, type RowLayout, deriveProviderRowLayout } from "./layout.js";
/** Readiness, in `ProvidersContent.tsx:225`'s exact vocabulary. */
export type Readiness = "pending" | "ready" | "missing";
+/**
+ * EVERY LABEL A CHIPPED STATUS CELL CAN EVER PRINT, in either of the two columns
+ * that print them — the provider list's billing cell and the model list's price
+ * cell. The list is the vocabulary, not a sample of it: `billingLabel` and
+ * `priceChipBg` between them answer exactly these four words and nothing else.
+ */
+export const CHIP_COLUMN_LABELS = ["$", "SUB", "FREE", "local"] as const;
+
+/**
+ * The fill EVERY chip in a status column paints, in cells.
+ *
+ * DERIVED, NEVER TYPED OUT. The owner asked for one width across the column, and the
+ * natural-looking number is 5 — `SUB` plus a space each side — which would clip
+ * `FREE` and `local` by one and two cells. Yoga does not report a clipped cell: it
+ * claws the columns out of a NEIGHBOURING cell and paints a stub of background under
+ * its first letter, which `captureCharFrame` cannot see (`widgets.tsx` measured it).
+ * So the width comes from the longest label the column can print, and a fifth state
+ * added to `CHIP_COLUMN_LABELS` widens the column instead of overflowing it.
+ */
+export const CHIP_FILL_CELLS =
+ Math.max(...CHIP_COLUMN_LABELS.map((label) => displayWidth(label))) + 2;
+
/** Where a list came from — the one value that drives every provenance encoding. */
export type ListOrigin = "roster" | "catalog";
@@ -130,7 +175,7 @@ export function priceLabel(display: string, billing: BillingMode): string {
*
* A NEON FOREGROUND IS NOT A FILL. `tokens.success` is `C.green`, `#39ff14`, and
* the skill is explicit that a colour tuned to read as text is harsh as a solid
- * block. `C.pillKeyBg` (`#15803d`) is this repo's already contrast-tuned muted
+ * block. `C.pillKeyBg` (`#3f7752`) is this repo's already contrast-tuned muted
* green, shared verbatim by both palettes and measured against BOTH reference pages
* (`theme-contrast.test.ts`) — and it is ALREADY the `FREE` chip on the session
* summary card (`session-summary.ts:176`), so this is the same object, not a second
@@ -178,37 +223,44 @@ export function readinessGlyph(r: Readiness): { glyph: string; fg: string } {
/**
* The provider view's billing token — the vocabulary a model row prices with.
*
- * `bg === null` MEANS "DRAW ME AS TEXT", and only `$` takes it. Metered is the
- * DEFAULT state of a route: `$` says the route bills per token, which is a fact
- * about it rather than a caution about it, and the number that matters is on the
- * model row. Filling it too would put a fill on every row of the column and fuse
- * the two halves into one band — the defect the file header describes.
+ * ALL THREE ARE CHIPS, AT ONE WIDTH, AND THE FILL IS THE ONLY THING THAT DIFFERS.
+ * `$` used to be drawn as muted text on the grounds that a fill on every row of the
+ * column is the banding defect; what the owner saw on the shipped screen was the
+ * other half of that trade — a 5-cell green chip beside a 1-cell word, so the column
+ * had no edges. Two fills that are 36.5 ΔE apart alternate visibly, which a single
+ * fill on every row could not. `C.pillMutedBg` is the quiet one deliberately:
+ * metered is what a route IS by default, not a caution about it, and the number that
+ * matters is on the model row.
+ *
+ * The ink is `C.ink` on both — we chose both fills, so we own both inks, and neither
+ * should change with the user's palette.
*/
-export function billingLabel(mode: BillingMode): { text: string; fg: string; bg: string | null } {
+export function billingLabel(mode: BillingMode): { text: string; fg: string; bg: string } {
if (mode === "sub") return { text: "SUB", fg: C.ink, bg: C.pillKeyBg };
if (mode === "local") return { text: "local", fg: C.ink, bg: C.pillKeyBg };
- return { text: "$", fg: tokens.subtle, bg: null };
+ return { text: "$", fg: C.ink, bg: C.pillMutedBg };
}
const SPACES = " ";
const gap = (n: number): string => SPACES.slice(0, Math.max(0, n));
/**
- * A chip that has to sit inside a fixed COLUMN, with the padding OUTSIDE the fill.
+ * A chip that has to sit inside a fixed COLUMN, at the column's ONE fill width.
*
- * `BadgeSpan` already pads outside (`badgePad`), which is the rule the skill states
- * verbatim and the reason an earlier pass in this file kept reverting chips to
- * coloured text. This adds only what a CELL needs and a chip does not:
+ * Two kinds of padding meet here and only one of them is inside the fill:
*
- * · it fits the LABEL to the column before the fill is drawn — `width - 2`,
- * because the fill is `displayWidth(label) + 2` and a column sized to the label
- * overflows by exactly those two cells, which Yoga then claws out of a
- * neighbouring cell (`widgets.tsx` measured a 1-column stub of background under
- * the next column’s first letter, invisible to `captureCharFrame`);
- * · it right-aligns by emitting the filler BEFORE the chip, since `badgePad` can
- * only pad after it;
- * · and it declines to draw below three columns, where a chip could only ever be
- * part of a fill.
+ * · the CELL's surplus — whatever the column has beyond `CHIP_FILL_CELLS` — is
+ * plain, unfilled space, emitted before the chip when the cell right-aligns
+ * (`badgePad` can only pad after it) and by `badgePad` when it left-aligns.
+ * This is the skill's rule and it is kept.
+ * · the LABEL's surplus — `local` is 5 cells and `$` is 1 — is centred INSIDE the
+ * fill, which is the sanctioned exception (file header). It is what makes one
+ * straight-edged column out of four labels of different lengths, and a column is
+ * not the row of 24 identical chips the rule was measured on.
+ *
+ * Below `CHIP_FILL_CELLS` the fill shrinks to the cell rather than overflow it, and
+ * below three columns it declines to draw at all — there a chip could only ever be
+ * part of a fill.
*/
function ChipCell({
label,
@@ -223,18 +275,22 @@ function ChipCell({
}): ReactNode {
const cells = Math.max(0, Math.floor(width));
if (cells < 3 || label === "") return cells > 0 ? <span>{gap(cells)}</span> : null;
- const fitted = truncate(label, cells - 2);
- const lead = align === "right" ? Math.max(0, cells - displayWidth(fitted) - 2) : 0;
+ const fill = Math.min(cells, CHIP_FILL_CELLS);
+ const fitted = truncate(label, fill - 2);
+ const slack = Math.max(0, fill - 2 - displayWidth(fitted));
+ const left = Math.floor(slack / 2);
+ const centred = `${gap(left)}${fitted}${gap(slack - left)}`;
+ const lead = align === "right" ? Math.max(0, cells - fill) : 0;
return (
<>
{lead > 0 ? <span>{gap(lead)}</span> : null}
{/* `fg={C.ink}` — WHITE, not `pickInk`'s answer. We chose this fill, so we own
both sides of it and its ink should not change with the user's palette:
- MEASURED on `#15803d`, `pickInk` returns white on the dark palette and
- BLACK on the light one, which is the same chip wearing two inks and the
- worse ratio (4.02 vs 5.02) on the page more likely to be squinted at. */}
+ MEASURED on the old `#15803d`, `pickInk` returned white on the dark palette
+ and BLACK on the light one — the same chip wearing two inks, and the worse
+ ratio (4.02 vs 5.02) on the page more likely to be squinted at. */}
<BadgeSpan
- label={fitted}
+ label={centred}
bg={bg}
fg={C.ink}
{...(align === "right" ? {} : { width: cells })}
@@ -243,20 +299,6 @@ function ChipCell({
);
}
-/**
- * The same CELL, drawn as plain coloured text — the form a column uses when every
- * row would otherwise carry a fill.
- *
- * The label is indented by one so it lands under a chip's first letter rather than
- * under the chip's own padding, which is what keeps `$` aligned with `SUB` in the
- * column above and below it.
- */
-function TextCell({ label, fg, width }: { label: string; fg: string; width: number }): ReactNode {
- const cells = Math.max(0, Math.floor(width));
- if (cells === 0) return null;
- return <span fg={fg}>{padTo(truncate(` ${label}`, cells), cells)}</span>;
-}
-
/**
* The column header. It exists so the four fixed cells are NAMED rather than
* guessed at, which is the cheapest possible answer to "what is happening here":
@@ -450,11 +492,11 @@ export function ProviderRow({
word was "super ugly". A fill marks the notable member of a column; here
there is no notable member, only a name. */}
<span fg={tokens.subtle}>{padTo(truncate(shortcut, L.shortcut), L.shortcut)}</span>
- {bill.bg === null ? (
- <TextCell label={bill.text} fg={bill.fg} width={L.billing} />
- ) : (
- <ChipCell label={bill.text} bg={bill.bg} width={L.billing} />
- )}
+ {/* BOTH STATES ARE CHIPS AND BOTH ARE `CHIP_FILL_CELLS` WIDE — the owner's
+ "make $$$ the same width and badge as well". What keeps the column from
+ reading as one band is the distance between the two fills, not a gap:
+ `theme-contrast.test.ts` pins it. */}
+ <ChipCell label={bill.text} bg={bill.bg} width={L.billing} />
<span fg={readiness === "missing" ? tokens.dead : tokens.subtle}>
{padStartTo(truncate(tail, L.tail), L.tail)}
</span>
diff --git a/packages/cli/src/tui/theme-contrast.test.ts b/packages/cli/src/tui/theme-contrast.test.ts
index 427a5c43..50004adc 100644
--- a/packages/cli/src/tui/theme-contrast.test.ts
+++ b/packages/cli/src/tui/theme-contrast.test.ts
@@ -30,6 +30,43 @@ function contrastRatio(first: string, second: string): number {
return (high! + 0.05) / (low! + 0.05);
}
+/**
+ * CIELAB, for the one question WCAG cannot answer.
+ *
+ * A contrast ratio is a function of LUMINANCE alone, so two fills of the same
+ * lightness and wildly different hue score 1.0:1 against each other — indistinguishable
+ * by that measure and obviously different to a reader. The picker's status column
+ * needs exactly that distinction (a green chip alternating with a grey one), and the
+ * luminance band an owned fill may occupy is too narrow to carry it, so the assertion
+ * has to be perceptual. Written out here rather than imported for the same reason the
+ * luminance formula is: the palette must not be able to agree with a broken helper.
+ */
+function lab(hex: string): [number, number, number] {
+ const [red, green, blue] = channels(hex).map((channel) => {
+ const value = channel / 255;
+ return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
+ }) as [number, number, number];
+ const x = (0.4124 * red + 0.3576 * green + 0.1805 * blue) / 0.95047;
+ const y = 0.2126 * red + 0.7152 * green + 0.0722 * blue;
+ const z = (0.0193 * red + 0.1192 * green + 0.9505 * blue) / 1.08883;
+ const f = (t: number): number => (t > 216 / 24389 ? Math.cbrt(t) : (841 / 108) * t + 4 / 29);
+ const [fx, fy, fz] = [f(x), f(y), f(z)];
+ return [116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)];
+}
+
+/** How LOUD a colour is — zero for any grey, ~52 for the green this fill replaced. */
+function chroma(hex: string): number {
+ const [, a, b] = lab(hex);
+ return Math.hypot(a, b);
+}
+
+/** CIE76 perceptual distance. ~2.3 is a just-noticeable difference. */
+function deltaE76(first: string, second: string): number {
+ const [l1, a1, b1] = lab(first);
+ const [l2, a2, b2] = lab(second);
+ return Math.hypot(l1 - l2, a1 - a2, b1 - b2);
+}
+
resetThemeModeForTests();
const INITIAL_DARK_PALETTE: TuiPalette = { ...C };
@@ -62,9 +99,12 @@ describe("light TUI palette contrast", () => {
});
}
- const ownedFills = ["pillKeyBg", "pillOauthBg", "tabActiveBg"] as const satisfies ReadonlyArray<
- keyof TuiPalette
- >;
+ const ownedFills = [
+ "pillKeyBg",
+ "pillMutedBg",
+ "pillOauthBg",
+ "tabActiveBg",
+ ] as const satisfies ReadonlyArray<keyof TuiPalette>;
for (const fill of ownedFills) {
it(`keeps ink legible on ${fill}`, () => {
@@ -158,6 +198,7 @@ describe("light TUI palette contrast", () => {
describe("owned chip fills clear 3:1 on BOTH reference terminals", () => {
const chipFills = [
"pillKeyBg", // FREE / SUB / local — the positive family
+ "pillMutedBg", // the picker's metered `$` — the quiet half of the same column
"pillOauthBg", // oauth pills in the config TUI's AUTH column
"chipKeycapBg", // footer keycaps
"tabActiveBg", // the active tab pill
@@ -187,7 +228,7 @@ describe("owned chip fills clear 3:1 on BOTH reference terminals", () => {
// ink on it, and `tabActiveBg` carries its own `tabActiveFg` rather than `C.ink`.
for (const mode of ["light", "dark"] as const) {
setThemeMode(mode);
- for (const fill of ["pillKeyBg", "pillOauthBg", "chipKeycapBg"] as const) {
+ for (const fill of ["pillKeyBg", "pillMutedBg", "pillOauthBg", "chipKeycapBg"] as const) {
expect({ mode, fill, ok: contrastRatio(C.ink, C[fill]) >= 4.5 }).toEqual({
mode,
fill,
@@ -209,6 +250,51 @@ describe("owned chip fills clear 3:1 on BOTH reference terminals", () => {
}
});
+ it("HOLDS THE TWO HALVES OF THE STATUS COLUMN APART — the banding gate", () => {
+ // The picker's billing column now carries a fill on EVERY row: `SUB`/`local` on
+ // `pillKeyBg`, `$` on `pillMutedBg`. That is the shape that fused into one solid
+ // vertical band when the prefix column was chipped — and what failed there was
+ // that all 17 fills were the SAME colour. Here they alternate, so the whole
+ // design rests on these two being visibly different fills.
+ //
+ // THE AXIS IS CHROMA, NOT LUMINANCE, AND THAT IS FORCED. Every owned fill must
+ // sit in L 0.1351…0.1833 (3:1 on near-black below, white ink at 4.5:1 above), a
+ // band only 1.26:1 wide — so two fills can differ in brightness by almost
+ // nothing. MEASURED: `#3f7752` is C* 31.2 and `#6b7280` is C* 8.6, ΔE76 36.5
+ // apart, where ~2.3 is a just-noticeable difference. The floor below is 20, well
+ // under the measured value and far above a tweak that would collapse them.
+ for (const mode of ["light", "dark"] as const) {
+ setThemeMode(mode);
+ expect({
+ mode,
+ distinct: C.pillKeyBg !== C.pillMutedBg,
+ deltaE: deltaE76(C.pillKeyBg, C.pillMutedBg) >= 20,
+ // And the METERED one is the QUIET one: a near-grey beside a green. If this
+ // inverts, the column is telling the reader that the default state is the
+ // notable one.
+ quieter: chroma(C.pillMutedBg) < chroma(C.pillKeyBg) / 2,
+ }).toEqual({ mode, distinct: true, deltaE: true, quieter: true });
+ }
+ });
+
+ it("KEEPS THE POSITIVE FILL SOFTER THAN THE TEXT-GRADE GREEN IT CAME FROM", () => {
+ // `pillKeyBg` was `#15803d` — claudeup's `success`, and also this palette's light
+ // `green`, which is a TEXT accent held to 4.5:1 on white. The owner's verdict on
+ // it as an AREA was "make sub badge not as bright, make it softer". Softness is
+ // chroma: C* 52.5 → 31.2, with the page ratios held (4.70/3.39 → 4.95/3.22). The
+ // pin is the comparison, not the hex — a future green may be softer still, but it
+ // may not climb back to a foreground's saturation.
+ for (const mode of ["light", "dark"] as const) {
+ setThemeMode(mode);
+ expect({ mode, softer: chroma(C.pillKeyBg) < chroma("#15803d") }).toEqual({
+ mode,
+ softer: true,
+ });
+ // A fill is never the neon/page-text green of its own palette either.
+ expect(C.pillKeyBg).not.toBe(C.green);
+ }
+ });
+
it("holds the POSITIVE family apart from the FAILURE hue", () => {
// `SUB` shipped in `tokens.warn`, the hue this app spends on failure, under a
// label that means the opposite of a failure. Three reviewers read it as correct,
diff --git a/packages/cli/src/tui/theme.ts b/packages/cli/src/tui/theme.ts
index b2c60b08..7c5513b1 100644
--- a/packages/cli/src/tui/theme.ts
+++ b/packages/cli/src/tui/theme.ts
@@ -57,6 +57,17 @@ export interface TuiPalette {
tabInactiveFg: string;
pillKeyBg: string;
pillOauthBg: string;
+ /**
+ * The QUIET half of a two-tone chip column — the picker's metered `$`.
+ *
+ * A second fill exists because a status column with one fill and one bare word is
+ * a ragged column, and the owner asked for both states chipped at one width. The
+ * two then have to be told apart by the fill alone, and the only axis left inside
+ * the 3:1 band is CHROMA: `pillKeyBg` is a green at C* 31.2, this is a near-grey
+ * at C* 8.6, ΔE76 36.5 apart. Grey is also the honest reading — metered is the
+ * unremarkable default, not a claim.
+ */
+ pillMutedBg: string;
/** Footer KEYCAP fill. Vivid, white ink, the same hex in both palettes. */
chipKeycapBg: string;
chipKeyBg: string;
@@ -116,15 +127,29 @@ const DARK: TuiPalette = {
// standard `green` / `cyan` are neon-bright and cause eye strain as a solid fill,
// so these are lower-saturation forest/teal versions carrying white ink.
//
- // RAISED FROM `#2d6e3e` / `#1f6d75` TO THE MEASURED PAIR. The old forest green
+ // RAISED FROM `#2d6e3e` / `#1f6d75` TO A MEASURED SET. The old forest green
// cleared 5.77:1 on a cream page and only 2.76:1 on a near-black one — under the
// 3:1 a UI component needs — so a `SUB` chip on a dark terminal was a fill that
- // barely separated from the page it sat on. These two clear 3:1 against BOTH
- // reference backgrounds (4.70/3.39 and 5.02/3.18) and keep white ink at 5.0+.
- // Same hexes as claudeup's `success` / `info`, and shared verbatim by both
- // palettes: a fill measured against both pages needs no per-theme variant.
- pillKeyBg: "#15803d", // forest green; white ink reads cleanly on both pages
+ // barely separated from the page it sat on. All three clear 3:1 against BOTH
+ // reference backgrounds and keep white ink at 4.8+, and all three are shared
+ // verbatim by both palettes: a fill measured against both pages needs no
+ // per-theme variant.
+ //
+ // `pillKeyBg` WAS `#15803d` (claudeup's `success`) AND WAS TOO BRIGHT AS A FILL —
+ // the owner's words, "make sub badge not as bright, make it softer". Softness here
+ // is CHROMA, not luminance: the band a fill may occupy is L 0.1351…0.1833 (3:1 on
+ // near-black sets the floor, white ink at 4.5:1 sets the ceiling), which is only
+ // 1.26:1 wide, so a fill cannot be meaningfully darkened without failing one side.
+ // MEASURED with `validation/chip-fill-shortlist.ts`: `#15803d` is C* 52.5 at
+ // L* 46.9 and `#3f7752` is C* 31.2 at L* 45.4 — 41% less chroma and slightly
+ // darker — while the page ratios IMPROVE on cream and hold on near-black
+ // (4.70/3.39 → 4.95/3.22). Contrast was not traded for softness.
+ pillKeyBg: "#3f7752", // softened forest green; white ink 5.29:1
pillOauthBg: "#0e7490", // muted teal; white ink reads cleanly on both pages
+ // Tailwind's `gray-500`, chosen for what it is NOT: it carries almost no hue
+ // (C* 8.6), so beside `pillKeyBg` it reads as the absence of a claim rather than
+ // as a second claim. 4.53/3.52 on the two pages, white ink 4.83:1.
+ pillMutedBg: "#6b7280",
// A KEYCAP IS A VIVID BLOCK WITH WHITE INK, in both palettes and at the same hex.
// Neutral grey was measured and rejected twice: `#3a3a3a` is 1.50:1 on a dark page
// and `#9ca3af` 2.38:1 on a light one, so whichever way it is tuned the chip melts
@@ -177,10 +202,17 @@ const LIGHT: TuiPalette = {
tabActiveFg: "#ffffff",
tabInactiveFg: "#374151",
- // The forest/teal pills and the keycap are mid-lightness fills with white ink —
+ // The green/teal/grey pills and the keycap are mid-lightness fills with white ink —
// they clear 3:1 on BOTH reference pages, so they are shared verbatim with DARK.
- pillKeyBg: "#15803d",
+ // `pillKeyBg` is deliberately NO LONGER the same hex as `green`: `green` is a page
+ // TEXT accent held to 4.5:1 on white, and this is an area fill held to 3:1 on two
+ // pages with white ink on top. One number cannot serve both tests.
+ pillKeyBg: "#3f7752",
pillOauthBg: "#0e7490",
+ // Same hex as this palette's `dim`, and that is a coincidence rather than a shared
+ // meaning: `dim` is page text on white, this is an area fill carrying white ink.
+ // They are measured against different references and may diverge.
+ pillMutedBg: "#6b7280",
chipKeycapBg: "#9333ea",
// The config TUI's TWO-TONE footer chip (`Footer.tsx`), and no longer the