Repository navigation
fix(editor): map .cts/.mts to the typescript language id - #11294
Conversation
Greptile SummaryFixes
Confidence Score: 5/5Safe to merge — two entries added to a static lookup table with no logic changes, no new dependencies, and no cross-cutting impact. The change is strictly additive: two key-value pairs in an object literal. Both the desktop and mobile tables are updated consistently. The existing toLowerCase() call before lookup already handles case-insensitive filesystems. Tests cover lowercase, uppercase, Windows paths, and a .d.mts declaration file, plus a regression guard for the adjacent .mjs/.cjs entries. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/lib/language-detect.ts | Adds .cts and .mts entries to EXT_TO_LANGUAGE; matches the existing comment that already documented these extensions and fixes the plaintext fallback. |
| src/renderer/src/lib/language-detect.test.ts | Adds two new test cases: .cts/.mts to typescript (including Windows paths and case-insensitive variants), and a regression guard asserting .mjs/.cjs remain on javascript. |
| mobile/src/session/mobile-file-language.ts | Mirrors the desktop fix: adds .cts and .mts to typescript in the mobile extension table, resolving the same plaintext-fallback inconsistency. |
| mobile/src/session/mobile-file-syntax.test.ts | Adds .mts and .CTS coverage to the mobile test and a resolveMobileSyntaxLanguage assertion for .cts. |
Reviews (2): Last reviewed commit: "fix(mobile): map cts and mts to typescri..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 666f44c9275eca2a00e246d1a772612371702727 and dfa99f0. 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughUpdated renderer and mobile language detection to map 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The comment above EXT_TO_LANGUAGE already documents that Monaco maps .tsx/.cts/.mts onto the typescript language id, but only .tsx was in the table, so .cts/.mts files opened as plaintext.
666f44c to
dfa99f0
Compare
) * fix(editor): map .cts/.mts to the typescript language id The comment above EXT_TO_LANGUAGE already documents that Monaco maps .tsx/.cts/.mts onto the typescript language id, but only .tsx was in the table, so .cts/.mts files opened as plaintext. * fix(mobile): map cts and mts to typescript --------- Co-authored-by: OrcaWin <[email protected]>
Summary
.ctsand.mtsfiles open as plaintext in the editor. The comment aboveEXT_TO_LANGUAGEinlanguage-detect.tsalready documents that Monaco maps.tsx/.cts/.mtsonto thetypescriptlanguage id, but only.tsxwas present in the table, sodetectLanguage()fell through to'plaintext'for the other two.No new language registration is needed. Monaco's own
typescript.contribution.jsdeclaresextensions: ['.ts', '.tsx', '.cts', '.mts'], so the id already exists and the TypeScript worker treats these files exactly like.ts— only the lookup entry was missing.MonacoEditoralways passes an explicitlanguage, so Monaco's URI-based inference never runs and this table is the only decision point.The repo was already inconsistent here:
file-type-icons.tsmapscts/mtsto the code-file icon, so the file explorer showed them as code while the editor rendered plain text.Screenshots
Same
.mtsfile opened in a build from this branch.Testing
pnpm lintpnpm typecheckpnpm testpnpm buildThe two unchecked boxes are explained under Notes.
AI Review Report
Three independent review passes with an AI agent — architecture/layering, error handling and edge cases, and project conventions/security. No critical or major findings.
Flagged and fixed:
.d.mts/.d.ctsdeclaration files.mjs/.cjsentries in the same block, so a typo there would have gone unnoticedbuilt-inqualifier that sibling tests useChecked and deliberately left unchanged:
extensionsarray'typescript'was already produced by.ts/.tsx— worker routing,canPreviewLanguage, and viewer selection are untouchedCross-platform compatibility (macOS, Linux, Windows) was explicitly checked. No platform branch is introduced.
extname()handles both/and\, and the extension is lowercased before lookup, so case-insensitive filesystems behave identically; the tests cover a Windows absolute path with an uppercase.MTS. No keyboard shortcuts, labels, shell behavior, path utilities, or Electron platform differences are touched. Nothing here is specific to SSH, remote or local hosts, a particular agent, or a git provider, and there is no performance risk in a two-entry object lookup.Security Audit
No risk surface. This adds two entries to a static lookup table. There is no input execution, no path resolution, no IPC, no auth, no secrets, and no dependency change.
extname()useslastIndexOfrather than a regex, so there is no ReDoS path, anddetectLanguage()never opens the file. No follow-up needed.Notes
pnpm lint: oxlint and the code-quality audits pass. The chain stops later atverify:skill-bundle-manifest, which reports stale generated artifacts underresources/skills/. That is a pre-existing state unrelated to this change, and those files are not part of this diff, so I left them untouched rather than regenerating them here.pnpm test: the full suite on a Windows machine fails 176 tests that require a POSIX shell (spawn /bin/sh ENOENT). The failure count is identical before and after this change, so there is no regression from this PR.language-detect.test.tspasses 12/12.mobile/src/session/mobile-file-language.tshas a parallel extension table that also lacks these two entries, so mobile still renders them as plaintext. It feeds a different highlighter and has already diverged on roughly twenty other extensions, so I kept this PR to a single topic. Happy to follow up separately if you would like them aligned.