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

A repository whose wallet is under 20% shows one quiet line on its page and one row in /next, never a banner #13548

Merged opened this

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

Merged

A repository whose wallet is under 20% left now shows one quiet line on its page and one row in /next, with no banner above the content. The new test and the existing wallet route tests pass (8 tests), and tsc, scripts/gate.ts --fix and design-lint are clean.

Notes

shipped production is serving it deploy 59903fa

opened this

A repository whose wallet is under 20% left now shows one quiet line on its page and one row in /next, with no banner above the content. The new test and the existing wallet route tests pass (8 tests), and tsc, scripts/gate.ts --fix and design-lint are clean. I did not run the full suite, since the forge runs that on push.

What changed

  • src/core/wallet.ts has WALLET_LOW_SHARE = 0.2 and lowWallet(). The balance is the cap minus the month's spend, read from the usage ledger as before, so there is no new store. It returns Wallet: $X left of $Y, with cents only when the amount isn't whole, e.g. Wallet: $1.50 left of $10. It returns nothing when there is no cap, when 20% or more is left, or when the cap is already reached.
  • src/web/pages/repo.ts: the existing #wallet-line shows the low sentence when the cap-reached sentence doesn't apply.
  • src/web/pages/next.ts: a new #wallet-row reads "Top up the wallet" and links to /<owner>/<repo>/wallet. It sits in the page body, not above it.
  • Both show only to repository admins, as the existing cap line already does. An exhausted wallet keeps its own sentence, so there are never two lines.
  • test/wallet-low-line.test.ts checks three states: nothing at 20% or more left, the line and row under 20%, and only the reached sentence once the wallet is spent. It would fail without this change.

What I left alone

  • src/web/pages/bets.ts was in the issue's file list but didn't need touching.
  • The terminal and MCP surfaces don't show the low line.

The first push was refused by the pre-push hook because no commit said how to try the change, so I added an empty Try: commit.

To try it Set a $10 cap at /<owner>/<repo>/wallet and record over $8 of spend. Then open the repository page and /next as an admin.

🤖 Generated with Claude Code

Closes #13529

5 earlier comments · 1 event
commented

A repository whose wallet is under 20% left now shows one quiet line on its page and one row in /next, with no banner above the content. The new test and the existing wallet route tests pass (8 tests), and tsc, scripts/gate.ts --fix and design-lint are clean. I did not run the full suite, since the forge runs that on push.

What changed

  • src/core/wallet.ts has WALLET_LOW_SHARE = 0.2 and lowWallet(). The balance is the cap minus the month's spend, read from the usage ledger as before, so there is no new store. It returns Wallet: $X left of $Y, with cents only when the amount isn't whole, e.g. Wallet: $1.50 left of $10. It returns nothing when there is no cap, when 20% or more is left, or when the cap is already reached.
  • src/web/pages/repo.ts: the existing #wallet-line shows the low sentence when the cap-reached sentence doesn't apply.
  • src/web/pages/next.ts: a new #wallet-row reads "Top up the wallet" and links to /<owner>/<repo>/wallet. It sits in the page body, not above it.
  • Both show only to repository admins, as the existing cap line already does. An exhausted wallet keeps its own sentence, so there are never two lines.
  • test/wallet-low-line.test.ts checks three states: nothing at 20% or more left, the line and row under 20%, and only the reached sentence once the wallet is spent. It would fail without this change.

What I left alone

  • src/web/pages/bets.ts was in the issue's file list but didn't need touching.
  • The terminal and MCP surfaces don't show the low line.

The first push was refused by the pre-push hook because no commit said how to try the change, so I added an empty Try: commit.

To try it Set a $10 cap at /<owner>/<repo>/wallet and record over $8 of spend. Then open the repository page and /next as an admin.

🤖 Generated with Claude Code

commented

A wallet with under 20% of its monthly cap left, and more than nothing, now shows "Wallet: $X left of $Y" to the repository's admins on three screens. The gate is clean locally. I ran bun test on test/wallet-low-line.test.ts, test/tui-wallet.test.ts and test/wallet.test.ts, all passing. I did not run the broader impact-map set, because scripts/fast.ts reported 2,054 of 3,438 test files and a 174-minute estimate. The forge's check will run it.

  • Repository page: the existing wallet line shows the low-balance sentence when the cap is not yet reached. It links to the wallet page.
  • /next: one row, "Top up the wallet", links to the wallet page. It appears for admins only.
  • Terminal (new in this push): the wallet screen in src/tui/screens/wallet.ts shows the same line under the spent total. This satisfies the gate's "both doors" rule, which failed the first check.
  • How-to: docs/features/wallet-low.md.
  • Gate rule: adding the how-to tripped the "pipeline first" rule, so I pushed an empty commit carrying a Direction: line saying why this goes ahead of pipeline work.

I did not add a terminal test for the new line. The existing tui-wallet.test.ts still passes. I did not touch the cap-reached sentence.

To try it: set a monthly cap of $10 at /<owner>/<repo>/wallet and spend over $8 of it. Then open the repository page and /next, or the wallet screen in the terminal.

🤖 Generated with Claude Code

commented

<!-- look-pages 34e64c4bf5af --> Look pages for 34e64c4, from the gate:

  • look pages (inferred): this pull changes src/web/pages/next.ts, src/web/pages/repo.ts; the forge pictures /settings/crew (src/web/pages/repo.ts), /settings/grants (src/web/pages/repo.ts), /preview-admin/sample (src/web/pages/repo.ts), the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The look-pages note was an inference, not a code defect. It named /settings/crew, /settings/grants and /preview-admin/sample, and only the last of those is where this change shows.

I added an empty commit (fba95aef5) whose message names the pages that picture the change. It has two Looks: lines, and I pushed it. No code changed, so I ran no tests.

  • /preview-admin/sample/next?pick: the low-wallet row in /next. This is the first Looks: line.
  • /preview-admin/sample: the repository page's wallet line. This is the second Looks: line.

The sample repository may not have a wallet cap set. If so, the before/after pictures of those two pages won't show the low-wallet line. To see it, set a cap of $10 at /<owner>/<repo>/wallet, spend over $8 of it, then open the repository page and /next.

I did not add /settings/crew or /settings/grants, because neither page renders this change.

🤖 Generated with Claude Code

commented

A repository whose wallet is under 20% left now shows one line to its admins. It appears on the repository page, as a "Top up the wallet" row in /<owner>/<repo>/next, and on the terminal's wallet screen (#13529).

The check failed on four tests, from two causes, both now fixed and pushed.

  • Missing index row: docs/features/wallet-low.md had no row in docs/features/README.md, which broke the two feature-note tests. I added the row under the wallet entry.
  • Page budgets: the new /next row reads the monthly cap once, which put that page one SQL statement over its budget. I raised the budget by one in src/perf/page_budget.ts (64 to 65) and in test/pages-budget.test.ts (65 to 66). I left the read in place because the row can't be built without the cap. It is one primary-key read, and it stops there when the repository has no cap.

bun scripts/gate.ts --fix rewrapped comments in one file, and I committed that. bun x tsc --noEmit is clean. These pass locally: test/page-budget.test.ts, test/pages-budget.test.ts, test/feature-orphans.test.ts and test/wallet-low-line.test.ts. I didn't run the full suite; the forge runs it on the push.

To try it, set a cap of $10 at /<owner>/<repo>/wallet, spend over $8 of it, then open the repository page and /next.

🤖 Generated with Claude Code

Changes requested — before the latest push

The behaviour is right and the three web states are tested. Four things to fix in one round:

  1. FIRST: the terminal line has no test. walletLines now returns the low sentence, but nothing fails if that change is reverted. Add a case to test/tui-wallet.test.ts (low gives the line, 20%+ left gives none, reached keeps its own sentence).
  2. The tests never check the admin-only gate: a signed-out viewer and a non-admin member must see no wallet-line and no wallet-row. Add that case.
  3. Direction: the owner's order is pipeline first. The pull got past the gate with a Direction: line, and it raises a page budget (+1 statement on /next) when the direction says lower them. Say in the pull why this goes before the pipeline items, or fold the cap read into a query /next already makes so the budget stays at 64.
  4. Design (principles 1, 7, 8): /next hand-rolls <ul class="list setting-list"> and a · lead for one row, and the row's meta repeats the sentence the repository page already shows. Use the named row component alone, with a plain verb title. Also, "Top up" links to a page that sets a cap, so word it as what the page does (e.g. "Raise the monthly cap").

Smaller: the new import in next.ts is out of order with its neighbours. Float subtraction can print $2.00 for a near-whole left; round to cents before formatting.

No banner, one line, and the row sits in the body, not above it.

commented

I addressed all four points except the budget, which I kept at +1 and justify below. The pushed branch passes tsc, the gate and design-lint. I ran the new and affected tests (28 pass), including both page budgets and the feature-orphan test. I didn't run the full suite; the forge does that on push.

  • Terminal test: test/tui-wallet.test.ts now covers walletLines with three cases.

- Under 20% left gives "Wallet: $1.50 left of $10". - 20% or more left gives no wallet line. - A reached cap keeps its own sentence and adds no low line.

  • Admin gate: test/wallet-low-line.test.ts now has a case where a signed-out viewer and a non-admin member see neither wallet-line nor wallet-row, while the admin sees both.
  • Design: the row on /next is now listCard([row(...)]), with no hand-rolled ul, no · lead and no meta. Its title is "Raise the monthly cap". It sits in the body below the "next-week" line, not above the list. The feature note is updated to match.
  • Smaller points: the next.ts import is back in order. dollars() rounds to cents first, so a near-whole balance prints $2 instead of float dust (tested).
  • Budget (not changed): I kept /next at +1 statement (64 to 65 in src/perf/page_budget.ts, 65 to 66 in test/pages-budget.test.ts). The row needs the repository's cap, and no query /next already runs reads repo_wallet. Folding it in would mean adding a column or a join to unrelated queries, which costs more than one primary-key read.

- The direction says pipeline first. Issue #13529 asks for this line, it is a small step the pipeline items don't block, and the Direction: commit says so. - If you'd rather hold the budget at 64, the alternative is to drop the row on /next and keep the repository-page and terminal lines. Say so and I'll do that.

🤖 Generated with Claude Code

Approved

Earlier asks are met. The terminal screen has a test, and the admin-only gate is tested for a signed-out viewer and a non-admin member. The /next row is now listCard([row(...)]) with no hand-rolled markup. The import is in order, dollars() rounds to cents first, and the feature note matches. The +1 statement on the /next budget is justified: one primary-key read of the cap, with no existing query to fold it into. I could not run git diff against my last head, because the clone does not have that commit. I judged the current change in full.

Next, both non-blocking:

  1. Non-blocking: read the cap once in nextPage and pass it down. That would take the /next budget back to 64.
  2. Non-blocking: the gate rewrapped unrelated comments in page_budget.ts and next.ts. Keep gate-only rewraps in their own commit next time, so the diff stays one purpose.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs