Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughCentralizes built-in terminal themes in shared typed catalogs, including default, classic, popular dark, and popular light themes. Adds duplicate-name validation, sorted theme-name and palette lookup APIs, and catalog invariant tests. Updates renderer theme resolution, previews, available options, and contrast tests to use shared palette utilities instead of the removed local theme data module. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
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: b7572174-7af2-4803-ac60-02633fcab396
📥 Commits
Reviewing files that changed from the base of the PR and between 17959a2 and 8bcab1fcad772cc4da0c068d5a300be94bc44807.
📒 Files selected for processing (14)
src/renderer/src/lib/terminal-contrast-correction.test.tssrc/renderer/src/lib/terminal-theme.tssrc/renderer/src/lib/terminal-themes-data.tssrc/renderer/src/lib/terminal-themes/types.tssrc/shared/terminal-themes/catalog-merge.tssrc/shared/terminal-themes/classic.tssrc/shared/terminal-themes/defaults.tssrc/shared/terminal-themes/index.tssrc/shared/terminal-themes/popular-dark-core.tssrc/shared/terminal-themes/popular-dark-extended.tssrc/shared/terminal-themes/popular-dark.tssrc/shared/terminal-themes/popular-light.tssrc/shared/terminal-themes/terminal-theme-catalog.test.tssrc/shared/terminal-themes/types.ts
💤 Files with no reviewable changes (2)
- src/renderer/src/lib/terminal-themes/types.ts
- src/renderer/src/lib/terminal-themes-data.ts
8bcab1f to
0b451fb
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8120db80-a7db-4f04-b3c5-5372dc5b7bfd
📥 Commits
Reviewing files that changed from the base of the PR and between 8bcab1fcad772cc4da0c068d5a300be94bc44807 and 0b451fbec4eb710edcdd36f1a914a00d208f08cf.
📒 Files selected for processing (19)
mobile/src/components/NewWorkspaceFab.tsxmobile/src/theme/mobile-theme-palette.test.tsmobile/src/theme/mobile-theme.tsmobile/src/theme/themed-style-factories.test.tsmobile/src/theme/unthemed-color-imports.test.tssrc/renderer/src/lib/terminal-contrast-correction.test.tssrc/renderer/src/lib/terminal-theme.tssrc/renderer/src/lib/terminal-themes-data.tssrc/renderer/src/lib/terminal-themes/types.tssrc/shared/terminal-themes/catalog-merge.tssrc/shared/terminal-themes/classic.tssrc/shared/terminal-themes/defaults.tssrc/shared/terminal-themes/index.tssrc/shared/terminal-themes/popular-dark-core.tssrc/shared/terminal-themes/popular-dark-extended.tssrc/shared/terminal-themes/popular-dark.tssrc/shared/terminal-themes/popular-light.tssrc/shared/terminal-themes/terminal-theme-catalog.test.tssrc/shared/terminal-themes/types.ts
💤 Files with no reviewable changes (2)
- src/renderer/src/lib/terminal-themes/types.ts
- src/renderer/src/lib/terminal-themes-data.ts
🚧 Files skipped from review as they are similar to previous changes (10)
- src/shared/terminal-themes/catalog-merge.ts
- src/shared/terminal-themes/terminal-theme-catalog.test.ts
- src/shared/terminal-themes/classic.ts
- src/shared/terminal-themes/defaults.ts
- src/shared/terminal-themes/popular-dark.ts
- src/shared/terminal-themes/types.ts
- src/shared/terminal-themes/popular-light.ts
- src/shared/terminal-themes/popular-dark-core.ts
- src/shared/terminal-themes/index.ts
- src/renderer/src/lib/terminal-theme.ts
7c63c13 to
a69838e
Compare
|
Addressed CodeRabbit on the catalog lookup:
Also rebased onto current |
|
@coderabbitai review |
✅ Action performedReview finished.
|
a69838e to
700b690
Compare
|
Rebased onto latest |
700b690 to
85d1b7a
Compare
|
Catch-up rebase onto latest |
85d1b7a to
fedc5bb
Compare
|
Catch-up rebase onto latest |
The built-in terminal theme catalog lived under src/renderer/src/lib/, which Metro cannot see: mobile/metro.config.js adds only <repo>/src/shared to watchFolders. Moving it to src/shared/ lets the phone render the exact same 30 palettes the desktop ships instead of a hardcoded copy that silently drifts. Two content changes ride along because they are what makes the destination correct rather than merely reachable: - types.ts drops `@xterm/xterm`'s ITheme for the shared TerminalColorOverrides. It is the same 22 keys plus an optional `bold`, and it is already the mobile wire shape (RuntimeMobileTerminalTheme['theme']). A renderer-only xterm type does not belong in a module Node and Metro both consume. - terminal-themes/shared.ts becomes catalog-merge.ts. "shared.ts" inside src/shared/ names nothing; AGENTS.md bans the vague form outright. index.ts absorbs the two one-line functions from terminal-themes-data.ts under domain-concrete names, so src/shared never exports a bare `getTheme`, and that file is deleted rather than left as a shim: only three call sites referenced the old paths repo-wide. The catalog had no test of its own. The new one pins the count at 30 (a naive grep for quoted keys reports 22 because eight themes use unquoted keys), pins the two shipped default names — the display name IS the persisted settings id — and asserts every palette defines exactly the 22 keys mobile's WebView copies, so no theme can render half-default on the phone. Behaviour is unchanged: terminal-theme.ts's export surface is identical, and terminal-contrast-correction.test.ts passes with only its import path edited, which is the proof no palette value moved.
getBuiltinTerminalThemePalette must only return own catalog entries so persisted or typed ids like constructor/toString never resolve through Object.prototype. Merge into a null-prototype map and pin the reject list.
fedc5bb to
233de0b
Compare
Greptile SummaryThis PR relocates the built-in terminal theme catalog from
Confidence Score: 5/5Safe to merge — this is a pure file relocation with no behaviour change to the catalog data, and both desktop test suites pass unmodified. All five data modules move with 100% similarity. The two substantive code changes (null-prototype merge map and Object.hasOwn guard) are strictly defensive and do not alter the set of themes or their values. The new catalog test pins count, sort order, default names, and per-palette key sets, so any accidental drift in a follow-up will be caught immediately. No consumer call-sites changed beyond import paths, and all three tsconfig projects compile cleanly. Files Needing Attention: No files require special attention. The key files to glance at are src/shared/terminal-themes/index.ts (new public API surface) and src/shared/terminal-themes/catalog-merge.ts (null-prototype change), both of which look correct.
|
| Filename | Overview |
|---|---|
| src/shared/terminal-themes/index.ts | New shared entry point: assembles the catalog, exports BUILTIN_TERMINAL_THEME_NAMES as readonly string[], and adds getBuiltinTerminalThemePalette with Object.hasOwn guard. |
| src/shared/terminal-themes/catalog-merge.ts | Renamed from shared.ts; adds Object.create(null) for null-prototype safety and switches to Object.hasOwn — both are defensive improvements over the original. |
| src/shared/terminal-themes/types.ts | TerminalThemeMap now maps to TerminalColorOverrides (the shared type) instead of ITheme, bounding catalog entries to the 22 mobile-compatible keys. |
| src/renderer/src/lib/terminal-theme.ts | Import paths updated to shared; BUILTIN_TERMINAL_THEME_NAMES is now a re-export of readonly string[] (previously derived via getThemeNames()). All return-type assignments compile cleanly. |
| src/shared/terminal-themes/terminal-theme-catalog.test.ts | New test suite pinning catalog size, sort order, default theme names, prototype-injection rejection, and exact mobile key set per palette — good regression coverage for future catalog changes. |
| src/renderer/src/lib/terminal-contrast-correction.test.ts | Single import path update; test logic and assertions are unchanged. |
| src/renderer/src/lib/terminal-themes-data.ts | Deleted; its getTheme and getThemeNames helpers are superseded by getBuiltinTerminalThemePalette and BUILTIN_TERMINAL_THEME_NAMES in the shared index. |
| src/renderer/src/lib/terminal-themes/index.ts | Deleted renderer-side index; functionality moved to src/shared/terminal-themes/index.ts. |
| src/renderer/src/lib/terminal-themes/types.ts | Deleted renderer-side types; superseded by src/shared/terminal-themes/types.ts. |
Reviews (1): Last reviewed commit: "fix(terminal-themes): reject prototype n..." | Re-trigger Greptile
|
Consolidated into #10421 (commit 1 of the stack there, byte-identical R100 move) so the maintainer has one user-visible feature to evaluate instead of three dependent refactor-shaped PRs. Closing. |
Summary
Pure relocation of the built-in terminal theme catalog from
src/renderer/src/lib/terminal-themes/tosrc/shared/terminal-themes/, plus itsterminal-themes-data.tsaccessors folded in. No behaviour change, no value change.Why:
mobile/metro.config.jswatches onlysrc/shared, so the mobile bundler cannot see anything undersrc/renderer. A follow-up PR lets the phone pick a terminal theme, and it must use the same definitions as the desktop rather than a second copy that drifts.Why the move is provably value-preserving
Not "the tests still pass" — the existing contrast test is value-blind (it only asserts which channels fall below a floor, so any hex that stays above it is invisible to it). The real proof:
git diff -Mreports R100 (100% similarity) for all five data modules andshared.ts→catalog-merge.tsorigin/mainThe existing desktop suites passing unchanged is a secondary signal only.
The catalog has 30 themes, not 22
Worth stating because it is easy to get wrong: eight entries use unquoted object keys (
Dracula,Nord,Monokai,Nightfox,Kanagawa,Palenight, …), so a grep for quoted keys undercounts by exactly those eight. There was no test on the catalog's contents at all before this PR; there is now one pinning the count and asserting every theme supplies the full slot set.Exports
Names are unchanged. One type widened:
BUILTIN_TERMINAL_THEME_NAMESisreadonly string[]where the oldgetThemeNames()returnedstring[]— strictly safer, sole consumer is a.map, and all three tsconfig projects compile clean.Note on #9663
That draft also edits
src/renderer/src/lib/terminal-theme.ts. This PR keeps its touch there minimal (import path only) so either landing order rebases cheaply.ELI5
Moves the built-in terminal theme list into shared code so both desktop and mobile can use the same definitions. No behavior change—just a relocation so the phone bundler can import the catalog.