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

The board shows each subscription's window and each app's units per shipped change #381

Merged opened this

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

Merged

The board (`/board`) now shows every subscription's 5-hour and weekly window to a site admin, and each app card in Today shows what a shipped change cost over the last 7 days. Neither adds a query per row. The full `forge.json` check passes (`tsc` clean, every shard 0 fail).

shipped production is serving it deploy a5415ba

opened this

The board (/board) now shows every subscription's 5-hour and weekly window to a site admin, and each app card in Today shows what a shipped change cost over the last 7 days. Neither adds a query per row. The full forge.json check passes (tsc clean, every shard 0 fail).

Subscription windows. These sit in a new strip, windowsStrip in src/web/pages/board.ts, under the forge-health strip. Only site admins see it, because the subscriptions belong to them. It updates itself on run.* events. For each window it shows:

  • money used, money left (or "full", or "cap not known yet"), and when it resets;
  • a small bar once the cap is known;
  • the word inferred next to any figure the provider did not give. If every figure in the row is inferred, the word appears once at the end.

The text comes from a new windowWords in src/web/studio/words.ts, as the issue asked.

Reading many accounts at once. src/core/standing.ts gains standings(db, ids, now). It reads all accounts in three statements: the kept-for-people share, the provider's last limit messages, and one usage-ledger read starting at the earliest point any account needs. Each account still only counts ledger rows from its own start point, so its figures are the same as before. standing() now just calls it with one id. I also switched the subscriptions settings page and the usage action/API (src/actions/usage.ts) to it, since both were reading one account at a time.

Spend per shipped change. The new src/core/efficiency.ts has efficiencyForRepos. It is one grouped query that adds the ledger's spend to the count of pulls merged in the window. The ratio is null when nothing shipped. The card then reads "$4.10 spent, nothing shipped this week" instead of a divide-by-zero, and the wording comes from perShippedWords. Today used to list only apps that run on their own. It now also lists apps the crew spent on this week, so those apps get the figure too.

Choices to look at:

  • No fifth board region. The big view and the 1–4 shortcut keys are built around four regions, so the windows are a strip instead.
  • Two "per shipped change" numbers. The board takes spend from the usage ledger, as the issue asked. The studio app page's "per shipped change" still uses run.cost_usd, so the two can differ slightly. I did not merge them.
  • Today still queries per app. Its existing per-app queries (autonomyStatus, today's runs and shipped count) are unchanged. Only the new readings are grouped.

Tests. The new test/board-windows.test.ts is added to the check in forge.json. It covers:

  • the wording against hand-worked values (3.20 ÷ 10.00 = 32% of the cap used);
  • efficiencyForRepos against a hand sum: ($1.00 + $2.50) ÷ 2 merges = $1.75, ignoring spend and merges from before the window and an open pull, in exactly one statement;
  • standings giving the same result as reading each account alone, in three statements for one account or four;
  • the rendered board: the strip with "inferred" and "full" for the admin, no strip for anyone else, "$2.50 per shipped change this week", and no extra statements when four more accounts are added.

docs/STUDIO.md's board section describes both readings. To try it, sign in as an admin, add a subscription under Settings → Subscriptions, let the crew run on it, then open /board.

🤖 Generated with Claude Code

Closes #374

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs