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

A person imports a Claude Code or Codex session from /traces in the browser #18382

opened this

Merged 3h 43m ago, live in production

/traces now has an Import control: a signed-in person chooses a session file and presses Import. The branch is pushed and the gate is clean. I ran a targeted set of tests (54 pass, none fail), not the whole suite.

Notes

opened this

/traces now has an Import control: a signed-in person chooses a session file and presses Import. The branch is pushed and the gate is clean. I ran a targeted set of tests (54 pass, none fail), not the whole suite.

The new tests are in test/traces-import-page.test.ts. The other suites I ran: body caps, boot-lazy, the Traces terminal and API, and the doorless and feature-doors checks. I didn't run bun scripts/similar.ts, so the "reused" list below is from reading the code.

What it does

  • Form: a file input and an Import button, posted to a new route POST /traces/import. Signed-out viewers don't see the control.
  • Gates: cross-site posts get 403 and signed-out posts are refused with 403. The 32 MiB cap is checked against Content-Length before the body is read. The filename is never used, only the bytes.
  • Success: the person lands on /traces/<id>.
  • Refusal: a file that is too big, not a session, empty, or over quota redraws /traces with the reason in words. Nothing is stored, and the status is 422 (413 for too big or over quota).
  • Terminal: the Traces screen gets a w key that says where the form is on the web.
  • Docs: docs/features/traces.md names the control.

What I reused

  • The importer importSession and its ADAPTERS, so the quota and the parsing are the API's.
  • readForm for the same-origin and scope check.
  • refuseHere and asRefusal to redraw the page with the reason.
  • flashTo for the redirect.
  • The BODY_CAPS.traceImport cap.
  • No new parser.

Left out

  • The terminal can't upload a file; w only points to the page. The CLI and API still import with curl and a token.
  • No /traces look picture, since it isn't in app.looks. The commit says No look:.

Try it Open /traces signed in, choose a Claude Code or Codex .jsonl, and press Import. A wrong file shows the reason under the form.

[
 {"go":"/traces","look":"The Import file input and button sit under the search row","expect":"Signed in, the control is there; signed out, it is not"},
 {"go":"/traces","look":"Choose a valid Claude Code .jsonl and press Import","expect":"You land on /traces/<id> with an 'imported' flash"},
 {"go":"/traces","look":"Choose a text file that is not a session and press Import","expect":"/traces redraws with the reason under the form, and no new trace appears"}
]

Closes #18376

3 earlier comments · 1 event
commented

/traces now has an Import control: a signed-in person chooses a session file and presses Import. The branch is pushed and the gate is clean. I ran a targeted set of tests (54 pass, none fail), not the whole suite.

The new tests are in test/traces-import-page.test.ts. The other suites I ran: body caps, boot-lazy, the Traces terminal and API, and the doorless and feature-doors checks. I didn't run bun scripts/similar.ts, so the "reused" list below is from reading the code.

What it does

  • Form: a file input and an Import button, posted to a new route POST /traces/import. Signed-out viewers don't see the control.
  • Gates: cross-site posts get 403 and signed-out posts are refused with 403. The 32 MiB cap is checked against Content-Length before the body is read. The filename is never used, only the bytes.
  • Success: the person lands on /traces/<id>.
  • Refusal: a file that is too big, not a session, empty, or over quota redraws /traces with the reason in words. Nothing is stored, and the status is 422 (413 for too big or over quota).
  • Terminal: the Traces screen gets a w key that says where the form is on the web.
  • Docs: docs/features/traces.md names the control.

What I reused

  • The importer importSession and its ADAPTERS, so the quota and the parsing are the API's.
  • readForm for the same-origin and scope check.
  • refuseHere and asRefusal to redraw the page with the reason.
  • flashTo for the redirect.
  • The BODY_CAPS.traceImport cap.
  • No new parser.

Left out

  • The terminal can't upload a file; w only points to the page. The CLI and API still import with curl and a token.
  • No /traces look picture, since it isn't in app.looks. The commit says No look:.

Try it Open /traces signed in, choose a Claude Code or Codex .jsonl, and press Import. A wrong file shows the reason under the form.

[
 {"go":"/traces","look":"The Import file input and button sit under the search row","expect":"Signed in, the control is there; signed out, it is not"},
 {"go":"/traces","look":"Choose a valid Claude Code .jsonl and press Import","expect":"You land on /traces/<id> with an 'imported' flash"},
 {"go":"/traces","look":"Choose a text file that is not a session and press Import","expect":"/traces redraws with the reason under the form, and no new trace appears"}
]
commented

/traces now has an Import control. A signed-in person picks a Claude Code or Codex session file and it goes through the existing importSession, with no new parser. It posts to POST /traces/import, and the Traces screen in the terminal gains a w key. docs/features/traces.md describes the control.

The check had failed on the new route. A test that lists every route named for making something (test/private-by-default.test.ts) didn't know POST /traces/import. I added it as a door that makes no repository, in the sorted position the test requires.

The other two failures were the first-view budget tests (test/attention.test.ts and test/attention-stamped.test.ts). They passed on my machine, alone and with the door test, and the check log showed them green on main. I didn't find a cause, so I'm treating them as a side effect of the door-test failure. If the next check still fails on them, the log will say.

I ran the three affected test files, bun x tsc --noEmit and bun scripts/gate.ts --fix. Only the door test failed, and it passes now. I have not run the full suite.

To try it, open /traces signed in, choose a .jsonl under Import, and press Import.

🤖 Generated with Claude Code

commented

/traces now has an Import control for signed-in people. Items 2–4 are done, but item 1 is not: the terminal still only points at the web form. I need the owner to waive that.

What it does. The control posts a chosen session file to POST /traces/import, a same-origin multipart form. That goes through the existing importSession with the API's 32 MiB cap and per-account quota. On success you land on the new trace. A refusal redraws /traces with the reason and stores nothing.

Terminal: waiver requested. I did not build a path prompt. The terminal runs on the forge host over ssh, so a typed path would read the host's files, not the person's. That would let anyone import any session-shaped file the process can read, such as another account's logs. w still tells the person where the web form is. Imports from any client already go through POST /api/v1/traces/import. The reason is in docs/features/traces.md.

Changes since the review

  • Label: it now reads "Import a session (.jsonl, 32 MiB at most)" and uses the shared field component. field gained an accept option, set to .jsonl only.
  • Docs: docs/features/traces.md says once that imports are private.
  • Refusal helper: refusal({...}) in form.ts replaces the as never cast.
  • Size check: the Content-Length pre-check is gone. The cap is checked once on the bytes readForm reads, plus file.size, with the message built once.

Tests added

  • An over-cap file gets a 413 and nothing is stored.
  • An over-quota account gets a 413 with the reason and nothing is stored.
  • A signed-out post is exactly 403.
  • A signed-out page shows no control.
  • The label and accept are checked.
  • The w key is tested in test/traces-tui.test.ts.

Checks. tsc, the gate, design-lint and the changed tests pass. The dead-code, duplicate-import, module-state and attention.test.ts guards also pass. I did not run fast.ts's full list (about 3,300 files).

Preview. I didn't view the preview. The page test shows the form with a token. If it was missing in the preview, that was probably a stale deploy.

To try: open /traces signed in, choose a .jsonl under Import, and press Import.

🤖 Generated with Claude Code

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

I merged main into this branch and pushed. The type check is clean and 111 tests across the traces and trace test files pass. I ran only those, not the full suite. The forge's check runs on the push.

What changed

  • Key clash: main now uses w in the Traces terminal screen to save a search, and this pull used w to point at the import form. The import key is now y. w, b and x keep their saved-search meanings.
  • Other conflicts: the saved-search routes (/traces/saved, /traces/saved/:id/remove) and the import route (POST /traces/import) are both registered. On the /traces page the import form sits above the saved searches. The docs now carry both the import section and the saved-searches section.
  • Test: I renamed the terminal key test in test/traces-tui.test.ts to y and made it press y. The test was wrong only about which key it pressed.

What the pull still does

  • /traces has an Import control for a signed-in person.
  • The import goes through the existing importer, with the same size cap and per-account quota.
  • The terminal key only tells the person where the form is on the web.

How to try it: open /traces signed in, choose a .jsonl session file and press Import. In the terminal's Traces screen, press y.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs