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

A repository's wallet page totals spend per month, above the ledger #14471

Merged opened this

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

Merged

/ / /wallet now has a "Spend per month" table above the 30-day and ledger tables. It has columns for month, spends and total, newest first, up to 12 months, with totals written as $x.xx like the ledger.

Notes

shipped production is serving it deploy 4b0992f

opened this

/<owner>/<repo>/wallet now has a "Spend per month" table above the 30-day and ledger tables. It has columns for month, spends and total, newest first, up to 12 months, with totals written as $x.xx like the ledger. The new test and the existing wallet tests pass and tsc is clean; I did not run the full suite, which the forge's check does on push.

  • Grouping: src/actions/wallet_months.ts does it in one SQL query by UTC month. It is not a separate pure function, since SQL does the grouping. It is shown only to people who can read the wallet, because it sits inside the existing page and its gate.
  • UTC: the page says "Months are UTC calendar months; the last 12 with spend, newest first."
  • Empty wallet: a wallet with no spends renders no table.
  • wallet.csv: its columns are unchanged.
  • Tests: test/wallet-months.test.ts covers four things. Months group in UTC across a month boundary, newest first. Totals and spend counts equal the sum of the rows readWallet lists, which is what wallet.csv writes. Fourteen months are cut to 12. The page shows the table to the owner, returns 404 to a guest, and shows no table for a wallet with no spends.
  • Months with no spend: a month with no spends is skipped, not shown as a zero row.
  • Ledger vs table: the ledger below lists only the last 20 spends. The monthly totals cover everything in those months, so they match the listed rows only while a wallet has fewer than 20 spends. That is the case the test asserts.
  • Extra commit: the repo's pre-push hook wanted a "Try:" commit, so one empty commit with that message is on the branch.
  • To try: open /<owner>/<repo>/wallet as the owner of a repo that has spends.

🤖 Generated with Claude Code

Closes #14458

7 earlier comments · 1 event
commented

/<owner>/<repo>/wallet now has a "Spend per month" table above the 30-day and ledger tables. It has columns for month, spends and total, newest first, up to 12 months, with totals written as $x.xx like the ledger. The new test and the existing wallet tests pass and tsc is clean; I did not run the full suite, which the forge's check does on push.

  • Grouping: src/actions/wallet_months.ts does it in one SQL query by UTC month. It is not a separate pure function, since SQL does the grouping. It is shown only to people who can read the wallet, because it sits inside the existing page and its gate.
  • UTC: the page says "Months are UTC calendar months; the last 12 with spend, newest first."
  • Empty wallet: a wallet with no spends renders no table.
  • wallet.csv: its columns are unchanged.
  • Tests: test/wallet-months.test.ts covers four things. Months group in UTC across a month boundary, newest first. Totals and spend counts equal the sum of the rows readWallet lists, which is what wallet.csv writes. Fourteen months are cut to 12. The page shows the table to the owner, returns 404 to a guest, and shows no table for a wallet with no spends.
  • Months with no spend: a month with no spends is skipped, not shown as a zero row.
  • Ledger vs table: the ledger below lists only the last 20 spends. The monthly totals cover everything in those months, so they match the listed rows only while a wallet has fewer than 20 spends. That is the case the test asserts.
  • Extra commit: the repo's pre-push hook wanted a "Try:" commit, so one empty commit with that message is on the branch.
  • To try: open /<owner>/<repo>/wallet as the owner of a repo that has spends.

🤖 Generated with Claude Code

commented

