codeant-ai-for-open-source[bot] commented on code in PR #43180:
URL: https://github.com/apache/superset/pull/43180#discussion_r3786643824
##########
superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts:
##########
@@ -154,9 +154,15 @@ class CategoricalColorScale extends ExtensibleFunction {
this.incrementColorRange();
}
- if (this.isColorUsed(color)) {
+ // colors owned by other labels are reserved: handing one of them to a
+ // brand new label would render two identical colors in this chart as
+ // soon as the owner label is resolved from the shared map or from a
+ // forced color, which happens after this call
+ const reservedColors = this.getReservedColors(cleanedValue);
+
+ if (this.isColorUsed(color) || reservedColors.has(color)) {
// fallback to least used color
- color = this.getNextAvailableColor(cleanedValue, color);
+ color = this.getNextAvailableColor(cleanedValue, color,
reservedColors);
Review Comment:
**Suggestion:** When `sliceId` is absent in dashboard mode, the fallback
color is stored only in `chartLabelsColorMap`, not in the shared map. A
subsequent lookup of the same label treats it as new because `currentColorMap`
is the shared map, calls the ordinal scale again, and can replace the
previously returned fallback with a different color. For example, with a shared
owner using the first palette color, the first call selects the second color,
while the second call can fall through to the score fallback and select the
reserved first color. Preserve the assigned color for repeated calls even when
no slice ID is available. [stale reference]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Graph category colors can vary across repeated lookups.
- ⚠️ Dashboard shared maps remain incomplete without `sliceId`.
- ⚠️ Direct categorical-scale consumers can observe inconsistent label
colors.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=5e00187cacb544a38dd03fb3a0a8635a&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=5e00187cacb544a38dd03fb3a0a8635a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts
**Line:** 157:165
**Comment:**
*Stale Reference: When `sliceId` is absent in dashboard mode, the
fallback color is stored only in `chartLabelsColorMap`, not in the shared map.
A subsequent lookup of the same label treats it as new because
`currentColorMap` is the shared map, calls the ordinal scale again, and can
replace the previously returned fallback with a different color. For example,
with a shared owner using the first palette color, the first call selects the
second color, while the second call can fall through to the score fallback and
select the reserved first color. Preserve the assigned color for repeated calls
even when no slice ID is available.
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%2F43180&comment_hash=8de9f6a74a5229c9f11ce69cc4ca9feaf1fa84a489681fcc36203495bf12110e&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43180&comment_hash=8de9f6a74a5229c9f11ce69cc4ca9feaf1fa84a489681fcc36203495bf12110e&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]