Commit 246fa6f
authored
feat(vnext): add CodeMirror completion adapter (#199)
## Summary
- add an explicit `@marimo-team/codemirror-sql/vnext/codemirror` entry
point with one caller-owned service and one session per `EditorView`
- translate composite CodeMirror document, context, and embedded-region
effects into one atomic session update
- map current relation results to exact CodeMirror edits with revision,
document, selection, context, and embedded-region guards
- coalesce exact-token catalog refreshes across active menus and empty
loading results without synchronous provider-driven dispatch
- contain Escape, close, blur, visibility, expiry, service-first
disposal, stale rejection, and repeated teardown races
## Why
The framework-independent service now has the identity and lease
contracts needed for a thin editor boundary. This adapter makes those
contracts usable without leaking CodeMirror into the core, while
preserving marimo's external completion sources and treating
transformed-document regions explicitly rather than guessing their
mapping.
## Validation
- 2,028 tests pass; 1 intentional expected failure
- adapter coverage: 97.70% statements, 95.86% branches, 100% functions,
99.01% lines
- all strict and loose-optional TypeScript configurations pass
- oxlint and test-integrity checks pass
- packed-consumer source covers the new package subpath; hosted package
CI will run the isolated install
- two independent exact-commit adversarial reviews approved `8d72a4c`
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds a CodeMirror 6 adapter for the vNext SQL language service, exposed
as `@marimo-team/codemirror-sql/vnext/codemirror`. This enables exact,
guarded completion edits and atomic document/context/region updates
without leaking CodeMirror into the core.
- **New Features**
- New `sqlEditor` adapter with one document session per `EditorView`;
caller owns the shared `service`.
- Atomic updates: merges document changes with `support.contextEffect`
and `support.embeddedRegionsEffect`.
- Exact completion edits with revision/context/selection guards; maps
unrelated embedded regions through its own edit; ignores overlaps.
- Coalesced refresh intents keyed by service tokens; cancels on Escape,
blur (configurable), visibility loss, selection change, or lease expiry;
no synchronous provider-driven dispatch.
- Single `autocompletion` configuration; supports `externalSources` for
extra providers.
- New docs: `docs/vnext/codemirror-adapter.md`; subpath export added in
`package.json`; smoke test updated.
- **Migration**
- Import from `@marimo-team/codemirror-sql/vnext/codemirror`, create a
service from `@marimo-team/codemirror-sql/vnext`, then add
`support.extension` to the editor.
- Do not install a second `autocompletion` extension; pass extra
providers via `externalSources`.
- Update context/regions via `support.setContext` or by dispatching
`support.contextEffect` and `support.embeddedRegionsEffect`. If embedded
regions exist, include the complete resulting set on every
document-changing transaction.
<sup>Written for commit 8d72a4c.
Summary will update on new commits.</sup>
<a
href="https://cubic.dev/pr/marimo-team/codemirror-sql/pull/199?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->1 parent 1b4c1af commit 246fa6f
7 files changed
Lines changed: 1960 additions & 0 deletions
File tree
- docs/vnext
- scripts
- src/vnext/codemirror
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
| |||
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
249 | 254 | | |
250 | 255 | | |
251 | 256 | | |
| |||
262 | 267 | | |
263 | 268 | | |
264 | 269 | | |
| 270 | + | |
265 | 271 | | |
266 | 272 | | |
267 | 273 | | |
| |||
278 | 284 | | |
279 | 285 | | |
280 | 286 | | |
| 287 | + | |
281 | 288 | | |
282 | 289 | | |
283 | 290 | | |
| |||
296 | 303 | | |
297 | 304 | | |
298 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
299 | 309 | | |
300 | 310 | | |
301 | 311 | | |
| |||
0 commit comments