VSCode theme support in T3 Code#2550
Conversation
- Document discovery, mapping, and persistence strategy - Outline desktop bridge, settings UI, and rollout phases
- Discover editor themes from desktop installs - Map theme colors into shared app and syntax tokens - Wire theme state through desktop, web, and settings
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Needs human review 2 blocking correctness issues found. This PR introduces a substantial new feature (VSCode/Cursor theme integration) with ~800 lines of new code, new IPC channels, significant state management changes in the theme hook, and runtime behavior changes across multiple components. Additionally, unresolved review comments identify potential bugs where the UI could become stuck in a loading state. You can customize Macroscope's approvability policy. Learn more. |
- Reset stored theme preference when the requested VS Code theme cannot be loaded - Reuse the resolved destructive color for both destructive and destructive-foreground mapping
- Add preference equality guard in theme hook - Prevent outdated async theme loads from overriding newer selections
| localStorage.setItem( | ||
| BOOTSTRAP_THEME_CACHE_KEY, | ||
| JSON.stringify({ id: theme.id, kind: theme.kind, appVariables: theme.appVariables }), | ||
| ); | ||
| recomputeSnapshot({ preference, resolvedColorTheme: theme, status: "ready", message: null }); | ||
| applyResolvedTheme(theme, suppressTransitions); |
There was a problem hiding this comment.
🟡 Medium hooks/useTheme.ts:315
If localStorage.setItem on line 315 throws (e.g., QuotaExceededError or SecurityError in private browsing), the exception propagates unhandled. This prevents recomputeSnapshot and applyResolvedTheme on lines 319-320 from executing, leaving the state stuck at status: "loading" while the successfully loaded theme is never applied.
- localStorage.setItem(
- BOOTSTRAP_THEME_CACHE_KEY,
- JSON.stringify({ id: theme.id, kind: theme.kind, appVariables: theme.appVariables }),
- );
- recomputeSnapshot({ preference, resolvedColorTheme: theme, status: "ready", message: null });
- applyResolvedTheme(theme, suppressTransitions);
+ try {
+ localStorage.setItem(
+ BOOTSTRAP_THEME_CACHE_KEY,
+ JSON.stringify({ id: theme.id, kind: theme.kind, appVariables: theme.appVariables }),
+ );
+ } catch {
+ // Cache failure should not block theme application
+ }
+ recomputeSnapshot({ preference, resolvedColorTheme: theme, status: "ready", message: null });
+ applyResolvedTheme(theme, suppressTransitions);🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/web/src/hooks/useTheme.ts around lines 315-320:
If `localStorage.setItem` on line 315 throws (e.g., `QuotaExceededError` or `SecurityError` in private browsing), the exception propagates unhandled. This prevents `recomputeSnapshot` and `applyResolvedTheme` on lines 319-320 from executing, leaving the state stuck at `status: "loading"` while the successfully loaded `theme` is never applied.
Evidence trail:
apps/web/src/hooks/useTheme.ts lines 275-322 (REVIEWED_COMMIT): `loadPreference` function. Line 290 sets status to 'loading'. try/catch on lines 291-301 only wraps `bridge.loadColorTheme`. Line 315-318 `localStorage.setItem(BOOTSTRAP_THEME_CACHE_KEY, ...)` is outside try/catch. Lines 319-320 set 'ready' status and apply theme. Callers at lines 392, 409, 421 all use `void loadPreference(...)` (fire-and-forget).
auto-detects vscode/cursor themes installed on ur machine. u pick one, it just works in t3 code
enjoy the 5.5 xHigh slop pr, do with it what u will I just want this to exist at some point in some way
Summary
Testing
bun fmtbun lintbun typecheckbun run testNote
Add VSCode/Cursor color theme support to the T3 Code desktop app
vscodeThemeDiscoverymodule to the desktop app that scans VS Code, VS Code Insiders, and Cursor extension directories, reads editor settings, and resolves full color themes including workbench and token colors.desktop:discover-color-themes,desktop:load-color-theme,desktop:get-editor-theme-preferences,desktop:set-window-theme-colors) and correspondingdesktopBridgemethods to the renderer.useThemeto support a richerThemePreferencemodel withsystem,builtin,external, andfollow-editormodes; external themes are loaded async with loading/error states and a bootstrap cache to prevent flash on cold start.syntaxThemelibrary, making code block and diff syntax highlighting follow the active editor theme.themePreferenceis now persisted inClientSettingsand localStorage; existinglight/dark/systemvalues are migrated automatically to the new schema.Macroscope summarized 4e4f44f.