Repository navigation
feat(web-ui): highlight Cangjie sources in the editor and chat - #3441
Merged
GCWing merged 5 commits intoOct 18, 2026
Merged
Conversation
Add a Monarch tokenizer for Cangjie derived from the TextMate grammar of the
CodeArts Agent Cangjie extension (scope `source.cj`); Monaco's standalone build
has no Oniguruma runtime, so the same lexical rules are expressed as Monarch.
- nested block comments, declarations, parameters, builtin types, macros
- raw, byte, J and triple-quoted strings with `${...}` interpolation
- `.cj` detection, status bar language name, language picker entry, code icon,
drop preview kind and snippet label
Single-line strings end at end of line, so an unterminated quote no longer leaks
into the following lines.
Co-authored-by: OpenBitFun <318544290+bitfun-ai@users.noreply.github.com>
Chat code blocks render through `react-syntax-highlighter`'s `prism-async-light`, which only knows its own refractor language map and silently falls back to plain text for everything else. Register the Cangjie grammar (the same keyword tables the editor uses) on the loaded highlighter instance, so ```cangjie fences are highlighted instead of losing their colors. Also label the fence "Cangjie" in the code block toolbar and treat `.cj` links in markdown as editor-openable. Co-authored-by: OpenBitFun <318544290+bitfun-ai@users.noreply.github.com>
`vs-dark` ships no rule for the `function` token, so any grammar that marks declared function names and call sites with it falls back to the default foreground. The light preset and five other builtin presets already define this token; add the matching rule to the dark preset. The builtin preset output snapshot changes accordingly (dark only). Co-authored-by: OpenBitFun <318544290+bitfun-ai@users.noreply.github.com>
Contributor
Author
EthanCheung-gh
marked this pull request as ready for review
October 17, 2026 12:05
The web UI i18n audit enforces a zero budget for CJK characters in source files outside the locale catalogs, and the language definition carried three: the file header comment, the Monaco alias list and the detection alias entry. Replace the CJK alias spellings with the ASCII ones; the language picker still lists the language through its `Cangjie`/`cangjie`/`cj` names. `pnpm run i18n:audit` — passed with 0 warnings. Co-authored-by: OpenBitFun <318544290+bitfun-ai@users.noreply.github.com>
Wrap the Prism grammar in a Refractor language registration function. Register it in the shared loader after engine preload and before exposing the cached highlighter, including CodePreview-first rendering. Cover real async highlighter output, cached Markdown rendering, and concurrent preload ordering. Validation: 97 focused tests, check:web, and production-file ESLint passed. Tests run in Node and jsdom; live remote scenarios were not exercised.
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.


Summary
.cj) language definition to the code editor: a Monarch tokenizer derived from the TextMate grammar shipped with the CodeArts Agent Cangjie extension (source.cj), because Monaco's standalone build cannot load TextMate grammars without an Oniguruma runtime..cj, status bar name, language picker entry, code icon, drop-preview kind and code-snippet label.cangjiefences in chat by registering a Prism grammar on the async highlighter, and label the fence "Cangjie".functiontoken a color in the default dark preset (the light preset and five other builtin presets already define it), so declared function names and call sites are visible.Fixes #
Type and Areas
Type: Feature
Areas: web UI (editor, markdown, appearance)
Motivation / Impact
Cangjie sources currently render as plain text in the editor and in chat code blocks, which makes
.cjfiles hard to read in OpenBitFun. After this change:.cjfiles open with syntax highlighting plus the correct comment, bracket and word configuration.cangjieorcjare highlighted instead of losing their colors.Scope is highlighting plus language configuration only; no language server (completion, diagnostics, build integration) is included.
Verification
pnpm --dir src/web-ui exec vitest run src/tools/editor/languages/cangjie.language.test.ts src/infrastructure/markdown/cangjiePrismLanguage.test.ts src/infrastructure/language-detection/utils/helpers.test.ts src/infrastructure/appearance/builtins/appearancePresetOutput.test.ts src/shared/context-system/core/types/CodeSnippetContextImpl.test.ts src/infrastructure/markdown/MarkdownRenderer.test.tsx— passed (91 tests)npx tsc --noEmitinsrc/web-ui— passed (no errors)npx eslinton every changed source file — passednode scripts/check-git-object-sizes.mjs --base origin/main --head HEAD— passedpnpm run i18n:audit— passed with 0 warnings (the language definition and detection entry carry no CJK source text)pnpm run desktop:preview:debug, opened a.cjsample; the status bar reportsCangjie, and highlighting is correct in both the dark and light appearance.Reviewer Notes
quote(...)bodies are not string-colored, and raw-string hash counts are not enforced when closing.${...}interpolation are covered by tests; an unterminated single-line string no longer colors the following lines.ruleslist is no longer empty.Checklist
Generated with OpenBitFun