Skip to content

Adopt shadcn, rebuild the overview, and stop polling - #15

Merged
fylorn merged 38 commits into
mainfrom
dev
Sep 16, 2026
Merged

fylorn merged 38 commits into
mainfrom
dev

Conversation

@fylorn

@fylorn fylorn commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

38 commits. It started as a component-library adoption and grew two more halves; squashing it whole because every later part depends on the theming done first.

Adopt shadcn — themed to this app, not to its defaults

Every hand-drawn control is gone: checkboxes, ~60 buttons, inputs, dropdowns, tables, overlays, the tab bar, the source list, banners and chips. Icons come from lucide, charts from recharts.

The theme layer carries this app's own metrics rather than the library's: a four-step type scale at 13px body, macOS row heights, and colours taken from tokens instead of the palette. Four self-inflicted regressions were found and fixed along the way — every borderless border drawing in the text colour (Tailwind v4's currentColor default), line heights written as a ratio in the wrong place, a collapsing rail that centred its icon one frame early, and a focused panel painting a blue edge.

Interactions were reviewed too, not only widgets: one place for errors, the request drawer became a Sheet, a draggable split, and dropdowns deliberately returned to native selects.

The overview is a different page

It was a stack of equal-weight strips led by a money figure. It now leads with three headline numbers — tokens, cost, requests — over one 200px chart stacked by model, with dense hairline-separated rows beneath: model ranking, cache, latency spreads, security.

Substantive changes behind that:

  • Usage is the headline. The page is called 用量概览 and had no token count above the fold. "Input" also had the wrong denominator: input_tokens is the part that missed cache, a small fraction of what was actually sent under a healthy hit rate.
  • Cache reports a rate, not a running total. A cumulative "saved so far" only climbs; it cannot say whether caching is working. The net figure also now subtracts the write premium (core side) and can read as an overspend.
  • A live mode. Two minutes at one second per bucket, fed off the event stream — no query, no polling.
  • Layout holds still. Blocks may change height because there is more data; they may not because a qualifier is present or absent.
  • Colour means something: --chart-1..5 were five greys with zero chroma, which is why the page read washed out.

Nothing polls

Six timers removed. The heaviest was invisible: the menu bar woke every second and made two control-plane round trips, guarded against repainting but never against fetching. Status, overview, supervisor state, sessions, clients and a relative-time clock all followed. What they watched for now announces itself — several of those announcements are new events in core (ThinkWatchProject/ThinkWatch-Core#17, #18, #19, #20, #21).

Idle cost, window open, measured over 45 seconds: 0.09s of CPU.

Also

  • The guard mode buttons never once worked — they sent an op the protocol dropped some time ago. Writes now go through one wrapper with tests asserting nobody bypasses it.
  • The traffic table answers model, tokens and cost; path and size moved to the drawer where they already were.
  • Developer-facing surfaces removed, and a colloquialism sweep with tests holding the line.
  • A missing core binary no longer aborts startup with no window at all.

Gates

pnpm typecheck, pnpm test (62), pnpm build, cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test. Verified throughout against a running gateway.

🤖 Generated with Claude Code

fylorn and others added 13 commits September 15, 2026 10:15
…aults

Groundwork only — no surface changes yet. Adds the `@/*` alias, the
`components.json` the CLI and the agent skill both read, `cn()`, and the
theme layer. One component (`button`) comes along as the proof.

**The theme layer is the whole point.** shadcn components read semantic
tokens, so the tokens decide whether they look like a macOS client or like
the enterprise web console. Taking the defaults gives the latter: 10px
radii, 14px body, 40px rows. These map the tokens onto metrics this app
already uses, and half of them already agreed — `muted-foreground` is
neutral-500 (used 185 times here) and `primary` is neutral-900 (what the
primary button already was). The rest were measured, not guessed:

* `--radius` is 8px, not the default 10px. shadcn's ladder is 0.6/0.8/1/1.4,
  so `md` lands on 6.4px and `lg` on 8px — near enough to Tailwind's own 6
  and 8 that the 51 `rounded-md` and 21 `rounded-lg` already in the app do
  not shift. The default would have fattened every corner in the app.
* `--border` is the table rule (neutral-200/800, 43 uses) and `--input` is
  the control edge (neutral-300/700, 68 uses). Separating those two is what
  shadcn has both tokens for.
* `--text-sm` and `--text-xs` are bound to 13px and 11px — this app's body
  and label sizes. Unbound, components drag in Tailwind's 14px and 12px,
  two sizes the scale does not have, and a page ends up with six.

Two defaults are deliberately not taken. Dark mode stays in
`prefers-color-scheme` instead of a `.dark` class: the class form needs a
script that runs before first paint, and it would also silently kill the
200-odd `dark:` utilities already in this app. And the Geist webfont is
skipped — the system font is most of why this reads as a desktop app.

The type-scale test now exempts `src/ui/`, where the vendored components
live, and a new test asserts the `--text-sm`/`--text-xs` binding that makes
the exemption safe. Without it `text-sm` would quietly drift back to 14px,
from inside a component, with no line of code looking wrong.

The skill's 328KB of vendored text is git-ignored; `skills-lock.json` is
kept, so `skills add` reproduces it — the node_modules/lockfile split.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
**Checkboxes.** All five, plus `Field`/`FieldLabel`/`FieldDescription`
around them — that is the composition the checkbox is drawn for; its own
styles reference `group-has/field-label`. It also restores something a bare
Radix checkbox loses: a Radix checkbox is a `<button>`, and wrapping a
button in a `<label>` does not make the label text toggle it. `htmlFor`
does. The hand-rolled `tw-check` utility is gone; `FieldDescription` lands
on 13px muted, which is exactly what the description spans already were.

**Buttons.** 60 of the 94, mapped by what each one already was: filled →
default, bordered → outline, bare text → ghost, red → destructive at `xs`.
`sm` (28px) is the height the old `px-2.5 py-1` came out at, so that is the
default choice here; `size` and `variant` carry the look and `className`
keeps only layout, per the skill's rules.

The remaining 34 are not plain buttons: segmented option sets (ToggleGroup),
the source-list rail, and a few with computed classNames. They want their
own components and their own decisions.

Verified per button rather than by eye: a script walks the old and new
files in document order, pairs each `<button>` with its `<Button>`, and
checks the variant against the original className. Five disagreed. Four
were cancel actions sitting inside amber warning banners — ghost is right
inside a tinted panel, but the converter had kept their light-mode amber
text while dropping the `dark:` half, which would have put dark amber text
on a dark amber ground. The colours are gone entirely now; they inherit the
banner. The fifth was a findings row whose border is its shape, so it went
back to outline.

Regex on JSX broke three things along the way — a global `</button>`
replacement that crossed skipped tags, and a `>` insertion that cut two
arrow functions in half. Both were caught by the compiler and are fixed;
mentioned because the lesson is that the per-button check above is what the
diff cannot give you.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
21 inputs and all 10 selects. No native `<input type=text>` or `<select>`
left; `<datalist>` stays, since its input has to accept a model name nobody
has typed before and a combobox is a constrained picker, not a suggestion.

**Two components gained an `inline` size.** The upstream table edits six
fields per row in place: borderless until hovered, because six 32px
bordered controls per row stop reading as a table and start reading as a
form. That is a cva variant on `Input` and a `data-size` on `SelectTrigger`
— shadcn's own extension path — rather than a `className` override at a
dozen call sites, which would scatter the styling and fight the components'
own focus and invalid states.

**Radix `SelectItem` refuses an empty string**, and an empty string is
exactly what the config means by "field not written": "all clients",
"the default route", "decide automatically". So the display layer carries a
sentinel and converts back to `null` on write. It is U+2400 (␀) rather than
`__none__` because route and upstream names are the user's to choose and
they can type the latter.

`--text-base` is bound to 13px alongside `--text-sm`. `Input` ships
`text-base md:text-sm`, the trick that stops iOS zooming on focus; below
768px the unbound `text-base` would have been 16px, a size the scale does
not have.

Checked per element the same way as the buttons: walk old and new in
document order, pair them up, and assert the inline variant matches where
the original was borderless, that no layout class was dropped, and that
every `<option>` became a `<SelectItem>`. Two reported losses were false —
`w-full min-w-0` moved into the cva base.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Seven of them. Three already went through a hand-written `Dialog` wrapper;
the other four were raw `fixed inset-0` overlays, which is exactly the list
that wrapper's own doc comment named and never got around to converting.

Each of those four was missing the same five things: Esc does not close,
Tab walks off into the background, focus does not enter on open or return
to the trigger on close, and a screen reader has no idea a dialog appeared.
Every one is writable by hand, and four hand-written copies means several
are wrong.

`Tip` (46 call sites) and `RowMenu` (the traffic row's right-click menu)
stay as thin wrappers, now built entirely out of shadcn parts — no styling
of their own, just a `text` prop instead of a trigger/content pair and an
`items` array instead of a dozen tag pairs. That is composition, which the
skill asks for; expanding 46 tooltips into four lines each would bury the
JSX they sit in.

Two things fell out of the move:

* `DialogContent` requires a `DialogTitle` — that is the line a screen
  reader announces — so the shared shell in the client screens now takes
  the title as a prop instead of finding it somewhere in `children`.
* The `danger` prop is gone. It drew a red dot before the title, which was
  our own decoration; the confirm button carrying `variant="destructive"`
  says the same thing in the library's vocabulary.

macOS's filesystem is case-insensitive, so fetching `tooltip.tsx` and
`dialog.tsx` silently overwrote `Tooltip.tsx` and `Dialog.tsx`. TypeScript
caught it (TS1261, differs only in casing); the files are renamed properly
now and the wrappers live at `tip.tsx` and `row-menu.tsx`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… palette

**All 14 tables.** Density is tuned once in `table.tsx` rather than at the
call sites: shadcn ships a 40px header and 8px cells, which suits an admin
screen showing a dozen rows; the traffic table here is scanned, and four
fewer rows per screen is one more scroll every time. 32px headers and 6px
cells give the 26px rows these tables already had.

Two row-level components live outside any `<table>` — the sortable header
cell and the replay comparison row — so the region-scoped converter did not
see them. The header cell's button became a `Button`, which also got it an
`aria-sort` it never had.

**229 raw colour classes became semantic tokens.** `text-neutral-500` →
`text-muted-foreground`, `border-neutral-200/800` → `border-border`,
`border-neutral-300/700` → `border-input`. By construction the rendered
colour does not change: those tokens were defined from these exact values
in the first commit. What changes is that the theme is now real — one
variable moves every use of it, which is the whole point of the token
layer, and it is the skill's rule that components never carry raw values.

A further 41 `dark:` halves were left redundant by that and are removed.
Each was checked against what its token actually resolves to in dark;
two that disagreed are left alone rather than silently restyled.

One bug of my own, found on the way: I had copied light's
`--muted-foreground` into the dark block, so secondary text would have sat
at neutral-500 on a near-black ground. Every call site in this app writes
`dark:text-neutral-400`, and shadcn's own dark default is the same. Fixed
before the replacement ran, so nothing rendered at the wrong value.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
**Three segmented controls become `ToggleGroup`** (dialect probes, listen
mode, guard modes) and **the request drawer's tab bar becomes `Tabs`**,
which is what it always was — and which brings arrow-key movement between
tabs, something the hand-written version never had.

The listen picker used to tint the selected chip amber whenever the gateway
was bound past loopback. `ToggleGroup` styles selection uniformly, and that
tint was the only "this is reachable from the network" signal in the whole
control. Rather than override a colour on one item, the thing it was saying
now gets said by the component that exists for saying it: an `Alert` under
the picker, shown when `listen.exposed`.

**The source list is now `Sidebar` with `collapsible="icon"`.** Everything
macOS-specific about it survives as configuration rather than markup:

* Both widths override shadcn's defaults through the CSS variables it reads
  — 196px expanded (256 is a web console's sidebar; this one holds one
  column of short words) and 80px collapsed. That second number is not a
  taste call: the title bar is an overlay, the three traffic lights float
  on the content, and the rightmost one's edge lands near 71pt. Narrower
  than that and the sidebar's own border cuts through the green light. 80
  leaves it 9pt. Measure the lights before narrowing it.
* `data-tauri-drag-region` passes straight through. Without it the window
  cannot be moved at all, since an overlay title bar leaves nothing to grab.
* Open state stays in `localStorage` via the controlled `open` prop rather
  than the provider's cookie — this is a local app and no server reads it.

Two things about `Sidebar` were worth checking before committing to it
rather than after. It swaps itself for an off-canvas `Sheet` below 768px:
unreachable here, because the window's `min_inner_size` is 820. And its
built-in ⌘B would have collided with the existing ⌘⌥S, so the shortcut
stays ours by controlling the state.

Nine hand-written buttons remain, all with computed classNames. They are
next.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…rail

**Every line in the app was 4.5px too tall.** Tailwind writes its line
heights as `calc(<line-height in rem> / <font-size in rem>)`, and I copied
the shape while putting the *ratio* in the numerator: `calc(1.5 / 0.8125)`
is 1.85, so 13px text got a 24px line instead of 19.5px. Table rows went
from 33px to 37px, and nothing anywhere looked wrong — it just read as
roomy. They are plain numbers now, the same two the type scale already
states.

**The collapsed rail had three faults**, all from overriding the icon width
to 80px while the component still assumed its own 48px:

* The 32px button sat against the left edge with 24px of dead space beside
  it. It is 40px and centred now — measured, not eyeballed: icon centre 40,
  rail centre 40.
* `justify-center` centred *icon plus label*, pushing the icon off-centre,
  because the label was only clipped by `overflow-hidden`, not hidden. It is
  hidden in icon mode now.
* 16px icons in a 40px tile are lost; 20px in icon mode.

Traffic-light clearance re-measured after the change: the green light's
right edge lands at 72px against an 80px border, so the border still does
not cut through it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
**Tailwind v4 changed the default `border-color` to `currentColor`.** v3
used a grey. So every class that sets a border's width but not its colour —
`border-r` on the sidebar, `border-b` on every table row, the dashed empty
states — was drawing in the *text* colour: a bright grey line against a
near-black ground.

shadcn's preset carries a `@layer base` rule that puts it back, and I had
skipped that block when setting up the theme by hand. It belongs in the
stylesheet rather than in any component, because it is the document's
default. The sidebar then takes `border-sidebar-border` explicitly, which
is the slightly cooler hairline the rail has always used.

**The collapse animation jumped** because two of the properties it went
through cannot be interpolated. The collapsed button had a fixed width and
`mx-auto`: `auto` margins have no intermediate value, and a fixed width and
`w-full` are not a continuous pair, so the button changed size and position
in one frame instead of moving.

The button is now always `w-full`, and what narrows it is the group's
horizontal padding — 8px expanded, 20px collapsed, which leaves 40px of an
80px rail. Container width, padding and height are all interpolable lengths,
so the whole transition is continuous.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…lide back

The icon was jumping to the middle on the first frame and then sliding left
for the rest of the animation — it read as moving the wrong way, because it
was. `justify-center` applies the moment `data-collapsible` flips, while the
rail is still 196px wide, so the icon centred itself in a full-width button
and then had to travel left as the rail closed around it.

There is no centring step now. The icon stays at the left and its position
is the sum of two paddings: the group's, 8→20px, and the button's, 8→10px.
That puts its left edge at 16px expanded and 30px collapsed, which with a
20px icon lands its centre on 40 — the middle of an 80px rail. It arrives
there by travelling, not by being centred on one frame. Measured across the
transition, the icon moves 16 → 20 → 23 → 27 → 30 while the rail's centre
comes down 98 → 84 → 69 → 55 → 40: both monotone, meeting at the end.

The label no longer hides itself either — it is clipped by the narrowing
button, which is a natural wipe. It was only hidden in the first place
because it shifted a centred icon, and nothing is centred any more.

Icon size transitions too; 16→20px in one frame was a small pop of its own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
No `<button>`, `<input>`, `<select>`, `<table>` or hand-rolled overlay is
left in the app.

**25 buttons**, sorted by what their classNames were saying: underlined text
became `variant="link"`, the `×` next to each glob became a ghost icon
button, and "only failures" became a `Toggle`, which is what a filter chip
that stays pressed actually is. The three amber confirm buttons became
`destructive` where the action destroys something and `default` where it
just costs money.

**15 banners became `Alert`, and the chips became `Badge`.**

Both needed a colour the library does not ship. shadcn offers `destructive`
and nothing else, but this app has three things to say, not two: red is
"it failed", amber is "this costs money / this changes your config / this is
reachable from the network", and green is "it is running". Collapsing those
into one red would lose the distinction that makes the amber ones readable
at a glance. So `--warning` and `--success` join `--destructive` as tokens,
and `Alert` and `Badge` each get the matching variants — the same extension
path `Input` and `SelectTrigger` took earlier.

One duplicate fell out: the listen section was warning about being exposed
twice — the `Alert` added when the amber toggle tint went away, and an older
hand-written banner three sections below saying the same thing. They are one
`Alert` now, keeping the older one's tooltip about key checking being
mandatory in that state.

`Skeleton` is deliberately not adopted. The seven "loading…" lines are
sentences, not drawn components, and a skeleton is a different thing to say.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The last two hand-drawn things in the app.

**Twelve icons become lucide re-exports.** The original argument was "no
dependency for nine icons" — but `components.json` names lucide as the icon
library and the components already use it (the checkbox's tick, the select's
chevron, the sidebar trigger's panel), so the dependency was already there
and two drawing styles were sitting in one column at different stroke
weights. The file stays as a renaming layer: the names say what the app
means (route, gateway, upstream), not what the shape is (Split, Router,
Server), so swapping a glyph is one edit rather than a search across pages.

A test now holds the rule the file's comment used to state alone: no two
concepts may share a glyph. Route, gateway, client and upstream are the four
easy ones to confuse, and with the rail collapsed a mix-up costs you a page.
Re-exporting is one keystroke away from aliasing two names to the same icon,
and nothing about that is a type error.

**The charts become recharts, through shadcn's `ChartContainer`.** This one
costs: the bundle goes 858 KB → 1211 KB, 270 → 377 KB gzipped, because
recharts brings Redux, immer and d3 along. Measured before committing to it
rather than discovered after. What it buys is axes, ticks, spacing and hit
areas that hand-written SVG never quite gets right, and a palette that
follows the tokens.

One rule had to be carried across by hand. The old bar list wrote "4 条无价"
next to any row whose cost could not be fully computed; the first pass only
dimmed those bars, which says "this one is different" but not "four requests
are missing from it". The note is back, appended to the value label.

The file is `charts.tsx`, plural: `chart.tsx` is shadcn's, and on a
case-insensitive filesystem `Chart.tsx` overwrites it — which is exactly how
`Tooltip.tsx` and `Dialog.tsx` disappeared earlier.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A sweep for behaviour that was still hand-rolled where the library has the
real thing.

**Confirms become `AlertDialog`.** Deleting a key, deleting a route and
quitting were plain `Dialog`s. An alert dialog is a different element: it
announces as `alertdialog`, it will not close on a click outside, and its
Cancel and Action carry the dismissal — which is why the confirm button
could stop hand-rolling `setConfirmDelete(null)` before doing the work.

**Busy states become `Spinner`.** Twelve buttons swapped their own label
for "…中". That resizes the button under the cursor mid-click, and a screen
reader hears a new sentence rather than "busy" — `Spinner` carries
`role="status"`. The skill says this outright: Button has no `isPending`,
compose it.

**Four empty states become `Empty`.** They already had its exact shape: a
dashed box whose first line is what happened and whose second is what to do
next, which is `EmptyTitle` and `EmptyDescription`.

**The config history becomes `Collapsible`.** `{show && …}` renders the same
pixels but says nothing: no `aria-expanded` on the button, no
`aria-controls` pointing at what it opens.

**Autostart becomes a `Switch`.** A checkbox is for picking several out of a
set; this turns one system behaviour on and off, which on macOS is a switch
everywhere in System Settings.

**The shortcut in the rail tooltip becomes `Kbd`.** `TooltipContent` ships a
`has-data-[slot=kbd]` rule — the slot was already there.

Two of my own converters needed fixing on the way. The empty-state one
mismatched a closing tag in `AddUpstream` and swallowed the form below it
(caught by the compiler, reverted, done by hand), and the button one had
hard-coded its indentation again — 75 call sites realigned.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
**63 error paths become toasts.** Every screen used to hang its own error
next to its own form: six separate implementations of "haven't read the
config version yet", and the ones below the fold were never seen at all.
`EditableCell` and `SelectCell` even took an `onSaved(err)` callback whose
only job was to hand an error back up to whichever page rendered it — that
parameter is gone; they call `toast.error` where the failure happens.

`sonner.tsx` dropped `next-themes`. The copy reads the current theme from
`useTheme()`, which is the Next.js arrangement where the app owns light and
dark and stamps a class on the root. This app follows the system — the
stylesheet says so in its first comment — so there is no theme state to
read, `theme="system"` is its only correct value, and a dependency that
exists to return a constant is not worth having.

**The request drawer's floating half becomes a `Sheet`.** It has two shells
and one body: split view renders it as the right column, because tracing
means comparing one row against the next and a covering drawer hides the
list; a narrow window floats it. The floating half was a hand-written
`fixed inset-y-0 right-0` and was missing what all the other hand-written
overlays were missing — Esc, the focus trap, focus returning to the row.
`Sheet` owns that half; the embedded half is not its business, so the shell
branches and the body does not.

Its own close button now only renders in the embedded shell, since a Sheet
brings one.

Two bulk passes were reverted and redone by hand. Deleting error state
mechanically left `setErr(null)` calls with nothing to set and, in one file,
took a `const [nics]` line with them; the compiler caught every one, but a
regex that can delete the wrong line is not worth re-running. `Config.tsx`
was done by line number against a listing instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fylorn and others added 16 commits September 15, 2026 14:03
They sent `{ op: "set" }`. The patch protocol has `replace`, `append`,
`remove` and `clear` — never `set`. Every click since #3 was rejected by
core, and the rejection rendered in a corner of the page where it read as
nothing happening. It only surfaced now because errors moved to a toast.

**Why the compiler did not catch it.** `invoke()` takes
`Record<string, unknown>`, so `ops` was never checked against `PatchOp` at
any of the twelve call sites. They all go through `patchConfig()` now, whose
only job is to make that array's type real — and it immediately found a
second bug, in the client adoption path, which was passing a `configVersion`
that can still be null while core is starting. Creating the key would have
failed there while the adoption continued, leaving the client configured
with a key that does not exist.

Two tests hold the seam: nothing may call `invoke("patch_config")` directly,
and every op passed to `patchConfig` must be one the protocol has. Checked
that they fail by putting `"set"` back.

Verified against a running gateway: `/security/inspect_tools` now reaches
`config.yaml` as `enforce`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…Items

**All ten dropdowns are `NativeSelect`.** shadcn ships both — `select` is
Radix drawing a panel, `native-select` styles a real `<select>` — so this
was never about using the library. It is about which one is a macOS app.
The native one opens the system menu: type-ahead by first letter, long
lists that scroll themselves, and no chance of being clipped by the window.
The Radix one is a div imitating that.

It also deletes a workaround. Radix's `SelectItem` refuses an empty string,
so "all clients", "the default route" and "decide automatically" were
carried through a U+2400 sentinel and converted back on write. A native
`<option>` takes an empty string, so the sentinel and both conversions are
gone — the display layer means what the config means again.

`NativeSelect` gained the same `inline` size `Input` and `SelectTrigger`
have, for the upstream table's edit-in-place cells.

**The guard rows become `Item`.** Title, description, and an action on the
right is exactly its shape; it was a `section` hand-composing
`flex items-baseline` and `ml-auto`, and "keep the action right, truncate
the title, wrap the description" had to be rewritten at each one.

Reviewed all 63 components in the registry against what this app actually
does. Twenty-eight have no matching interaction here (avatars, carousels,
calendars, OTP inputs, mobile drawers, pagination — the table does not
paginate, sliders — there are no ranges, `form` — every form here has two
or three fields and it would mean react-hook-form). The rest are listed for
the next pass; `resizable` for the split view's fixed 45% divider is the
one with real value left.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
**The split is draggable.** It was a hard-coded `w-[min(30rem,45%)]`, and
how wide the list should be against the detail is only knowable by whoever
is tracing at the time: reading paths and errors wants a wide list, reading
a payload wants a wide pane. Every packet inspector lets you drag that line.
`react-resizable-panels` v4 dropped `autoSaveId`, so the width is persisted
by hand — one read, one write.

**`ButtonGroup`** around four confirm/cancel pairs — only where the parent
holds nothing but buttons, so the toolbars that mix in explanatory text are
left alone.

**`Item` and `Card`** for the two remaining hand-composed section boxes.
Title, description, action-on-the-right is `Item`'s shape, and "keep the
action right, truncate the title, wrap the description" had been rewritten
at each one.

**`Progress` on the price update.** It is a three-step flow and the only
indication of where you were was a spinner on a button — a spinner says
"busy", not "step two of three is busy and there is a third". The whole
point of that flow is that nothing downloads silently, which means saying
how many steps there are.

**Both `<datalist>`s become `Combobox`.** Model names have to stay freely
typeable — one may have shipped this morning, or be a name a relay invented
— so this needed the free-input kind, which `Combobox`'s `inputValue` is.
The native datalist could do that too but is drawn by the OS and cannot
fuzzy-match.

**The payload bodies become `Collapsible`**, not `Accordion`: request and
response must be expandable at the same time to compare them, and an
accordion is exactly the "only one open" behaviour that would prevent it.

Two are deliberately skipped. `HoverCard` is for previewing an entity on
hover and this app has none — exactly one tooltip here runs past 70
characters, which is not a reason. `Accordion` has no place for the reason
above.

**A correction.** I had said Base UI was stale at `1.0.0-rc.0` and used that
to justify the `radix-nova` style. I was reading `@base-ui-components/react`
— the old package name. The project renamed to `@base-ui/react`, which is at
1.8.0, ships monthly and does 9.7M downloads a week. The style choice still
stands on its own (radix was already a dependency), but the reason I gave
for it was wrong. `Combobox` is Base UI, and that is fine.

Bundle: 1258 KB → 1391 KB, from Base UI and react-resizable-panels.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…me mistake

That button exported a request as a replay fixture and its own tooltip said
the file goes into git. It was in the product because it is useful to
whoever maintains this, not to whoever runs it — nobody using a gateway
needs to contribute a regression case to it. Gone from the drawer, from the
Tauri command, and from the control client.

Swept the rest of the UI for the same mistake. One more: probing an upstream
whose model list came back in an unfamiliar shape told the user it was
"worth filing an issue". That is our workflow handed to them. They need to
know whether it affects them — it does not, beyond model-name routing — and
if they want to tell us, the diagnostics bundle in Settings is already
there.

Everything else that looked developer-facing earns its place. The
diagnostics bundle is for the user to hand to support. Dry-run answers
"which route would this request take" before they commit the config. Replay
answers "would the other upstream have been faster for this exact request".
All three are things the person running this needs.

A test now looks for our vocabulary in user-visible copy: issue, git,
repository, compile, unit test, regression, debug, stack. Those words
appearing on screen means the feature under them is serving us. Writing it
tripped a rule that was already there — I had used "we" in the replacement
copy, and the UI does not speak in the first person.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Two things about the same button.

**It was drawn on top of the line.** `SheetContent` positions its own close
at `absolute top-3 right-3` and it is 28px tall, so it spans y=12–40 — while
the drawer's own header is `py-2`, putting its bottom rule at y=37. The
button crossed it. The close now lives inside the header row instead, so it
sits on the same baseline as the title: measured at 9px clear of the rule
and 12px from the edge. Both shells share it, which also removes the
`inline &&` branch that used to hide it in the floating one.

**It took focus on open.** Radix focuses the first focusable element, which
was that close button, so opening a request put a highlight ring around
"close" — it reads as a suggestion to shut what you just opened. Focus goes
to the panel itself now: still inside the trap, Tab still cannot leave, Esc
still closes, it just does not land on a control.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Focus goes to the drawer panel on open — deliberately, so it does not land
on the close button — and the browser draws its default focus outline on
whatever has focus. On a panel flush against the right edge of the window,
what you see of that outline is a blue line down its left side.

`DialogContent` carries `outline-none` for exactly this. `SheetContent`
does not; added. The focus is unchanged — Tab still cannot leave, Esc still
closes — it is just not painted, which is right for a container that holds
focus rather than a control that received it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… name beside it

**The states were backwards, and it was my doing.** The `ghost` variant
carries `aria-expanded:bg-muted` — styling for "the menu this button opens
is currently open" — and I had put `aria-expanded={railOpen}` on it. So
whenever the source list was open the button wore a solid background, while
hovering gave it `hover:bg-muted/50`, half as strong. Hovering made it
darker than not hovering. shadcn's own `SidebarTrigger` sets no
`aria-expanded`, and it is used instead.

**It scrolled with the table.** The toolbar was the first child of the
scrolling container. What sits on it — which page you are on, and the switch
that collapses the source list — belongs on screen at all times, so the
toolbar is now outside the scroller and the layer below it scrolls.

**The page name is beside the button now.** This is not decoration for an
empty bar: with the source list collapsed to icons, "which page am I on" has
no answer left except recognising a glyph, and the toolbar is where every
system app puts it. Expanded, it agrees with the highlighted row; collapsed,
it is the only answer.

It is `tw-head`, not `tw-title` — a position indicator, not a page heading.
Which has a consequence worth stating rather than doing quietly: three pages
opened with a heading that said exactly what the toolbar now says, and those
are removed. Their one-line descriptions stay; those carry information.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
**The overview takes a range instead of assuming today.** 24 hours, 7 days,
30 days, or a start date picked from a calendar. "Since local midnight" was
not a choice the user made; it was a choice made for them, and right after
midnight it is close to useless. The bucket width follows the window — an
hour up to two days, six hours up to a week, a day beyond — because 30 days
at hourly granularity is seven hundred bars, which is not a chart. Front and
back compute it the same way, or filling empty buckets fills the wrong count.

**The overview is composed rather than stacked.** The amount is the answer
this page exists to give, so it is display size with the 24h shape directly
under it, full width, no box and no heading of its own — the number says how
much and the shape says when, and they are one sentence. Requests and
failures ride along the same line. The three tiles below hold only figures
no other tool can give you: what the cache saved, what was answered locally
and cost nothing, and how many requests could not be priced. Request counts
and token totals are not tiles; they are footnotes to the amount.

`tw-display` is a fifth step on the type scale, for that one number. One
place only — a second would stop it being a display size.

**The colloquialisms are gone.** "花在哪儿" → 成本构成, "哪家更快" →
上游延迟对比, "排这么多秒还没轮到就放弃" → 排队超过此时长后放弃, and a
dozen more. This is a tool for reconciling spend and diagnosing failures;
copy that reads like conversation reads as unreliable in a screen that shows
someone their bill. A test now catches the handful of markers that are
easiest to slip back into.

`history` is removed from the overview. It was the same rows the traffic
page already lists, and it rendered only a time of day — so it sat under
"no requests today" showing timestamps that looked like today's.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The wording pass that removed location-implying words also replaced
every 全部 with 不限, which turns "all of it" into "no limit" — two
unrelated meanings. It landed in three comments; the one user-facing
string it damaged sits on the overview and is repaired with that page.

That pass also left a provider named after a place in two examples.
One of them is here; the other lives in a file the next commit rewrites
anyway. How a user configures an upstream is their choice, and an
example has no business implying one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Three of the seven columns were not carrying information. 路径 is
/v1/messages on every row; 大小 is a bare byte count that nobody acts
on; and 时间, being relative, collapses to "1d" down the whole column
the moment you open the app a day later — while the point of that
column is to pick one row out of the list. Meanwhile the two columns
that decide what a request costs and how long it takes — model and
money — were not there at all.

New columns: 状态 · 时间 · 模型 · 上游 · 延迟 · token · 花费. 路径 and
大小 move to the drawer, where they already were. 客户端 renders only
when more than one client has actually sent traffic; with one key for
five clients it is a constant, and that width belongs to the model name.

Three disciplines hold the numeric columns honest:

  · missing is "—", never 0. An in-flight request has no duration, a
    subscription upstream has no per-token cost, and a model absent
    from the price table has no price. Zero would let all three pass
    for a measurement — and sorting by cost would then rank them as
    the cheapest calls of the day.
  · estimated money carries a "~" and says so on hover.
  · numbers are right-aligned and tabular, because these columns exist
    to be scanned for extremes.

Plumbing: the event mirror was missing model on request_started and
usage on request_finished, both of which core has always sent — so
live rows now fill in immediately. Cost is the exception: it is
computed when the row is written to storage, after the event, so the
list reconciles against the history a few seconds after a batch of
requests lands. Reconciliation only adds; the live row stays
authoritative for redaction, dialect translation and flagged calls,
which exist nowhere else.

Also here: filtering by free text now searches the model (its own doc
comment claimed it already did), and an empty result under an active
filter says so instead of claiming there are no requests at all — that
message reads as "the gateway is down" when the fix is one click.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The traffic table opened with "暂无请求记录" while the first read of
the history was still in flight — stating something we did not yet
know, and then dropping a table in where that sentence was, so the
page jumped. The overview did the same with a "读取中…" line two
hundred pixels shorter than the content that replaced it, and the
largest number on the page sits right where the jump happens.

Both now render their real frame first: the table keeps its header and
fills six rows with placeholders, the overview holds the amount, the
chart and the three tiles. Chrome that does not depend on the data —
the page title, the range picker — stays live throughout, so switching
the range works while the first read is still running.

A skeleton means "loading", never "empty": the table falls through to
its empty state once the read completes with nothing, and it never
covers rows the event stream delivered first.

The empty overview no longer collapses into a single card. $0, an
empty axis and three tiles reading "—" are the answer to "what has
happened so far", and they keep the page recognizable; one line
underneath says what to do next. Also fixed here: 成本构成 claimed
"最近 24 小时" whatever range was selected, and the tile hint damaged
by the earlier find-and-replace.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`max-width` on a `<td>` is advisory under the automatic table layout —
the column-width algorithm overrides it, so the truncation never fired
and a long name pushed the numeric columns off the right edge. Moved
the clamp onto a box inside the cell, where it holds.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Three causes stacked on one symptom — the amounts on the cost bars
blinking every couple of seconds while nothing was happening.

The page was on a two-second timer. It queries the database, and the
database only changes when a request lands, so on an idle gateway that
timer did nothing but re-serialize, re-render and re-animate the same
numbers, thirty times a minute. It now refreshes off the request
stream: the traffic list already reconciles against storage a couple
of seconds after a batch of requests lands, and the overview follows
that. Idle means zero queries.

The window start was `now - range`, recomputed per call, so every
bucket boundary slid forward on every refresh. A request at a fixed
time drifted between buckets and the bar heights changed with no new
data — a chart that depends on when you look at it. The start is now
floored to the bucket grid, so the same hour reads the same. That
alignment is done in local calendar terms (local midnight, local
hours): an epoch-aligned "day" is UTC midnight, which in UTC+8 puts
nine hours of the previous day in a bucket labelled with the next
one's date. The axis already prints that start, so what the window
actually covers stays visible.

recharts re-runs its enter animation whenever the data changes, and
the labels are positioned at the bar ends — so they slid for 400ms on
every refresh. Animation is off on both charts; a dashboard that
replays itself is not showing anything extra.

Two smaller things came out of it. The dashboard command now takes the
window start and the bucket width instead of a duration: the bucket
formula used to be written on both sides, and the empty-bucket fill
requires that both sides agree exactly — disagree and the whole chart
reads zero. And the payload goes through the same equality check the
status poll has used all along, so an identical response no longer
re-renders the page.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Six timers were asking the same questions over and over. All six are
gone; what they were watching for now announces itself.

The heaviest one was invisible: the menu bar woke every second and made
two control-plane round trips (quota, summary) on every wake. The
redraw was guarded — "text unchanged, don't repaint" — but the fetch
never was, so an idle machine spent all day asking about two numbers
that change when a request lands. The menu bar is the only part of this
application that is always resident; it paying for that violates the
first constraint in the project.

The rest:

  · status + overview, every 2s — two IPC round trips. Their reasons to
    change are countable, and each now has an event: the config was
    swapped (config_reloaded), a provider tripped or recovered
    (health_changed, new in core), the supervisor moved.
  · the supervisor state itself, every 2s — a mutex read forwarded over
    IPC. It is now a watch channel published straight to the window.
  · the sessions page, every 10s — an aggregate over stored requests.
  · the clients page, every 5s — a re-scan of the user's home
    directory, waiting for two things: a file edit (clients_changed,
    new in core) and the first real request (already an event).
  · the relative-time clock, every 10s — it repainted the whole traffic
    table so one tooltip could say "3s". The column moved to absolute
    time, so the only thing left that depends on "now" is the
    today/not-today line, which a day crosses once. The timer is set
    for the next local midnight, via setDate rather than +86400000
    because two days a year are not 24 hours long.

Two disciplines carried through all of it. Subscribe before reading the
current value, never after — an event only reports a change, and the
one that happens in between is lost, which shows up as a window stuck
on "stopped" until something else moves. And throttle rather than
debounce: pushing the refresh back on every arrival means a steady
stream of requests never gets one, which is exactly when it is wanted.

Idle cost, window open, measured over 45 seconds: 0.09s of CPU.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The page read as a stack of equal-weight blocks: one big number, then
three outline tiles, a definition list, two tables and two bar-row
charts — all the same size, the same grey, the same border. Nothing to
look at first, so it read like an inventory rather than a panel.

**The chart now carries both halves of one question.** When the money
went and what it went on were two separate pictures; stacked by model
into one area chart, "yesterday afternoon was opus" is a single glance,
and the two bar-row charts fold into the legend line beneath it — the
page got shorter, not longer. Buckets are much finer (30 min / 2 h /
6 h by range, roughly 50–120 points): a handful of fat columns can only
say "used or not used", while at that density the shape of a working
day appears — mornings solid, nights at the floor, weekends lower. An
area chart is honest here only because `densify` fills empty buckets
with real zeros, so the curve sits on the baseline overnight instead of
running from one peak to the next.

**Failures moved onto the baseline.** The old marker added one fixed
unit of height to a bar stacked by money — invisible on a $0.50 bucket,
doubling a $0.0005 one, and representing no amount at all.

**Cache reports a rate, not a running total.** "Saved so far" only ever
climbs over a long session; it cannot answer whether caching is working.
The hit rate can: of all the context sent, how much came from cache.
The bar under it is that formula — three segments ordered by price
(0.1x read, 1x new input, 1.25x write), so a longer bright segment is
literally better. The net figure now subtracts the write premium (core
side), so it can read "net overspend" in red, and the read:write ratio
carries the break-even that makes it actionable.

**Latency is a spread, not eight numbers.** Each model gets a bar from
P50 to P95 with P50 marked. "Which model is both slow and erratic" is
the position and length of a bar, not two columns to read line by line.

**Colour means something now.** `--chart-1` through `--chart-5` were
five greys with zero chroma — that is why the whole page looked washed
out. They are a single blue ramp (one hue, five steps: these are parts
of one quantity, not five unrelated things; the expensive model is the
heaviest layer). Cache gets its own three, ordered by price. Red and
amber are spent on exactly one thing: a row of what went wrong, which
does not render at all when everything is zero.

Everything above the fold now has a reference: the amount is followed
by its change against the previous equal window, and the chart has a
grid. A number with nothing to compare against can be read but not
judged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The page is called 用量概览 and had no token count anywhere above the
fold — only money. Tokens now sit beside the amount at the same weight,
with their own change against the previous window. It is the one number
in this tool that is better when it is larger, and it is the other half
of what the money bought.

**The input figure had the wrong denominator.** `input_tokens` is the
part of the input that missed cache, which under a healthy hit rate is
a small fraction of what was actually sent — labelling it 输入 tells a
user with a 68% hit rate that they sent 56k tokens when they sent 514k.
Input is now the whole context: uncached input plus cache reads plus
cache writes. The cache strip then decomposes exactly that number by
price, so the two read as one statement instead of two unrelated ones.

**The cache block folded into the header.** It explained the input
figure from two sections away; sitting directly underneath, it needs no
heading and no introductory sentence.

The footer strip is gone. Its contents went where they belong: tokens
moved up (with the corrected denominator), the two conditional facts —
locally answered probes, subscription-quota calls — joined the row of
things worth noting, and per-provider totals were dropped, along with
the two control-plane queries that fed them. The pricing snapshot date
came off the page entirely: it is on the pricing page already, and it
does not deserve a permanent place on the first screen.

Copy: another pass for register. 条子 (for a bar), 亏钱, 回本, 送上去,
白跑 had all crept back in. They are in the guard list now, which is
the only thing that has kept this from drifting before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fylorn and others added 9 commits September 16, 2026 11:29
…the guards report in

**The chart can be read as usage.** A single opus burst dominates a
cost chart and flattens the week around it — dramatic, but the only
thing it says is that opus is expensive, which the legend already
says. The same period drawn in tokens puts that burst back in
proportion, and the shape of a working week appears. Both readings are
useful, the header carries both numbers at equal weight, so the chart
takes a toggle and defaults to tokens: this page is called 用量概览.

**The legend is a ranking.** A row of pills wraps and misaligns as soon
as a user has more than a few models, and it carries no proportion. Now
each model is a row: the swatch still maps to its layer in the chart,
the bar is its share, and both numbers are shown with the current
metric in bold. Top five, the rest folded into one row. Bars are
normalised to the largest item rather than the total — against the
total, a model holding 70% squashes everything below it into slivers,
and comparing the rest is the whole point of a ranking.

**Security is on the page, and it says so when nothing is wrong.**
Everywhere else here the rule is that a condition which is not met does
not render — a row of zeros is not reassurance, it is wasted space.
Security inverts that: protection you cannot see reads as protection
that is off. Each of the three defences states two things — which mode
it is in, and what it saw in this window. Observe and enforce are
completely different propositions for a user, and until now that
difference was only visible on the guard page.

The two modes leave different traces and are reported differently:
observe records detected leaks, enforce replaced them in place and
records how many. Wording them the same way would make a switch to
enforce read as "nothing found" — the strongest setting looking like
the quietest. The config-face line deliberately does not follow the
time range: it describes what is on disk now, which has nothing to do
with how many days you asked to see.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The page read as a stack of equal-weight horizontal strips: every block
was a line of text, a thin bar, another line of text. Organised, but
with no composition — no contrast of scale, nothing to look at first.
A 96px chart in a full-width column is a strip, not a centrepiece.

**One anchor.** The chart is 200px and everything else is a dense row
separated by a hairline, with a label column on the left holding them
to one vertical line. The reference is a native monitoring tool, not a
web console — a grid of rounded cards is exactly what makes something
look like a console.

**A live mode.** Two minutes at one second per bucket, fed straight off
the event stream: `request_started` carries the model, `request_finished`
carries usage, and the two correlate by id. No query, no polling, no
core change. A request lands and the rightmost bucket grows; the curve
walks left once a second so an idle stretch reads as idle rather than
as a frozen window. Cost is not in the event stream — it is computed
when the row is stored — so this mode plots tokens only, which is what
it can say honestly.

Only the chart is live. Two minutes is not enough to compute a latency
quantile or a cache hit rate, so those stay on 24 hours, and one line
under the chart says so once rather than repeating it on each block.

**The row of pills is gone.** A line of number-plus-label chips is the
most console-looking thing on a page, and every fact in it belonged
somewhere else: failures next to the request count (the red baseline
already says *when*), estimated and unpriced next to the money they
qualify, locally-answered probes into the empty state where they are
actually evidence of anything, leaks in the security block that already
reports them.

**Latency is two columns.** Models on the left, upstreams on the right,
each growing downward. Laid out in one row, a handful of upstreams blew
it sideways. Each column caps at six with a line saying how many more —
in latency data, the row that got dropped may be the slow one.

Requests joined tokens and money as a third headline: they are the same
order of fact, and the failure count only makes sense attached to it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… vendor's cache rates

**An empty chart collapsed to a line of text.** So did the model
ranking, the cache strip and the latency block — each one rendered only
when it had something to show. Switching time ranges then moved the
whole page up and down by a couple of hundred pixels, and the reader
had to find their place again every time. Those four now keep their
height and say what they have nothing of; the chart's empty state is a
dashed box the size of the chart.

**The cache multipliers were one provider's price list.** "Writes at
1.25x, reads at 0.1x, break even at 28%" is Anthropic's schedule, and
the models on this page can come from any upstream — printed as a rule
of the interface it is simply wrong for the others. The explanation is
gone and so are the per-segment multiplier labels, which asserted the
same thing more quietly. What remains is the net figure, and that one
is computed from each model's own entry in the price table. The
segments are ordered cheapest to dearest, which holds regardless.

**The metric toggle sat on top of the chart.** The chart is 200px and
the curve reaches the top when it should; the buttons were floating in
its path. Moved to the right end of the row of headline numbers, where
there was already empty space, so it costs no height and still sits
directly above what it controls.

Also: the latency column was a few pixels too narrow for a four-digit
range and wrapped to two lines.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The three headline numbers sat in flexible blocks, and the qualifier
that reads "against the previous window" is only there when there is a
previous window to compare against. So switching from 24 hours to 30
days — where nothing precedes it — narrowed the first block and slid
the other two left. Every switch moved all three, and the eye had to
find them again.

They are equal-width columns now, and every qualifier moved to a second
line of fixed height. The first line holds only the number and its
unit, which is roughly the same width in any range.

The same defect, found in four more places once I went looking:

  · the note under the chart vanished when there were no failures and
    the range was not live, lifting everything below it
  · the money column in the model ranking was dropped in live mode,
    where cost cannot be computed, changing every column width in the
    table — it stays and reads "—"
  · the metric toggle was hidden in live mode, so the header re-flowed;
    it is disabled instead, with a title saying why
  · the toggle had also been sitting on top of the chart, which is 200px
    and reaches the top when the data says so

The rule this settles: a block may change height because there is more
data in it — five models take more room than two, and that is the data
speaking. It may not change size because a qualifier is present or
absent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The metric switch and the time range ended up side by side in the
header, styled identically, reading as a single group of seven peer
options. They are not peers: the range governs the whole page — every
block below follows it — while the metric only says what one chart
plots.

The range stays at the right of the page title, where a page-level
control belongs. The metric moved directly above the chart, left
aligned, with the row of headline numbers between them. Nothing about
either changed except that they are no longer adjacent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
They snapped to a new value before. A cumulative total that climbs is
the one number in this tool that is better when larger, and watching it
move is most of why anyone looks at it.

Two rules keep it from lying.

**It only runs within one measure.** Switching the range from 24 hours
to 30 days is not growth, it is looking at something else — rolling
251k up to 661k would read as usage having tripled. A change of range
lands on the new value in a single frame.

**It only runs when the value actually changed.** The payload already
passes through the equality check that stops an identical response from
re-rendering, so every animation here corresponds to real requests
having landed. This is the opposite of the chart animation removed
earlier: that one replayed itself on every refresh, covering a refresh
that changed nothing.

Motion is off under prefers-reduced-motion, where a decorative ease is
exactly what the setting is for.

One thing worth noting for later: the three hooks sit above the two
early returns, and they have to. React counts hooks per render, and
this component returns early for "no data yet" and "failed to read" —
called below those, the first successful read would have crashed the
page. `tsc` cannot see that, and this project runs no lint, so it is a
reading-the-code check rather than a mechanical one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Cost was missing from the live chart for a structural reason: it is
computed when the row is written, not when the request finishes, so it
was never on the event stream. Core now reports it (`request_priced`),
which changes two things here.

**Live mode can plot money.** Both readings are available in the live
window now; the bucket grows in tokens the moment a request finishes
and in money a beat later, when the price lands. The toggle is enabled
in every range.

**The reconcile is gone.** `useRequests` re-read the last two hundred
rows a couple of seconds after every batch of requests, and the only
reason was this one missing number. Cost now arrives by push, on the
same stream as everything else. What is left of that mechanism is a
throttled signal saying "the store has caught up, aggregates can be
recomputed" — the overview needs it because its figures are SQL over
rows that are written asynchronously, but it no longer queries anything
itself.

The live footnote now names both scopes instead of one. The model
ranking is the chart's legend — its swatches have to match the layers —
so it follows the chart's two-minute window, while the headline numbers
and the cache, latency and security blocks stay on 24 hours. Saying
only "the following are 24 hours" was wrong about the row directly
beneath it.

The metric toggle is right-aligned.

Verified against a live gateway: a request through a stub upstream
returning usage produced `cost_micros: 12975` and
`cache_saved_micros: 21225`, which is 1200 input + 340 output + 8000
cache-read + 500 cache-write priced at Sonnet's table, and the saving
net of the write premium.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Restarting core stacked three identical toasts reading "connection
refused (os error 61)". Three, because the effect that reads status
re-runs on every supervisor transition — stopped, starting, running —
and each failure raised one.

Not being connected yet is not an error, it is a stage of starting up.
And the toast was the least informed thing on screen: the supervisor
was already reporting "starting", "third restart, two seconds out",
"safe mode", and the interface threw that away to report a socket
errno instead.

**Three levels, so a normal launch says nothing.** A cold start takes
about a second; a progress bar that never stays is noise. Level zero is
a skeleton with no words. After a second and a half a single line
appears. Only a state needing a person — a repeated restart, safe mode,
a core that will not start — skips the wait and lays out what to do.

**The retry window is real and now handled.** The process is up and the
control socket has not bound yet, which is exactly what those toasts
were. Backoff, eight attempts, the count shown on screen. Then it stops
— continuing would be polling, and the supervisor's next transition is
what should wake it.

**Losing the connection keeps the page.** The figures stay where they
were with a strip above them saying why they stopped moving. Clearing
them loses the answer to "what was it a moment ago", and a toast
vanishes and leaves stale numbers looking fresh.

This does not reinstate the two full-screen gates that were removed.
Those stood in front of *configuration* state while everything behind
them worked; this one covers *connection* state, where every page's
data has no source. It gets out of the way the moment the control plane
answers, including in safe mode, where config, rollback and restore are
exactly what someone needs.

**A missing binary no longer kills the launch.** `locate_core` was
called with `?` inside `setup`, so a failure aborted Tauri's startup —
no window at all, the application simply did not open. It now opens and
prints the paths it searched. Verified: with the binary pointed
somewhere invalid the process stays alive and logs all three locations.

`restart_core` is new. The supervise loop exits for good in two cases —
safe-mode core exited, or core never started — and nothing could bring
it back. It is guarded by a flag so a second loop cannot be started
alongside the first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The "core not found" message listed every path searched — including
`../../thinkwatch-core/target/debug/twcore` — and advised running
`cargo build -p twcore`. That is the right answer for whoever is
developing this and noise for anyone else: they have no such checkout
and will not be running cargo.

A bundled app now says the installation is missing a component and to
install it again. The candidate list and the cargo advice stay for the
development layout, where they are the answer. The two are told apart
by the shape of the resource directory on macOS.

Verified both: running the bundle from a directory where no fallback
resolves prints the short sentence; running the loose binary still
prints the full list.

Nothing here was ever a hardcoded path — every candidate is derived at
runtime from where the binary sits, an environment variable, or the
working directory. Worth stating because the screenshot that prompted
this looked like one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn fylorn changed the title Adopt shadcn, themed to this app rather than to its defaults Adopt shadcn, rebuild the overview, and stop polling Sep 16, 2026
@fylorn
fylorn merged commit 0412b7a into main Sep 16, 2026
4 checks passed
@fylorn
fylorn deleted the dev branch September 16, 2026 06:04
fylorn added a commit that referenced this pull request Sep 17, 2026
The upstream page was rewritten in #35, but the rest of the app still
talked to the user the way a chat would: "没绑路由的密钥走这条", "并发上限
要是一个 1 以上的整数", "第一个请求进来时,它会出现在这里", "像密钥的内容都
打了码". In a tool people use to read costs and debug traffic that tone
reads as unreliable, and it no longer matched the page next to it.

Every other page now uses the upstream page's register: statements
rather than asides or questions, no first or second person, 费用 for
amounts, 尚无/未/无法 rather than 还没/没/…不了, and an upstream is 上游
rather than 这家/一家. Tooltips that only justified a design choice (why
custom scan rules are appended, why a replay is byte-identical, why
small samples are not compared) keep the fact a user acts on and drop
the reasoning, which belongs in comments.

Two strings were wrong on screen, not just informal:

- A global 全部 -> 不限 replace in #15 left 不限还原, 请求不限失败, 展开不限,
  拖垮不限 and 不限网卡. They read 全部/所有 again, and the traffic filters
  say 全部客户端/全部上游, as that commit message described them.
- Core 0.2 reports trust as a slug, so the Guard page showed "official"
  and "untrusted"; redaction categories were always slugs. Both now use
  the labels the upstream dialog already defines.

The copy test rejects the spoken markers removed here (要是, 还没, 删掉,
拿到, 这家, 只计到, 知道了, 吗?, 你 and others) so they cannot return one
string at a time. 就好了, 怎么办 and 稍等一下 are widened to 就好, 怎么 and
稍等, and 成本 joins 花费 as a synonym to reject.

Not changed here: strategy names (手动选, 轮流, 选最快, 选最便宜), the disk
status line and the scan rule summary are strings core sends, so they
have to change in core.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
fylorn added a commit that referenced this pull request Sep 22, 2026
The header has carried `sticky top-0` since #8, but it stopped sticking
in #15, when it moved inside shadcn's `Table`. That component wraps the
table in a div with `overflow-x: auto`, and a box that scrolls on one
axis is a scroll container on both: the other axis's `visible` computes
to `auto`. The header stuck to that div, which never scrolls vertically,
so it went up with the rows. 600px down the list it sat 540px above the
top of the scroller.

`Table` gets a `scroll` prop. The request table turns it off, so the
header sticks to the page's scroller instead.

The wrapper was doing real work, though. At the minimum window width
with the sidebar expanded the table is 808px in a 584px column, and
without the wrapper the page's scroller takes the horizontal overflow
too, which would slide the filter bar sideways with the table. So the
page is split into three blocks. The filter bar (with the no-upstream
notice) and the footnote are direct children of the scroller with
`sticky left-0`: that makes them exactly as wide as what is visible, and
they stay put while the table scrolls sideways. The table sits in a
`w-fit min-w-full` block that grows with it, so its right padding still
scrolls into view. The horizontal scrollbar now sits at the bottom of
the window rather than under the last of two hundred rows.

Two things only showed once the header actually stuck:

- The table uses collapsed borders, and a collapsed border is painted by
  the table, not the row, so the line under the header stayed behind and
  scrolled away with the rows. The header cells draw it as an inset
  shadow instead, which moves with them.
- The header's background was neutral-50/950, which no longer matches
  the window ground (#f7f8fa / #0c0e11); rows passing under it would
  show a band. It uses `bg-background` now.

Not taken: pinning the filter bar above a table that scrolls on both
axes costs 60-96px of list height at every window size, about two rows;
`overflow-x: clip` cuts off the cost column at the minimum width.

Also points three comments that still sent readers to `Split`, removed
in #82, at the scroll layer that exists now.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant