diff --git a/CHANGELOG.md b/CHANGELOG.md index d7edd463..9994316a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,29 @@ auto-generated per-PR notes; this file is the curated, human-readable history. ## [Unreleased] ### Changed +- **The SQL editor is now CodeMirror 6** (#21) — the deliberate 4th bundled + runtime dependency, replacing the hand-rolled textarea editor wholesale + behind the #143 `EditorPort` seam (`src/editor/codemirror-adapter.js`; + `main.js` swaps one injected factory). What changes for users: **per-tab + undo history** (the shared textarea undo stack couldn't do this), real + IME/touch editing, CM6's find/replace panel (`⌘F`), and measured-text + rendering (no more fixed-glyph-width geometry). Highlighting still tracks + the connected server's `system.keywords`/`functions` — the sets now feed a + ClickHouse `SQLDialect` swapped via a Compartment on connect — and + completion keeps the pure `core/completions.js` candidate set + ranking + (CM6 renders the UI; `filter: false` preserves our order). Global shortcuts + (`⌘↵` run, `⌘⇧↵` format, `⌘S`/`⌘⇧S`) stay on the document handler — CM6's + conflicting `Mod-Enter` binding is stripped so an open completion can never + swallow the run chord. Deleted with the cutover: the textarea adapter, + `editor-complete/intel/search`, `core/editor-{marks,geometry,brackets,search}` + and the `maskLiterals`-based literal masking (~2,600 LOC incl. tests) — + execCommand undo, four-way scroll sync, and the editor's `html{zoom}` + popover bridging all go with them. Signature help is dropped in this parity + v0 (#60 rebuilds docs properly); function docs show as the completion info + tooltip and on hover. Bundle: **+402,911 B raw (+83%) / +132,903 B gzip + (+85%)** (484,674 → 887,585 raw; 155,810 → 288,713 gzip) — over the issue's + raw estimate, accepted at the plan gate as the price of the Phase-4 editor + foundation (#84 schema-aware autocomplete builds directly on this). - **The SQL editor now sits behind an injected `EditorPort` seam** (#143): the hand-rolled textarea editor moved from `src/ui/` to `src/editor/` and is the first adapter (`createTextareaEditor`) of a small port interface diff --git a/CLAUDE.md b/CLAUDE.md index c8c0ef3f..1e5f63c4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,7 +1,7 @@ # Contributor guide — altinity-sql-browser A modular ES-module SPA that builds to one self-contained HTML file served from -ClickHouse. No framework; runtime deps are rare and deliberate (currently three, +ClickHouse. No framework; runtime deps are rare and deliberate (currently four, all bundled — see hard rule 4). Quality is held by tests. ## Hard rules @@ -25,7 +25,8 @@ all bundled — see hard rule 4). Quality is held by tests. (see README "Configuring OAuth"). 4. **The build is esbuild only; runtime deps are rare and deliberate.** Source files are the tested files; esbuild bundles `src/main.js` → `dist/sql.html`. - There are **three** bundled runtime dependencies — **Chart.js** (the Chart + There are **four** bundled runtime dependencies — **CodeMirror 6** (the SQL + editor, behind the `EditorPort` seam — #21), **Chart.js** (the Chart result view), **@dagrejs/dagre** (the EXPLAIN pipeline-graph layout), and **@preact/signals-core** (the reactivity primitive — see `docs/ADR-0001-reactivity.md`) — all inlined into the artifact, so the page @@ -35,8 +36,10 @@ all bundled — see hard rule 4). Quality is held by tests. keep the testable logic pure in `src/core/` (chart axis/role/pivot math in `src/core/chart-data.js`; DOT→positions in `src/core/dot-layout.js`, both 100%-covered) and make the library call an **injected seam** (`app.Chart` / - `app.Dagre`, like the fetch/crypto seams) so the DOM wrapper stays fully tested - rather than dropping below the coverage gate. + `app.Dagre` / `env.Editor`, like the fetch/crypto seams) so the DOM wrapper + stays fully tested rather than dropping below the coverage gate. (The CM6 + adapter is the port-shaped variant: the *factory* is injected, and the + adapter is unit-tested against the real library under happy-dom.) 5. **No UI framework; signals for state, imperative adapters for islands.** State reactivity is `@preact/signals-core` (`signal`/`effect`/`computed`/`batch`), migrated slice-by-slice (ADR-0001). **No React/Preact/Solid** — a Preact spike @@ -45,9 +48,9 @@ all bundled — see hard rule 4). Quality is held by tests. paradigm the roadmap doesn't justify. The hard, third-party, or high-frequency-pointer surfaces (the editor, the EXPLAIN/schema graphs, Chart.js, result-grid resize/sort) stay **imperative behind an injected seam** — - signals coordinate state, they don't own every mousemove. CodeMirror 6 is the - pre-approved next runtime dep, behind an `EditorPort` seam, to land when - schema-aware autocomplete (#84) does (#21). When a *second* consumer of a + signals coordinate state, they don't own every mousemove. The editor is + **CodeMirror 6** behind the `EditorPort` seam (#21, landed ahead of #84 — + the completion source swaps to from-scope data there). When a *second* consumer of a complex UI pattern appears, extract a shared primitive (e.g. `EditorPort`, `GraphSurface`, a result-view registry, `Drawer`) rather than copy it — but don't build a primitive speculatively for a single caller. diff --git a/README.md b/README.md index f8982b3d..85190f26 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,10 @@ schema-aware autocomplete, streaming results with table / JSON / chart views, saved queries, history, and shareable links. It ships as a **single self-contained HTML file served from ClickHouse itself** (no Node server, no CDN, no external fonts) — the page makes **zero third-party -requests** and renders in the OS's native UI font. Its two bundled runtime -dependencies — **Chart.js** (the chart result view) and **@dagrejs/dagre** (the -EXPLAIN pipeline-graph layout) — are inlined into that one file. +requests** and renders in the OS's native UI font. Its four bundled runtime +dependencies — **CodeMirror 6** (the SQL editor), **Chart.js** (the chart +result view), **@dagrejs/dagre** (the EXPLAIN pipeline-graph layout), and +**@preact/signals-core** (state reactivity) — are inlined into that one file. Refactored from a single-file SPA into a fully modular, test-first codebase held at **100% test coverage**. @@ -34,29 +35,37 @@ only moving parts are ClickHouse's HTTP handlers and your OAuth provider. ## SQL editor -The editor is a hand-rolled `