You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "semohr (via GitHub)" <gi...@apache.org> on 2026/04/02 12:27:49 UTC
[PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
semohr opened a new pull request, #39063:
URL: https://github.com/apache/superset/pull/39063
### SUMMARY
Added `data-theme-mode` attribute to `<html>` element to expose the currently active theme mode (`dark` or `light`) for use by extensions and custom CSS.
### Motivation
Previously, extensions and custom dashboard styles had no way to determine which theme mode (light/dark) was currently active through CSS alone. Users had to rely on `prefers-color-scheme` media queries, which only detect OS-level preference not Superset's explicit theme selection or user overrides.
This created a gap where:
- Custom CSS in dashboards couldn't adapt to Superset's actual theme
- Extensions couldn't implement theme-aware styling without JavaScript injection
### Usage Example
Extensions and custom CSS can now adapt to Superset's theme without JavaScript:
```css
[data-theme-mode="light"] {
.custom-card {
background-color: var(--background-light);
color: var(--text-light);
}
}
[data-theme-mode="dark"] {
.custom-card {
background-color: var(--background-dark);
color: var(--text-dark);
}
}
```
### ADDITIONAL INFORMATION
- [x] Introduces new feature or API
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "semohr (via GitHub)" <gi...@apache.org>.
semohr commented on PR #39063:
URL: https://github.com/apache/superset/pull/39063#issuecomment-4215468003
There is a way to inject markdown and html without react afaik. This is not directly about extensions.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39063:
URL: https://github.com/apache/superset/pull/39063#issuecomment-4177518592
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "semohr (via GitHub)" <gi...@apache.org>.
semohr commented on code in PR #39063:
URL: https://github.com/apache/superset/pull/39063#discussion_r3059399777
##########
superset-frontend/src/theme/tests/ThemeProvider.test.tsx:
##########
@@ -276,4 +277,61 @@ describe('SupersetThemeProvider', () => {
);
});
});
+
+ describe('Theme Mode Data Attribute', () => {
Review Comment:
Im not entierly sure what you mean by flatten the tests but I moved them out of the describe block into the `describe('SupersetThemeProvider', () => {...})` scope.
Hope this is what you had in mind.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "semohr (via GitHub)" <gi...@apache.org>.
semohr commented on code in PR #39063:
URL: https://github.com/apache/superset/pull/39063#discussion_r3059031122
##########
superset-frontend/src/theme/ThemeProvider.tsx:
##########
@@ -53,11 +53,19 @@ export function SupersetThemeProvider({
);
useEffect(() => {
- const unsubscribe = themeController.onChange(theme => {
+ // TODO: Once we migrate to react>=18 is should be possible
+ // to replace the useState and useEffect with a singular
+ // useSyncExternalStore, simplifying quite a bit
+ const updateState = (theme: Theme) => {
setCurrentTheme(theme);
setCurrentThemeMode(themeController.getCurrentMode());
- });
-
+ document.documentElement.setAttribute(
+ 'data-theme-mode',
+ themeController.getCurrentModeResolved(),
+ );
Review Comment:
This was my idea first too but we need to initialize the css state correctly. The event handler will not trigger on mount. Note that it is called twice once in the onChange and once in the root of the useffect.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "semohr (via GitHub)" <gi...@apache.org>.
semohr commented on code in PR #39063:
URL: https://github.com/apache/superset/pull/39063#discussion_r3059031122
##########
superset-frontend/src/theme/ThemeProvider.tsx:
##########
@@ -53,11 +53,19 @@ export function SupersetThemeProvider({
);
useEffect(() => {
- const unsubscribe = themeController.onChange(theme => {
+ // TODO: Once we migrate to react>=18 is should be possible
+ // to replace the useState and useEffect with a singular
+ // useSyncExternalStore, simplifying quite a bit
+ const updateState = (theme: Theme) => {
setCurrentTheme(theme);
setCurrentThemeMode(themeController.getCurrentMode());
- });
-
+ document.documentElement.setAttribute(
+ 'data-theme-mode',
+ themeController.getCurrentModeResolved(),
+ );
Review Comment:
This was my idea first too but we need to initialize the state correctly. The event handler will not trigger on mount, only once the state is changed. If not done like that, the css variable is not set until a user clicks the light/dark mode switch button.
Note that `updateState` it is called twice once attached in onChange and once in the root of the useEffect.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #39063:
URL: https://github.com/apache/superset/pull/39063#issuecomment-4215355816
> Extensions couldn't implement theme-aware styling without JavaScript injection
Hi @semohr. I'm assuming you're talking about CSS overrides here?
[Superset Extensions](https://superset.apache.org/developer-docs/extensions/overview) can access the theme like:
```
import { theme } from '@apache-superset/core';
const { useTheme, isThemeDark } = theme;
function MyComponent() {
const currentTheme = useTheme();
const isDark = isThemeDark(currentTheme);
return <div style={{
background: isDark ? currentTheme.colorBgBase : currentTheme.colorBgContainer
}} />;
}
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #39063:
URL: https://github.com/apache/superset/pull/39063#discussion_r3027774752
##########
superset-frontend/src/theme/ThemeController.ts:
##########
@@ -307,6 +307,18 @@ export class ThemeController {
return this.currentMode;
}
+ /**
+ * Returns the resolved theme mode as 'dark' or 'light'.
+ * Takes into account SYSTEM mode and returns the actual resolved preference.
+ */
+ public getCurrentModeResolved(): 'dark' | 'light' {
+ const mode =
+ this.currentMode === ThemeMode.SYSTEM
+ ? this.systemMode
+ : this.currentMode;
Review Comment:
**Suggestion:** `getCurrentModeResolved` assumes every non-`DARK` mode is light, which is incorrect when the configured default theme is actually dark (for example, single-theme deployments with `THEME_DARK = None` and a dark default). This will set `data-theme-mode="light"` while a dark theme is active, breaking extension/custom CSS behavior. Resolve the mode from the actual active theme config instead of inferring from `ThemeMode`. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ data-theme-mode misreports theme in dark-default deployments.
- ⚠️ Extensions using [data-theme-mode="dark"] never activate correctly.
- ⚠️ Custom CSS cannot reliably detect actual dark appearance.
```
</details>
```suggestion
const activeTheme = this.getThemeForMode(this.currentMode);
if (activeTheme) {
const normalizedTheme = this.normalizeTheme(activeTheme);
return isThemeConfigDark(normalizedTheme) ? 'dark' : 'light';
}
return this.currentMode === ThemeMode.DARK ? 'dark' : 'light';
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Configure a Superset deployment with a single custom dark theme as the default and no
separate dark theme: backend config sends bootstrap data where `common.theme.default`
contains dark tokens and `common.theme.dark` is empty, so in `ThemeController`'s
constructor (`superset-frontend/src/theme/ThemeController.ts:24-31,44-47`)
`this.defaultTheme` is set to the dark-looking theme and `this.darkTheme` remains `null`.
2. Start the Superset frontend and load any page; `RootContextProviders`
(`superset-frontend/src/views/RootContextProviders.tsx:15-25`) creates `const
themeController = new ThemeController();` and wraps the entire app in
`<SupersetThemeProvider themeController={themeController}>`.
3. On initial render, `SupersetThemeProvider`'s effect
(`superset-frontend/src/theme/ThemeProvider.tsx:20-29`) runs `updateState`, which calls
`document.documentElement.setAttribute('data-theme-mode',
themeController.getCurrentModeResolved());`, wiring the HTML `data-theme-mode` attribute
directly to `ThemeController.getCurrentModeResolved()`.
4. In this single-theme (default-only) configuration, `determineInitialMode()`
(`ThemeController.ts:52-61`) forces `this.currentMode` to `ThemeMode.DEFAULT` because
`this.darkTheme === null`, while the active theme for that mode is the dark-looking
`this.defaultTheme` via `getThemeForMode(ThemeMode.DEFAULT)` (`ThemeController.ts:23-46);
however `getCurrentModeResolved()` (`ThemeController.ts:35-40`) computes `mode` as
`ThemeMode.DEFAULT` and returns `'light'` for any non-`DARK` mode, so
`document.documentElement` ends up with `data-theme-mode="light"` even though a dark theme
is applied, causing any extensions or custom CSS that rely on `[data-theme-mode="dark"]`
to mis-detect the active theme.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/theme/ThemeController.ts
**Line:** 315:318
**Comment:**
*Logic Error: `getCurrentModeResolved` assumes every non-`DARK` mode is light, which is incorrect when the configured default theme is actually dark (for example, single-theme deployments with `THEME_DARK = None` and a dark default). This will set `data-theme-mode="light"` while a dark theme is active, breaking extension/custom CSS behavior. Resolve the mode from the actual active theme config instead of inferring from `ThemeMode`.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39063&comment_hash=bcae5e0781ce8c728865b3340dab2a1083217f39f0386c7519067bd61bb2f8ee&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39063&comment_hash=bcae5e0781ce8c728865b3340dab2a1083217f39f0386c7519067bd61bb2f8ee&reaction=dislike'>👎</a>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39063:
URL: https://github.com/apache/superset/pull/39063#issuecomment-4216343122
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/39063?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `90.00000%` with `1 line` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 64.45%. Comparing base ([`bf9aff1`](https://app.codecov.io/gh/apache/superset/commit/bf9aff19b54932703caa7b58040e84dc887c6f51?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`1bacf65`](https://app.codecov.io/gh/apache/superset/commit/1bacf65f7c9513af8534c8930a41dcd0cd5c7022?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 35 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/39063?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset-frontend/src/theme/ThemeController.ts](https://app.codecov.io/gh/apache/superset/pull/39063?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2Ftheme%2FThemeController.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3RoZW1lL1RoZW1lQ29udHJvbGxlci50cw==) | 83.33% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39063?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #39063 +/- ##
=======================================
Coverage 64.45% 64.45%
=======================================
Files 2540 2540
Lines 131639 131648 +9
Branches 30515 30518 +3
=======================================
+ Hits 84849 84857 +8
- Misses 45324 45325 +1
Partials 1466 1466
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/39063/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [javascript](https://app.codecov.io/gh/apache/superset/pull/39063/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.06% <90.00%> (+<0.01%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/39063?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39063:
URL: https://github.com/apache/superset/pull/39063#issuecomment-4216012715
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 1bacf65f7c9513af8534c8930a41dcd0cd5c7022 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69d7d93b9c63040008377ec4 |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-39063--superset-docs-preview.netlify.app](https://deploy-preview-39063--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-39063--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "semohr (via GitHub)" <gi...@apache.org>.
semohr commented on code in PR #39063:
URL: https://github.com/apache/superset/pull/39063#discussion_r3059031122
##########
superset-frontend/src/theme/ThemeProvider.tsx:
##########
@@ -53,11 +53,19 @@ export function SupersetThemeProvider({
);
useEffect(() => {
- const unsubscribe = themeController.onChange(theme => {
+ // TODO: Once we migrate to react>=18 is should be possible
+ // to replace the useState and useEffect with a singular
+ // useSyncExternalStore, simplifying quite a bit
+ const updateState = (theme: Theme) => {
setCurrentTheme(theme);
setCurrentThemeMode(themeController.getCurrentMode());
- });
-
+ document.documentElement.setAttribute(
+ 'data-theme-mode',
+ themeController.getCurrentModeResolved(),
+ );
Review Comment:
This was my idea first too but we need to initialize the css state correctly. The event handler will not trigger on mount. Note that it is called twice once in the onChange and once in the root of the useffect.
The css variable would only be set after a change if we do not sync the state onmount too.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "semohr (via GitHub)" <gi...@apache.org>.
semohr commented on code in PR #39063:
URL: https://github.com/apache/superset/pull/39063#discussion_r3059031122
##########
superset-frontend/src/theme/ThemeProvider.tsx:
##########
@@ -53,11 +53,19 @@ export function SupersetThemeProvider({
);
useEffect(() => {
- const unsubscribe = themeController.onChange(theme => {
+ // TODO: Once we migrate to react>=18 is should be possible
+ // to replace the useState and useEffect with a singular
+ // useSyncExternalStore, simplifying quite a bit
+ const updateState = (theme: Theme) => {
setCurrentTheme(theme);
setCurrentThemeMode(themeController.getCurrentMode());
- });
-
+ document.documentElement.setAttribute(
+ 'data-theme-mode',
+ themeController.getCurrentModeResolved(),
+ );
Review Comment:
This was my idea first too but we need to initialize the state correctly. The event handler will not trigger on mount, only once the state is changed. This yields that the css variable is not set until a user clicks the light/dark mode switch button.
Note that `updateState` it is called twice once attached in onChange and once in the root of the useEffect.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39063:
URL: https://github.com/apache/superset/pull/39063#issuecomment-4178009948
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #39063:
URL: https://github.com/apache/superset/pull/39063#discussion_r3058778439
##########
superset-frontend/src/theme/ThemeProvider.tsx:
##########
@@ -53,11 +53,19 @@ export function SupersetThemeProvider({
);
useEffect(() => {
- const unsubscribe = themeController.onChange(theme => {
+ // TODO: Once we migrate to react>=18 is should be possible
+ // to replace the useState and useEffect with a singular
+ // useSyncExternalStore, simplifying quite a bit
+ const updateState = (theme: Theme) => {
setCurrentTheme(theme);
setCurrentThemeMode(themeController.getCurrentMode());
- });
-
+ document.documentElement.setAttribute(
+ 'data-theme-mode',
+ themeController.getCurrentModeResolved(),
+ );
Review Comment:
I think just this is enough right? No need to make it a named function
##########
superset-frontend/src/theme/tests/ThemeProvider.test.tsx:
##########
@@ -276,4 +277,61 @@ describe('SupersetThemeProvider', () => {
);
});
});
+
+ describe('Theme Mode Data Attribute', () => {
Review Comment:
Can we avoid describe here and flatten the tests?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "semohr (via GitHub)" <gi...@apache.org>.
semohr commented on code in PR #39063:
URL: https://github.com/apache/superset/pull/39063#discussion_r3059031122
##########
superset-frontend/src/theme/ThemeProvider.tsx:
##########
@@ -53,11 +53,19 @@ export function SupersetThemeProvider({
);
useEffect(() => {
- const unsubscribe = themeController.onChange(theme => {
+ // TODO: Once we migrate to react>=18 is should be possible
+ // to replace the useState and useEffect with a singular
+ // useSyncExternalStore, simplifying quite a bit
+ const updateState = (theme: Theme) => {
setCurrentTheme(theme);
setCurrentThemeMode(themeController.getCurrentMode());
- });
-
+ document.documentElement.setAttribute(
+ 'data-theme-mode',
+ themeController.getCurrentModeResolved(),
+ );
Review Comment:
This was my idea first too but we need to initialize the state correctly. The event handler will not trigger on mount, only once the state is changed. This yields that the css variable is not set until a user clicks the light/dark mode switch button.
Note that it is called twice once in the onChange and once in the root of the useffect.
##########
superset-frontend/src/theme/ThemeProvider.tsx:
##########
@@ -53,11 +53,19 @@ export function SupersetThemeProvider({
);
useEffect(() => {
- const unsubscribe = themeController.onChange(theme => {
+ // TODO: Once we migrate to react>=18 is should be possible
+ // to replace the useState and useEffect with a singular
+ // useSyncExternalStore, simplifying quite a bit
+ const updateState = (theme: Theme) => {
setCurrentTheme(theme);
setCurrentThemeMode(themeController.getCurrentMode());
- });
-
+ document.documentElement.setAttribute(
+ 'data-theme-mode',
+ themeController.getCurrentModeResolved(),
+ );
Review Comment:
This was my idea first too but we need to initialize the state correctly. The event handler will not trigger on mount, only once the state was changed once. This yields that the css variable is not set until a user clicks the light/dark mode switch button.
Note that it is called twice once in the onChange and once in the root of the useffect.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39063:
URL: https://github.com/apache/superset/pull/39063#issuecomment-4216338884
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(themes): expose active theme mode via data-theme-mode attribute [superset]
Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz merged PR #39063:
URL: https://github.com/apache/superset/pull/39063
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org