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

A person saves a /traces search by name and reopens it from the list and the palette #18381

opened this

Merged 2h 56m ago, live in production

Saved /traces searches are in: a person names a search, then reopens it from the list, the palette, the API, MCP or the terminal. The tests I ran pass (traces, MCP size, OpenAPI, page budgets, account purge, schema and the repo-wide rule tests, 995 pass).

Notes

opened this

Saved /traces searches are in: a person names a search, then reopens it from the list, the palette, the API, MCP or the terminal. The tests I ran pass (traces, MCP size, OpenAPI, page budgets, account purge, schema and the repo-wide rule tests, 995 pass). I did not run the whole suite; the forge's check does that on push.

What changed

  • Storage: a trace_saved table (migration 20261206075300, pinned) holds a name and the /traces query string for each person. It is capped at 50, and every read and write is keyed by the person's id. Saving a name again replaces its query. It goes with the person on account purge.
  • Reused code: the logic is in src/trace/saved.ts and goes through the list's own readFilter and filterQuery, not a second parser. A saved query is read again on every open, and a facet that no longer exists is dropped and named (dropped in the API; the page and terminal say it in words).
  • Page: with a filter set, /traces shows a "Name this search" form. Saved searches are links above the results and rows in the palette on that page. "Remove a saved search" is a disclosure of small buttons, and it says it deletes the saved search only and no trace. POST /traces/saved and POST /traces/saved/<id>/remove are same-origin, so a cross-site post is a 403. A name is escaped on the page.
  • API: GET, POST and DELETE /api/v1/traces/saved[/<id>], with OpenAPI routes. The 51st search is a 422 limit_reached that says why. Another person's id is a 404.
  • MCP: trace takes action: "saved", which lists, keeps with name and query, or ends with remove. I made repo optional on that tool for it. test/mcp-size.test.ts passes without raising any ceiling.
  • Terminal: b types the start of a saved name and Enter opens it. w names and keeps the filters on screen. x removes the search last opened.
  • Docs: a "Saved searches" section in docs/features/traces.md.
  • Tests: test/traces-saved.test.ts covers save, list, open, remove, privacy between two people, the 51st refused, cross-site 403, the dropped-facet re-validation, MCP and the terminal.

What I chose not to do

  • No typed-name confirm on remove: it deletes a saved query only, and the control says so.
  • No GET /traces/saved/<id> route: each link carries the re-validated query itself.
  • Palette: saved searches appear only on /traces, not on every page's palette, to keep other pages' first paint unchanged.

Try it

  1. Sign in and open /traces?outcome=failed on the preview.
  2. Name the search and press Save search.
  3. Reopen it from the "Saved:" links or Ctrl-K.
  4. In the terminal, open Traces, press b, type the first letters of the name and press Enter.

The gate's similar-function notes (removeSaved vs cancelTimer, and the test helpers call and press) are false positives. The commits carry No door: and No look: lines explaining where the terminal side and the look-page decision sit.

Closes #18369

2 earlier comments
commented

Saved /traces searches are in: a person names a search, then reopens it from the list, the palette, the API, MCP or the terminal. The tests I ran pass (traces, MCP size, OpenAPI, page budgets, account purge, schema and the repo-wide rule tests, 995 pass). I did not run the whole suite; the forge's check does that on push.

What changed

  • Storage: a trace_saved table (migration 20261206075300, pinned) holds a name and the /traces query string for each person. It is capped at 50, and every read and write is keyed by the person's id. Saving a name again replaces its query. It goes with the person on account purge.
  • Reused code: the logic is in src/trace/saved.ts and goes through the list's own readFilter and filterQuery, not a second parser. A saved query is read again on every open, and a facet that no longer exists is dropped and named (dropped in the API; the page and terminal say it in words).
  • Page: with a filter set, /traces shows a "Name this search" form. Saved searches are links above the results and rows in the palette on that page. "Remove a saved search" is a disclosure of small buttons, and it says it deletes the saved search only and no trace. POST /traces/saved and POST /traces/saved/<id>/remove are same-origin, so a cross-site post is a 403. A name is escaped on the page.
  • API: GET, POST and DELETE /api/v1/traces/saved[/<id>], with OpenAPI routes. The 51st search is a 422 limit_reached that says why. Another person's id is a 404.
  • MCP: trace takes action: "saved", which lists, keeps with name and query, or ends with remove. I made repo optional on that tool for it. test/mcp-size.test.ts passes without raising any ceiling.
  • Terminal: b types the start of a saved name and Enter opens it. w names and keeps the filters on screen. x removes the search last opened.
  • Docs: a "Saved searches" section in docs/features/traces.md.
  • Tests: test/traces-saved.test.ts covers save, list, open, remove, privacy between two people, the 51st refused, cross-site 403, the dropped-facet re-validation, MCP and the terminal.

What I chose not to do

  • No typed-name confirm on remove: it deletes a saved query only, and the control says so.
  • No GET /traces/saved/<id> route: each link carries the re-validated query itself.
  • Palette: saved searches appear only on /traces, not on every page's palette, to keep other pages' first paint unchanged.

Try it

  1. Sign in and open /traces?outcome=failed on the preview.
  2. Name the search and press Save search.
  3. Reopen it from the "Saved:" links or Ctrl-K.
  4. In the terminal, open Traces, press b, type the first letters of the name and press Enter.

The gate's similar-function notes (removeSaved vs cancelTimer, and the test helpers call and press) are false positives. The commits carry No door: and No look: lines explaining where the terminal side and the look-page decision sit.

commented

The check failed because GET /api/v1/traces/saved answered 200 without recording a session phase. It now records that phase, the same way the other /api/v1/traces handlers do. I added one line to listSaved in src/http/api/traces.ts. I didn't add the route to the timing test's UNTIMED allowlist, because that list is meant to shrink.

test/route-timing-coverage.test.ts and the traces tests pass locally (61 tests), and bun x tsc --noEmit reports no errors. I did not run the gate script or the full suite. The fix is pushed.

The rest of the pull is as before: saved /traces searches can be kept, listed, opened and removed by name on the page, in the API, in MCP and in the terminal.

🤖 Generated with Claude Code

commented

All three review points are fixed and pushed. bun x tsc --noEmit is clean and test/traces-saved.test.ts passes (13 tests). I didn't run the full suite or the four tests you listed (dead code, duplicate import, first-view budget, process-wide state). The forge's check runs those on this push.

  1. Save form at the limit. /traces now shows the Save form whenever a search is active. At 50 saved searches a new name is refused with the limit_reached words ("remove one to save another"), and an existing name still replaces its query.
  2. Case-insensitive names. saveSearch now finds an existing name with COLLATE NOCASE. Saving "failures" over "Failures" updates the one row and keeps the newer spelling. I left the UNIQUE(user_id, name) key as it was, so the migration is unchanged. The lookup is what makes it one name.
  3. New tests. Each one asserts behaviour the pull added.
    • The Save form is still on the page at 50, and an existing name replaces its query.
    • "Failures" and "failures" are one row.
    • The page's data-dropped sentence shows for a stale facet.
    • The palette rows are in category "Saved trace searches" for their owner and absent for another person.
    • A browser session's cross-origin POST and DELETE on /api/v1/traces/saved get 403 and change nothing.
    • The MCP tool refuses the 51st save with the shared words.

    I haven't run them against the old code to check that they fail without the fix.

The gate lists some similarity notes in my files (for example press in the new test file is identical to the one in test/traces-touch-tui.test.ts). They are notes, not failures, and I left them alone.

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs