Skip to content

Commit 39f7403

Browse files
committed
replace auto-populated changelog dates with opt-in intermediate date picker
1 parent 3fa557b commit 39f7403

4 files changed

Lines changed: 82 additions & 63 deletions

File tree

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '@/components/ui/chart-selectors';
1212
import { DateRangePicker } from '@/components/ui/date-range-picker';
1313
import { LabelWithTooltip } from '@/components/ui/label-with-tooltip';
14+
import { MultiDatePicker } from '@/components/ui/multi-date-picker';
1415
import { MultiSelect } from '@/components/ui/multi-select';
1516
import {
1617
Select,
@@ -68,9 +69,14 @@ const GROUPED_Y_AXIS_OPTIONS = (() => {
6869
interface ChartControlsProps {
6970
/** Hide GPU Config selector and related date pickers (used by Historical Trends tab) */
7071
hideGpuComparison?: boolean;
72+
/** Intermediate dates within the comparison range that have changelog entries */
73+
intermediateDates?: string[];
7174
}
7275

73-
export default function ChartControls({ hideGpuComparison = false }: ChartControlsProps) {
76+
export default function ChartControls({
77+
hideGpuComparison = false,
78+
intermediateDates = [],
79+
}: ChartControlsProps) {
7480
const {
7581
selectedModel,
7682
setSelectedModel,
@@ -86,6 +92,8 @@ export default function ChartControls({ hideGpuComparison = false }: ChartContro
8692
availableGPUs,
8793
selectedDateRange,
8894
setSelectedDateRange,
95+
selectedDates,
96+
setSelectedDates,
8997
dateRangeAvailableDates,
9098
isCheckingAvailableDates,
9199
availablePrecisions,
@@ -327,6 +335,32 @@ export default function ChartControls({ hideGpuComparison = false }: ChartContro
327335
/>
328336
</div>
329337
)}
338+
339+
{!hideGpuComparison &&
340+
selectedGPUs.length > 0 &&
341+
selectedDateRange.startDate &&
342+
selectedDateRange.endDate &&
343+
intermediateDates.length > 0 && (
344+
<div className="flex flex-col space-y-1.5 lg:col-span-2">
345+
<LabelWithTooltip
346+
htmlFor="intermediate-dates-select"
347+
label="Intermediate Dates"
348+
tooltip="Select up to 2 additional intermediate dates with config changelog entries. These dates will be added to the chart for comparison alongside the start and end dates."
349+
/>
350+
<MultiDatePicker
351+
dates={selectedDates}
352+
onChange={(value) => {
353+
setSelectedDates(value);
354+
track('inference_intermediate_dates_selected', {
355+
dates: value.join(','),
356+
});
357+
}}
358+
availableDates={intermediateDates}
359+
maxDates={2}
360+
placeholder="Select intermediate dates"
361+
/>
362+
</div>
363+
)}
330364
</div>
331365
</div>
332366
</TooltipProvider>

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

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22
import { track } from '@/lib/analytics';
33
import Link from 'next/link';
4-
import { useEffect, useMemo, useRef, useState } from 'react';
4+
import { useMemo, useState } from 'react';
55
import { ChevronDown, X } from 'lucide-react';
66

77
import { useInference } from '@/components/inference/InferenceContext';
@@ -37,7 +37,6 @@ import {
3737
Sequence,
3838
} from '@/lib/data-mappings';
3939
import { useComparisonChangelogs } from '@/hooks/api/use-comparison-changelogs';
40-
import { configKeyMatchesHwKey } from '@/components/inference/utils/changelogFormatters';
4140
import { useTrendData } from '@/components/inference/hooks/useTrendData';
4241

4342
import ChartControls from './ChartControls';
@@ -113,8 +112,6 @@ export default function ChartDisplay() {
113112
selectedGPUs,
114113
selectedPrecisions,
115114
selectedDateRange,
116-
setSelectedDates,
117-
availableDates,
118115
dateRangeAvailableDates,
119116
selectedModel,
120117
selectedSequence,
@@ -130,49 +127,15 @@ export default function ChartDisplay() {
130127

131128
const {
132129
changelogs,
130+
intermediateDates,
133131
loading: changelogsLoading,
134132
totalDatesQueried,
135-
} = useComparisonChangelogs(selectedGPUs, selectedDateRange, availableDates);
136-
137-
// Auto-populate intermediate dates from changelog dates so they appear on the GPU graph
138-
const prevChangelogDatesRef = useRef('');
139-
useEffect(() => {
140-
if (!selectedDateRange.startDate || !selectedDateRange.endDate || selectedGPUs.length === 0)
141-
return;
142-
const gpuDatesSet = new Set(dateRangeAvailableDates);
143-
const precSet = new Set(selectedPrecisions);
144-
const changelogDates = changelogs
145-
.filter((c) =>
146-
c.entries.some((entry) =>
147-
entry.config_keys.some((key) => {
148-
const precision = key.split('-')[1];
149-
return (
150-
precSet.has(precision) && selectedGPUs.some((gpu) => configKeyMatchesHwKey(key, gpu))
151-
);
152-
}),
153-
),
154-
)
155-
.map((c) => c.date)
156-
.filter(
157-
(d) =>
158-
d !== selectedDateRange.startDate &&
159-
d !== selectedDateRange.endDate &&
160-
gpuDatesSet.has(d),
161-
)
162-
.sort();
163-
const key = changelogDates.join(',');
164-
if (key !== prevChangelogDatesRef.current) {
165-
prevChangelogDatesRef.current = key;
166-
setSelectedDates(changelogDates);
167-
}
168-
}, [
169-
changelogs,
170-
selectedDateRange,
133+
} = useComparisonChangelogs(
171134
selectedGPUs,
172135
selectedPrecisions,
173-
setSelectedDates,
136+
selectedDateRange,
174137
dateRangeAvailableDates,
175-
]);
138+
);
176139

177140
const { unofficialRunInfo, getOverlayData, isUnofficialRun } = useUnofficialRun();
178141

@@ -705,7 +668,7 @@ export default function ChartDisplay() {
705668
<SocialShareButtons compact className="hidden sm:flex" />
706669
</div>
707670
</div>
708-
<ChartControls />
671+
<ChartControls intermediateDates={intermediateDates} />
709672
<ModelArchitectureDiagram model={selectedModel} />
710673
{selectedGPUs.length === 0 && <WorkflowInfoDisplay workflowInfo={workflowInfo} />}
711674
{selectedGPUs.length > 0 &&
@@ -715,7 +678,6 @@ export default function ChartDisplay() {
715678
changelogs={changelogs}
716679
selectedGPUs={selectedGPUs}
717680
selectedPrecisions={selectedPrecisions}
718-
selectedDateRange={selectedDateRange}
719681
loading={changelogsLoading}
720682
totalDatesQueried={totalDatesQueried}
721683
/>

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

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ interface ComparisonChangelogProps {
1717
changelogs: ComparisonChangelogType[];
1818
selectedGPUs: string[];
1919
selectedPrecisions: string[];
20-
selectedDateRange: { startDate: string; endDate: string };
2120
loading?: boolean;
2221
totalDatesQueried: number;
2322
}
@@ -26,7 +25,6 @@ export default function ComparisonChangelog({
2625
changelogs,
2726
selectedGPUs,
2827
selectedPrecisions,
29-
selectedDateRange,
3028
loading,
3129
totalDatesQueried,
3230
}: ComparisonChangelogProps) {
@@ -51,20 +49,13 @@ export default function ComparisonChangelog({
5149
.filter((item) => item.entries.length > 0);
5250
}, [changelogs, selectedGPUs, selectedPrecisions]);
5351

54-
// Always include start/end dates, even if they have no changelog entries
55-
const sortedChangelogs = useMemo(() => {
56-
const byDate = new Map(filteredChangelogs.map((c) => [c.date, c]));
57-
const { startDate, endDate } = selectedDateRange;
58-
if (startDate && !byDate.has(startDate)) {
59-
byDate.set(startDate, { date: startDate, entries: [] });
60-
}
61-
if (endDate && !byDate.has(endDate)) {
62-
byDate.set(endDate, { date: endDate, entries: [] });
63-
}
64-
return [...byDate.values()].sort(
65-
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime(),
66-
);
67-
}, [filteredChangelogs, selectedDateRange]);
52+
const sortedChangelogs = useMemo(
53+
() =>
54+
[...filteredChangelogs].sort(
55+
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime(),
56+
),
57+
[filteredChangelogs],
58+
);
6859

6960
const handleToggle = () => {
7061
const newState = !isExpanded;

packages/app/src/hooks/api/use-comparison-changelogs.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useQueries } from '@tanstack/react-query';
22
import { useMemo } from 'react';
33

44
import { fetchWorkflowInfo, type ChangelogRow, type WorkflowInfoResponse } from '@/lib/api';
5+
import { configKeyMatchesHwKey } from '@/components/inference/utils/changelogFormatters';
56

67
export interface ComparisonChangelog {
78
date: string;
@@ -16,13 +17,14 @@ export interface ComparisonChangelog {
1617

1718
export function useComparisonChangelogs(
1819
selectedGPUs: string[],
20+
selectedPrecisions: string[],
1921
selectedDateRange: { startDate: string; endDate: string },
2022
availableDates: string[],
2123
) {
2224
const isComparisonMode =
2325
selectedGPUs.length > 0 && !!selectedDateRange.startDate && !!selectedDateRange.endDate;
2426

25-
// Query all available dates within the selected range
27+
// Query all available dates within the selected range to discover which have changelog entries
2628
const datesInRange = useMemo(() => {
2729
if (!isComparisonMode) return [];
2830
return availableDates.filter(
@@ -66,7 +68,37 @@ export function useComparisonChangelogs(
6668
return results;
6769
}, [isComparisonMode, datesInRange, queries]);
6870

71+
// Intermediate dates with changelog entries matching selected GPUs/precisions (excluding start/end)
72+
const intermediateDates = useMemo(() => {
73+
if (!isComparisonMode) return [];
74+
const precSet = new Set(selectedPrecisions);
75+
return changelogs
76+
.filter(
77+
(c) =>
78+
c.date !== selectedDateRange.startDate &&
79+
c.date !== selectedDateRange.endDate &&
80+
c.entries.some((entry) =>
81+
entry.config_keys.some((key) => {
82+
const precision = key.split('-')[1];
83+
return (
84+
precSet.has(precision) &&
85+
selectedGPUs.some((gpu) => configKeyMatchesHwKey(key, gpu))
86+
);
87+
}),
88+
),
89+
)
90+
.map((c) => c.date)
91+
.sort();
92+
}, [
93+
isComparisonMode,
94+
changelogs,
95+
selectedGPUs,
96+
selectedPrecisions,
97+
selectedDateRange.startDate,
98+
selectedDateRange.endDate,
99+
]);
100+
69101
const loading = queries.some((q) => q.isLoading);
70102

71-
return { changelogs, loading, totalDatesQueried: datesInRange.length };
103+
return { changelogs, intermediateDates, loading, totalDatesQueried: datesInRange.length };
72104
}

0 commit comments

Comments
 (0)