Skip to content

Upstreams page: design kit, vendor logos, 24-hour sparklines, undoable enable/disable - #193

Merged
fylorn merged 3 commits into
devfrom
ui/upstreams
Sep 24, 2026
Merged

fylorn merged 3 commits into
devfrom
ui/upstreams

Conversation

@fylorn

@fylorn fylorn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Upstreams page (Upstreams / Proxies / Price sheets) moved onto the design kit from #187, following src/ui/README.md.

Page

  • Page + PageHeader with the three tabs in the header (TabsList variant="line", counts via @/ui/count). The summary line is the page's status at a glance: upstream count, healthy / need attention / disabled (status dots), and 24-hour requests and cost. The numbers count up (AnimatedNumber); the 24-hour part is a skeleton until it loads and is left out, not zeroed, if it cannot be read.
  • Data goes through useResource (24-hour stats, price sheet status, account usage, each upstream's model list), so coming back to the page shows the last data at once and refreshes in the background. Stats refetch when requests finish (throttled), when the hour rolls over and when the window regains focus; quota events patch the cache directly. No polling.
  • State trio everywhere: table-shaped skeletons (hero, 24-hour and latency cells, model popover, price sheet and link-test dialogs, account quota), designed empty states with an icon and the create action (upstreams, proxies), and a warning banner with Retry when the page's own reads fail while the list keeps working.

Upstream table

  • Vendor logos (monochrome, @/ui/logos) in a tile on every row; the tile carries a pulsing dot while requests are in flight through that upstream (seeded from /in-flight, then followed by events, including failover).
  • 24-hour column: an hourly sparkline next to requests and cost, in the same visual language as the Keys page's (Keys and Clients pages: design kit, per-key 24-hour sparklines, live state #190), plus failures as a red cap on the hour they happened in. Hover gives requests, failures with success rate, cost and unpriced requests. The per-upstream series comes from core's existing CostBucketsBy (dimension provider), added to the upstream_stats bridge command, so no core change was needed.
  • Quota / billing: account upstreams get a quota bar for the tightest window with the reset time; windows past their reset are not shown as current. Upstreams without reported quota show their billing mode, as decided in feat: sign in on another device, and read the table in one pass #46.
  • Problems (sign in again, credential rejected, circuit open) appear after the name only when something is wrong; disabled rows are muted including their numbers.
  • Single click or Enter/Space opens the edit dialog; every row has the "..." button and the same right-click menu. New menu item: "View traffic" opens Traffic filtered to that upstream. Deep links (nav.open("upstreams", { upstream })) scroll to and flash the row.
  • Enable / disable is optimistic and undoable (undoable), with no confirmation.

Proxies and price sheets

  • Proxy rows now read like upstream rows: name, with type · address · authentication on the line below. The seven columns pushed the row menu out of view at the minimum window size. "Check all" has a pending state; connectivity uses StatusLabel.
  • Price sheets: the "Used by" lists show logo chips (table, edit dialog, read-only default sheet dialog); the default sheet row shows data date, model count and last check.
  • Banners: unpriced requests (warning, with "Set prices"), failed status read (warning) and failed update (warning, or error when no prices were ever loaded).

Dialogs

  • One error style in every upstream dialog: DialogError, an inline error Banner that animates in and out (was Alert, red <p> and Note tone="error" side by side). Login notices and the reset-credit confirmation use Banner too.
  • Every async button uses pending (save, create, delete, check, test, sign in, use credit), deletes stay open with a pending destructive AlertDialogAction and report failure in place, footers are Cancel (outline) then the primary on the right.
  • New upstream: the service type is a dropdown with vendor logos; the account sign-ins sit below a separator. Edit dialog headers show the upstream's logo. Form dialogs do not close on an outside click (Esc, × and Cancel still do).
  • Model list popover, link test and inference test show vendor logos and skeletons instead of "Loading" lines.

Narrow window (820×560)

  • Checked in zh and en: the name column never collapses (plan badge folds away, problems shrink to their dot with the label in the tooltip), the sparkline folds away, and secondary header actions become icon buttons with tooltips so the summary stays at two lines. All through @container/page, the same container name and 48rem breakpoint as the Keys page.

Clean-up

  • Removed the old StatusDot, NameChips and RadioRow from upstreams/parts.tsx (no callers left after Routing page: chain map hero, design kit, live paths #191), Note's error tone, a local Count, dead i18n keys and the unused onNavigate prop. Other areas' imports from upstreams/parts (Segmented, Boxed, FormItem, Note) are unchanged.
  • Tests for the hourly slots behind the sparkline.

Decisions made without asking

  • Sparkline colours follow the Keys page (chart tokens) so the two pages read as one system; failures are the one addition.
  • The hero stays the same on all three tabs (it is the page's status, not the tab's); only the actions change with the tab.
  • Read failures of secondary data are warnings, not errors: the list still works.
  • English copy: "Selected" under the model count (the edit dialog calls the option "Selected models"), "Overrides" as the price sheet column header.

Core changes that would help (not done here)

  • ProxyView only reports faults seen while forwarding (unreachable). If it also carried the last successful handshake seen in real traffic (time and duration), the Connectivity column could show live status instead of "Not checked" until someone runs a check.

Checks

  • pnpm typecheck, pnpm test (283 tests), pnpm build
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo clippy --lib -- -D warnings, cargo test (control-plane tests run against twcore 0.47.0)
  • Visual: full-app preview harness, light and dark, zh and en, 1100×720 and 820×560, with ?issues, ?empty, ?fail=upstream_stats,Pricing,ChatgptUsage, ?slow, ?live; real clicks for undo, keyboard open, delete confirm and popovers.

🤖 Generated with Claude Code

fylorn and others added 3 commits September 25, 2026 06:58
…otion

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nner tones

- Narrow window (820x560, English): the name column no longer collapses. The
  plan badge folds away and a row's problem shrinks to its dot (the tooltip
  still says what it is); the quota column narrows; "Selected models" under the
  model count becomes "Selected".
- Secondary header actions (connection test, inference test, check all, update
  now) turn into icon buttons with a tooltip when the page is narrow, so the
  header summary stays at two lines. CSS container query on the page, no JS
  measuring and no flash.
- Proxies: type, address and authentication move into a line under the name,
  like the upstream rows. Seven columns pushed the row menu out of view at the
  minimum window size.
- Price sheets: shorter English column header so the table fits; the default
  price sheet dialog lists its upstreams as logo chips like everywhere else.
- Banner tones: a failed read of the 24-hour statistics or of the price sheet
  status is a warning (the page keeps working); a failed price update is an
  error only when no prices were ever loaded.
- Disabled upstreams: their 24-hour and latency figures are muted with the row.
- The reset-credit confirmation uses the kit Banner instead of Alert; English
  hero plural for "need attention"; long proxy check failures wrap.
- Tests for the hourly slots behind the sparkline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ead parts

- The 24-hour sparkline now looks like the one on the Keys page (#190):
  2px chart-coloured bars, 16px tall, the current hour emphasised, a faint
  baseline for empty hours. What stays specific to upstreams: failures are a
  red cap on the hour they happened in, and a single request does not fill
  the bar.
- Every narrow-window rule on the page (sparkline, plan badge, problem dot,
  quota width, icon-only header actions) keys off the page container at the
  Keys page's breakpoint (48rem) instead of a table-level container.
- Removed NameChips and RadioRow (no callers left after #191) and Note's
  error tone (dialog errors are DialogError).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit dc79de5 into dev Sep 24, 2026
4 checks passed
@fylorn
fylorn deleted the ui/upstreams branch September 24, 2026 23:26
fylorn added a commit that referenced this pull request Sep 24, 2026
- Cmd+R and the palette's "Refresh data" also refetch every mounted
  useResource (new invalidateAll in lib/resource.ts), not only the shell's
  status and overview, so the page in front actually refreshes.
- The Settings page handles nav.open("settings", { section }) in its own
  useNavParams (Config.tsx) instead of the shell scrolling for it; a
  restructured Settings page replaces that handler without a second
  scroller left behind in App.tsx. NavParams.settings.section is a plain
  string again; the palette's section ids live in palette/sections.ts,
  with a note on keeping them in step with the page.
- Rebased onto the Upstreams page (#193): the palette's dialog params are
  merged into the page's existing useNavParams handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn added a commit that referenced this pull request Sep 24, 2026
…192)

* Command palette: search entities, open page dialogs, shortcut sheet

- ⌘K palette on cmdk (src/ui/command.tsx, src/palette/): pages with
  ⌘1-⌘9, actions (new upstream / key / route / group / proxy / price
  sheet, inference and connection tests, routing dry run, search traffic,
  switch connection, add a remote connection, refresh, sidebar, config
  file, version history, check for updates, notices, shortcuts), and
  search over data already on hand: upstreams, keys, routes, groups,
  clients, connections, Settings sections and Traffic's loaded requests
  (by model, one row per model, or by id).
- The palette only navigates. Each item is nav.open(page, params) and the
  page opens its own dialog in useNavParams, exactly as its button or row
  click would; NavParams gains create / edit / test / dryRun / detail /
  setup / section. A source test checks every param the palette sends is
  read somewhere.
- Recent (last five used) above Pages and Actions; frequent use nudges
  search ranking. Names outrank aliases (other language, synonyms, URL).
- Switch connection is a second level (Esc / Backspace goes back); the
  current connection is listed but not selectable.
- ? (outside text fields) or the palette footer opens a shortcut sheet
  generated from the same key table as the palette caps and the sidebar
  tooltips (palette/keys.tsx). Sidebar items show their ⌘n in a tooltip.
- Global shortcuts do nothing while a form dialog is open; the palette
  and the sheet are passive, so ⌘4 read off the sheet works.
- Palette scales and fades in from the top; list height follows the
  results; selection and scroll are computed with the results so typing
  never scrolls to a stale row.
- Settings sections scroll into view when opened from the palette.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Palette: Cmd+R refreshes page data; Settings scrolls to its own sections

- Cmd+R and the palette's "Refresh data" also refetch every mounted
  useResource (new invalidateAll in lib/resource.ts), not only the shell's
  status and overview, so the page in front actually refreshes.
- The Settings page handles nav.open("settings", { section }) in its own
  useNavParams (Config.tsx) instead of the shell scrolling for it; a
  restructured Settings page replaces that handler without a second
  scroller left behind in App.tsx. NavParams.settings.section is a plain
  string again; the palette's section ids live in palette/sections.ts,
  with a note on keeping them in step with the page.
- Rebased onto the Upstreams page (#193): the palette's dialog params are
  merged into the page's existing useNavParams handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.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