feat(web): add modular theme library - #5226
Conversation
|
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 Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Adds semantic theme roles, persisted light and dark variants, personal theme import and creation, contrast-safe surfaces, and themed message actions. Includes the T3 Chat palette, follow-system behavior, splash handling, and the theme library UI.
e0f79e4 to
607dd6b
Compare
ApprovabilityVerdict: Needs human review This PR introduces a complete modular theme library feature with ~4100 new lines across multiple files, including a theme editor UI, color management system, import/export workflows, and boot script changes. The scope and complexity of this new user-facing feature warrants human review. You can customize Macroscope's approvability policy. Learn more. |
Full review pass over the modular theme system: - Rewrite the index.html boot script to mirror runtime resolution exactly: clamp built-in themes to their available modes (T3 Chat is light-only), treat unrecognized preferences as the system default, follow the OS in the storage-failure fallback, and honor corrupted follow-system values the same way the runtime does. Add a boot/runtime parity test that evaluates the inline script against resolveThemeAppearance. - Keep the color picker's hue when a grey/white/black echo round-trips, open hand-tuned themes in advanced mode so guided regeneration cannot silently discard their palettes, and regenerate every saved appearance when toggling Advanced off. - Cache the useTheme snapshot instead of reading localStorage on every consumer render, and share one storage/matchMedia listener pair. - Restore hover and emphasis states lost in the token migration (message action hover, provider update pill, sidebar read/unread, plan-mode toggle) and fix message-foreground tokens used on background surfaces. - Extract the theme library/editor into ThemeSettings.tsx, memoize the color rows, reuse the Alert component and shared isThemeColor, drop the dead StageBackdropButtonArt and themePreferenceForSystem, and make stored-theme parsing tolerant of unknown roles from other builds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a096aba. Configure here.
- The boot script no longer follows the OS for a `:system`-suffixed preference when follow-system is explicitly off, matching the runtime; covered by two new parity cases. - setTheme/setFollowSystem report write success, so the follow-system toggle leaves the theme preference untouched when its write fails, and removing the active theme keeps it installed when the selection cannot be moved off it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The document ships light-media, dark-media, and plain theme-color metas; the browser reads whichever matches the OS, so mutating only the first element left themed chrome colors unapplied on a dark OS. Both the boot script and syncBrowserChromeTheme now write the resolved color to every matching meta. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Summary
T3 Code now has a token-based theme foundation that can grow from maintainer themes into user-created themes across the web client and desktop app.
Closes #418
Screenshots
The library views show the maintainer themes alongside personal-theme cards.
Verification
Note
Add modular theme library with custom theme support and semantic color tokens
themePalette.ts, a new theme management module with APIs to parse/serialize theme files, resolve light/dark appearance, manage custom themes in localStorage, and subscribe to theme changes.ThemeLibrarycomponent, and addsfollowSystemstate touseThemewith dedicatedsetFollowSystemandrefreshThemecontrols.index.htmlthat resolves custom and built-in themes (t3-chat,t3-grove) from storage, applies splash CSS variables, and falls back to OS preference on failure.index.cssfor error/warning/update surfaces, message surfaces, code/terminal surfaces, and ahtml[data-theme-id]block that maps theme-file roles to these tokens.text-muted-foreground/*variants to named tokens (text-secondary-label,text-icon-muted,text-placeholder,text-message-foreground, etc.) across the chat, sidebar, composer, and settings UI.ThreadTerminalDrawer.tsxnow reads--terminal-*CSS variables so it respects the active theme palette.documentElementdataset attributes synchronously on page load; errors fall back to OS preference rather than forcing dark mode, which changes the previous failure behavior.Macroscope summarized 46827f2.
Note
Medium Risk
Large cross-surface styling and boot-time localStorage logic; incorrect theme resolution could cause flash or wrong colors, but scope is mostly UI and persisted preferences rather than auth or data.
Overview
Adds a token-based theme system with maintainer themes (Default, T3 Chat, T3 Grove), personal themes in localStorage, and a Follow system preference separate from the stored theme id.
Appearance settings replace the light/dark/system dropdown with a theme library (select, create, edit, import/export JSON, guided vs advanced color editing).
useThemegainsfollowSystem,setFollowSystem, andrefreshTheme; theme writes return success/failure booleans.Boot script in
index.htmlmirrors runtime resolution for custom/built-in themes, splash--boot-*variables, anddata-theme-*attributes; storage failures now follow OS appearance instead of forcing dark.UI migration swaps ad-hoc
muted-foreground/*and hard-coded blues/reds/ambers for semantic tokens (secondary-label,icon-muted,placeholder,message/message-action,code-*,error/warning/updatesurfaces). Composer send/actions, user message bubbles, diffs, file previews, terminals (--terminal-*), and update pills align with the active palette. Stage backdrop compact button art on the send control is removed.Reviewed by Cursor Bugbot for commit 46827f2. Bugbot is set up for automated code reviews on this repo. Configure here.