11import { useMemo , useState } from "react" ;
2- import ChartSelector , { SelectedData } from "../components/ChartSelector" ;
2+ import ChartSelector , {
3+ DataSelection ,
4+ EmptyDataSelection ,
5+ } from "../components/ChartSelector" ;
36import ChartGrid from "../components/ChartGrid" ;
47import { useTestMetadata , useMultipleDataSeries } from "../utils/useDataSeries" ;
58import { DataSeries } from "../types" ;
@@ -13,7 +16,7 @@ function RunComparison() {
1316 throw new Error ( "Benchmark run ID is required" ) ;
1417 }
1518
16- const [ selection , setSelection ] = useState < SelectedData [ ] > ( [ ] ) ;
19+ const [ selection , setSelection ] = useState < DataSelection > ( EmptyDataSelection ) ;
1720
1821 const { data : allBenchmarkRuns , isLoading : isLoadingBenchmarkRuns } =
1922 useTestMetadata ( ) ;
@@ -42,15 +45,15 @@ function RunComparison() {
4245 } , [ allBenchmarkRuns , benchmarkRunId ] ) ;
4346
4447 const dataQueryKey = useMemo ( ( ) => {
45- return selection . map ( ( query ) => {
48+ return selection . data . map ( ( query ) => {
4649 // Find the run that matches this outputDir to get the runId
4750 const run = benchmarkRuns . runs . find (
4851 ( r ) => r . outputDir === query . outputDir ,
4952 ) ;
5053 const runId = run ?. id || query . outputDir ; // Fallback to outputDir if no ID found
5154 return [ runId , query . outputDir , query . role ] as [ string , string , string ] ;
5255 } ) ;
53- } , [ selection , benchmarkRuns ] ) ;
56+ } , [ selection . data , benchmarkRuns ] ) ;
5457
5558 const { data : dataPerFile , isLoading } = useMultipleDataSeries ( dataQueryKey ) ;
5659 const data = useMemo ( ( ) => {
@@ -59,15 +62,15 @@ function RunComparison() {
5962 }
6063
6164 return dataPerFile . map ( ( data , index ) : DataSeries => {
62- const { name, color } = selection [ index ] ;
65+ const { name, color } = selection . data [ index ] ;
6366 return {
6467 name,
6568 data,
6669 color,
67- thresholds : selection [ index ] . thresholds ,
70+ thresholds : selection . data [ index ] . thresholds ,
6871 } ;
6972 } ) ;
70- } , [ dataPerFile , selection ] ) ;
73+ } , [ dataPerFile , selection . data ] ) ;
7174
7275 if ( ! benchmarkRuns || isLoadingBenchmarkRuns ) {
7376 return < div > Loading...</ div > ;
@@ -82,7 +85,11 @@ function RunComparison() {
8285 onChangeDataQuery = { setSelection }
8386 benchmarkRuns = { benchmarkRuns }
8487 />
85- { isLoading ? "Loading..." : < ChartGrid data = { data ?? [ ] } /> }
88+ { isLoading ? (
89+ "Loading..."
90+ ) : (
91+ < ChartGrid role = { selection . role } data = { data ?? [ ] } />
92+ ) }
8693 </ div >
8794 </ div >
8895 </ div >
0 commit comments