codeant-ai-for-open-source[bot] commented on code in PR #37482:
URL: https://github.com/apache/superset/pull/37482#discussion_r3190854023


##########
superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx:
##########
@@ -325,16 +325,18 @@ const SliceHeaderControls = (
   const updatedWhen = updatedDttm
     ? (extendedDayjs.utc(updatedDttm) as any).fromNow()
     : '';
-  const getCachedTitle = (itemCached: boolean) => {
+  const getCachedTitle = (itemCached: boolean, index: number) => {
     if (itemCached) {
-      return t('Cached %s', cachedWhen);
+      return t('Cached %s', cachedWhen[index]);
     }
     if (updatedWhen) {
       return t('Fetched %s', updatedWhen);
     }
     return '';
   };
-  const refreshTooltipData = [...new Set(isCached.map(getCachedTitle) || '')];
+  const refreshTooltipData = [
+    ...new Set(isCached.map((itemCached, index) => getCachedTitle(itemCached, 
index))),
+  ];

Review Comment:
   Yes — the comment is correct.
   
   Using `new Set(...)` here dedupes **all** repeated titles, which can shrink 
the array and make the later `Query %s` numbering no longer match the original 
query positions. That’s especially visible when there are mixed cache states or 
repeated titles across different queries.
   
   ### Safe fix
   Only collapse to one line when **all** tooltip titles are identical; 
otherwise keep the per-query list intact.
   
   ```typescript
   const refreshTooltipData = (() => {
     const titles = isCached.map((itemCached, index) =>
       getCachedTitle(itemCached, index),
     );
     return new Set(titles).size === 1 ? [titles[0]] : titles;
   })();
   ```
   
   ### Why this is better
   - Preserves correct `Query 1`, `Query 2`, etc. labels
   - Still deduplicates the common case where every query shares the same 
timestamp
   - Avoids misleading cache info in the Force refresh tooltip
   
   So yes, I’d recommend applying the fix above rather than unconditionally 
using `Set` 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: [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