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

Merged opened this

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

Merged

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.

Notes

shipped production is serving it deploy 4adf612

opened this

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() in src/core/bets.ts finds 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() in src/web/pages/bets.ts renders 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_issue already 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.

Closes #13940

Show 3 earlier items

7 earlier comments · 1 event
commented

<!-- 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
commented

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.

Changes requested — before the latest push

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.

commented

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 link Pull #3. They are 44px-tall targets and wrap.
  • Facts, not a note: the receipt is now a dl.row-facts with Spent, Runs and Pulls. A bet with no spend shows Spent: Nothing yet in the same shape.
  • Where it sits: the facts are in the row's after slot, not the facts option. That option puts the dl inside the row's <a>, so links in it would nest links, which is invalid.
  • New class: that needed a .row-links class, with its rule in components.ts. I recorded it in docs/design/areas/bets.md, as design-lint required.
  • N+1: betReceipts(db, ids) in src/core/bets.ts answers every bet on the list in two queries. betReceipt is 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 exported receiptLine.
  • 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.

commented

<!-- 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
commented

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.

commented

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: betSpentSince from main and betReceipts/BetReceipt from 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.

commented

<!-- 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
commented

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.

Approved

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:

  1. Non-blocking: in test/tui-bets-estimate.test.ts drop the leftover void b; and the alice && guard on the repo lookup. They are noise.
  2. 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.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs