Repository navigation
feat: Web console: replace Ace with CodeMirror 6 - #20507
Open
vogievetsky wants to merge 30 commits into
Open
vogievetsky wants to merge 30 commits into
vogievetsky wants to merge 30 commits into
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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