CrispStrobe commited on
Commit
644a44f
·
1 Parent(s): aea9373

fix: unify grouping logic using canonical IDs and getGroupKey helper

Browse files
Files changed (1) hide show
  1. src/App.tsx +15 -9
src/App.tsx CHANGED
@@ -142,6 +142,10 @@ function App() {
142
  const [liveProviders, setLiveProviders] = useState<Provider[]>((providersData as any).providers);
143
  const [liveBenchmarks, setLiveBenchmarks] = useState<BenchmarkEntry[]>(benchmarksData as BenchmarkEntry[]);
144
 
 
 
 
 
145
  useEffect(() => {
146
  fetch('/api/data')
147
  .then(r => r.ok ? r.json() : null)
@@ -399,19 +403,23 @@ function App() {
399
  if (!groupByModel) return sortedModels;
400
 
401
  const groups: Record<string, typeof sortedModels> = {};
 
 
402
  sortedModels.forEach(m => {
403
- // Grouping priority: HF ID > Canonical ID > Name
404
- const key = (m.hf_id || m.canonical_id || m.name || '').toLowerCase();
405
- if (!groups[key]) groups[key] = [];
 
 
406
  groups[key].push(m);
407
  });
408
 
409
  const result: typeof sortedModels = [];
410
- Object.values(groups).forEach(group => {
411
- result.push(...group);
412
  });
413
  return result;
414
- }, [sortedModels, groupByModel]);
415
 
416
  const requestSort = (key: string) => {
417
  let direction: 'asc' | 'desc' = 'asc';
@@ -549,9 +557,7 @@ function App() {
549
  {displayModels.map((model, idx) => {
550
  const prev = displayModels[idx - 1];
551
  const isGroupStart = groupByModel && (
552
- idx === 0 ||
553
- (prev.hf_id?.toLowerCase() !== model.hf_id?.toLowerCase()) ||
554
- (!model.hf_id && prev.name.toLowerCase() !== model.name.toLowerCase())
555
  );
556
  const bm = findBenchmark(model.name);
557
  return (
 
142
  const [liveProviders, setLiveProviders] = useState<Provider[]>((providersData as any).providers);
143
  const [liveBenchmarks, setLiveBenchmarks] = useState<BenchmarkEntry[]>(benchmarksData as BenchmarkEntry[]);
144
 
145
+ const getGroupKey = useCallback((m: Model) => {
146
+ return (m.hf_id || m.canonical_id || m.name || '').toLowerCase();
147
+ }, []);
148
+
149
  useEffect(() => {
150
  fetch('/api/data')
151
  .then(r => r.ok ? r.json() : null)
 
403
  if (!groupByModel) return sortedModels;
404
 
405
  const groups: Record<string, typeof sortedModels> = {};
406
+ const groupOrder: string[] = [];
407
+
408
  sortedModels.forEach(m => {
409
+ const key = getGroupKey(m);
410
+ if (!groups[key]) {
411
+ groups[key] = [];
412
+ groupOrder.push(key);
413
+ }
414
  groups[key].push(m);
415
  });
416
 
417
  const result: typeof sortedModels = [];
418
+ groupOrder.forEach(key => {
419
+ result.push(...groups[key]);
420
  });
421
  return result;
422
+ }, [sortedModels, groupByModel, getGroupKey]);
423
 
424
  const requestSort = (key: string) => {
425
  let direction: 'asc' | 'desc' = 'asc';
 
557
  {displayModels.map((model, idx) => {
558
  const prev = displayModels[idx - 1];
559
  const isGroupStart = groupByModel && (
560
+ idx === 0 || getGroupKey(prev) !== getGroupKey(model)
 
 
561
  );
562
  const bm = findBenchmark(model.name);
563
  return (