codeant-ai-for-open-source[bot] commented on code in PR #42700:
URL: https://github.com/apache/superset/pull/42700#discussion_r3702522218
##########
superset-frontend/src/pages/ThemeList/index.tsx:
##########
@@ -273,9 +274,22 @@ function ThemesList({
(theme: ThemeObject) => {
showConfirm({
title: t('Set System Default Theme'),
- body: t(
- 'Are you sure you want to set "%s" as the system default theme? This
will apply to all users who haven\'t set a personal preference.',
- theme.theme_name,
+ body: (
+ <Space direction="vertical">
+ {t(
+ 'Are you sure you want to set "%s" as the system default theme?
This will apply to all users who haven\'t set a personal preference.',
+ theme.theme_name,
+ )}
+ {hasConflictingAlgorithm(theme.json_data, false) && (
Review Comment:
**Suggestion:** The warning is calculated from the raw `theme.json_data`,
but the backend applies the configured base theme before enforcing the slot
algorithm. Consequently, a partial theme with no `algorithm` field can inherit
an explicit opposing algorithm from the configured theme and still be assigned
without any warning. Resolve the effective merged algorithm, or use the same
fallback configuration as the backend, before calling
`hasConflictingAlgorithm`. [api mismatch]
<details>
<summary><b>Severity Level:</b> Minor ๐งน</summary>
```mdx
- โ ๏ธ Theme assignment warning omits inherited algorithm conflicts.
- โ ๏ธ Admins may miss that configured colors are remapped.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1558fa45eef149e2aa061f5c54dc65a4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1558fa45eef149e2aa061f5c54dc65a4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/pages/ThemeList/index.tsx
**Line:** 283:283
**Comment:**
*Api Mismatch: The warning is calculated from the raw
`theme.json_data`, but the backend applies the configured base theme before
enforcing the slot algorithm. Consequently, a partial theme with no `algorithm`
field can inherit an explicit opposing algorithm from the configured theme and
still be assigned without any warning. Resolve the effective merged algorithm,
or use the same fallback configuration as the backend, before calling
`hasConflictingAlgorithm`.
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.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42700&comment_hash=67427f0e99854a10042d759b3315bc07dc8108f068fe6743c773c00429a91006&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42700&comment_hash=67427f0e99854a10042d759b3315bc07dc8108f068fe6743c773c00429a91006&reaction=dislike'>๐</a>
##########
superset-frontend/src/features/themes/utils.ts:
##########
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { ThemeAlgorithm } from '@apache-superset/core/theme';
+
+const getThemeAlgorithms = (jsonData?: string): string[] => {
+ if (!jsonData) return [];
+
+ try {
+ const { algorithm } = JSON.parse(jsonData) ?? {};
+ if (typeof algorithm === 'string') return [algorithm];
+ if (Array.isArray(algorithm))
+ return algorithm.filter(alg => typeof alg === 'string');
+ return [];
+ } catch {
+ return [];
+ }
+};
+
+/**
+ * Whether a theme declares an algorithm that contradicts the system slot it is
+ * about to fill. Such a theme is still served with the slot's algorithm, so
the
+ * colors it was authored with will not be the ones users see.
+ */
+export const hasConflictingAlgorithm = (
+ jsonData: string | undefined,
+ isDarkSlot: boolean,
+): boolean => {
+ const algorithms = getThemeAlgorithms(jsonData);
+ if (!algorithms.length) return false;
+
+ return algorithms.includes(ThemeAlgorithm.DARK) !== isDarkSlot;
Review Comment:
**Suggestion:** The conflict check treats every algorithm list that does not
contain `ThemeAlgorithm.DARK` as a light algorithm. A theme declaring only a
modifier such as `compact` is compatible with either slot, and the backend
preserves that modifier while adding the slot algorithm. This condition
therefore displays a misleading warning for valid modifier-only themes; check
for an explicit opposing algorithm instead of using absence of `dark` as
evidence of `default`. [incorrect condition logic]
<details>
<summary><b>Severity Level:</b> Minor ๐งน</summary>
```mdx
- โ ๏ธ System-dark confirmation warns for compact-only themes.
- โ ๏ธ Admins may incorrectly believe compact themes are incompatible.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=bd6a0d87e67a4f8f9e971f98dc5764a0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=bd6a0d87e67a4f8f9e971f98dc5764a0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/features/themes/utils.ts
**Line:** 47:47
**Comment:**
*Incorrect Condition Logic: The conflict check treats every algorithm
list that does not contain `ThemeAlgorithm.DARK` as a light algorithm. A theme
declaring only a modifier such as `compact` is compatible with either slot, and
the backend preserves that modifier while adding the slot algorithm. This
condition therefore displays a misleading warning for valid modifier-only
themes; check for an explicit opposing algorithm instead of using absence of
`dark` as evidence of `default`.
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.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42700&comment_hash=9963723c8db4f4dc38e9fbe65c5ea56292950042813714615e564c36aa74eb30&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42700&comment_hash=9963723c8db4f4dc38e9fbe65c5ea56292950042813714615e564c36aa74eb30&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: [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]