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

The client list downloads as a CSV: who was sent a forge, when, and what happened #14742

Merged opened this

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

Merged

The client list now downloads as a CSV from /forges.csv, linked as "Download as CSV" at the foot of the forges page. The CSV tests, the client-search and terminal-forges tests, tsc, the design lint, scripts/gate.ts --fix and the guide and feature-index tests pass. I did not run the full suite.

Notes

shipped production is serving it deploy 4ec2c16

opened this

The client list now downloads as a CSV from /forges.csv, linked as "Download as CSV" at the foot of the forges page. The CSV tests, the client-search and terminal-forges tests, tsc, the design lint, scripts/gate.ts --fix and the guide and feature-index tests pass. I did not run the full suite. scripts/fast.ts found the diff too broad to name (2466 files), so I ran the tests covering the change instead.

  • Columns: the file is text/csv with the header client, forge, sent at, state, last seen. The client is the person the forge was sent for, or whoever claimed it if there is no name. State uses the page's own wording ("Claimed", "Not claimed yet", and so on).
  • Spreadsheet safety: it reuses the wallet's writer (src/text/csv_write.ts) rather than a second escaper. Cells starting =, +, -, @, tab or CR get a leading ', and quotes are doubled.
  • Access: admins only, the same gate as the page. Anyone else gets the answer a missing page gets, and the test checks both signed-out and non-admin callers.
  • Code and docs: the builder is src/spawn/clients_csv.ts, the handler forgesCsv is in src/web/pages/forges.ts, and the route is in src/http/server.ts. The reference is docs/features/clients-csv.md.
  • Tests: test/clients-csv.test.ts covers the header, an injecting cell with doubled quotes, and the unauthorised callers.
  • Terminal door: the forges screen gets a c key that only toasts where the CSV is.

Not done:

  • Filtering: the file is the whole list, not the current search or state filter.
  • Row cap: there is none, because the rows come from memory.
  • Look: none, since this adds one link and no layout change.

To try it: sign in as an admin, open /forges and press "Download as CSV". The link only shows once at least one forge has been sent.

Closes #14461

6 earlier comments · 1 event
commented

The client list now downloads as a CSV from /forges.csv, linked as "Download as CSV" at the foot of the forges page. The CSV tests, the client-search and terminal-forges tests, tsc, the design lint, scripts/gate.ts --fix and the guide and feature-index tests pass. I did not run the full suite. scripts/fast.ts found the diff too broad to name (2466 files), so I ran the tests covering the change instead.

  • Columns: the file is text/csv with the header client, forge, sent at, state, last seen. The client is the person the forge was sent for, or whoever claimed it if there is no name. State uses the page's own wording ("Claimed", "Not claimed yet", and so on).
  • Spreadsheet safety: it reuses the wallet's writer (src/text/csv_write.ts) rather than a second escaper. Cells starting =, +, -, @, tab or CR get a leading ', and quotes are doubled.
  • Access: admins only, the same gate as the page. Anyone else gets the answer a missing page gets, and the test checks both signed-out and non-admin callers.
  • Code and docs: the builder is src/spawn/clients_csv.ts, the handler forgesCsv is in src/web/pages/forges.ts, and the route is in src/http/server.ts. The reference is docs/features/clients-csv.md.
  • Tests: test/clients-csv.test.ts covers the header, an injecting cell with doubled quotes, and the unauthorised callers.
  • Terminal door: the forges screen gets a c key that only toasts where the CSV is.

Not done:

  • Filtering: the file is the whole list, not the current search or state filter.
  • Row cap: there is none, because the rows come from memory.
  • Look: none, since this adds one link and no layout change.

To try it: sign in as an admin, open /forges and press "Download as CSV". The link only shows once at least one forge has been sent.

commented

<!-- look-pages 0b4a4433594d --> Look pages for 0b4a443, from the gate:

  • look pages (none): this pull changes src/web/pages/forges.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 client list now downloads as a CSV (client, forge, sent at, state, last seen), with a "Download as CSV" link at the foot of /forges. This push changes no code. It adds one empty commit that carries the three lines the gate asked for.

The check failed on three gate rules, and the commit message now answers each:

  • Look page: Looks: src/web/pages/forges.ts, because the gate could not trace the route of /settings/security/controls to a page.
  • Both doors: No door: says the CSV is a download for the web client list and the terminal has no file to save it to. I added no terminal screen.
  • Pipeline first: Direction: says the export is an operator request that waits on no pipeline item, and names #14461.

I did not re-run bun test, tsc or the gate here, since nothing else changed. The forge's check on this push will show whether the gate now passes.

To try it, sign in as an admin, open /forges and press "Download as CSV" at the foot.

[{"go":"/forges","look":"The foot of the client list has a Download as CSV link","expect":"The link downloads a CSV with the header client, forge, sent at, state, last seen"}]
commented

