Skip to content

Commit 137fd77

Browse files
authored
remove leftover shuffle colors action (#122)
* feat: remove shuffle colors button and all related plumbing * feat: add high contrast toggle to TCO calculator legend * remove shuffle tests
1 parent 02ec963 commit 137fd77

12 files changed

Lines changed: 27 additions & 249 deletions

File tree

packages/app/cypress/e2e/high-contrast.cy.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,12 @@ describe('High Contrast Mode', () => {
1111
cy.get('#scatter-high-contrast').first().should('have.attr', 'data-state', 'unchecked');
1212
});
1313

14-
it('shuffle colors button is hidden when high contrast is off', () => {
15-
cy.get('[data-testid="scatter-shuffle-colors"]').should('not.exist');
16-
});
17-
1814
it('visiting with i_hc=1 applies high contrast on load', () => {
1915
cy.visit('/inference?i_hc=1');
2016
cy.get('[data-testid="scatter-graph"]').should('exist');
2117
cy.get('#scatter-high-contrast').first().should('have.attr', 'data-state', 'checked');
2218
});
2319

24-
it('shuffle colors button appears when high contrast is enabled', () => {
25-
// Still on /?i_hc=1 from previous test
26-
cy.get('[data-testid="scatter-shuffle-colors"]').should('exist');
27-
cy.get('[data-testid="scatter-shuffle-colors"]').should('contain.text', 'Shuffle Colors');
28-
});
29-
30-
it('clicking shuffle colors changes the point colors', () => {
31-
// Still on /?i_hc=1 from previous test
32-
cy.get('[data-testid="scatter-graph"] .visible-shape')
33-
.first()
34-
.invoke('attr', 'fill')
35-
.then((colorBefore) => {
36-
cy.get('[data-testid="scatter-shuffle-colors"]').first().click();
37-
cy.get('[data-testid="scatter-graph"] .visible-shape')
38-
.first()
39-
.invoke('attr', 'fill')
40-
.should('not.equal', colorBefore);
41-
});
42-
});
43-
4420
it('multiple high contrast params can coexist in URL', () => {
4521
cy.visit('/inference?i_hc=1&r_hc=1&e_hc=1');
4622
cy.get('[data-testid="scatter-graph"]').should('exist');
@@ -65,17 +41,9 @@ describe('High Contrast Mode', () => {
6541
cy.get('#historical-high-contrast').first().should('have.attr', 'data-state', 'unchecked');
6642
});
6743

68-
it('historical trends high contrast toggle enables HC and shows shuffle button', () => {
44+
it('historical trends high contrast toggle enables HC via URL', () => {
6945
cy.visit('/historical?i_hc=1');
7046
cy.get('[data-testid="historical-trends-display"]').should('exist');
7147
cy.get('#historical-high-contrast').first().should('have.attr', 'data-state', 'checked');
72-
cy.get('[data-testid="historical-shuffle-colors"]').should('exist');
73-
cy.get('[data-testid="historical-shuffle-colors"]').should('contain.text', 'Shuffle Colors');
74-
});
75-
76-
it('historical trends shuffle button is hidden when high contrast is off', () => {
77-
cy.visit('/historical');
78-
cy.get('[data-testid="historical-trends-display"]').should('exist');
79-
cy.get('[data-testid="historical-shuffle-colors"]').should('not.exist');
8048
});
8149
});

packages/app/cypress/support/mock-data.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ export function createMockInferenceContext(
203203
setHidePointLabels: namedStub('setHidePointLabels'),
204204
highContrast: false,
205205
setHighContrast: namedStub('setHighContrast'),
206-
colorShuffleSeed: 0,
207-
shuffleColors: namedStub('shuffleColors'),
208206
logScale: false,
209207
setLogScale: namedStub('setLogScale'),
210208
useAdvancedLabels: false,

packages/app/src/components/calculator/ThroughputBarChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export default function ThroughputBarChart({
451451
};
452452

453453
return [barLayer, labelLayer];
454-
}, [sortedResults, barMetric, costType, hardwareConfig, mode]);
454+
}, [sortedResults, barMetric, costType, hardwareConfig, mode, colorResolver]);
455455

456456
// ── Tooltip ──
457457

packages/app/src/components/calculator/ThroughputCalculatorDisplay.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export default function ThroughputCalculatorDisplay() {
224224
const [visibleHwKeys, setVisibleHwKeys] = useState<Set<string>>(new Set());
225225
const [selectedBars, setSelectedBars] = useState<Set<string>>(new Set());
226226
const [isLegendExpanded, setIsLegendExpanded] = useState(true);
227+
const [highContrast, setHighContrast] = useState(false);
227228
const [viewMode, setViewMode] = useState<'chart' | 'table'>('chart');
228229

229230
const { hardwareConfig, ranges, getResults, loading, error, hasData, availableHwKeys } =
@@ -232,7 +233,7 @@ export default function ThroughputCalculatorDisplay() {
232233
// Dynamic vendor-aware colors for visible GPUs
233234
const visibleKeysArray = useMemo(() => [...visibleHwKeys], [visibleHwKeys]);
234235
const { resolveColor } = useThemeColors({
235-
highContrast: false,
236+
highContrast,
236237
activeKeys: visibleKeysArray,
237238
});
238239

@@ -884,6 +885,17 @@ export default function ThroughputCalculatorDisplay() {
884885
setIsLegendExpanded(expanded);
885886
track('calculator_legend_expanded', { expanded });
886887
}}
888+
switches={[
889+
{
890+
id: 'calc-high-contrast',
891+
label: 'High Contrast',
892+
checked: highContrast,
893+
onCheckedChange: (checked: boolean) => {
894+
setHighContrast(checked);
895+
track('calculator_high_contrast_toggled', { enabled: checked });
896+
},
897+
},
898+
]}
887899
actions={
888900
visibleHwKeys.size < availableHwKeys.length
889901
? [

packages/app/src/components/inference/InferenceContext.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ export function InferenceProvider({
117117
const { highContrast, setHighContrast, isLegendExpanded, setIsLegendExpanded } = useChartUIState({
118118
urlPrefix: 'i_',
119119
});
120-
const [colorShuffleSeed, setColorShuffleSeed] = useState(0);
121-
const shuffleColors = useCallback(() => {
122-
setColorShuffleSeed((prev) => prev + 1);
123-
}, []);
124120

125121
const [hideNonOptimal, setHideNonOptimal] = useState(() => getUrlParam('i_optimal') !== '0');
126122
const [hidePointLabels, setHidePointLabels] = useState(() => getUrlParam('i_nolabel') === '1');
@@ -772,8 +768,6 @@ export function InferenceProvider({
772768
setHidePointLabels,
773769
highContrast,
774770
setHighContrast,
775-
colorShuffleSeed,
776-
shuffleColors,
777771
logScale,
778772
setLogScale,
779773
selectedXAxisMetric,
@@ -865,7 +859,6 @@ export function InferenceProvider({
865859
hideNonOptimal,
866860
hidePointLabels,
867861
highContrast,
868-
colorShuffleSeed,
869862
logScale,
870863
isLegendExpanded,
871864
useAdvancedLabels,

packages/app/src/components/inference/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,6 @@ export interface InferenceChartContextType {
485485
setHidePointLabels: (hide: boolean) => void;
486486
highContrast: boolean;
487487
setHighContrast: (highContrast: boolean) => void;
488-
colorShuffleSeed: number;
489-
shuffleColors: () => void;
490488
logScale: boolean;
491489
setLogScale: (logScale: boolean) => void;
492490
useAdvancedLabels: boolean;

packages/app/src/components/inference/ui/GPUGraph.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ const GPUGraph = React.memo(
5757
setUseAdvancedLabels,
5858
highContrast,
5959
setHighContrast,
60-
colorShuffleSeed,
61-
shuffleColors,
6260
selectAllActiveDates,
6361
} = useInference();
6462
const { resolvedTheme } = useTheme();
@@ -89,7 +87,6 @@ const GPUGraph = React.memo(
8987
const { resolveColor, getCssColor } = useThemeColors({
9088
highContrast,
9189
identifiers: graphIdentifiers,
92-
colorShuffleSeed,
9390
});
9491

9592
// Dynamic GPU×date color map
@@ -480,18 +477,6 @@ const GPUGraph = React.memo(
480477
},
481478
]}
482479
actions={[
483-
...(highContrast
484-
? [
485-
{
486-
id: 'gpu-shuffle-colors',
487-
label: 'Shuffle Colors',
488-
onClick: () => {
489-
shuffleColors();
490-
track('interactivity_shuffle_colors');
491-
},
492-
},
493-
]
494-
: []),
495480
{
496481
id: 'gpu-reset-filter',
497482
label: 'Reset filter',

packages/app/src/components/inference/ui/ScatterGraph.tsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ const ScatterGraph = React.memo(
100100
selectAllHwTypes,
101101
highContrast,
102102
setHighContrast,
103-
colorShuffleSeed,
104-
shuffleColors,
105103
logScale,
106104
setLogScale,
107105
scaleType,
@@ -184,7 +182,6 @@ const ScatterGraph = React.memo(
184182
const { resolveColor, getCssColor } = useThemeColors({
185183
highContrast,
186184
identifiers: activeHwKeys,
187-
colorShuffleSeed,
188185
activeKeys: activeOfficialKeys,
189186
});
190187

@@ -1493,20 +1490,8 @@ const ScatterGraph = React.memo(
14931490
},
14941491
},
14951492
]}
1496-
actions={[
1497-
...(highContrast
1498-
? [
1499-
{
1500-
id: 'scatter-shuffle-colors',
1501-
label: 'Shuffle Colors',
1502-
onClick: () => {
1503-
shuffleColors();
1504-
track(`${eventPrefix}_shuffle_colors`);
1505-
},
1506-
},
1507-
]
1508-
: []),
1509-
...(effectiveOfficialHwTypes.size < hwTypesWithData.size ||
1493+
actions={
1494+
effectiveOfficialHwTypes.size < hwTypesWithData.size ||
15101495
activeOverlayHwTypes.size < allOverlayHwTypes.size
15111496
? [
15121497
{
@@ -1520,8 +1505,8 @@ const ScatterGraph = React.memo(
15201505
},
15211506
},
15221507
]
1523-
: []),
1524-
]}
1508+
: []
1509+
}
15251510
showFpShapeIndicators={selectedPrecisions.length > 1}
15261511
enableTooltips={true}
15271512
/>

packages/app/src/components/trends/HistoricalTrendsDisplay.tsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ export default function HistoricalTrendsDisplay() {
5757
workflowInfo,
5858
highContrast,
5959
setHighContrast,
60-
colorShuffleSeed,
61-
shuffleColors,
6260
} = useInference();
6361

6462
// Check if interactivity chart data exists
@@ -132,7 +130,6 @@ export default function HistoricalTrendsDisplay() {
132130
const { resolveColor } = useThemeColors({
133131
highContrast,
134132
identifiers: activeHwKeys,
135-
colorShuffleSeed,
136133
activeKeys: activeHwKeys,
137134
});
138135

@@ -576,20 +573,8 @@ export default function HistoricalTrendsDisplay() {
576573
},
577574
},
578575
]}
579-
actions={[
580-
...(highContrast
581-
? [
582-
{
583-
id: 'historical-shuffle-colors',
584-
label: 'Shuffle Colors',
585-
onClick: () => {
586-
shuffleColors();
587-
track('historical_shuffle_colors');
588-
},
589-
},
590-
]
591-
: []),
592-
...(activeHwTypes.size < hwTypesWithData.size
576+
actions={
577+
activeHwTypes.size < hwTypesWithData.size
593578
? [
594579
{
595580
id: 'historical-reset-filter',
@@ -600,8 +585,8 @@ export default function HistoricalTrendsDisplay() {
600585
},
601586
},
602587
]
603-
: []),
604-
]}
588+
: []
589+
}
605590
enableTooltips={true}
606591
showFpShapeIndicators={true}
607592
/>

packages/app/src/hooks/useThemeColors.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ export interface UseThemeColorsOptions {
1616
*/
1717
identifiers?: string[];
1818

19-
/**
20-
* Seed for shuffling high contrast color assignments.
21-
* 0 (default) means no shuffle; any other value produces a deterministic shuffle.
22-
*/
23-
colorShuffleSeed?: number;
24-
2519
/**
2620
* Hardware keys that are currently checked / active in the legend.
2721
* When provided, dynamic vendor-aware colors are generated for these keys
@@ -71,7 +65,7 @@ export interface UseThemeColorsResult {
7165
* Consolidates common theme color patterns across all D3 charts
7266
*/
7367
export function useThemeColors(options: UseThemeColorsOptions): UseThemeColorsResult {
74-
const { highContrast, identifiers = [], colorShuffleSeed = 0, activeKeys } = options;
68+
const { highContrast, identifiers = [], activeKeys } = options;
7569
const { resolvedTheme } = useTheme();
7670

7771
// get base theme colors
@@ -91,8 +85,8 @@ export function useThemeColors(options: UseThemeColorsOptions): UseThemeColorsRe
9185
if (!highContrast) return null;
9286
const keysForHc = activeKeys && activeKeys.length > 0 ? activeKeys : identifiers;
9387
if (keysForHc.length === 0) return null;
94-
return generateHighContrastColors(keysForHc, resolvedTheme || 'light', colorShuffleSeed);
95-
}, [highContrast, activeKeys, identifiers, resolvedTheme, colorShuffleSeed]);
88+
return generateHighContrastColors(keysForHc, resolvedTheme || 'light');
89+
}, [highContrast, activeKeys, identifiers, resolvedTheme]);
9690

9791
// generate dynamic vendor-aware colors for active keys
9892
const vendorColorMap = useMemo(() => {

0 commit comments

Comments
 (0)