feat(theme): add in-memory theme set registration#9
Conversation
ThemeSource::Bundled in gpui-component-app currently has to sync embedded themes to config_dir before ThemeRegistry will pick them up, since the only ingestion path is reading files from themes_dir. Add ThemeRegistry::register_theme_set so callers can hand a ThemeSet straight to the registry, unblocking bundled/embedded themes and a future wasm build with no filesystem. reload() is refactored to cache the disk-loaded sets and rebuild themes/theme_sets from a shared helper, so a later watch_dir reload with the same set name still wins over an in-memory registration.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 15 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Adds
ThemeRegistry::register_theme_set(&mut self, set: ThemeSet), letting callers hand aThemeSetstraight to the registry without writing it tothemes_dirfirst.gpui-component-app'sThemeSource::Bundledcurrently has to sync embedded themes out toconfig_dirbecauseThemeRegistry's only ingestion path is reading files from disk. This adds a direct path, which also unblocks a future wasm build with no filesystem.Behavior
reload()protects them: a registered theme can't replace a built-in theme of the same name.watch_dirlater reloads a disk file with the same set name, the on-disk version wins on the next reload — registrations behave like a previously loaded file that disk can supersede.global_muton this fork notifies observers, so callers just useThemeRegistry::global_mut(cx).register_theme_set(set).reload()is refactored to share its merge logic with the new method via arebuild_theme_setshelper, caching the last disk-loaded sets so registration doesn't need to touch the filesystem.Test plan
cargo test -p gpui-component(186 passed, incl. 4 new registry tests)cargo clippy -p gpui-component --all-targets -- --deny warningscargo fmt --check crates/ui/src/theme/registry.rs