Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Sync from huggingface/lerobot-dataset-visualizer via hub-sync
Browse files
src/app/[org]/[dataset]/[episode]/episode-viewer.tsx
CHANGED
|
@@ -110,6 +110,113 @@ function UrlTimeSync() {
|
|
| 110 |
// component type on every parent render — and the parent re-renders ~12.5×/s
|
| 111 |
// during playback because it consumes `currentTime` from useTime. React
|
| 112 |
// would unmount and remount every tab on every tick.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
function TabButton({
|
| 114 |
active,
|
| 115 |
onClick,
|
|
@@ -303,12 +410,6 @@ function EpisodeViewerInner({
|
|
| 303 |
}
|
| 304 |
return "episodes";
|
| 305 |
});
|
| 306 |
-
const tabBarRef = useRef<HTMLDivElement>(null);
|
| 307 |
-
useEffect(() => {
|
| 308 |
-
tabBarRef.current
|
| 309 |
-
?.querySelector("[data-active]")
|
| 310 |
-
?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
| 311 |
-
}, [activeTab]);
|
| 312 |
const isLoading = activeTab === "episodes" && (!videosReady || !chartsReady);
|
| 313 |
|
| 314 |
useEffect(() => {
|
|
@@ -608,26 +709,10 @@ function EpisodeViewerInner({
|
|
| 608 |
<div className="flex flex-col h-screen max-h-screen bg-[var(--bg)] text-[var(--text-primary)]">
|
| 609 |
<UrlTimeSync />
|
| 610 |
{/* Top tab bar */}
|
| 611 |
-
<div
|
| 612 |
-
ref={tabBarRef}
|
| 613 |
-
className="flex items-center border-b border-white/5 bg-[var(--surface-0)] shrink-0 overflow-x-auto [scrollbar-width:none]"
|
| 614 |
-
>
|
| 615 |
{renderTab("episodes", "Episodes")}
|
| 616 |
{urdfSupported && renderTab("urdf", "3D Replay")}
|
| 617 |
-
{
|
| 618 |
-
"annotations",
|
| 619 |
-
"Annotations",
|
| 620 |
-
"Edit subtask / plan / memory / interjection / VQA atoms (lerobot v3.1 schema)",
|
| 621 |
-
)}
|
| 622 |
-
{renderTab("statistics", "Statistics")}
|
| 623 |
-
{renderTab("filtering", "Filtering")}
|
| 624 |
-
{renderTab("frames", "Frames")}
|
| 625 |
-
{renderTab("insights", "Action Insights")}
|
| 626 |
-
{renderTab(
|
| 627 |
-
"doctor",
|
| 628 |
-
"Doctor",
|
| 629 |
-
"Dataset quality diagnostics (powered by lerobot-doctor)",
|
| 630 |
-
)}
|
| 631 |
<div className="ml-auto shrink-0 pl-2">
|
| 632 |
<HfAuthButton variant="tab" />
|
| 633 |
</div>
|
|
|
|
| 110 |
// component type on every parent render — and the parent re-renders ~12.5×/s
|
| 111 |
// during playback because it consumes `currentTime` from useTime. React
|
| 112 |
// would unmount and remount every tab on every tick.
|
| 113 |
+
/** Analysis tabs, grouped under "Advanced" so the bar leads with Episodes and 3D Replay. */
|
| 114 |
+
const ADVANCED_TABS: { tab: ActiveTab; label: string; title?: string }[] = [
|
| 115 |
+
{
|
| 116 |
+
tab: "annotations",
|
| 117 |
+
label: "Annotations",
|
| 118 |
+
title:
|
| 119 |
+
"Edit subtask / plan / memory / interjection / VQA atoms (lerobot v3.1 schema)",
|
| 120 |
+
},
|
| 121 |
+
{ tab: "statistics", label: "Statistics" },
|
| 122 |
+
{ tab: "filtering", label: "Filtering" },
|
| 123 |
+
{ tab: "frames", label: "Frames" },
|
| 124 |
+
{ tab: "insights", label: "Action Insights" },
|
| 125 |
+
{
|
| 126 |
+
tab: "doctor",
|
| 127 |
+
label: "Doctor",
|
| 128 |
+
title: "Dataset quality diagnostics (powered by lerobot-doctor)",
|
| 129 |
+
},
|
| 130 |
+
];
|
| 131 |
+
|
| 132 |
+
function AdvancedTabsMenu({
|
| 133 |
+
activeTab,
|
| 134 |
+
onSelect,
|
| 135 |
+
}: {
|
| 136 |
+
activeTab: ActiveTab;
|
| 137 |
+
onSelect: (tab: ActiveTab) => void;
|
| 138 |
+
}) {
|
| 139 |
+
const [open, setOpen] = useState(false);
|
| 140 |
+
const rootRef = useRef<HTMLDivElement>(null);
|
| 141 |
+
const active = ADVANCED_TABS.find((t) => t.tab === activeTab);
|
| 142 |
+
|
| 143 |
+
useEffect(() => {
|
| 144 |
+
if (!open) return;
|
| 145 |
+
const onPointerDown = (e: PointerEvent) => {
|
| 146 |
+
if (!rootRef.current?.contains(e.target as Node)) setOpen(false);
|
| 147 |
+
};
|
| 148 |
+
const onKeyDown = (e: KeyboardEvent) => {
|
| 149 |
+
if (e.key === "Escape") setOpen(false);
|
| 150 |
+
};
|
| 151 |
+
window.addEventListener("pointerdown", onPointerDown);
|
| 152 |
+
window.addEventListener("keydown", onKeyDown);
|
| 153 |
+
return () => {
|
| 154 |
+
window.removeEventListener("pointerdown", onPointerDown);
|
| 155 |
+
window.removeEventListener("keydown", onKeyDown);
|
| 156 |
+
};
|
| 157 |
+
}, [open]);
|
| 158 |
+
|
| 159 |
+
return (
|
| 160 |
+
<div ref={rootRef} className="relative">
|
| 161 |
+
<button
|
| 162 |
+
onClick={() => setOpen((v) => !v)}
|
| 163 |
+
aria-haspopup="menu"
|
| 164 |
+
aria-expanded={open}
|
| 165 |
+
data-active={active ? true : undefined}
|
| 166 |
+
className={`relative flex items-center gap-1.5 whitespace-nowrap px-3 lg:px-5 py-3 text-xs font-medium tracking-wide uppercase transition-colors ${
|
| 167 |
+
active ? "text-cyan-300" : "text-slate-400 hover:text-slate-100"
|
| 168 |
+
}`}
|
| 169 |
+
>
|
| 170 |
+
{active ? `Advanced · ${active.label}` : "Advanced"}
|
| 171 |
+
<svg
|
| 172 |
+
width="10"
|
| 173 |
+
height="10"
|
| 174 |
+
viewBox="0 0 24 24"
|
| 175 |
+
fill="none"
|
| 176 |
+
stroke="currentColor"
|
| 177 |
+
strokeWidth="2.5"
|
| 178 |
+
className={`transition-transform ${open ? "rotate-180" : ""}`}
|
| 179 |
+
aria-hidden="true"
|
| 180 |
+
>
|
| 181 |
+
<polyline points="6 9 12 15 18 9" />
|
| 182 |
+
</svg>
|
| 183 |
+
<span
|
| 184 |
+
className={`pointer-events-none absolute bottom-0 left-3 right-3 h-px transition-all ${
|
| 185 |
+
active
|
| 186 |
+
? "bg-cyan-400 shadow-[0_0_8px_rgba(56,189,248,0.55)]"
|
| 187 |
+
: "bg-transparent"
|
| 188 |
+
}`}
|
| 189 |
+
/>
|
| 190 |
+
</button>
|
| 191 |
+
{open && (
|
| 192 |
+
<div
|
| 193 |
+
role="menu"
|
| 194 |
+
className="absolute left-0 top-full z-50 mt-1 min-w-[12rem] panel-raised bg-[var(--surface-1)] p-1.5 shadow-xl animate-menu-pop [transform-origin:top_left]"
|
| 195 |
+
>
|
| 196 |
+
{ADVANCED_TABS.map(({ tab, label, title }) => (
|
| 197 |
+
<button
|
| 198 |
+
key={tab}
|
| 199 |
+
role="menuitem"
|
| 200 |
+
title={title}
|
| 201 |
+
onClick={() => {
|
| 202 |
+
onSelect(tab);
|
| 203 |
+
setOpen(false);
|
| 204 |
+
}}
|
| 205 |
+
className={`block w-full rounded-md px-2.5 py-1.5 text-left text-sm transition-colors ${
|
| 206 |
+
tab === activeTab
|
| 207 |
+
? "bg-cyan-400/10 text-cyan-300"
|
| 208 |
+
: "text-slate-300 hover:bg-white/5 hover:text-slate-100"
|
| 209 |
+
}`}
|
| 210 |
+
>
|
| 211 |
+
{label}
|
| 212 |
+
</button>
|
| 213 |
+
))}
|
| 214 |
+
</div>
|
| 215 |
+
)}
|
| 216 |
+
</div>
|
| 217 |
+
);
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
function TabButton({
|
| 221 |
active,
|
| 222 |
onClick,
|
|
|
|
| 410 |
}
|
| 411 |
return "episodes";
|
| 412 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
const isLoading = activeTab === "episodes" && (!videosReady || !chartsReady);
|
| 414 |
|
| 415 |
useEffect(() => {
|
|
|
|
| 709 |
<div className="flex flex-col h-screen max-h-screen bg-[var(--bg)] text-[var(--text-primary)]">
|
| 710 |
<UrlTimeSync />
|
| 711 |
{/* Top tab bar */}
|
| 712 |
+
<div className="relative z-20 flex items-center border-b border-white/5 bg-[var(--surface-0)] shrink-0">
|
|
|
|
|
|
|
|
|
|
| 713 |
{renderTab("episodes", "Episodes")}
|
| 714 |
{urdfSupported && renderTab("urdf", "3D Replay")}
|
| 715 |
+
<AdvancedTabsMenu activeTab={activeTab} onSelect={handleTabChange} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 716 |
<div className="ml-auto shrink-0 pl-2">
|
| 717 |
<HfAuthButton variant="tab" />
|
| 718 |
</div>
|