Files
qqq-cli/packages
james.maesandClaude Fable 5.1 cc7839639f feat(tui): SQL Runner over the sql-workbench extension
The owner asked whether anyone was getting the SQL Runner working in the
terminal. The Next UI's Runner (a SQL_WORKBENCH widget on its own app page)
had no TUI screen: its app opened an empty app home.

Add a classic database-TUI screen over the sql-workbench UI API extension:
- editor on top: multi-line buffer, syntax tint (server keywords included),
  F5 / Ctrl+Enter (Ctrl+J) runs the statement under the cursor, Tab completes
  tables and columns (alias.columns) from the schema endpoint, Ctrl+Up/Down
  steps through the on-disk run history; :name parameters are asked for,
  bound as values and remembered
- result grid below: server-paged and server-sorted over the cached result,
  column widths from the column kinds, NULL dimmed, V whole value, x export
  (csv/xlsx/json through the file flow), status line with rows, elapsed,
  backend, read-only and the row limit (cursor tokens dropped first)
- errors inline under the editor with the SQL position marked (H2 [*],
  PostgreSQL Position, line/column forms)
- F6 EXPLAIN as an indented, foldable plan tree with costs and a relative
  cost bar (raw text with r); quick text bar charts (c)
- F3 schema browser (backends, tables, columns; filter; Enter inserts)
- F2 notebooks (mine/shared, open, save as a new version, save as,
  duplicate, delete, publish when allowed), F4 cells (SQL and markdown,
  markdown rendered as text, move, title, backend, run all), F7 audited
  history with open and re-run
- reachable from the Runner app in the tree, `/` (the SQL Workbench widget
  hit opens the Runner instead of `widget get`), F9 > Work and :sql
  (:sql <statement>, :sql open <id>); without the extension the Runner apps
  and their SQL_WORKBENCH widgets leave the metadata and :sql says the
  extension is missing

Registration is kept to a few lines: store.setMeta hides the Runner apps
(extensions now load before the metadata), a screen may claim a global key
(F2 here; its keys reach F1 through the existing helpKeys), openApp routes
Runner apps, and commands gain :sql, the Work entry and the widget route. Write mode is not offered (the Next UI keeps
the gated write flow).

Tests: editor model, completion, statements, parameters, error positions,
history, notebooks, absent-extension metadata, result paging and sort,
column widths, plan tree, bars, and the screen end to end against a fake
server (80x24 clipping checked). scripts/smoke-sql.sh drives it in tmux at
80x24 and 120x36 against a server with the extension.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-01 06:00:35 -06:00
..