Spaces:
Running
Running
Commit
·
2f4e514
1
Parent(s):
fc5fea2
improvements
Browse files- src/components/runs-list.tsx +136 -48
- src/components/viewer-tab.tsx +1 -37
src/components/runs-list.tsx
CHANGED
@@ -2,6 +2,9 @@
|
|
2 |
|
3 |
import { Card } from "@/components/ui/card";
|
4 |
import { cn } from "@/lib/utils";
|
|
|
|
|
|
|
5 |
|
6 |
interface Run {
|
7 |
start_article: string;
|
@@ -20,57 +23,142 @@ export default function RunsList({
|
|
20 |
onSelectRun,
|
21 |
selectedRunId,
|
22 |
}: RunsListProps) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
return (
|
24 |
-
<div className="h-full w-full
|
25 |
-
|
26 |
-
<
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
</svg>
|
55 |
-
<span>{run.destination_article}</span>
|
56 |
-
</p>
|
57 |
-
<p className="text-sm text-muted-foreground">{run.steps.length} hops</p>
|
58 |
-
</div>
|
59 |
-
{selectedRunId === index && (
|
60 |
-
<div
|
61 |
-
className="h-2 w-2 rounded-full bg-primary"
|
62 |
-
aria-hidden="true"
|
63 |
-
/>
|
64 |
)}
|
65 |
-
</
|
66 |
-
</Card>
|
67 |
-
))}
|
68 |
-
|
69 |
-
{runs.length === 0 && (
|
70 |
-
<div className="flex items-center justify-center h-full text-muted-foreground">
|
71 |
-
No runs available
|
72 |
</div>
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
</div>
|
75 |
);
|
76 |
}
|
|
|
2 |
|
3 |
import { Card } from "@/components/ui/card";
|
4 |
import { cn } from "@/lib/utils";
|
5 |
+
import { useState, useEffect, useRef } from "react";
|
6 |
+
import { Input } from "@/components/ui/input";
|
7 |
+
import { Button } from "@/components/ui/button";
|
8 |
|
9 |
interface Run {
|
10 |
start_article: string;
|
|
|
23 |
onSelectRun,
|
24 |
selectedRunId,
|
25 |
}: RunsListProps) {
|
26 |
+
const [isPlaying, setIsPlaying] = useState(true);
|
27 |
+
const [startFilter, setStartFilter] = useState("");
|
28 |
+
const [endFilter, setEndFilter] = useState("");
|
29 |
+
const timerRef = useRef<NodeJS.Timeout | null>(null);
|
30 |
+
|
31 |
+
// Filter runs based on start and end filters
|
32 |
+
const filteredRuns = runs.filter((run) => {
|
33 |
+
const matchesStart = startFilter === "" ||
|
34 |
+
run.start_article.toLowerCase().includes(startFilter.toLowerCase());
|
35 |
+
const matchesEnd = endFilter === "" ||
|
36 |
+
run.destination_article.toLowerCase().includes(endFilter.toLowerCase());
|
37 |
+
return matchesStart && matchesEnd;
|
38 |
+
});
|
39 |
+
|
40 |
+
// Auto-play functionality
|
41 |
+
useEffect(() => {
|
42 |
+
if (isPlaying) {
|
43 |
+
timerRef.current = setInterval(() => {
|
44 |
+
if (filteredRuns.length === 0) return;
|
45 |
+
|
46 |
+
const nextIndex = selectedRunId === null
|
47 |
+
? 0
|
48 |
+
: (selectedRunId + 1) % filteredRuns.length;
|
49 |
+
|
50 |
+
const originalIndex = runs.findIndex(
|
51 |
+
run => run === filteredRuns[nextIndex]
|
52 |
+
);
|
53 |
+
|
54 |
+
onSelectRun(originalIndex);
|
55 |
+
}, 1000);
|
56 |
+
} else if (timerRef.current) {
|
57 |
+
clearInterval(timerRef.current);
|
58 |
+
timerRef.current = null;
|
59 |
+
}
|
60 |
+
|
61 |
+
return () => {
|
62 |
+
if (timerRef.current) {
|
63 |
+
clearInterval(timerRef.current);
|
64 |
+
}
|
65 |
+
};
|
66 |
+
}, [isPlaying, selectedRunId, filteredRuns, runs, onSelectRun]);
|
67 |
+
|
68 |
+
const togglePlayPause = () => {
|
69 |
+
setIsPlaying(prev => !prev);
|
70 |
+
};
|
71 |
+
|
72 |
return (
|
73 |
+
<div className="h-full w-full flex flex-col">
|
74 |
+
<div className="space-y-2 mb-3">
|
75 |
+
<div className="flex gap-2 items-center">
|
76 |
+
<Input
|
77 |
+
placeholder="Filter by start"
|
78 |
+
value={startFilter}
|
79 |
+
onChange={(e) => setStartFilter(e.target.value)}
|
80 |
+
className="h-8"
|
81 |
+
/>
|
82 |
+
<Input
|
83 |
+
placeholder="Filter by end"
|
84 |
+
value={endFilter}
|
85 |
+
onChange={(e) => setEndFilter(e.target.value)}
|
86 |
+
className="h-8"
|
87 |
+
/>
|
88 |
+
<Button
|
89 |
+
size="sm"
|
90 |
+
variant="outline"
|
91 |
+
onClick={togglePlayPause}
|
92 |
+
className="flex-shrink-0 h-8 w-8 p-0"
|
93 |
+
>
|
94 |
+
{isPlaying ? (
|
95 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
96 |
+
<rect x="6" y="4" width="4" height="16" />
|
97 |
+
<rect x="14" y="4" width="4" height="16" />
|
98 |
+
</svg>
|
99 |
+
) : (
|
100 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
101 |
+
<polygon points="5 3 19 12 5 21 5 3" />
|
102 |
+
</svg>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
)}
|
104 |
+
</Button>
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
</div>
|
106 |
+
</div>
|
107 |
+
|
108 |
+
<div className="flex-1 overflow-y-auto overflow-x-hidden space-y-2 pr-1">
|
109 |
+
{filteredRuns.map((run) => {
|
110 |
+
const originalIndex = runs.indexOf(run);
|
111 |
+
return (
|
112 |
+
<Card
|
113 |
+
key={originalIndex}
|
114 |
+
className={cn(
|
115 |
+
"p-3 cursor-pointer transition-all border",
|
116 |
+
selectedRunId === originalIndex
|
117 |
+
? "bg-primary/10 border-primary/50 shadow-sm"
|
118 |
+
: "hover:bg-muted/80 border-transparent"
|
119 |
+
)}
|
120 |
+
onClick={() => onSelectRun(originalIndex)}
|
121 |
+
>
|
122 |
+
<div className="flex items-center justify-between">
|
123 |
+
<div>
|
124 |
+
<p className="font-medium flex items-center">
|
125 |
+
<span>{run.start_article}</span>
|
126 |
+
<svg
|
127 |
+
xmlns="http://www.w3.org/2000/svg"
|
128 |
+
width="16"
|
129 |
+
height="16"
|
130 |
+
viewBox="0 0 24 24"
|
131 |
+
fill="none"
|
132 |
+
stroke="currentColor"
|
133 |
+
strokeWidth="2"
|
134 |
+
strokeLinecap="round"
|
135 |
+
strokeLinejoin="round"
|
136 |
+
className="mx-1"
|
137 |
+
>
|
138 |
+
<path d="M5 12h14" />
|
139 |
+
<path d="m12 5 7 7-7 7" />
|
140 |
+
</svg>
|
141 |
+
<span>{run.destination_article}</span>
|
142 |
+
</p>
|
143 |
+
<p className="text-sm text-muted-foreground">{run.steps.length} hops</p>
|
144 |
+
</div>
|
145 |
+
{selectedRunId === originalIndex && (
|
146 |
+
<div
|
147 |
+
className="h-2 w-2 rounded-full bg-primary"
|
148 |
+
aria-hidden="true"
|
149 |
+
/>
|
150 |
+
)}
|
151 |
+
</div>
|
152 |
+
</Card>
|
153 |
+
);
|
154 |
+
})}
|
155 |
+
|
156 |
+
{filteredRuns.length === 0 && (
|
157 |
+
<div className="flex items-center justify-center h-full text-muted-foreground">
|
158 |
+
No runs available
|
159 |
+
</div>
|
160 |
+
)}
|
161 |
+
</div>
|
162 |
</div>
|
163 |
);
|
164 |
}
|
src/components/viewer-tab.tsx
CHANGED
@@ -6,14 +6,6 @@ import type { RepoDesignation } from "@huggingface/hub";
|
|
6 |
import mockResults from "../../results/qwen3.json"
|
7 |
// import mockResults from "../../qwen3-final-results.json"
|
8 |
import { useMemo, useState, useEffect } from "react";
|
9 |
-
import {
|
10 |
-
Select,
|
11 |
-
SelectContent,
|
12 |
-
SelectItem,
|
13 |
-
SelectTrigger,
|
14 |
-
SelectValue,
|
15 |
-
} from "@/components/ui/select";
|
16 |
-
import { Button } from "@/components/ui/button";
|
17 |
import { Card } from "@/components/ui/card";
|
18 |
import ForceDirectedGraph from "@/components/force-directed-graph";
|
19 |
import RunsList from "@/components/runs-list";
|
@@ -26,10 +18,8 @@ type Run = {
|
|
26 |
};
|
27 |
|
28 |
export default function ViewerTab() {
|
29 |
-
const [selectedDataset, setSelectedDataset] = useState<string>("");
|
30 |
const [selectedRun, setSelectedRun] = useState<number | null>(null);
|
31 |
const [runs, setRuns] = useState<Run[]>([]);
|
32 |
-
const [loading, setLoading] = useState<boolean>(false);
|
33 |
|
34 |
const fetchDataset = async () => {
|
35 |
console.log("Fetching dataset...");
|
@@ -37,38 +27,12 @@ export default function ViewerTab() {
|
|
37 |
setRuns(mockResults.runs);
|
38 |
|
39 |
return;
|
40 |
-
setLoading(true);
|
41 |
-
|
42 |
-
// https://huggingface.co/datasets/HuggingFaceTB/wikispeedia-traces/resolve/main/qwen3-final-results.json
|
43 |
-
// const response = await fetch("https://huggingface.co/datasets/HuggingFaceTB/wikispeedia-traces/resolve/main/qwen3-final-results.json");
|
44 |
-
// const json = await response.json();
|
45 |
-
// setRuns(json.runs);
|
46 |
-
// setLoading(false);
|
47 |
-
|
48 |
-
// const repo: RepoDesignation = {
|
49 |
-
// type: "dataset",
|
50 |
-
// name: "HuggingFaceTB/wikispeedia-traces",
|
51 |
-
// };
|
52 |
-
// const file = await hub.downloadFile({ repo, path: "qwen3-final-results.json" });
|
53 |
-
// if (!file) {
|
54 |
-
// console.error("Failed to download file");
|
55 |
-
// return;
|
56 |
-
// }
|
57 |
-
// const text = await file.text();
|
58 |
-
// console.log("GOT FILE!", text);
|
59 |
-
// const json = JSON.parse(text);
|
60 |
-
// setRuns(json.runs);
|
61 |
-
// setLoading(false);
|
62 |
};
|
63 |
|
64 |
useEffect(() => {
|
65 |
fetchDataset();
|
66 |
}, []);
|
67 |
|
68 |
-
const handleDatasetChange = (value: string) => {
|
69 |
-
setSelectedDataset(value);
|
70 |
-
setSelectedRun(null);
|
71 |
-
};
|
72 |
|
73 |
const handleRunSelect = (runId: number) => {
|
74 |
setSelectedRun(runId);
|
@@ -79,7 +43,7 @@ export default function ViewerTab() {
|
|
79 |
}, [runs]);
|
80 |
|
81 |
return (
|
82 |
-
<div className="grid grid-cols-1 md:grid-cols-12 gap-4 h-[calc(100vh-
|
83 |
<div className="md:col-span-3 flex flex-col max-h-full overflow-hidden">
|
84 |
<div className="bg-card rounded-lg p-3 border flex-grow overflow-hidden flex flex-col">
|
85 |
<h3 className="text-sm font-medium mb-2 text-muted-foreground flex-shrink-0">
|
|
|
6 |
import mockResults from "../../results/qwen3.json"
|
7 |
// import mockResults from "../../qwen3-final-results.json"
|
8 |
import { useMemo, useState, useEffect } from "react";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
import { Card } from "@/components/ui/card";
|
10 |
import ForceDirectedGraph from "@/components/force-directed-graph";
|
11 |
import RunsList from "@/components/runs-list";
|
|
|
18 |
};
|
19 |
|
20 |
export default function ViewerTab() {
|
|
|
21 |
const [selectedRun, setSelectedRun] = useState<number | null>(null);
|
22 |
const [runs, setRuns] = useState<Run[]>([]);
|
|
|
23 |
|
24 |
const fetchDataset = async () => {
|
25 |
console.log("Fetching dataset...");
|
|
|
27 |
setRuns(mockResults.runs);
|
28 |
|
29 |
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
};
|
31 |
|
32 |
useEffect(() => {
|
33 |
fetchDataset();
|
34 |
}, []);
|
35 |
|
|
|
|
|
|
|
|
|
36 |
|
37 |
const handleRunSelect = (runId: number) => {
|
38 |
setSelectedRun(runId);
|
|
|
43 |
}, [runs]);
|
44 |
|
45 |
return (
|
46 |
+
<div className="grid grid-cols-1 md:grid-cols-12 gap-4 h-[calc(100vh-200px)] max-h-[calc(100vh-200px)] overflow-hidden p-2">
|
47 |
<div className="md:col-span-3 flex flex-col max-h-full overflow-hidden">
|
48 |
<div className="bg-card rounded-lg p-3 border flex-grow overflow-hidden flex flex-col">
|
49 |
<h3 className="text-sm font-medium mb-2 text-muted-foreground flex-shrink-0">
|