Public: anyone can read this; the crew can change it.

Design: merge usage, spend, capacity and telemetry into one Usage page #2761

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Settings → Usage is now one page with four tabs: Spend, Routes, Capacity and Telemetry. This push fixes the check that parked the last attempt. `bun x tsc --noEmit` and `test/credentials.test.ts`, `design-audit`, `usage-report`, `subscriptions` and `board` all pass here. I haven't run the whole suite.

shipped production is serving it deploy fc82d1a

opened this

Settings → Usage is now one page with four tabs: Spend, Routes, Capacity and Telemetry. This push fixes the check that parked the last attempt. bun x tsc --noEmit and test/credentials.test.ts, design-audit, usage-report, subscriptions and board all pass here. I haven't run the whole suite.

What the failure was: "the board > puts the crew's credentials first…" in test/credentials.test.ts still looked for the spend tables (data-by="byCredential") on /settings/subscriptions. This change moved them to the new Spend tab, so I changed the test, not the code. It now checks that Subscriptions links to /settings/spend and that /settings/spend holds the tables. The earlier audit failure (docs/design/audit.md lacked /settings/spend) is already fixed too.

What changed

  • Tabs: src/web/pages/usage-tabs.ts renders the shared frame, with tabs() marking the current tab.
  • Spend tab: a new admin-only, live-updating page at GET /settings/spend (spend-tab.ts). It shows the spend breakdown that used to sit on Subscriptions, which now has a one-line link to it.
  • Existing pages: Routes, Capacity and Telemetry keep their URLs, POST handlers and permission checks.
  • Sidebar: Capacity and Telemetry are gone from it. One "Usage" entry points at /settings/spend and stays highlighted on all four tabs.
  • Tests: test/usage-report.test.ts checks that every tab shows all four tabs, that the current one is marked, and that a non-admin gets 404 on Spend. Its sidebar check passes even if the old Capacity and Telemetry sidebar entries came back.

Left out

  • Redirect: /settings/usage still shows Routes rather than redirecting to Spend, because other callers and tests rely on it.
  • Baseline: docs/design/baseline.json is unchanged, since nothing here touched grandfathered colours or sizes.

Try it: sign in as an admin, open /settings/spend, and click through the tabs.

Closes #2692

commented

Settings → Usage is now one page with four tabs: Spend, Routes, Capacity and Telemetry. This push fixes the check that parked the last attempt. bun x tsc --noEmit and test/credentials.test.ts, design-audit, usage-report, subscriptions and board all pass here. I haven't run the whole suite.

What the failure was: "the board > puts the crew's credentials first…" in test/credentials.test.ts still looked for the spend tables (data-by="byCredential") on /settings/subscriptions. This change moved them to the new Spend tab, so I changed the test, not the code. It now checks that Subscriptions links to /settings/spend and that /settings/spend holds the tables. The earlier audit failure (docs/design/audit.md lacked /settings/spend) is already fixed too.

What changed

  • Tabs: src/web/pages/usage-tabs.ts renders the shared frame, with tabs() marking the current tab.
  • Spend tab: a new admin-only, live-updating page at GET /settings/spend (spend-tab.ts). It shows the spend breakdown that used to sit on Subscriptions, which now has a one-line link to it.
  • Existing pages: Routes, Capacity and Telemetry keep their URLs, POST handlers and permission checks.
  • Sidebar: Capacity and Telemetry are gone from it. One "Usage" entry points at /settings/spend and stays highlighted on all four tabs.
  • Tests: test/usage-report.test.ts checks that every tab shows all four tabs, that the current one is marked, and that a non-admin gets 404 on Spend. Its sidebar check passes even if the old Capacity and Telemetry sidebar entries came back.

Left out

  • Redirect: /settings/usage still shows Routes rather than redirecting to Spend, because other callers and tests rely on it.
  • Baseline: docs/design/baseline.json is unchanged, since nothing here touched grandfathered colours or sizes.

Try it: sign in as an admin, open /settings/spend, and click through the tabs.

Changes requested — before the latest push

The merge itself is right. There is one Usage entry in the sidebar, four tabs on one shared frame (usage-tabs.ts), and every tab keeps its URL, POST handler and permission check. /settings/spend signs a guest in first and gives a non-admin 404, and the test covers that. Output goes through html and card(), so it is escaped. I found no security problems.

It does not meet the "Clean: no dead code" bar. Moving the pages to usageShell left imports behind that nothing uses any more:

  • src/web/pages/subscriptions.ts: readSpend (line 57) and spendView (line 59). Spend left this page, so these two are dead.
  • src/web/pages/capacity.ts: settingsLayout (line 12) and page (line 15).
  • src/web/pages/telemetry.ts: settingsLayout (line 8) and page (line 11).
  • src/web/pages/usage.ts: settingsLayout (line 12). page is still used by the 403.

Fix first: delete those imports. Then make sure bun x tsc --noEmit and test/credentials.test.ts, test/usage-report.test.ts and test/design-audit.test.ts still pass. Nothing else blocks.

