Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(insights): spread the heat map's tones over the scores shown

Cihanec72a1de756d
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/insights/_topic-heatmap.tsx b/web/src/app/[locale]/(dashboard)/dashboard/insights/_topic-heatmap.tsx
index 33ce40dcb..76c3cfc09 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/insights/_topic-heatmap.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/insights/_topic-heatmap.tsx
@@ -15,15 +15,16 @@ const VISIBLE_ROWS = 6;
const gapText = (gap: number) => `−${Math.abs(gap).toFixed(1)}`;
/**
- * Cell shades, light to dark, as theme-relative tints so they read in both
- * themes; the darkest two flip the text color.
+ * Cell shades, light to dark: soft theme-relative tints, so they read in
+ * both themes and a full table doesn't turn into dark blocks. The text keeps
+ * its color on every shade.
*/
const SHADES = [
- 'bg-muted/60 text-muted-foreground',
- 'bg-foreground/10 text-foreground',
- 'bg-foreground/20 text-foreground',
- 'bg-foreground/40 text-foreground',
- 'bg-foreground/75 text-background',
+ 'bg-muted/40 text-muted-foreground',
+ 'bg-foreground/[0.06] text-foreground',
+ 'bg-foreground/[0.12] text-foreground',
+ 'bg-foreground/[0.2] text-foreground',
+ 'bg-foreground/[0.32] text-foreground',
] as const;
/**
@@ -52,6 +53,9 @@ export function TopicHeatmap({
columns.map((c) => c.key),
);
const shown = expanded ? rows : rows.slice(0, VISIBLE_ROWS);
+ // The tones spread over the scores of every row, so folding doesn't shift them.
+ const named = rows.flatMap((r) => r.scores).filter((v) => v > 0);
+ const [low, high] = [Math.min(...named), Math.max(...named)];
return (
<Card className={className}>
@@ -91,7 +95,7 @@ export function TopicHeatmap({
title={t('openTopic', { topic: row.name })}
className={cn(
'block rounded-md px-1 py-1.5 text-center font-semibold tabular-nums transition-opacity hover:opacity-80',
- SHADES[heatShade(value)],
+ SHADES[heatShade(value, low, high)],
// Too few answers to read much into: shown, but faded.
row.status === 'lowSample' && 'opacity-50',
)}
diff --git a/web/src/lib/insights-topics.test.ts b/web/src/lib/insights-topics.test.ts
index 101a8466e..f6251e287 100644
--- a/web/src/lib/insights-topics.test.ts
+++ b/web/src/lib/insights-topics.test.ts
@@ -78,8 +78,15 @@ describe('topicHeatmap', () => {
});
describe('heatShade', () => {
- it('darkens at the mockup’s steps', () => {
- expect([0, 14.9, 15, 25, 35, 45, 90].map(heatShade)).toEqual([0, 0, 1, 2, 3, 4, 4]);
+ it('spreads the tones over the scores in view', () => {
+ // Quarters of the range: 50–57.5, 57.5–65, 65–72.5, 72.5–80.
+ expect([50, 56, 62, 70, 80].map((v) => heatShade(v, 50, 80))).toEqual([1, 1, 2, 3, 4]);
+ expect([12, 48.6].map((v) => heatShade(v, 12, 48.6))).toEqual([1, 4]);
+ });
+
+ it('keeps a score of 0 the lightest, and one score the middle', () => {
+ expect(heatShade(0, 50, 80)).toBe(0);
+ expect(heatShade(60, 60, 60)).toBe(2);
});
});
diff --git a/web/src/lib/insights-topics.ts b/web/src/lib/insights-topics.ts
index 2a4ce6554..4449ccf23 100644
--- a/web/src/lib/insights-topics.ts
+++ b/web/src/lib/insights-topics.ts
@@ -119,11 +119,15 @@ export function topicHeatmap(topics: TopicCompetitors[], columns: string[]): Hea
);
}
-/** A cell's shade, light to dark, by score (the mockup's 15/25/35/45 steps). */
-export function heatShade(score: number): 0 | 1 | 2 | 3 | 4 {
- if (score >= 45) return 4;
- if (score >= 35) return 3;
- if (score >= 25) return 2;
- if (score >= 15) return 1;
- return 0;
+/**
+ * A cell's shade, light to dark, by where its score sits between the lowest
+ * and highest non-zero score in view. The map compares, so its tones spread
+ * over the scores shown whatever their level (a table of 50s and 70s still
+ * reads in steps); a score of 0, never named, stays the lightest.
+ */
+export function heatShade(score: number, min: number, max: number): 0 | 1 | 2 | 3 | 4 {
+ if (score <= 0) return 0;
+ if (max <= min) return 2;
+ const position = (score - min) / (max - min);
+ return (1 + Math.min(3, Math.floor(position * 4))) as 1 | 2 | 3 | 4;
}