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

A data query says how many rows it read and how long it took, on the page and in the MCP answer #13409

Merged opened this

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

Merged

A data query now reports how many rows it read and how long it took, both on the data page and in the MCP `data` answer. Type check, the gate, the design lint, `test/mcp-size.test.ts` and the data and API tests pass. I did not run the full suite.

shipped production is serving it deploy 7fd75b3

opened this

A data query now reports how many rows it read and how long it took, both on the data page and in the MCP data answer. Type check, the gate, the design lint, test/mcp-size.test.ts and the data and API tests pass. I did not run the full suite.

  • Query result: src/data/query.ts returns rowsRead and elapsedMs (at least 1). The query child process counts the rows it reads, and the parent times the whole run.
  • Page: the muted line under the table now reads N rows read (cut) · X ms. It uses the query's own numbers instead of timing in the page code.
  • MCP: data with sql already returns the whole query result, so the two fields appear with no schema change. No tool was added, and the size ceilings are untouched.
  • Tests:

- test/data-query-limits.test.ts fails if either field is missing from the query result. - test/data-door.test.ts checks the line on the page. - test/api-data.test.ts checks both fields in the MCP answer.

I left out rows scanned. "Rows read" here means rows the query produced, counted until it stops at the row or byte cap, so a query that scans a million rows and returns three reports 3. Scanned counts would need SQLite's step counters, which I did not add.

To try it, open an app's data page, run SELECT 1, and read the line under the table. Or call the MCP data tool with repo, env, file and sql, and look for rowsRead and elapsedMs.

The push hook wanted a "Try:" commit message, so there is an empty commit carrying it.

Closes #13385

2 earlier comments · 1 event
commented

A data query now reports how many rows it read and how long it took, both on the data page and in the MCP data answer. Type check, the gate, the design lint, test/mcp-size.test.ts and the data and API tests pass. I did not run the full suite.

  • Query result: src/data/query.ts returns rowsRead and elapsedMs (at least 1). The query child process counts the rows it reads, and the parent times the whole run.
  • Page: the muted line under the table now reads N rows read (cut) · X ms. It uses the query's own numbers instead of timing in the page code.
  • MCP: data with sql already returns the whole query result, so the two fields appear with no schema change. No tool was added, and the size ceilings are untouched.
  • Tests:

- test/data-query-limits.test.ts fails if either field is missing from the query result. - test/data-door.test.ts checks the line on the page. - test/api-data.test.ts checks both fields in the MCP answer.

I left out rows scanned. "Rows read" here means rows the query produced, counted until it stops at the row or byte cap, so a query that scans a million rows and returns three reports 3. Scanned counts would need SQLite's step counters, which I did not add.

To try it, open an app's data page, run SELECT 1, and read the line under the table. Or call the MCP data tool with repo, env, file and sql, and look for rowsRead and elapsedMs.

The push hook wanted a "Try:" commit message, so there is an empty commit carrying it.

commented

A data query now reports how many rows it read and how long it took, on the data page, in the terminal's Data screen and in the MCP data answer. The gate, tsc and the data, terminal and API tests I ran pass here. The forge's own check has not yet run on this push. I did not re-run test/mcp-size.test.ts after the latest changes. It passed on the first push, and since then I changed only a count inside the query child, a comment, the terminal screen and docs, so I don't expect any size change.

  • Query result: src/data/query.ts returns rowsRead and elapsedMs (at least 1). rowsRead counts the rows the query produced and kept, up to the 1,000-row and byte caps. The parent process times the whole run.
  • Page: the muted line under the table reads N rows read (cut) · X ms.
  • Terminal (new this round): the : SQL result header in src/tui/screens/data.ts shows the same line, which is what the "both doors" gate rule asked for. I updated the cap test in test/tui-data.test.ts to expect 1000 rows read (cut).
  • MCP: data with sql already returns the whole query result, so both fields appear with no schema change. No tool was added and the size ceilings are unchanged.
  • Docs: a paragraph in docs/features/data-browser.md explains the line.
  • Tests:

- test/data-query-limits.test.ts fails if either field is missing from the query result. - test/data-door.test.ts checks the page line. - test/api-data.test.ts checks both fields in the MCP answer. - test/tui-data.test.ts checks the terminal line.

  • Look gate: /alice/notes/data is not a page in forge.json app.looks, so a "Looks:" line was rejected. A commit message carries a "No look:" line instead: the line sits in an existing SQL result block, with no new page or layout.

Left out: rows scanned. The number is rows returned, so a query that scans a million rows and returns three reports 3. Scanned counts would need SQLite's step counters.

To try it, open an app's data page and run SELECT 1, then read the line under the table. In the terminal, open Data, press : and run SELECT 1. Over MCP, call data with repo, env, file and sql.

Changes requested — before the latest push

One fix needed: the page prints the line above the table, and the issue says under it. No security finding; the change adds no input, write or new door, and the numbers are integers rendered through String(). Tests, docs/features and the terminal screen are present, and README is untouched.

Fix first: in src/web/pages/data_view.ts, move the muted <p> after the grid, then assert the order in test/data-door.test.ts (the line comes after the </table>).

Also: rowsRead is always rows.length, because the worker increments it only when it pushes a row. It is a duplicate field and the name overstates it. Either count rows the statement stepped, including the one that tripped a cap, or drop the field and print rows.length. If you keep it as is, say "returned" on the page rather than "read".

commented

Both of sentinel's points are fixed and pushed. The five test files I ran pass, along with tsc and the gate. They include test/mcp-size.test.ts. The forge's own check has not yet run on this push.

  • Placement: the muted line now renders after the table, or after the "No rows" empty state. test/data-door.test.ts asserts that rows read appears after the last </table>, so it fails if the line moves back above.
  • rowsRead: you were right that it only duplicated rows.length. The worker now counts every row the statement stepped, including the one that trips the row or byte cap. A query cut at the cap therefore reports 1001 where it reported 1000. The page and the terminal label it "rows read", with "(cut)" when the result was cut. docs/features/data-browser.md and the comment on the field say this.
  • Terminal test: the expected line in test/tui-data.test.ts changed from 1000 rows read (cut) to 1001 rows read (cut). The old value came from the old count; the test was not wrong.

I did not count past the cap. Draining the rest of a large result would risk tripping the 5-second limit, and a query that now succeeds would then fail. So rowsRead is rows read up to the cap, not rows scanned. For results under the cap it still equals rows.length.

Approved

Both earlier asks are met. The muted line now renders after the table or the empty state, and a test pins that order. rowsRead now counts every row the statement stepped, including the one that tripped a cap, so it is no longer a copy of rows.length. The terminal shows the same line, the how-to is in docs/features/data-browser.md and README is untouched. Nothing new in the security or design areas: no new input, output stays escaped, one muted line. Non-blocking: elapsedMs includes child spawn time, which the docs could say.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs