Repository navigation
Conversation
Walkthrough
Pre-merge checks:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/lib/monaco-languages/register-glimmer.ts (1)
6-50: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReduce explanatory comments in the Glimmer tokenizer and its tests.
Keep only comments that state non-obvious invariants or fixture rationale.
src/renderer/src/lib/monaco-languages/register-glimmer.ts#L6-L50: retain a short embed-stack invariant comment and remove state-transition walkthroughs.src/renderer/src/lib/monaco-languages/register-glimmer.test.ts#L65-L84: remove comments that restate fixture contents and assertions.As per coding guidelines, comments must be concise, limited to non-obvious information, and must not describe how code works.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 85067b4a-5d97-4003-8edc-0361e8274472
📥 Commits
Reviewing files that changed from the base of the PR and between 6da7b8e and a732910877419a5117ddff5d80c8816f513de5b6.
📒 Files selected for processing (5)
src/renderer/src/lib/language-detect.test.tssrc/renderer/src/lib/language-detect.tssrc/renderer/src/lib/monaco-languages/register-glimmer.test.tssrc/renderer/src/lib/monaco-languages/register-glimmer.tssrc/renderer/src/lib/monaco-setup.ts
a732910 to
d8d94bf
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a3324983-d9ef-42ca-ad7e-ce5ac3a3b9e1
📥 Commits
Reviewing files that changed from the base of the PR and between a732910877419a5117ddff5d80c8816f513de5b6 and d8d94bf.
📒 Files selected for processing (2)
src/renderer/src/lib/monaco-languages/register-glimmer.test.tssrc/renderer/src/lib/monaco-languages/register-glimmer.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/lib/monaco-languages/register-glimmer.ts
|
Thanks @albarracin-jorge for this work. #23371 covers the Keeping this PR open because its Glimmer |
Register glimmer-js and glimmer-ts Monaco languages that embed JavaScript/TypeScript as the background script and tokenize each <template> block as a Handlebars island. Embed entry is bounded by the shared line budget so long lines cannot blow the Monarch recursion limit. Mobile maps the new ids to javascript/typescript highlighting. Co-authored-by: Neil <[email protected]>
f1fe66d to
0a4ef06
Compare
ELI5
Ember developers write
.gjsand.gtsfiles. These mix normal JavaScript/TypeScript with small HTML-like<template>blocks. Orca used to show these files as plain, uncolored text. Now it colors the code part like JavaScript/TypeScript and the template part like Handlebars, so these files are as easy to read as any other code file.What Changed
Before: opening a
.gjsor.gtsfile in the editor or diff viewer showed it asplaintext, with no highlighting.After:
.gtsgets TypeScript colors and.gjsgets JavaScript colors. Each<template>...</template>block is colored as Handlebars, including HTML tags, attributes and{{ }}mustaches. This works for inline templates too, and so does a component that is only a template.How it works:
src/shared/editor-language/editor-language-detect.tsmaps.gjstoglimmer-jsand.gtstoglimmer-ts. The lookup ignores case and path separators.src/renderer/src/lib/monaco-languages/register-glimmer.tsadds one Monarch grammar, generated in a JS variant and a TS variant:<template>is ahandlebarsisland.@rematchinroot, which pushes the script embed again. That way@popnever runs when no embed is active.restOfLineWithinEmbedBudget. Lines over the budget keep the template boundaries but skip embeds, so a line packed with hundreds of template islands cannot overflow Monarch's recursion. This is the same invariant the Astro/Svelte/Vue grammars follow.monaco-setup.tsnext to Vue/Svelte/Astro.mobile/src/session/mobile-file-syntax.tsmapsglimmer-jsandglimmer-tsto lowlight'sjavascriptandtypescript, so mobile gets approximate JS/TS highlighting instead of plaintext..hbsand.handlebarsalready map to Monaco's built-inhandlebarson main (fix(editor): recognize all bundled Monaco language associations #23371). The original PR's change for those is not included here.Why
Ember's template-tag format is the default for new Ember and Glimmer code, and Monaco has no Glimmer language built in. A Monarch embed grammar is the same approach as the existing Vue/Svelte/Astro support. It reuses Monaco's built-in TS/JS and Handlebars tokenizers instead of writing a new lexer.
Known limitation, the same one Vue/Svelte/Astro have: a literal
<template>inside a JS string or comment switches the coloring to Handlebars until the next</template>.Linked Issue
N/A. There is no linked issue; this was a community feature PR.
Visual Proof
The same
hello.gtsfile, opened in a non-git folder workspace:Testing
Reproduced on main:
detectLanguage('…/hello.gjs')returnsplaintext, and the new detection test fails withexpected 'plaintext' to be 'glimmer-js'.Tokenizer tests drive the real
MonarchTokenizerthroughmonarch-tokenizer-test-harness. They use inline snapshots to show which language covers each line, and they include a template-only component, inline templates, and an empty template.monarch-embed-entry-recursion.test.tshas a new Glimmer block:Electron, launched in the background with CDP screenshots, macOS, non-git folder workspace:
hello.gtsandhello.gjsshowed TS/JS colors, with Handlebars inside templates.pnpm teston the touched test files (147 tests) passed.oxfmt --check, oxlint (anti-slop and code-quality configs), ast-grep andcheck-changed-code-qualitywere all clean.Cross-platform: this is a renderer-only change. Extension detection ignores case and path separators, and a Windows path is covered by a test.
Remote/mixed versions: there is no protocol change. An older client or mobile that gets an unknown
glimmer-*id falls back to plaintext, which is what happens today.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Two rounds of adversarial review. Fixes made during review:
Accepted trade-off: a literal
<template>inside a string or comment switches the coloring (see Why).Agent skill upstream boundary
Notes
Original fix by @albarracin-jorge in #13236. Their authorship is kept on the commit.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)