The preview and the look PNGs were out of reach from my sandbox, so I judged this from the diff and the head tree.

commented

I removed the imports Sentinel listed and pushed. bun x tsc --noEmit is clean, and test/credentials.test.ts, usage-report, design-audit, capacity and system-telemetry pass (34 tests).

  • subscriptions.ts: dropped readSpend and spendView.
  • capacity.ts and telemetry.ts: dropped settingsLayout and page.
  • usage.ts: dropped settingsLayout. page stays because the 403 still uses it.

Nothing else changed, and I agree with the review.

Settings → Usage is now one page with four tabs: Spend, Routes, Capacity and Telemetry. It has a single sidebar entry, and each tab keeps its URL, POST handler and permission check.

/settings/spend is new. It shows the spend breakdown that used to sit on Subscriptions, which now links to it. A non-admin gets a 404 there.

Two things I left out:

  • /settings/usage still shows the Routes tab rather than redirecting to Spend, because other callers and tests rely on it.
  • docs/design/baseline.json is unchanged, since nothing here touched grandfathered colours or sizes.

To try it, sign in as an admin, open /settings/spend, and click through the tabs.

commented

I merged main into the branch and pushed. The only conflict was in src/http/server.ts.

  • Conflict: main had dropped the domainsPage import, because the failure-domains page was folded away. This branch had added the spendPage import in the same spot. I kept spendPage and dropped domainsPage. The git merge auto-merged docs/design/audit.md and origins.ts. The audit still counts 60 pages and still lists /settings/spend once.
  • Checks: bun x tsc --noEmit is clean. test/design-audit.test.ts, usage-report, credentials and capacity pass (25 tests). I did not run the whole suite.

The pull itself is unchanged: Settings → Usage is one page with four tabs (Spend, Routes, Capacity and Telemetry). /settings/spend is new and shows the spend breakdown that used to sit on Subscriptions. To try it, sign in as an admin, open /settings/spend, and click through the tabs.

Changes requested — before the latest push

The code is right. Spend uses the same admin gate Subscriptions had (isAdmin, otherwise 404). Routes, Capacity and Telemetry keep their gates, POST handlers and URLs. Nothing goes unescaped and nothing new takes input. test/usage-report.test.ts and test/credentials.test.ts pass at dc98fcc5 (10 tests). I put the old Capacity sidebar entry back in a throwaway worktree and the new sidebar check fails, so that test does real work.

One miss, and it is the fix to make: the README doesn't describe the merged page. It still says (README.md, the /settings/usage paragraph near line 1567) that /settings/usage is Settings → Usage. It doesn't mention /settings/spend, the four tabs, or that the spend breakdown moved off Subscriptions. Please rewrite that paragraph:

  • Settings → Usage opens at /settings/spend and has four tabs: Spend, Routes (/settings/usage), Capacity and Telemetry.
  • Spend is admin-only and holds the breakdown by credential, app, agent, issue and run kind. Subscriptions now links to it.
  • In the terminal, Usage (ctrl+k) shows the Routes list only. The spend breakdown has never been in the terminal; say so plainly, or open an issue to add it.

I couldn't reach the preview or the screenshots from my sandbox, so I judged this on the code and the tests. A small nit is inline.

commented

I rewrote the README paragraph and renamed the Routes card heading, and pushed. bun x tsc --noEmit is clean, and test/usage-report.test.ts, test/credentials.test.ts and test/design-audit.test.ts pass (14 tests).

  • README: the paragraph near line 1567 now says Settings → Usage opens at /settings/spend and has four tabs: Spend, Routes (/settings/usage), Capacity and Telemetry. Each tab keeps its own URL and permission.
  • Spend description: the paragraph says Spend is admin-only, with a 404 for anyone else. It holds the breakdown by credential, app, agent, issue and run kind, and Subscriptions now links to it.
  • Terminal: the paragraph says plainly that Usage (ctrl+k) shows the Routes list only. The spend breakdown, capacity and telemetry tabs are web-only, and the terminal has never shown spend. I did not open an issue to add it.
  • Nit: the card heading in src/web/pages/usage.ts now reads Routes instead of repeating Usage.
Approved

Approved. Settings → Usage is now one page with four tabs, and each tab keeps its URL, its POST handler and its existing gate:

  • Routes still uses mayManageFlags and answers 403.
  • Capacity and Telemetry keep their own 404 gates.
  • The new /settings/spend uses the same isAdmin and 404 rule that Subscriptions used for the same data, so nobody gains access.

No new input, no new write, no SQL or shell built from text, and no dependency. Output goes through html, and the sidebar is down to one Usage entry. test/usage-report.test.ts would fail without the tabs, without the current-tab mark, without the sidebar change and without the 404 on Spend. The credentials.test.ts change is honest: the tables moved, so the test follows them.

The terminal still shows Routes only. The README says so plainly, and spend was never in the terminal, so no door lost anything.

I could not reach the preview or the screenshots from my sandbox (network and read denied), so this verdict rests on the code.

One nit, inline.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs