You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gabotorresruiz (via GitHub)" <gi...@apache.org> on 2026/08/06 23:57:19 UTC

[PR] feat(theme): allow deployments to register extra theme tokens [superset]

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

   ### SUMMARY
   
   Superset's theme system supports custom tokens beyond Ant Design's (for example `brandLogoUrl`, `echartsOptionsOverrides`, and the `label*` / `button*` tokens in `SupersetSpecificTokens`). Deployments, white-label distributors, and custom chart plugins legitimately define their **own** tokens and consume them via `useTheme`. Today the theme editor validates token names against a fixed allowlist (`antdTokenNames.ts`), so any such deployment-specific token is flagged as an "Unknown token" warning with no supported way to register it.
   
   This adds an `EXTRA_THEME_TOKENS` config that lets a deployment register extra custom token names. It follows the exact pattern already used for `EXTRA_CATEGORICAL_COLOR_SCHEMES` / `EXTRA_SEQUENTIAL_COLOR_SCHEMES`: a config default, shipped to the frontend in the common bootstrap payload, and merged into the theme editor's valid-token set at runtime.
   
   Design notes:
   - `EXTRA_THEME_TOKENS: list[str] = []` in `config.py` (empty default, fully opt-in, no behavior change for existing deployments).
   - Exposed via `common_bootstrap_payload` in `views/base.py`, typed in `bootstrapTypes.ts`, defaulted in `constants.ts`.
   - `antdTokenNames.ts` merges `common.extra_theme_tokens` into the valid-token set and treats them as Superset custom tokens (not Ant Design) for correct categorization.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Before: a deployment-defined token (e.g. `myBrandToken`) in a theme's JSON shows an "Unknown token 'myBrandToken' — may be ignored by Ant Design" warning in the theme editor.
   
   After: with `EXTRA_THEME_TOKENS = ["myBrandToken"]`, the token validates cleanly and the warning is gone. Ant Design still ignores tokens it does not recognize; this only affects editor validation.
   
   ### TESTING INSTRUCTIONS
   
   1. Set `EXTRA_THEME_TOKENS = ["myBrandToken"]` in `superset_config.py`.
   2. Open the theme editor and add `"myBrandToken": "..."` inside a theme's `token` object.
   3. Confirm no "Unknown token" warning is shown for it (an unregistered token like `"foo"` still warns).
   4. Unit tests: `superset-frontend/src/theme/utils/antdTokenNames.test.ts` covers the injected-token path (valid, categorized as a Superset custom token).
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] 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
   


-- 
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(theme): allow deployments to register extra theme tokens [superset]

Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on PR #42874:
URL: https://github.com/apache/superset/pull/42874#issuecomment-5219305734

   @rebenitez1802 good catch, thanks. You are right that the two paths agreed only because of `getBootstrapData`'s memoization, which is an implicit invariant rather than a guarantee.
   
   I pushed a change that snapshots the registered extras once (`extraThemeTokensCache`), so the cached valid-token set (`isValidTokenName`) and the live reads (`isSupersetCustomToken`, `getAllValidTokenNames`) now derive from the same list by construction. That removes the divergence in your second scenario, and the internal split inside `getAllValidTokenNames` where `supersetTokens` was live but total came from the frozen cache.
   
   On the first scenario (a first `isValidTokenName` call before the `#app[data-bootstrap]` DOM exists): that one is really a property of `getBootstrapData` itself, which caches `DEFAULT_BOOTSTRAP_DATA` permanently if called pre-bootstrap, so it affects every consumer rather than theme tokens specifically. `isValidTokenName` is only reachable from the theme editor, which renders well after bootstrap, so I left that alone rather than adding a reset hook here.


-- 
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(theme): allow deployments to register extra theme tokens [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42874:
URL: https://github.com/apache/superset/pull/42874#issuecomment-5210106870

   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(theme): allow deployments to register extra theme tokens [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #42874:
URL: https://github.com/apache/superset/pull/42874#issuecomment-5210232321

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/42874?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 66.29%. Comparing base ([`ae66b69`](https://app.codecov.io/gh/apache/superset/commit/ae66b697e5c682e4aaf886e9017923408aacb72a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`855f5e8`](https://app.codecov.io/gh/apache/superset/commit/855f5e8321daad176c6667f6ecae7172db936274?dropdown=coverage&el=desc&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   #42874   +/-   ##
   =======================================
     Coverage   66.29%   66.29%           
   =======================================
     Files        2857     2857           
     Lines      162841   162845    +4     
     Branches    37361    37364    +3     
   =======================================
   + Hits       107949   107959   +10     
   + Misses      52799    52793    -6     
     Partials     2093     2093           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/42874/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/42874/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.18% <100.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 Harness](https://app.codecov.io/gh/apache/superset/pull/42874?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(theme): allow deployments to register extra theme tokens [superset]

Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz merged PR #42874:
URL: https://github.com/apache/superset/pull/42874


-- 
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(theme): allow deployments to register extra theme tokens [superset]

Posted by "rebenitez1802 (via GitHub)" <gi...@apache.org>.
rebenitez1802 commented on PR #42874:
URL: https://github.com/apache/superset/pull/42874#issuecomment-5219158414

   **Two sources of truth for extra theme tokens** (non-blocking follow-up / hardening suggestion — not a merge blocker)
   
   In `superset-frontend/src/theme/utils/antdTokenNames.ts`, `getValidTokenNames()` bakes `getExtraThemeTokens()` into the module-level `validTokenNamesCache` on first call and never resets it, while the rewritten `isSupersetCustomToken()` and `getAllValidTokenNames()` read `getExtraThemeTokens()` **live** on every call.
   
   These paths agree today only because `getBootstrapData()` is itself memoized and warmed at import — an undocumented, load-bearing invariant. Two ways that can bite:
   
   - If the first `isValidTokenName` call ever runs before the `#app[data-bootstrap]` DOM is present, the cache freezes `extra = []` permanently, so registered tokens silently warn forever.
   - A future refactor that drops `getBootstrapData`'s memoization reintroduces true divergence between `isValidTokenName` (reads the frozen cache) and the other two helpers (read live).
   
   Suggestion: derive all three helpers from the single snapshot used to build `validTokenNamesCache` (or add a small cache-reset export used in tests), so consistency isn't an accident of double-memoization.
   


-- 
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(theme): allow deployments to register extra theme tokens [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42874:
URL: https://github.com/apache/superset/pull/42874#issuecomment-5219945279

   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