rebenitez1802 opened a new pull request, #43778:
URL: https://github.com/apache/superset/pull/43778

   ### SUMMARY
   
   Setting a new **system default** or **system dark** theme from the Themes 
admin page did not take effect until a full browser refresh — a regression from 
the previous behavior where it applied immediately.
   
   **Root cause:** the four save/unset handlers in `ThemeList` only called 
`refreshData()` (which re-fetches the CRUD list rows) and never updated the 
live `ThemeController`. The controller reads its `defaultTheme`/`darkTheme` 
once at construction from `getBootstrapData()`, which memoizes the 
server-rendered bootstrap JSON in a module-level variable that is never 
invalidated for the SPA session. So the app kept rendering the constructor-time 
theme until a reload rebuilt it.
   
   **Fix:**
   - New `GET /api/v1/theme/system` endpoint on `ThemeRestApi` returning the 
resolved system theme slice — the *same* processed payload used to bootstrap 
the page (the config-file merge and slot-algorithm coercion happen server-side, 
so a live apply matches a reload by construction). Gated on `can_read`; the 
slice is already sent to every user in the page bootstrap, so it exposes 
nothing new.
   - New non-throwing `ThemeController.refreshSystemThemes()` that re-reads 
that endpoint, reassigns the theme slots exactly as the constructor does, 
re-syncs the `prefers-color-scheme` listener (so first-time-dark / unset-dark 
transitions keep OS auto-switching correct), recomputes the mode, and 
re-applies the theme live through the existing `updateTheme()` path — 
preserving any active dev theme override and never setting the embedded-SDK 
override flag.
   - Exposed it on the theme context; the four set/unset handlers now `await 
refreshSystemThemes()` after a successful mutation.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   _Before:_ changing the system default/dark theme required a manual page 
refresh to take effect.
   
   _After:_ the new theme applies immediately, no refresh needed.
   
   ### TESTING INSTRUCTIONS
   
   Manual:
   1. Enable `ENABLE_UI_THEME_ADMINISTRATION` and log in as an admin.
   2. Go to **Settings → Themes**.
   3. Pick a theme and choose **Set as system default** (or **system dark**) 
and confirm.
   4. The theme applies immediately — no page refresh. Repeat for **unset**; 
the app reverts live to the config-file fallback.
   
   Automated:
   - Frontend: `superset-frontend/src/theme/tests/ThemeController.test.ts`, 
`ThemeProvider.test.tsx`, and `src/pages/ThemeList/ThemeList.test.tsx` cover 
live apply, dev-override preservation, media-query listener reconciliation, 
unset fallback, and the handler wiring.
   - Backend: `tests/integration_tests/themes/test_theme_api_permissions.py` 
covers admin/gamma read access to `/theme/system` and that a freshly set 
default is reflected on a subsequent read.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [x] Required feature flags: `ENABLE_UI_THEME_ADMINISTRATION` (needed to 
reach the affected admin UI)
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to