Repository navigation
feat: Web console: replace Ace with CodeMirror 6 - #20507
Conversation
Fixes GHSA-ch52-4w7c-c8xp via npm audit fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…agement - Add .node-version (24.21.0 for web-console, 22 for website) and mise.toml - Remove the volta block from package.json - Exclude .node-version from the RAT license check - Document mise setup in both READMEs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndex Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add eslint-plugin-regexp's no-super-linear-backtracking and no-super-linear-move rules (CodeQL: polynomial / inefficient regular expressions) and a no-restricted-syntax rule for replacing a single escape-like character with a string (CodeQL: incomplete string escaping), and rewrite the existing regular expressions they flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ges/dsql-docs.ts The lib folder no longer exists in a fresh checkout so writing the generated docs there failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FrankChen021
left a comment
There was a problem hiding this comment.
🟢 Approval recommended
The body-level tooltip container avoids clipping, but the autocomplete and documentation styles remain scoped to the editor wrapper, so these popups lose the intended console styling. This is a presentation issue and does not affect query execution, so it can be addressed after merging.
Reviewed 100 of 100 changed files.
Validation: git diff --check 1265b47c9a51252295a4aed42d95c459b00bf2a3...ef4a7b16e0ad63a1139a5342d284c0c1e4fd1c22 passed. Static review only; no tests or builds run.
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 0 |
| P3 | 1 |
| Total | 1 |
This is an automated review by Codex GPT-5.6-Luna(max)
After addressing the findings or replying to the comments, you can request another review from me to trigger a new automated review.
| icons: false, | ||
| positionInfo, | ||
| }), | ||
| tooltips({ parent: getTooltipHost() }), |
There was a problem hiding this comment.
[P3] Keep tooltip styles on the external host
Finding: This moves CodeMirror tooltips outside the editor element, but the custom tooltip rules in code-editor-theme.ts are emitted by EditorView.theme and scoped beneath the editor's generated theme class. The body-level host is not beneath that class, so the autocomplete list and documentation pane lose the console's intended colors, sizing, and pre-wrapped multiline signatures.
Suggestion: Add equivalent styles scoped to the tooltip host, such as through a base or global theme, so the body-level tooltip container receives the custom editor styling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g Druid Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Note from the human
When the console was started I used Ace because it was the only editor that could support all the features the console needed. Ace is really a pain to use, the documentation is basically non existent. Everything the console does with Ace is basically a hack. I have always dreamed of switching to one of the more popular editors but it always felt like a mountain of effort. Well Claude Opus 5.5 did it, and tidied up all the code to remove all the Ace-isms that were all over the place, and it fixed some bugs in highlighting and completions. Otherwise everything is pixel perfect (except for a few nothingburger edge cases). You can see a migration plan file that I checked in then deleted if you want to follow the reasoning. I reviewed the results after each commit.
We are living in the future.
This branch also migrates the console build to mise as volta is deprecated and bumps
http-cache-semanticsto avoid a reported npm issueAI Summary
The web console's code editors moved from Ace (
ace-builds+react-ace) to CodeMirror 6. All the editors now share oneCodeEditorcomponent: the workbench, the explore view's SQL inputs, JSON inputs, spec and value dialogs, history and explain. Two Lezer grammars, one for DruidSQL and one for Hjson, drive the highlighting and the completions.The goal was to keep the console looking and behaving the same. On top of that, the code was cleaned up until it reads as if the console had used CodeMirror from the start, with no Ace-shaped leftovers. Where the behavior changes, it's either a bug fix or listed below.
What changed
Editor (
src/components/code-editor/)CodeEditor: a controlled component (value/onChange). The props that change at runtime are applied through CodeMirror compartments: language, read-only, line numbers, padding, transparent background and placeholder.refgives the CodeMirrorEditorView.stateCacheId/forgetEditorState: they keep the undo history and selection between mounts, usingEditorState.toJSON. They replaceAceEditorStateCache.code-editor-theme.ts): reproduces the previous look (solarized_dark colors with the console's overrides).<body>, so dialogs and popovers don't clip them.search-panel.tsx) instead of CodeMirror's default panel.showEditorError(error-mark.ts) underlines a parse error in the text and shows the message as adata-tooltipon hover.JsonInputand the workbench (for JSON queries) use it.CLEANUP.md, which records what was cleaned up and which Ace behaviors were kept on purpose.Languages (
src/editor-languages/)dsql.grammar: DruidSQL tokens and nested parentheses.getDsqlLanguage(availableSqlFunctions)makes a language that also knows the functions the cluster reports.initAceDsqlMode.hjson.grammar: a real Hjson grammar: objects, properties, arrays, the root object without braces, strings with escapes, and comments. An external tokenizer handles quoteless keys and quoteless strings.dsql(options)/hjson({ jsonCompletions }): each returns aLanguageSupportthat brings its own completions and bracket closing.script/build-grammars.mjsbuilds them at build time. They are gitignored, likelib/sql-docs.ts, and run as part ofscript/buildandnpm run test-unit.lib/keywords.tsmoved tosrc/editor-languages/dsql-keywords.ts.Completions (
src/editor-completions/)Completions with a structureddoc(name, syntax, description), notdocHTML. The SQL docs are now "doc markdown" rendered as DOM, with no HTML strings;snarkdownwas removed.hjson-context.ts, which replaces the 400-line scanner inutils/) now sees the properties after the cursor too.$as a word character. Hjson treats$and-as word characters.Positions
RowColumnis replaced by the 1-basedLineColumneverywhere, which matches how Druid, Hjson and CodeMirror number lines.offsetToRowColumn→offsetToLineColumnDruidError.startRowColumn→DruidError.startLineColumn, and the same forendgetRowColumnFromIssue→getLineColumnFromIssueQuerySlice.startRowColumn→QuerySlice.startLineColumn, and the same forendextractRowColumnFromHjsonError→extractLineColumnFromHjsonErrorfocusEditorAt(view, position)replaces thegoToPositionimperative handles.Workbench
sub-query-markers.ts).User-visible changes
host:port, URLs) are no longer partly shown as keys. That affected 97 of the 452 valid JSON examples in the Druid docs.'…or"…is colored as a string or identifier up to the end of the line.a-1isa,-,1.ARRAY<STRING>are no longer swallowed as HTML.{is not auto-closed in SQL.-no longer joins words, soSELECT a-cocompletesco.Dependencies and licenses
@codemirror/{autocomplete,commands,language,search,state,view}and@lezer/{common,highlight,lr}.@lezer/generatoris a dev dependency, used only at build time.ace-builds,react-aceandsnarkdown.licenses.yamlandlicenses/binwere updated. The CodeMirror packages and their dependencies (style-mod,w3c-keyname,crelt,@marijn/find-cluster-break) are all MIT. Theace-builds,react-aceandfast-equalsentries were removed.Testing
npm run test-unitpasses, with 850 Jest tests.CodeEditoritself (find/replace, state caching).Prompt for migrating a fork or feature branch that still uses Ace