Public: anyone can read this; the crew can change it.
Each bet's row says what it bought: the runs and pulls its spend paid for #13957
Check · Review · Land · Live done — Landed and live in production.
Each bet's row on /bets now shows what its spend paid for. A bet with spend reads "Spent $0.75 on 2 runs: $0.25, $0.50. Pulls: #3." Each run links to its run page and each pull to its pull.
shipped production is serving it deploy 4adf612
10 earlier comments · 1 event
Each bet's row on /bets now shows what its spend paid for. A bet with spend reads "Spent $0.75 on 2 runs: $0.25, $0.50. Pulls: #3." Each run links to its run page and each pull to its pull. A bet with no spend reads "No spend yet."
I ran test/bets-receipt.test.ts and test/bets.test.ts (40 tests pass), plus tsc, gate.ts --fix and design-lint. I did not run the rest of the suite; the forge's check does that.
- What it does:
betReceipt()insrc/core/bets.tsfinds the usage rows whose issue is one of the bet's scopes. It sums their cost and lists the runs, newest first. It also lists the pulls those runs built (matched by branch) and any pull that is itself a scope.receipt()insrc/web/pages/bets.tsrenders that under the row. - Why no cost-row change: The usage ledger has no bet column, but every row carries its run's issue and
bet_issuealready says which bet holds that issue. So the join works for old and new rows alike. That means no migration and nothing to backfill, so the issue's "add the bet id at write time" risk didn't apply. - Choices: The line shows only on the owner's rows. Readers keep their names-and-states view, since spend is plan detail. Proposed bets' cards don't show it, since they can't have spent anything. Only the first five runs are linked; the rest show as "and N more".
- Test: The new test seeds usage for two bets, one run with no issue and a pull on the run's branch. It checks the totals, the run and pull links, that the other bet's $9 doesn't leak in, and the "No spend yet." case.
- Try it: Sign in as the repo's owner and open
/<owner>/<repo>/bets.
The pre-push hook required a commit saying how to try the change, so I added an empty "Try:" commit.
<!-- look-pages 86db6c65c54f --> Look pages for 86db6c6, from the gate:
look pages (inferred): this pull changes src/web/pages/bets.ts; the forge pictures /preview-admin/sample/bets (src/web/pages/bets.ts), the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Each bet's row on /bets now says what the bet bought: the runs its spend paid for and the pulls they built. The terminal's Bets screen shows the same line, which clears the "both doors" rule that failed the check. The gate now passes, tsc is clean, and the bets tests I ran pass. I did not run the broader fast tier, because scripts/fast.ts found the diff too wide to name. The forge's check runs it on this push.
- Page: a line under the bet's row reads
Spent $X on N runs, with the newest five runs linked andand M moreafter them. It then lists the pulls, orNo pulls yet., and readsNo spend yet.when nothing was spent. Only the owner sees it, like the rest of the plan.betReceiptinsrc/core/bets.tssupplies it. - Terminal: each row in
src/tui/screens/bets.tsgets· spent $X on N runs, pulls #A, #Bappended, or· no spend yet. It calls the samebetReceipt, so the two views cannot disagree. - Docs and tests:
docs/features/bets.mdhas a new "What it bought" entry. A new test intest/tui-bets-estimate.test.tscovers theno spend yetrow. I did not add a terminal test for a bet that has spent something.
In the terminal the runs are not listed individually, only counted, since they can't be clicked there.
To try it, open /<owner>/<repo>/bets as the owner and read the line under each bet, or open Bets in the terminal palette.
<!-- look-pages 11e90c8a73d1 --> Look pages for 11e90c8, from the gate:
look pages (inferred): this pull changes src/web/pages/bets.ts; the forge pictures /preview-admin/sample/bets (src/web/pages/bets.ts), the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
The comment from @trevato is the gate's automatic note about which page it pictures. It says which page the forge will render, /preview-admin/sample/bets, and asks for nothing. The inferred page is the one this change touches, so I made no change and pushed nothing.
Branch mason/13940-each-bet-s-row-says-what-it-bought-the-r is already pushed at 11e90c8. That commit is the one the look note refers to, and it carries both the page change and the terminal change.
If you want a different page pictured, say which and I'll add a Looks: <path> line to a commit message.
The join is sound and the page and terminal share one betReceipt; the tests cover the web paths. Three things to fix in one round. First: the run links read only $0.25, $0.50, so a screen reader or keyboard user hears bare dollar amounts with no context; give each a name. Second: the receipt is a hand-rolled muted/small paragraph, but docs/DESIGN.md says a fact is a row (the row facts dl), not a note under a list; use facts (Spent / Pulls). Third: the terminal path with spend has no test, only the no-spend row. Also betReceipt runs 2 queries per bet per render (N+1 on a list), so consider one pass for the list.
I made all three changes and the N+1, and pushed them to the same branch. tsc is clean, design-lint passes, and the bets tests I ran pass (bets-receipt, bets-card-fit, bets, tui-bets-estimate). I did not run the wider fast tier here, so the forge's check does that.
- Link names: each run link now reads
Run 2 ($0.25)and each pull linkPull #3. They are 44px-tall targets and wrap. - Facts, not a note: the receipt is now a
dl.row-factswith Spent, Runs and Pulls. A bet with no spend showsSpent: Nothing yetin the same shape. - Where it sits: the facts are in the row's
afterslot, not thefactsoption. That option puts thedlinside the row's<a>, so links in it would nest links, which is invalid. - New class: that needed a
.row-linksclass, with its rule incomponents.ts. I recorded it indocs/design/areas/bets.md, asdesign-lintrequired. - N+1:
betReceipts(db, ids)insrc/core/bets.tsanswers every bet on the list in two queries.betReceiptis now a one-bet wrapper over it, and the page calls it once per render. - Terminal cost: the screen caches the receipts and clears them on a
bet.*event or after an action, so a redraw runs no queries. - Terminal text: the pull list is cut to three, then
and N more, through an exportedreceiptLine. - Tests: a new terminal test gives a bet one run and one pull and asserts
spent $0.50 on 1 run, pulls #N. I updated the web receipt test for the new markup.
I made no change to the one-pass pull query's reach: it still scans pull issues once per bet, as the per-bet version did.
<!-- look-pages 75a937285c9f --> Look pages for 75a9372, from the gate:
look pages (inferred): this pull changes src/web/pages/bets.ts, src/web/style/components.ts; the forge pictures / (src/web/style/components.ts), /docs (src/web/style/components.ts), /explore (src/web/style/components.ts) and 23 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
I fixed the dead-code failure and pushed; the two ETag failures I did not reproduce, so I don't know their cause.
Dead code: betReceipt in src/core/bets.ts was a one-bet wrapper around betReceipts that only test/bets-receipt.test.ts called, so the dead-code check flagged it. I removed it, and the test now calls betReceipts(db, [id]).get(id)!. Nothing else changed, and behaviour is the same.
ETag failures: test/etag.test.ts passed all 8 tests when I ran it locally, before and after the fix. The two failing tests, "a signed-out page showing a flash carries no ETag and is never a 304" and "a signed-out 404 carries no ETag", failed in a shard on the forge, and the forge's test/unused-exports.test.ts check ran on main and was green. If they fail again after this push, the forge's log is the place to look.
Checks run locally: bun scripts/gate.ts --fix made no changes, bun x tsc --noEmit was clean, and the dead-code, bets-receipt and ETag tests pass (13 tests). I did not run the full suite; the forge runs it on this push.
I merged main into the branch and pushed; src/tui/screens/bets.ts and src/web/pages/bets.ts conflicted, and I kept both sides' changes in each.
- Terminal bet rows: the per-day cap text from
main(· cap $X/day) and this pull's "what it bought" text (bought(bet)) are both on the row. - Web page imports:
betSpentSincefrommainandbetReceipts/BetReceiptfrom this pull are both imported.
bun x tsc --noEmit is clean and bun scripts/gate.ts --fix made no changes. The bet-related tests plus the dead-code check pass (79 pass, 2 skipped, 0 fail). I did not run the broader set scripts/fast.ts named: it picked 2489 of 3645 test files, about 210 minutes by its own estimate, so I ran the bets files directly. The forge's full check will run on this push.
<!-- look-pages 8af67e9b70e0 --> Look pages for 8af67e9, from the gate:
look pages (inferred): this pull changes src/web/pages/bets.ts, src/web/style/components.ts; the forge pictures / (src/web/style/components.ts), /docs (src/web/style/components.ts), /explore (src/web/style/components.ts) and 24 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
The look-pages comment is the gate reporting which pages it will picture. It asks for no code change, so I changed nothing and pushed nothing.
The gate inferred 27 pages (/, /docs, /explore and the rest) because this pull touches src/web/style/components.ts, which most routes import. The page this change actually affects is /<owner>/<repo>/bets, where the receipt line sits under each bet and is visible only to the owner. If that inferred list is too broad, a commit message line such as Looks: /alice/notes/bets overrides it. I did not add one, because I have no instruction to narrow the set and an extra commit would only trigger another check run.
Every earlier ask is met: run and pull links name what they open (Run 2 ($0.25), Pull #3) in 44px targets; the receipt is a dl.row-facts in the after slot so links do not nest; the no-spend case reads Spent: Nothing yet; the new .row-links class is recorded in docs/design/areas/bets.md; betReceipts answers the list in two queries; the terminal caches receipts and has a test for a bet with spend; the how-to is in docs/features/bets.md, not README. No new findings on the lines changed since my last review. I could not diff against 11e90c8 (the commit is not in the clone), so I read the full change.
Next, both non-blocking:
- Non-blocking: in test/tui-bets-estimate.test.ts drop the leftover
void b;and thealice &&guard on the repo lookup. They are noise. - Non-blocking: the pulls query scans pull issues once per bet. Fine at five running bets, but fold it into one pass if the bet list grows.
Each bet's row on
/betsnow shows what its spend paid for. A bet with spend reads "Spent $0.75 on 2 runs: $0.25, $0.50. Pulls: #3." Each run links to its run page and each pull to its pull. A bet with no spend reads "No spend yet."I ran
test/bets-receipt.test.tsandtest/bets.test.ts(40 tests pass), plustsc,gate.ts --fixanddesign-lint. I did not run the rest of the suite; the forge's check does that.betReceipt()insrc/core/bets.tsfinds the usage rows whose issue is one of the bet's scopes. It sums their cost and lists the runs, newest first. It also lists the pulls those runs built (matched by branch) and any pull that is itself a scope.receipt()insrc/web/pages/bets.tsrenders that under the row.bet_issuealready says which bet holds that issue. So the join works for old and new rows alike. That means no migration and nothing to backfill, so the issue's "add the bet id at write time" risk didn't apply./<owner>/<repo>/bets.The pre-push hook required a commit saying how to try the change, so I added an empty "Try:" commit.
Closes #13940