<!-- look-pages ab365e9a6be6 --> Look pages for ab365e9, from the gate:

  • look pages (none): this pull changes src/web/pages/wallet.ts but the forge could not trace the route of /settings/security/controls (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

The wallet page now has a "Spend per month" table above the 30-day and ledger tables. It lists month, spends count and total in US dollars, newest first, up to 12 UTC months, and the page says the months are UTC. The code is unchanged since the first push. This push only adds one commit carrying the lines the failing gate asked for.

The gate had flagged three rules, and the commit message answers each:

  • Pipeline first: a Direction: line says the issue asks for this money-pillar view ahead of pipeline items (#14458).
  • Both doors: a No door: line says the monthly totals are a read-only table on the wallet web page, and the terminal wallet screen is outside this issue.
  • Look pages: a No look: line says the gate could not trace the wallet route, and the table is server-rendered inside the existing page.

bun scripts/gate.ts printed nothing after that commit, and the push went through. The forge's check on pull #14471 has not reported back yet.

The tests for the table are unchanged from before. The ledger below the new table still lists only the last 20 spends. The monthly totals cover every spend in those months, so they match the listed rows only while a wallet has fewer than 20 spends, which is what the test asserts. A month with no spends is skipped, not shown as a zero row.

Anyone who can read the wallet sees the table, and an empty wallet shows none. wallet.csv is unchanged. To try it, open /<owner>/<repo>/wallet as the owner of a repo that has spends.

🤖 Generated with Claude Code

commented

Nothing to change: no page of app.looks shows the wallet, and adding one would change forge.json for a look nobody asked for.

The look-pages note was generated for ab365e9, before commit 894ad866a. That later commit already carries the line the gate asks for:

No look: the wallet page route is not traceable by the gate; the table is server-rendered inside the existing wallet page

The gate's message is advisory ("the reviewer decides"), and its own text accepts a No look: line in place of a Looks: line.

The wallet page is behind the repo owner's session, so a look of it would need a sample repo with spend seeded in. That is a separate change. To see the table, open /<owner>/<repo>/wallet as the owner of a repo that has spends, on this pull's preview.

No code or push this turn.

🤖 Generated with Claude Code

commented

The wallet page now totals spend per UTC month above the ledger, and I raised the wallet page's statement cap from 40 to 41 to cover it.

The month table needs one more query (readWalletMonths). The page was already at exactly 40 statements, so the extra query broke the "10,000 ledger rows" test. I changed that test's cap rather than the code, because the extra statement is deliberate. It still catches a per-row query.

test/wallet.test.ts and test/wallet-months.test.ts pass, and bun x tsc --noEmit is clean. I did not run scripts/gate.ts.

I did not change anything for the other two failures. test/attention.test.ts and test/snappy.test.ts pass locally with no changes. On the forge, "home owner answers under its p95" failed at 813 ms, which looks like load on a busy shard. The wallet page is not in the first-view budget table, so my change shouldn't affect it. If either fails again on this push, it is not caused by this pull.

To try it, open /wallet on a repository that has spends and read the "Spend per month" table.

commented

I merged main into the branch and pushed it. The wallet tests pass (32 tests) and bun x tsc --noEmit is clean. I didn't run the full suite, because the forge runs it on the push.

  • src/web/pages/wallet.ts: The page now has main's days-left line and my "Spend per month" table. I dropped my second readWalletDays call and use main's daily, so the page reads the daily rows once.
  • test/wallet.test.ts: The statement cap for the 10,000-row page is 41. Main's 40 stands, plus the one statement for the month totals.
  • bun scripts/gate.ts --fix: It rewrapped comments in three files, and I committed that in the merge commit. It still prints two "one implementation?" similarity notes, on readWalletMonths and on spend in test/wallet-months.test.ts. I left both alone.

To try it, open /wallet on a repository with spends and read the "Spend per month" table above the last-30-days table.

commented

The gate failure is fixed and pushed. I restored src/git/pace.ts and test/check-times.test.ts to match main. My earlier gate --fix had rewrapped comments in them that this pull didn't write. The pull's diff against main is now four files:

  • src/actions/wallet_months.ts
  • src/web/pages/wallet.ts
  • test/wallet-months.test.ts
  • test/wallet.test.ts

I merged main again first, with no conflicts. bun scripts/gate.ts now reports only two "one implementation?" similarity notes (readWalletMonths, spend in the wallet-months test). Those were also in the failing log, but the gate only failed on the two comment rules. I haven't re-run the forge's check on this push. Locally, the wallet tests pass (32 tests) and bun x tsc --noEmit is clean.

Changes requested — before the latest push

The table works and the page gate is unchanged, but three things need fixing in one round.

  1. Both doors: the terminal wallet screen (src/tui/screens/wallet.ts) shows no monthly totals. Add them there, reading readWalletMonths, with a test, and say so in docs/features/wallet.md (which still says the page lists only the last 20 spends). The commit message line saying the terminal is out of scope does not satisfy the rule.
  2. Box 2: the test proves months equal the ledger only for fewer than 20 spends, because the ledger is capped at 20. With more spends the table and the ledger/wallet.csv disagree, and the page does not say so. Either word the table so it is clearly all spend in those months (not the rows below), or add a test with more than 20 spends that asserts the totals equal the sum of all rows in those months.
  3. Direction: this is a feature while the pipeline items (#6534, #6611, #5276 and the rest) are open. Keep it small, but do not widen it further.

Smaller: the explanatory paragraph under the h3 explains itself twice (principle 1). Cut it to one short line, e.g. UTC months, newest first. The month table duplicates the page heading rhythm without a lead sentence; keep the h3 only.

commented

I made the three changes juniper asked for and pushed them. The wallet tests, the terminal wallet tests and bun x tsc --noEmit pass locally; I haven't run the forge's check on this push.

  1. Both doors:
    • The terminal wallet screen in src/tui/screens/wallet.ts now reads readWalletMonths. It shows one line, Per month, all spends, UTC: 2026-11 $1.25 · 2026-10 $2.50 …, newest first.
    • That line appears only for an admin, because that screen's gate is the admin check. Non-admins see the months on the web page only.
    • The terminal is no longer out of scope. A new test in test/tui-wallet.test.ts covers the line, and covers its absence when a repository has no spends.
    • docs/features/wallet.md has a new "Spend per month" bullet. It says the totals cover every spend in those months, not only the 20 rows listed, and that the terminal prints them.
  2. Box 2: I did both fixes. The line under the heading now says the table covers all spends, and a new test in test/wallet-months.test.ts records 25 spends in one month. It asserts that month totals 25 spends and $12.50 while the ledger lists 20.
  3. Direction: I added nothing beyond that. The explanatory paragraph under the h3 is now one line, All spends, UTC months, newest first., and the h3 stays.

The gate still prints two "one implementation?" similarity notes, on readWalletMonths and on spend in the months test. I left them alone; they did not fail the earlier check.

I did not change the file-level heading in docs/features/wallet.md, "the last 20 spends". It still describes the ledger the page lists, which is still 20 rows.

Approved

Earlier asks, all met on this head: (1) both doors: the terminal wallet screen prints the months (admin-only, same gate as that screen) with a test for presence and absence, and docs/features/wallet.md carries the how-to, not README; (2) box 2: the 25-spend test shows the month totals cover every spend, and the page line says "All spends"; (3) the explainer under the h3 is down to one line. Table is a plain table in table-scroll, no JS, no new accent, no card, month as row header, numbers right-aligned in mono, so it holds on a 360px phone. Empty wallet renders no table; gate is the existing page gate. Next, non-blocking: (a) the terminal months line can reach 12 entries and gets cut at narrow widths, so consider showing only the newest 3 there; (b) the two gate similarity notes (readWalletMonths, spend helper) could be folded into existing helpers.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs