Custom Dark Theme - theme & sidebar theme creation#12760
Custom Dark Theme - theme & sidebar theme creation#12760mayagbarnes merged 3 commits intodevelopfrom
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ PR preview is ready!
|
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.0300%
🎉 Great job on improving test coverage! |
2d8dfca to
fac9e6b
Compare
3266a92 to
b4327a2
Compare
There was a problem hiding this comment.
Pull Request Overview
Implements frontend logic for Custom Dark Theme feature (part 3): merges nested theme inputs (light/dark and sidebar), generates appropriate custom theme variants, and centralizes sidebar theme creation.
- Adds utilities to merge theme sections with correct precedence and create custom light/dark themes.
- Moves and consolidates sidebar theme creation into lib.
- Introduces getSystemThemePreference and updates App to select the initial custom theme based on system preference.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/lib/src/theme/utils.ts | Adds custom theme merging utilities, sidebar theme creation, and system theme preference helper. |
| frontend/lib/src/theme/utils.test.ts | Adds extensive unit tests for custom theme creation and sidebar theming. |
| frontend/lib/src/index.ts | Re-exports new theme utilities and constants. |
| frontend/app/src/components/Sidebar/ThemedSidebar.tsx | Refactors to use centralized createSidebarTheme from lib. |
| frontend/app/src/components/Sidebar/ThemedSidebar.test.tsx | Updates imports to use the centralized sidebar theme factory. |
| frontend/app/src/App.tsx | Integrates new custom theme creation and selects default variant based on system preference. |
| frontend/app/src/App.test.tsx | Adds tests for selecting light/dark custom theme based on system preference. |
fac9e6b to
1da7156
Compare
7f6da10 to
f90316c
Compare
1da7156 to
d1bd138
Compare
kmcgrady
left a comment
There was a problem hiding this comment.
Overall, the logic makes sense. I gave a couple non-blocking ideas for readability. Definitely look up the lodash merge as it can be really powerful here, but there are some gotchas to consider (how it handles arrays for example). I don't know the shape of the theme config, so please just double check if it would work well.
| "Sidebar", | ||
| { | ||
| ...activeTheme.themeInput, // Use the theme props from the main theme as basis | ||
| // @ts-expect-error - baseTheme is not null |
There was a problem hiding this comment.
Why is this error being thrown?
There was a problem hiding this comment.
This exists because of a mismatch between protobuf types and TypeScript's Partial type.
base is an optional field, which protobuf uses null for (so can be base | null | undefined), but TypeScript's Partial expects base | undefined.
When I spread ...activeTheme.themeInput, TypeScript preserves the possibility that properties could be null, even when I've explicitly set base: baseTheme
f90316c to
f64a0ec
Compare
**Part 5 of Custom Dark Theme Feature** **Resolves section merge** issue introduced with updating to lodash merge in #12760 - Use `mergeWith` instead to handle protobuf defaults - Have sidebar theme creation also use `mergeWith` **Adds e2e tests** for `theme.light` and `theme.dark` configurations * Light/Dark e2e tests: Test precedence between `[theme]` & `[theme.light/dark]` configs * Sidebar light/dark e2e tests: Test precedence between `[theme.light/dark]`, `[theme.sidebar]`, & `[theme.light/dark.sidebar]` configs

Describe your changes
Part 3 of Custom Dark Theme Feature
PR handles the FE logic to take the newly formed
themeInputfrom the new session proto message (example below), create a mergedthemeInputwith the proper section inheritance, and then create custom theme(s).# Theme configs provided by BE { "base": "light", "primaryColor": "blue", "sidebar": {...}, # Config options from theme.sidebar "light": { # Config options from theme.light ...other options... "sidebar": {...}, # Config options from theme.light.sidebar }, "dark": { # Config options from theme.dark ...other options... "sidebar": {...}, # Config options from theme.dark.sidebar }, ...other theme options... }lightordarksection properties provided, 2 custom themes are created -> "Custom Theme Light" and "Custom Theme Dark".lightordarksection properties) 1 custom theme is created -> "Custom Theme"theme<theme.light/darktheme<theme.light/dark<theme.sidebar<theme.light/dark.sidebarTesting Plan