I pushed another empty commit with the look-pages answer, but the local gate still prints the same "look pages (none)" message, so I can't say it clears.

  • What the gate flagged: the feedback was written against commit 0b4a443. That commit's own look line was malformed: Looks: No look: ….
  • What I added: commit 37ee11b5a carries a No look: line saying the change is a download link at the foot of /forges with no layout change. It also carries Looks: src/web/pages/forges.ts. An earlier commit, c16b02ce8, already had the Looks: line.
  • What I could not confirm: the gate cannot trace the route of /settings/security/controls, since that handler is inline or wrapped, so it cannot infer a page itself. The message says the reviewer decides, which leaves the call with you. Nothing else changed in this push.
commented

The client list's CSV download now lives at /forges/export.csv instead of /forges.csv. That removes the top-level route that was making four of the six checks fail. I ran those four test files and test/clients-csv.test.ts locally and all 53 tests pass; tsc is clean and the gate rewrapped one file, which is in the commit. I did not run the two tests that are also red on main, and I did not run the full suite. I pushed the change.

  • Route marks: I marked the route admin in src/http/marks/forges.json.
  • Design audit: I added forges/export.csv to the not-a-page list in test/design-audit.test.ts, next to fleet/graph.csv.
  • Behaviour change: because the route is marked admin, a non-admin or signed-out request now gets a refusal of 400 or above, a 403 for a signed-in non-admin, not the 404 a missing page gives. I loosened test/clients-csv.test.ts to check that status (400 or above) and that no CSV comes back.
  • Link and docs: the link on /forges, the terminal toast and docs/features/clients-csv.md all use the new path.
  • Not mine: fetch-timeout and docs-link were already red on main, per the check log, so I left them alone.
Changes requested — before the latest push

Three changes. 1) Both doors: the terminal c key only toasts a web path; give the forges screen a real way to get the CSV (e.g. write it under FORGE_APP_DATA and say where, or show it), and fix the doc line to match. 2) Box 2: a non-admin gets the route mark 403, not the missing-page answer; make non-admin and signed-out get the identical 404 and tighten the test to assert 404 (it now accepts any status >=400). 3) Direction: the repo says pipeline first (#6534, #6611, #5276, ...) before any feature; this export waits on none and the pull should say why it jumps the queue or wait. Unit tests otherwise fine; the admin test only covers an empty list, add one with a row.

commented

The forges list now downloads as a CSV from the web page, and the terminal writes the same file. tsc is clean, and the gate and the five test files I ran locally are green (55 pass, 0 fail). I did not run the full suite. One sandbox note: the row test spawns a forge and tried to reach maria--forge.test:443, which the sandbox denied, and the test still passed.

  • Terminal door: on the forges screen, c (admin only) now writes the same CSV to exports/forges-sent.csv under FORGE_APP_DATA. It shows the path and row count in a toast. writeClientsCsv in src/spawn/clients_csv.ts does the writing, and docs/features/clients-csv.md says so.
  • Non-admins get the missing-page answer: I marked /forges/export.csv as open in src/http/marks/forges.json. The handler decides, and it returns the missing-page 404 to anyone who is not an admin, whether signed in or not. The test now asserts exactly 404 instead of "400 or above".
  • Row test: a new test sends a forge for "Maria at the bakery" through the API and checks that the CSV has that row after the header. A second new test covers the terminal write.
  • Why it goes ahead of the pipeline items (#6534, #6611, #5276): it is a read-only export built on the existing clientRows and servedRows, the same rows the page already shows, so it touches none of the pipeline work and none of those items is waiting on it. The Direction: line in c16b02ce8 says the same, citing #14461.
commented

I merged main into this branch and pushed. The only conflict was the NOT_PAGES regex in test/design-audit.test.ts.

I kept main's version, which adds maintenance\.json$, and re-added this branch's forges\/export\.csv$.

bun x tsc --noEmit ran clean. test/design-audit.test.ts and test/clients-csv.test.ts pass, 10 tests in all. I did not run the full suite. scripts/fast.ts reported the merge touches 2,482 test files, over its time budget, so it could not name a smaller set. The forge's check will run the whole suite on this push.

Approved

Earlier asks are met. Preview opened: / answers 200, and /forges/export.csv gives my non-admin token the missing-page 404 with no CSV. The screenshot files are outside this sandbox (the path does not exist for me), so my view of the page is the HTML and the diff: one <a> in the existing footer row, no new component, no new accent, no layout change. The terminal door is there: c on the forges screen writes the same CSV under FORGE_APP_DATA. The feature doc is docs/features/clients-csv.md and README is untouched. The CSV goes through the shared formula-safe writer. Tests cover the header, an injecting cell with doubled quotes, a real row, and the unauthorised callers. Non-blocking: the CSV is uncapped, fine for an admin-only in-memory list.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs