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

A person deletes one of their imported sessions from its page, by typing its name #18371

opened this

Merged 3h 30m ago, live in production

An imported session can now be deleted by the person who imported it, and only after they type its title. I haven't seen the preview run it. The new tests and the OpenAPI, dup-imports and module-state suites pass, as does tsc.

Notes

opened this

An imported session can now be deleted by the person who imported it, and only after they type its title. I haven't seen the preview run it. The new tests and the OpenAPI, dup-imports and module-state suites pass, as does tsc. The full check runs on this push.

  • API: DELETE /api/v1/traces/<id> takes {"name": <title>}. A wrong or missing name is a 422 and removes nothing. Another person's session or an unknown id is a 404. A crew run or Talk turn the caller can see is a 403 saying its record is kept forever. A cross-site request is refused with 403. A success answers a receipt: what was removed and how many bytes were freed.
  • Page: /traces/<id> for an imported session has a red Delete form whose field wants the title. A plain click does nothing, because the field is required and the server checks the name. A wrong name goes back to the page with a message. Success goes to /traces with the receipt.
  • Terminal: X on an imported row in the Traces list asks for the title and deletes. On a run or Talk row it says the record is kept.
  • What deletion does: deleteImported in src/trace/import.ts removes the row and the stored file. The file path is derived from a 32-hex id, never from the request. Quota is the sum of stored files, so it frees at once, and the same session can be imported again.
  • Docs and contract: docs/features/traces.md drops "deleting one" from its Not yet, and the route has an OpenAPI entry.
  • Tests: test/trace-delete.test.ts covers a wrong name, a right name, a stranger's 404, a cross-site 403 on both doors, and a crew run's 403. test/traces-tui.test.ts covers the X key.

I chose not to build an undo. I also didn't build a share-link step: imported sessions are never shared by link (only crew runs are), so nothing needs unsharing first.

The typed name is compared with runs of whitespace treated as one space, since a one-line field can't hold a newline.

Reused: seenTraceRow as the visibility gate, readForm, requireScope, flashTo, promptScreen, removeImported and putTraceRow's row shape.

The gate notes that press in test/traces-tui.test.ts duplicates the one in test/tui-steer.test.ts. It was already in the file, so I left it.

Try: open /traces/<id> of an imported session and type its title in the red Delete, or call DELETE /api/v1/traces/<id> with the title as name.

[
  {"go": "/traces/<imported id>", "look": "the red Delete form under the totals", "expect": "a field asking for the session's title, and a Delete button"},
  {"go": "/traces/<imported id>", "look": "submit with a wrong title", "expect": "back on the page with 'nothing was removed'; the session is still listed at /traces"},
  {"go": "/traces/<imported id>", "look": "submit with the exact title", "expect": "lands on /traces with a receipt line naming the title and the bytes freed; the session is gone from the list"}
]

Closes #18359

12 earlier comments · 1 event
commented

An imported session can now be deleted by the person who imported it, and only after they type its title. I haven't seen the preview run it. The new tests and the OpenAPI, dup-imports and module-state suites pass, as does tsc. The full check runs on this push.

  • API: DELETE /api/v1/traces/<id> takes {"name": <title>}. A wrong or missing name is a 422 and removes nothing. Another person's session or an unknown id is a 404. A crew run or Talk turn the caller can see is a 403 saying its record is kept forever. A cross-site request is refused with 403. A success answers a receipt: what was removed and how many bytes were freed.
  • Page: /traces/<id> for an imported session has a red Delete form whose field wants the title. A plain click does nothing, because the field is required and the server checks the name. A wrong name goes back to the page with a message. Success goes to /traces with the receipt.
  • Terminal: X on an imported row in the Traces list asks for the title and deletes. On a run or Talk row it says the record is kept.
  • What deletion does: deleteImported in src/trace/import.ts removes the row and the stored file. The file path is derived from a 32-hex id, never from the request. Quota is the sum of stored files, so it frees at once, and the same session can be imported again.
  • Docs and contract: docs/features/traces.md drops "deleting one" from its Not yet, and the route has an OpenAPI entry.
  • Tests: test/trace-delete.test.ts covers a wrong name, a right name, a stranger's 404, a cross-site 403 on both doors, and a crew run's 403. test/traces-tui.test.ts covers the X key.

I chose not to build an undo. I also didn't build a share-link step: imported sessions are never shared by link (only crew runs are), so nothing needs unsharing first.

The typed name is compared with runs of whitespace treated as one space, since a one-line field can't hold a newline.

Reused: seenTraceRow as the visibility gate, readForm, requireScope, flashTo, promptScreen, removeImported and putTraceRow's row shape.

The gate notes that press in test/traces-tui.test.ts duplicates the one in test/tui-steer.test.ts. It was already in the file, so I left it.

Try: open /traces/<id> of an imported session and type its title in the red Delete, or call DELETE /api/v1/traces/<id> with the title as name.

[
  {"go": "/traces/<imported id>", "look": "the red Delete form under the totals", "expect": "a field asking for the session's title, and a Delete button"},
  {"go": "/traces/<imported id>", "look": "submit with a wrong title", "expect": "back on the page with 'nothing was removed'; the session is still listed at /traces"},
  {"go": "/traces/<imported id>", "look": "submit with the exact title", "expect": "lands on /traces with a receipt line naming the title and the bytes freed; the session is gone from the list"}
]
commented

<!-- look-pages 1dbd0fea56ec --> Look pages for 1dbd0fe, from the gate:

  • look pages (none): "Looks: /traces" is not a page of app.looks in forge.json; this pull changes src/web/pages/trace_imported.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 more (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

I merged main into the branch, resolved the two conflicts, and pushed. The merge commit is 129fe34dc. Both conflicts were places where each side had added something, so I kept both.

  • src/trace/import.ts: the import lines now include putTouches/touchesOf from main and getTraceRow from this branch.
  • src/tui/screens/traces.ts: the doc comment and the key list now carry both main's u/e tool and file keys and this branch's X key for deleting an imported session.

bun x tsc --noEmit reports no errors. I ran the 8 trace test files closest to the change (delete, imported page, import, touch, TUI, API, kinds) and all 45 tests pass.

I did not run the broader test set that scripts/fast.ts named, because it covers 2,971 files and its own estimate is over 4 hours. I also started bun scripts/gate.ts --fix but didn't wait for it, and it may still be running in the background. I didn't check what, if anything, it changed, so I don't know if it left anything uncommitted. The forge's check will run the full suite and the gate on this push.

commented

<!-- look-pages 129fe34dcf3f --> Look pages for 129fe34, from the gate:

  • look pages (none): "Looks: /traces" is not a page of app.looks in forge.json; this pull changes src/web/pages/trace_imported.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 more (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
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 the 7 trace and OpenAPI test files I ran pass (47 tests). I did not run the full suite, because scripts/fast.ts could only name about 2,970 of 5,035 test files, which is too many for the sandbox.

The merge conflicted in three files. Where both sides added something, I kept both:

  • OpenAPI route index: it exports both deleteApiV1TracesId (deleting an imported session) and deleteApiV1TracesSavedId (removing a saved search).
  • src/http/api/traces.ts: it imports the import-deletion helpers (deleteImported, deletedWords, KEPT_WORDS) alongside the saved-search ones (cleanName, openSaved and the rest). The DELETE /api/v1/traces/:id route is registered after DELETE /api/v1/traces/saved/:id.
  • src/tui/screens/traces.ts: the key list has both X (delete an imported session) and b, w, x (open, save, remove a saved search), and the header comment describes both.

The gate flagged one thing I left alone: press in test/traces-tui.test.ts is nearly identical to press in test/traces-saved.test.ts.

The gate also asked for a commit that names the issue. The last commit, which also rewraps comments, now says it serves #18359.

commented

<!-- look-pages ec07bf4b041d --> Look pages for ec07bf4, from the gate:

  • look pages (none): "Looks: /traces" is not a page of app.looks in forge.json; this pull changes src/web/pages/trace_imported.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 more (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

I merged main into this branch again and pushed. The merge had conflicts in src/tui/screens/traces.ts and test/traces-tui.test.ts, and I kept both sides' work. The traces screen has X (delete an imported session) and y (open the import form on the web), and the test file has both tests. tsc is clean. These pass: test/traces-tui.test.ts and test/trace-delete.test.ts, plus the dead-code, duplicate-import, module-state and page-budget tests you named.

  • Look pages: the gate's look-pages rule wants a "Looks:" or "No look:" line, and it still prints its warning because it reads the line from the commit message. I put No look: in the latest commit message, with the reason: /traces/:id is a per-trace route with no fixed path in app.looks. The delete form is covered by test/trace-imported-page.test.ts and test/trace-delete.test.ts. I haven't confirmed the forge accepts it.
  • press helper: the gate also says the press helper in test/traces-tui.test.ts is identical to the one in test/traces-saved.test.ts. I left it, because sharing one helper would mean editing a test file this pull doesn't otherwise touch.
commented

I fixed the check that failed and pushed. The branch had also moved on the remote, so I merged that work in first. I didn't run the full suite, so the forge's check on this push is the real test.

  • Failing check: deleteTrace in src/http/api/traces.ts passed a bare 4096 to readBounded. I added a traceDelete row to BODY_CAPS in src/kernel/body_caps.ts (4 KiB, with its reason) and the handler now names it. This is the failure you quoted.
  • Dead-code check: the allowlist still listed readImported after it gained a caller. I pruned scripts/unused-exports-allow.json.
  • Not touched: I didn't act on the gate's "one implementation?" note about the press helpers in test/traces-tui.test.ts and test/traces-saved.test.ts. I also left its look-pages note and the "each page stays inside its first-view budget" test alone.
  • Checks run: bun x tsc --noEmit is clean. I ran test/body-caps.test.ts, test/unused-exports.test.ts and test/dup-imports.test.ts after the merge, and all passed.
  • Not run: bun scripts/design-lint.ts. I didn't run the first-view budget test either.

Try it: import a session at /traces, open its page and delete it by typing its name. curl -X DELETE /api/v1/traces/<id> with a JSON {name} body does the same.

🤖 Generated with Claude Code

commented

I merged main into the branch, resolved both conflicts, and pushed. I ran bun x tsc --noEmit (clean) and the trace tests (30 of 31 pass). I did not run the whole suite.

  • src/tui/screens/traces.ts: I kept both key sets. X deletes an imported session (#18359). s and z share and unshare it (#18377). The header comment, imports and key list cover both.
  • src/web/pages/trace_imported.ts: The page now has both forms, the red Delete form and the share/unshare form.
  • Failing test: The one failure is the 30 MiB parse benchmark in test/trace-imported-open.test.ts. It took 801 ms against a 500 ms limit. The benchmark doesn't touch the merged files, and I didn't re-run it.
  • Gate: I committed the comment rewrap that gate --fix asked for. The gate also noted that the press helpers in test/traces-tui.test.ts and test/traces-saved.test.ts look identical. I left them as they are.
commented

Still red on current main: the repository has no duplicate import beyond the allowlist (rule duplicate-import). Fix it and push.

commented

I fixed the failing check. src/web/pages/trace_imported.ts imported ../../trace/import.ts twice (lines 10 and 17), and I merged the two into one import.

The type check is clean, and test/dup-imports.test.ts now passes (6 of 6). I didn't run the rest of the suite locally; the forge runs the full check on the push.

I pushed the fix as 50e053b7e. This is a cleanup only, so nothing else about the pull changes.

commented

Deleting an imported session now also ends its share link, and the stale comment and doc sentence are corrected. I ran the share test file (8 pass) and tsc --noEmit (clean). I did not run the check's full suite, or the dead-code, duplicate-import, first-view-budget and process-wide-state tests. The forge runs those on this push.

  • Fix: deleteImported in src/trace/import.ts now calls revokeShare in the same transaction as the index-row delete. The file is removed right after. The old link can no longer open a re-imported copy, which gets the same id from the same account and session.
  • Comment and doc: the comment above deleteImported and the sentence in docs/features/traces.md no longer say imported sessions are never shared. Both now say that deleting a session ends its link (#18377).
  • Test: in test/trace-imported-share.test.ts, the test shares a session and checks the link opens. It then deletes the session through DELETE /api/v1/traces/<id> with its title, and the link answers 404. It re-imports the same file, gets the same id, and the old link still answers 404. I placed it before the rate-limit tests so their 429s don't interfere.
  • Gate: gate.ts --fix changed nothing. Its only output was an advisory about two similar press helpers in test/traces-tui.test.ts and test/traces-saved.test.ts, which this change doesn't touch. The commit says No door: because no page, route or tool changed.
  • Left out: deleting an account removes its imported files, but I did not check whether the share rows go too. That is separate from this fix.
commented

I merged main into the branch and pushed it. The four conflicting files are resolved, and the tests I ran pass.

Main now has its own DELETE /api/v1/traces/<id> (#18390). It takes {confirm}, and a session with a live share link answers 409 "stop sharing first". That makes the earlier revokeShare fix redundant: nothing can be deleted while it is shared, and an old link is already revoked. So I took main's side of the API, its OpenAPI route entry, deleteImported and the docs, and dropped my own revokeShare call and my duplicate traceDelete cap in body_caps.ts.

What this pull still adds is the page and terminal delete, now on main's contract:

  • Page and terminal: the red Delete form on /traces/<id> and X in the Traces list call main's deleteImported. A wrong title says nothing was removed, and a shared session says to stop sharing first. The shared-session message (SHARED_WORDS) and the receipt (deletedWords, KEPT_WORDS) are small additions in src/trace/import.ts.
  • Docs: docs/features/traces.md now describes the page and terminal delete and no longer says "Not yet: a button on the page and a terminal screen".
  • Tests:
    • test/trace-delete.test.ts uses {confirm}, removed: true and record_kept.
    • The share test now checks a shared session answers 409 and its link keeps working until sharing stops. After that, delete and a re-import leave the old link at 404.

I ran tsc --noEmit (clean), design-lint, gate --fix and the delete, share, TUI and OpenAPI test files. The gate's only output was the advisory about the two similar press helpers in the Traces TUI tests (test/traces-tui.test.ts and test/traces-saved.test.ts), which this change doesn't touch. I did not run the whole suite.

Main compares the typed title exactly. My earlier version also ignored runs of whitespace, and that is gone.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs