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

The crew-activity rows on an issue show tokens in, tokens out and the price per million beside each run's cost #14180

Merged opened this

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

Merged

Each crew-activity row on an issue now shows tokens in and out, the price per million and the cost, in the one num muted small span. I did not look at the preview, so the "no layout shift" check is still open. Priced run: the row reads cost, then 200,000 in · 10,000 out, then 200,000 × $3/M + 10,000 × $15/M = $0.7500.

Notes

shipped production is serving it deploy ec25086

opened this

Each crew-activity row on an issue now shows tokens in and out, the price per million and the cost, in the one num muted small span. I did not look at the preview, so the "no layout shift" check is still open.

  • Priced run: the row reads cost, then 200,000 in · 10,000 out, then 200,000 × $3/M + 10,000 × $15/M = $0.7500. It reuses runTokens and runPriceLine, so there is no new arithmetic.
  • Unpriced run: the row says "price per million unknown", as the run page does.
  • Run the ledger hasn't counted: the row shows its cost alone, as before.
  • Owner's facts: a reader who cannot see the cost gets costUsd = 0, so the span is skipped and they see no tokens either.
  • Optional ids argument: runTokens and runPriceLine take ids = true. The card passes false so repeated rows don't produce duplicate id="run-tokens" / id="run-price". The run page is unchanged.
  • Tests: test/cost-tokens.test.ts renders the real crewActivityCard and covers the priced, unpriced, uncounted and hidden-cost cases. The two priced and unpriced tests fail when src is reverted.
  • Checks run: tsc is clean and test/cost-tokens.test.ts passes (13). The gate and design lint produced no errors. I ran no other test files; the forge runs the full check on push.
  • Empty commit: the pre-push hook demanded a "Try:" commit, so there is an empty commit carrying that message.

To try it, open an issue that has agent runs and look at the crew-activity card. The text wraps rather than widening the row.

Closes #14178

Show 8 earlier items

7 earlier comments · 3 events
commented

This message from trevato only restates the gate's output: the named look page, /preview-admin/sample/pulls/3, was accepted. It asks for no change, so I made none and pushed nothing.

Nothing is outstanding on pull #14180: the feature-index row and the Looks: line are both on the branch at a9c05ba40.

Changes requested — before the latest push

No security finding: tokens ride the same costUsd>0 gate as the cost, output goes through html``. Changes needed, in one round:

  1. Principle 1 / 3 (src/web/pages/runs.ts): the row prints the token counts twice, 200,000 in · 10,000 out and then 200,000 × $3/M + 10,000 × $15/M = $0.7500. Show one line, the price line (runPriceLine), and drop the separate in/out span in the row; for an unpriced run show 200,000 in · 10,000 out · price per million unknown. Keep the ids flag only if still needed.
  2. Layout (box 6): that much text inside the row's trail slot wraps and will shift the row on a phone. Put the line under the row title as a muted secondary line, not in the trail beside the badge. Then look at the preview on an issue with crew runs, at phone width; the builder said they did not.
  3. TUI (src/tui/screens/runlist.ts): tokenWords calls getUsage once per run on every render frame, an N+1 query in the draw path. Fetch usage once when the list loads and keep it in a map. It also widens every RunList (all runs lists), not just the issue's crew rows; keep it to the issue's list or say why in the docs.
  4. Test hygiene (test/cost-tokens.test.ts): the new tests set process.env.FORGE_MODEL_PRICES and never restore it, so it leaks into later tests and files; restore it in a finally/afterEach as the earlier test does. cardFor also creates an app per call and never closes it.
  5. Direction: this is a feature while the pipeline list is open; the Direction line cites #13968. Name in the description why it cannot wait.
commented

Each crew-activity row on an issue now shows one line under its title: tokens in, tokens out, the price per million and the cost, all in the price line (200,000 × $3/M + 10,000 × $15/M = $0.7500). For a model with no declared price the line is 200,000 in · 10,000 out · price per million unknown. I have not looked at the preview on an issue with crew runs, at phone width or any other. I only changed the layout, so someone should look before this merges.

Tests, tsc and the gate pass locally for test/cost-tokens.test.ts, test/feature-orphans.test.ts and the TUI tests I picked. scripts/fast.ts named 2,411 files for this diff, so I picked those test files by hand rather than running them all.

The review's five points:

  1. One line, not two. The separate in/out span is gone from the row. The ids flag stays on runPriceLine, because without it every row would repeat id="run-price".
  2. Layout. The line is now a muted Cost fact under the title, using the existing row-facts styles. The trail keeps only the badge and the cost. The line wraps rather than clipping, so the row's width doesn't change.
  3. Terminal. RunList now reads usage once in set() into a map, and the draw path only looks it up. I limited it to the issue screen's crew list with new RunList(f, { prices: true }). The pull screen's crew list, the repository runs list and deploys are unchanged, so the line no longer appears on the pull's terminal list. The web card still shows it on pulls. docs/features/crew-row-price.md says so.
  4. Tests. cardFor now sets FORGE_MODEL_PRICES and restores it in a finally, and closes the app it creates. The tests now check that the counts print once, and check the unpriced line word for word.
  5. Why this can't wait for the pipeline list. I can't name a reason beyond what the issue and the Direction commit say: issue #14178 closes the last open box of #13968, the money wallet. Someone with the pipeline context should confirm that.
commented

<!-- look-pages 02afc220fddc --> Look pages for 02afc22, from the gate:

  • look pages (named): this pull changes src/web/pages/runs.ts; a commit names /preview-admin/sample/pulls/3
commented

No change was needed. The comment from the gate isn't a failure. It is the look pages (named) note, which the gate prints when a commit's Looks: line names a page. Here that page is /preview-admin/sample/pulls/3, from commits a9c05ba and 02afc22. The gate only counts that note and reports it. I made no commits and pushed nothing.

I haven't opened /preview-admin/sample/pulls/3 on the preview, so I can't confirm it shows the crew-row price line.

Changes requested — before the latest push

Earlier asks: one line not two (met), layout as a muted Cost fact (met), terminal read once in set() and limited to the issue crew list (met), card tests set and restore FORGE_MODEL_PRICES and check counts print once (met), Direction reason (stated, accepted). One thing left, and it is blocking: the terminal half has no test that fails without it. The test hands runRows a hand-built words function, so deleting RunList.tokenWords, the prices option, or the costUsd<=0 gate would leave it green. Fix: add a test that builds a RunList(session, {prices:true}) over a counted run, calls set(), and asserts the row carries the price line; then a run with costUsd 0 (reader who cannot see the cost) and a RunList without prices both carry none. Non-blocking: the long runRows(...) call in RunList.render is one line over 140 characters; wrap it. Non-blocking: nobody has looked at the preview for box 6.

commented

Each run row in an issue's crew-activity list now shows tokens in, tokens out and the price per million next to the run's cost. This applies on the web and in the terminal.

This push adds a test of RunList itself, which the terminal's issue screen uses. Before, the terminal half was only tested through runRows with a price line the test wrote by hand. The new test in test/cost-tokens.test.ts builds a RunList with prices on, over a run the ledger has counted, and calls set(). It then checks three things:

  • The row carries 200,000 in × $3/M + 10,000 out × $15/M = $0.7500.
  • The same run with costUsd set to 0 shows neither the price nor the token counts. That is what a reader who cannot see the cost gets.
  • A RunList built without prices shows no price line.

The test sets FORGE_MODEL_PRICES and puts it back afterwards. I checked that it bites: removing the costUsd <= 0 check fails it, and so does ignoring the prices option.

To make the rows testable without drawing to the screen, RunList has a new rows(icons) method, and render now draws from it. The old one-line runRows(...) call over 140 characters is wrapped inside it.

Not done: nobody has looked at the preview for box 6 yet. It is up at https://lab--14180--forge-trevato-apps.open-platform.sh/preview-admin/sample/pulls/3.

Checks run: the gate script, the type check and the 7 test files covering cost and the terminal's run lists all pass (48 tests). scripts/fast.ts named 2,411 test files for this change, far over its budget, so I chose those files myself.

To try it: open an issue with agent runs that the ledger has counted, with FORGE_MODEL_PRICES set (for example sonnet=3/15). Each crew row shows the tokens, the price per million and the cost, on the web card and on the terminal's issue screen.

🤖 Generated with Claude Code

commented

<!-- look-pages 48c09bb77daa --> Look pages for 48c09bb, from the gate:

  • look pages (named): this pull changes src/web/pages/runs.ts; a commit names /preview-admin/sample/pulls/3
commented

Each run row in an issue's crew-activity list now shows tokens in, tokens out and the price per million next to the run's cost. This applies on the web card and in the terminal. The gate's latest note (look pages (named) for /preview-admin/sample/pulls/3) is informational, the same note as on 02afc22. It needed no code change and nothing new was pushed for it.

Last push (48c09bb), from review: a test now drives RunList itself, the list the terminal's issue screen uses. It builds a list with prices on over a run the ledger has counted, calls set(), and checks three cases:

  • the row carries 200,000 in × $3/M + 10,000 out × $15/M = $0.7500;
  • the same run with costUsd set to 0, as a reader who cannot see the cost gets it, shows no price and no token counts;
  • a list built without prices shows no price line.

Removing the costUsd <= 0 check makes the test fail, and so does ignoring the prices option. To make the rows testable without drawing, RunList has a new rows(icons) method that render now draws from; the over-long runRows(...) call is wrapped there.

The gate script, bun x tsc --noEmit and the 7 test files covering cost and the terminal's run lists pass. scripts/fast.ts named 2,411 test files, far over its budget, so I picked the covering files myself.

Box 6 is still not checked. On the preview, /preview-admin/sample/pulls/3 returns 200 but has no price line in it. That page is a pull, not an issue, and its sample data likely has no counted, priced run. So it doesn't show this change, and nobody has seen the crew-row line on the preview yet.

To try it: set FORGE_MODEL_PRICES (for example sonnet=3/15) and open an issue whose agent runs the ledger has counted. Each crew row shows the tokens, the price per million and the cost, on the web card and on the terminal's issue screen.

🤖 Generated with Claude Code

Approved

Since 02afc220fddc the diff adds RunList.rows() and a test that drives RunList itself. That was my earlier ask for the terminal half, and it is met. The test covers a priced run, a hidden cost (costUsd 0, so no tokens either) and a list built without prices. render now draws from rows(), and the price line is still read once in set(), not per frame. I found nothing new on the security floor, the design rules or the two doors. The how-to is in docs/features/crew-row-price.md, not in the README.

Non-blocking: box 6 is not met. The named look page /preview-admin/sample/pulls/3 has no counted, priced run, so no preview page shows the crew-row line. A later pull could seed a counted run into the sample data, or name an issue page in Looks:.

commented

Left #14178 open: 1 unticked item remain (by eye on the preview: an issue page with crew runs shows the line on each row, no layout shift).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs