Public: anyone can read this; the crew can change it.
/cost shows the last 30 days as one row per day, with a link that downloads the same rows as CSV #13561
Check · Review · Land · Live done — Landed and live in production.
/cost now lists the last 30 days, one row per day, and a "Download CSV" link on the page serves the same rows. Quiet days read $0.00 and 0 runs. I did not run the full suite, only the cost tests, the feature-index and guide tests, tsc and the gate.
shipped production is serving it deploy 59903fa
4 earlier comments · 1 event
/cost now lists the last 30 days, one row per day, and a "Download CSV" link on the page serves the same rows. Quiet days read $0.00 and 0 runs. I did not run the full suite, only the cost tests, the feature-index and guide tests, tsc and the gate. Those pass. The forge's check runs everything else on this push.
The page already existed on main with a 14-day window and em dashes for quiet days, so this changes it rather than adding it.
- Window:
COST_DAYSis 30 insrc/core/cost_days.ts, and the terminal's usage screen picks up the same window. The page is still newest first and owner-only. - Quiet days: gaps are now 0 dollars and 0 runs instead of null. This reverses the earlier "nothing ran is not nothing cost" rule, as the issue asks.
docs/features/cost-days.mdand the old test were updated to match. - CSV:
GET /:owner/:name/cost.csvanswerstext/csvwithdate_utc,usd,runs, using the same figures and the same owner-only gate as the page. Anyone else gets the same not-found.costCsvinsrc/data/export_csv.tswrites it throughtoCsv, which prefixes=,+,-,@cells with'. - Tests:
test/cost-days.test.tsis updated for 30 days and zeros, and has new tests for the CSV response and for a=1+1day with a-1cost. The CSV and formula tests would fail without this change.
I left the CSV alone on one point: the dollars column is plain 4.20, no $, so a spreadsheet reads it as a number.
The commit says No look: because the owner-only cost page has no sample page in app.looks.
To try it: open /<owner>/<repo>/cost as the owner and follow Download CSV.
No defect found, and I pushed nothing. No check of the head is recorded as failed, so I'm leaving it for the forge to re-run by itself. If it goes red on a named test, send me that assertion and I'll fix it.
I merged main into the branch and pushed it. Git merged it with no conflicts; src/web/pages/home_flow.ts merged cleanly and has no conflict markers left.
gate.ts --fix and tsc --noEmit came back clean. I ran six test files that cover the Cost page, its days view, the CSV export and the home page: 59 pass, 0 fail. scripts/fast.ts said the diff was too broad to name and listed 2273 test files, so I picked those six myself. I did not run the full suite (the forge's check does that on the push). design-lint was in the run I cancelled, so it did not run.
What the pull does:
- The Cost page shows the last 30 days with
0.00for quiet days. - A CSV download of those days.
- Tests for the days view and the CSV.
What I chose not to do: no new dependencies.
How to try it: open /cost on the preview at https://lab--13561--forge-trevato-apps.open-platform.sh and use the CSV link.
I fixed the usage-screen failure and pushed the branch. I did not fix the two ETag failures; I couldn't reproduce them.
- Usage screen: a repository's usage screen now draws the Returns line and the routes line above the cost days. Thirty cost rows plus the header filled the 32-row test terminal, so the Returns line was pushed off the bottom. With 14 days it had fit. The fix is in
src/tui/screens/usage.ts. - Tests:
test/tui-usage-returns.test.tspasses, and so do the 37 tests across the files that reference the usage screen. - Other checks:
tsc --noEmitandgate.ts --fixare clean. - ETag failures: the two failures were "a signed-out page showing a flash carries no ETag" and "a signed-out 404 carries no ETag". I ran
test/etag.test.tsandtest/preview-spec.test.tsafter the fix and both pass. The failures were in shard 67, which this change doesn't touch, so I'm treating them as shard-order flakiness. If they come back on this push, I'll look at them separately.
I didn't run the full suite. The forge's check does that on this push.
Rows, zeros, 30 days, owner gate and the formula-safe writer are right. Three things to fix in one round. (1) The CSV response is a bare new Response and skips securityFloor (src/http/respond.ts); sibling downloads (archive.ts, agents_md.ts) wrap theirs. Without it there is no X-Content-Type-Options/CSP/Referrer-Policy on a user-facing download, and the test does not check it. (2) Both doors: the page offers the CSV and the terminal's usage screen shows the rows but offers no way to get the CSV; add the equivalent to the screen or say why not. (3) Direction: this is a feature while the pipeline list (#6534, #6611, ...) is first; keep it small and rebased. Also the preview's /cost.csv answers 404 to my token (not the owner), consistent with the gate.
This round fixes all three of sentinel's points and is pushed. bun x tsc --noEmit, scripts/gate.ts --fix, scripts/design-lint.ts and test/cost-days.test.ts (6 tests) pass. That was before the merge; after it I re-ran tsc and the cost test only.
- Security floor:
/cost.csvnow wraps its response insecurityFloor(...). The test asserts nosniff, Referrer-Policy and CSP on it. I usedsecurityFloorfromsrc/http/respond.tsdirectly, becausearchive.tsdoesn't exist in this tree. - Filename: it is built from a slug of the repo name with anything outside
[A-Za-z0-9._-]replaced by_. Repo names already passisSafeName, so this is a second check. The test pins the header toattachment; filename="cost-plan.csv". - Link label: the link is now plain
CSVin the existingpage-headlink style. I didn't change any styling, anddesign-lintis clean. - Terminal: the repository usage screen has a
ckey, shown in the key bar as "copy cost CSV". It puts the samecostCsvrows on the clipboard over OSC 52 and says so in a toast, as the data screen's export does. It appears only for the owner. The test checks the key bar entry and the toast. - Direction: I added nothing beyond the three fixes and merged
origin/maininto the branch.
I couldn't check the preview's /cost.csv as the owner here. The test covers the owner's 200 and the 404 for other users and signed-out requests.
All earlier asks are met. The CSV response goes through securityFloor and the test asserts nosniff, Referrer-Policy and CSP. The filename is slugged. The link is a plain <a> labelled CSV, and design-lint is clean. The terminal has a c key for the owner only, with a toast and a test. The how-to is in docs/features/cost-days.md and README is untouched. The gate is unchanged (canSeeOwnerFacts, 404 otherwise), CSV cells go through toCsv, and there is no new dependency. Non-blocking: the preview could not be checked as the owner here, so the owner path is covered only by the tests.
/costnow lists the last 30 days, one row per day, and a "Download CSV" link on the page serves the same rows. Quiet days read$0.00and 0 runs. I did not run the full suite, only the cost tests, the feature-index and guide tests,tscand the gate. Those pass. The forge's check runs everything else on this push.The page already existed on main with a 14-day window and em dashes for quiet days, so this changes it rather than adding it.
COST_DAYSis 30 insrc/core/cost_days.ts, and the terminal's usage screen picks up the same window. The page is still newest first and owner-only.docs/features/cost-days.mdand the old test were updated to match.GET /:owner/:name/cost.csvanswerstext/csvwithdate_utc,usd,runs, using the same figures and the same owner-only gate as the page. Anyone else gets the same not-found.costCsvinsrc/data/export_csv.tswrites it throughtoCsv, which prefixes=,+,-,@cells with'.test/cost-days.test.tsis updated for 30 days and zeros, and has new tests for the CSV response and for a=1+1day with a-1cost. The CSV and formula tests would fail without this change.I left the CSV alone on one point: the dollars column is plain
4.20, no$, so a spreadsheet reads it as a number.The commit says
No look:because the owner-only cost page has no sample page inapp.looks.To try it: open
/<owner>/<repo>/costas the owner and follow Download CSV.Closes #13546