diff --git a/PARITY.md b/PARITY.md index afe474f0f..fb478452e 100644 --- a/PARITY.md +++ b/PARITY.md @@ -369,8 +369,9 @@ Rust binary and the Python and TypeScript launchers. It serves the embedded SQL explorer shell at `/` on the API's origin and exposes its load diagnostic through `GET /frontend/state` (HTTP 503 when unavailable). The page needs no runtime asset download; the option adds no SDK binding API. Without the flag, -the existing HTTP routes are unchanged. Query controls and distribution -validation are tracked in the subsequent frontend issues. +the existing HTTP routes are unchanged. The page runs SQL through `POST +/query` (script at `/frontend.js`). Distribution validation is tracked in a +subsequent frontend issue. **Parity by construction, no drift; no SDK API change (#662).** Query is the default CLI mode: `dirsql ""` runs one query and prints JSON rows, diff --git a/docs/reference/cli.md b/docs/reference/cli.md index e0a4383c0..de5289869 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -240,8 +240,14 @@ requests, closes open `/events` streams, and exits. Pass `--frontend` to serve the bundled dirsql SQL explorer shell at `/` on the same origin as the HTTP API. It works offline and prints `Frontend at http://:/` without opening a browser. With `--port 0`, the -printed URL uses the assigned port. The initial shell shows server status; -query controls are coming in a subsequent update. +printed URL uses the assigned port. The page offers an editable SQL box +holding the starter query `SELECT * FROM './' LIMIT 100`. Nothing runs until +you press **Run** (or Ctrl/Cmd+Enter); pressing it again refreshes the +result. Queries go through `POST /query`, so the read-only rule applies, and +run exactly as written. The page shows elapsed time, the number of rows +returned, and errors. Values render as text (`NULL` is marked), and only the +first 1000 rows are displayed. An empty result says so and shows no column +names, since the response carries none. ```bash dirsql server --frontend diff --git a/packages/python/e2e-attestations/bot-1487-frontend-query-1011.json b/packages/python/e2e-attestations/bot-1487-frontend-query-1011.json new file mode 100644 index 000000000..f20b39801 --- /dev/null +++ b/packages/python/e2e-attestations/bot-1487-frontend-query-1011.json @@ -0,0 +1,7 @@ +{ + "command": "uv run python -m pytest tests/e2e/cli_version_test.py tests/e2e/query_contract_test.py tests/e2e/fanout_test.py tests/e2e/extension_package_test.py tests/e2e/server_speed_test.py -x -q", + "ran_at": 1791765336, + "exit_code": 0, + "commit": "a2b5671787b3cfa038a128d5cbbeac13e6c268a9", + "branch": "bot/1487-frontend-query-1011" +} diff --git a/packages/rust/changelog.d/2026-10-11-frontend-query.md b/packages/rust/changelog.d/2026-10-11-frontend-query.md new file mode 100644 index 000000000..a211739c1 --- /dev/null +++ b/packages/rust/changelog.d/2026-10-11-frontend-query.md @@ -0,0 +1 @@ +**Added** SQL execution in the `dirsql server --frontend` explorer: an editable `LIMIT 100` starter query, an explicit Run control, elapsed time, result rows rendered as text, and query and server errors. diff --git a/packages/rust/migrations.d/2026-10-11-frontend-query.md b/packages/rust/migrations.d/2026-10-11-frontend-query.md new file mode 100644 index 000000000..dfe18bb96 --- /dev/null +++ b/packages/rust/migrations.d/2026-10-11-frontend-query.md @@ -0,0 +1,21 @@ +### Frontend SQL execution + +#### Summary + +The `dirsql server --frontend` page can now run read-only SQL and show the result. It adds the `/frontend.js` route, served only with `--frontend`. Nothing breaks. + +#### Required changes + +_None._ + +#### Deprecations removed + +_None._ + +#### Behavior changes without code changes + +_None._ + +#### Verification + +Run `dirsql server --frontend --port 0`, open the printed URL, and press Run. The page lists the files under the current directory. diff --git a/packages/rust/src/cli/frontend.html b/packages/rust/src/cli/frontend.html index 18f20a66d..6300a4fb6 100644 --- a/packages/rust/src/cli/frontend.html +++ b/packages/rust/src/cli/frontend.html @@ -16,6 +16,18 @@ .panel { margin-top: 2.5rem; padding: 1.5rem; border: 1px solid #d9e1da; border-radius: 12px; background: #fff; box-shadow: 0 3px 12px #17302609; } .panel h2 { margin: 0 0 .5rem; font-size: 1rem; } .panel p { margin: 0; } + form { margin-top: 2rem; } + label { display: block; font-weight: 600; margin-bottom: .4rem; } + textarea { width: 100%; min-height: 7rem; padding: .7rem; border: 1px solid #b9c7bd; border-radius: 8px; font: .95rem/1.5 ui-monospace, monospace; resize: vertical; } + button { margin-top: .6rem; padding: .5rem 1.2rem; border: 0; border-radius: 8px; background: #1f6b46; color: #fff; font: inherit; font-weight: 600; cursor: pointer; } + button[aria-busy="true"] { opacity: .6; cursor: progress; } + .hint { font-size: .85rem; margin: .4rem 0 0; } + #result { margin-top: 1.5rem; overflow-x: auto; } + #result p.error { color: #a0362a; white-space: pre-wrap; overflow-wrap: anywhere; } + table { border-collapse: collapse; font: .85rem/1.4 ui-monospace, monospace; background: #fff; } + th, td { border: 1px solid #d9e1da; padding: .3rem .6rem; text-align: left; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 40rem; } + th { background: #eef2ee; } + td.null { color: #7a8a80; font-style: italic; } .error { border-color: #d7a7a1; background: #fff8f7; } .error h2 { color: #a0362a; } .error pre { white-space: pre-wrap; overflow-wrap: anywhere; font: .9rem/1.5 ui-monospace, monospace; margin: .8rem 0; } @@ -30,7 +42,15 @@

dirsql SQL explorer

Connecting to dirsql…

Checking the server state.

+
+ + + +

Runs exactly as written; edit the LIMIT as needed. Press Ctrl+Enter or Cmd+Enter to run.

+
+
+