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

The Data tab of an SQLite file filters a table by one column's value, from the address #16823

Merged opened this

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

Merged

The Data tab now has one filter box per column under the header, and the MCP data tool takes the same filter. bun test on the three files this change touches (the new test, test/data-top-values.test.ts and test/mcp-size.test.ts), bun x tsc --noEmit, design-lint and gate --explain pass.

Notes

opened this

The Data tab now has one filter box per column under the header, and the MCP data tool takes the same filter. bun test on the three files this change touches (the new test, test/data-top-values.test.ts and test/mcp-size.test.ts), bun x tsc --noEmit, design-lint and gate --explain pass. I did not run the full suite; the forge runs it on push.

  • Address: each box is f.<column>=<text> in the URL (for example ?table=t&f.city=Par&f.kind=cafe). The boxes sit in the table's own form, so Enter in any of them applies all of them, and every box must match. Sorting, paging and Clear keep the filters. The boxes stay visible when nothing matches, so you can edit them. A table with no rows and no filter still shows only the empty message.
  • Query: each filter is one CAST("col" AS TEXT) LIKE ? ESCAPE '\' condition with the value bound as a parameter, and % and _ in the value are treated literally. The column name has to be one the table reports (the same check rows already did), and a name that isn't one gets the table back unfiltered with the existing "cannot be … searched" note. A sealed column matches nothing, so it can't be guessed a character at a time. At most 20 filters, 200 characters each.
  • MCP: data takes filter: {column: text} on both its repo path and its source path. A bad shape returns invalid. test/mcp-size.test.ts passes without raising any ceiling.
  • Reused: rows in browse.ts is extended with a by option, and rowPage is extended and now used by both MCP paths. src/data/column_filters.ts is the one new module, for reading the address and the tool object.
  • Tests: test/data-column-filters.test.ts covers a hostile value (x' OR 1=1 --, '; DROP TABLE t; --), % and _ as literals, hostile column names (including sqlite_master), the sealed column, and the page's boxes and escaping.

Left out:

  • The committed-file SQLite viewer (src/web/render/sqlite.ts) is unchanged. I took "Data tab" to mean the data browser. That viewer would need new fields on RenderInput and the cache key, so it deserves its own pull.
  • The terminal data tree has no per-column filter; the commit line says No door: for that.
  • data-browser.md is updated.
  • No app.looks page shows the Data tab, so the commit says No look:.

Try it: open /data?source=<file>&table=<table>, type in a box under a column header and press Enter.

[{"go":"/data?source=<file>&table=<table>","look":"A second header row with one filter box per column","expect":"Typing a value and pressing Enter puts f.<column>=<value> in the URL and narrows the rows; a value that matches nothing keeps the boxes visible"},{"go":"/data?source=<file>&table=<table>&f.city%22%20OR%201%3D1%20--=x","look":"The table with a note","expect":"The note says that column cannot be sorted or searched, and the rows are not filtered"}]

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

🤖 Generated with Claude Code

Closes #16315

commented

The Data tab now has one filter box per column under the header, and the MCP data tool takes the same filter. bun test on the three files this change touches (the new test, test/data-top-values.test.ts and test/mcp-size.test.ts), bun x tsc --noEmit, design-lint and gate --explain pass. I did not run the full suite; the forge runs it on push.

  • Address: each box is f.<column>=<text> in the URL (for example ?table=t&f.city=Par&f.kind=cafe). The boxes sit in the table's own form, so Enter in any of them applies all of them, and every box must match. Sorting, paging and Clear keep the filters. The boxes stay visible when nothing matches, so you can edit them. A table with no rows and no filter still shows only the empty message.
  • Query: each filter is one CAST("col" AS TEXT) LIKE ? ESCAPE '\' condition with the value bound as a parameter, and % and _ in the value are treated literally. The column name has to be one the table reports (the same check rows already did), and a name that isn't one gets the table back unfiltered with the existing "cannot be … searched" note. A sealed column matches nothing, so it can't be guessed a character at a time. At most 20 filters, 200 characters each.
  • MCP: data takes filter: {column: text} on both its repo path and its source path. A bad shape returns invalid. test/mcp-size.test.ts passes without raising any ceiling.
  • Reused: rows in browse.ts is extended with a by option, and rowPage is extended and now used by both MCP paths. src/data/column_filters.ts is the one new module, for reading the address and the tool object.
  • Tests: test/data-column-filters.test.ts covers a hostile value (x' OR 1=1 --, '; DROP TABLE t; --), % and _ as literals, hostile column names (including sqlite_master), the sealed column, and the page's boxes and escaping.

Left out:

  • The committed-file SQLite viewer (src/web/render/sqlite.ts) is unchanged. I took "Data tab" to mean the data browser. That viewer would need new fields on RenderInput and the cache key, so it deserves its own pull.
  • The terminal data tree has no per-column filter; the commit line says No door: for that.
  • data-browser.md is updated.
  • No app.looks page shows the Data tab, so the commit says No look:.

Try it: open /data?source=<file>&table=<table>, type in a box under a column header and press Enter.

[{"go":"/data?source=<file>&table=<table>","look":"A second header row with one filter box per column","expect":"Typing a value and pressing Enter puts f.<column>=<value> in the URL and narrows the rows; a value that matches nothing keeps the boxes visible"},{"go":"/data?source=<file>&table=<table>&f.city%22%20OR%201%3D1%20--=x","look":"The table with a note","expect":"The note says that column cannot be sorted or searched, and the rows are not filtered"}]

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

🤖 Generated with Claude Code

commented

The Data tab's per-column filter now works from the terminal too. Both MCP problems and the bad f.<column> in the web links are fixed. The tests I ran pass (63 across the data suites), tsc is clean and design-lint is clean. I didn't run the full suite; the forge runs it on the push.

  • Terminal door: f on a table or one of its rows asks for column=text. It filters through the same rows by option as the page. Empty text lifts that column's filter, and every column named must match. A sealed column matches nothing, and an unknown column labels the table no such column. While a filter is on, the table line shows the filtered count (users 0 rows of 1, where name~zzz). src/data/tree.ts takes the per-table filters. docs/features/data-browser.md names the key. The earlier No door: line no longer applies. A new tui-data test covers a match, a miss, a sealed column and a hostile column name.
  • MCP unknown column: a filter column the table lacks now answers invalid: filter names a column the table does not have. A missing table still answers not_found: no such table.
  • MCP format: csv with filter: I refused the combination (invalid) instead of applying the filter, because the CSV export has no filter path. The tool answers invalid before reading anything. A test covers this and the unknown-column answer.
  • Web links: after the "cannot be sorted or searched" note, base no longer carries f.<column> for columns the table lacks. Sort and pager links drop them, and filters on real columns stay. The page test asserts the hostile key is gone from the links.

No look block this time either: the Data tab has no before/after page in app.looks, and the visible change is the terminal key.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs