mishig HF Staff commited on
Commit
a461926
·
verified ·
1 Parent(s): f4b626c

Sync from huggingface/lerobot-dataset-visualizer via hub-sync

Browse files
src/app/[org]/[dataset]/[episode]/episode-viewer.tsx CHANGED
@@ -18,7 +18,8 @@ import StatsPanel from "@/components/stats-panel";
18
  import OverviewPanel from "@/components/overview-panel";
19
  import Loading from "@/components/loading-component";
20
  import HfAuthButton from "@/components/hf-auth-button";
21
- import { EpisodeHeader } from "@/components/ui";
 
22
  import { hasURDFSupport } from "@/lib/so101-robot";
23
  import {
24
  computeColumnMinMax,
@@ -313,10 +314,10 @@ export default function EpisodeViewer({
313
 
314
  if (error) {
315
  return (
316
- <div className="flex h-screen items-center justify-center bg-[var(--bg)] text-red-300">
317
  <div className="panel-raised max-w-xl p-6 border-red-500/40">
318
  <h2 className="text-xl font-medium mb-3">Something went wrong</h2>
319
- <p className="text-sm font-mono whitespace-pre-wrap text-red-200/90">
320
  {error}
321
  </p>
322
  </div>
@@ -576,6 +577,8 @@ function EpisodeViewerInner({
576
  // which would redraw this whole component ~12×/s. <UrlTimeSync /> handles
577
  // the one thing here that needs `currentTime` (the ?t= URL writer).
578
  const { seek, setIsPlaying } = useTimeControls();
 
 
579
 
580
  // URDFViewer episode changer and play toggle — populated by URDFViewer on mount
581
  const urdfChangerRef = useRef<((ep: number) => void) | undefined>(undefined);
@@ -713,7 +716,8 @@ function EpisodeViewerInner({
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>
719
  </div>
@@ -902,7 +906,7 @@ function EpisodeViewerInner({
902
  </a>
903
  </div>
904
  <iframe
905
- src={`https://jashshah999-lerobot-doctor.hf.space/?dataset=${org}/${dataset}`}
906
  title="lerobot-doctor"
907
  className="flex-1 w-full rounded-lg border border-line bg-[var(--surface-0)]"
908
  sandbox="allow-scripts allow-same-origin allow-popups allow-forms"
 
18
  import OverviewPanel from "@/components/overview-panel";
19
  import Loading from "@/components/loading-component";
20
  import HfAuthButton from "@/components/hf-auth-button";
21
+ import { EpisodeHeader, ThemeToggle } from "@/components/ui";
22
+ import { useTheme } from "@/utils/theme";
23
  import { hasURDFSupport } from "@/lib/so101-robot";
24
  import {
25
  computeColumnMinMax,
 
314
 
315
  if (error) {
316
  return (
317
+ <div className="flex h-screen items-center justify-center bg-[var(--bg)] text-red-600 dark:text-red-300">
318
  <div className="panel-raised max-w-xl p-6 border-red-500/40">
319
  <h2 className="text-xl font-medium mb-3">Something went wrong</h2>
320
+ <p className="text-sm font-mono whitespace-pre-wrap text-red-700/90 dark:text-red-200/90">
321
  {error}
322
  </p>
323
  </div>
 
577
  // which would redraw this whole component ~12×/s. <UrlTimeSync /> handles
578
  // the one thing here that needs `currentTime` (the ?t= URL writer).
579
  const { seek, setIsPlaying } = useTimeControls();
580
+ /// Passed to the embedded lerobot-doctor Space, which follows `__theme` like any HF Space.
581
+ const theme = useTheme();
582
 
583
  // URDFViewer episode changer and play toggle — populated by URDFViewer on mount
584
  const urdfChangerRef = useRef<((ep: number) => void) | undefined>(undefined);
 
716
  {renderTab("episodes", "Episodes")}
717
  {urdfSupported && renderTab("urdf", "3D Replay")}
718
  <AdvancedTabsMenu activeTab={activeTab} onSelect={handleTabChange} />
719
+ <div className="ml-auto flex shrink-0 items-center gap-1 pl-2">
720
+ <ThemeToggle />
721
  <HfAuthButton variant="tab" />
722
  </div>
723
  </div>
 
906
  </a>
907
  </div>
908
  <iframe
909
+ src={`https://jashshah999-lerobot-doctor.hf.space/?dataset=${org}/${dataset}&__theme=${theme}`}
910
  title="lerobot-doctor"
911
  className="flex-1 w-full rounded-lg border border-line bg-[var(--surface-0)]"
912
  sandbox="allow-scripts allow-same-origin allow-popups allow-forms"
src/app/globals.css CHANGED
@@ -1,14 +1,59 @@
1
  @import "tailwindcss";
2
 
3
  /* ── Design tokens ────────────────────────────────────────────────
4
- Consolidated palette + surface scale. Use via Tailwind arbitrary
5
- values (bg-[var(--surface-1)]) or via the semantic helpers below. */
 
 
 
6
  :root {
7
- /* Surfaces, text and lines follow the Hub (moon-landing): its gray scale,
8
- with gray-950 / gray-925 / gray-850 as the dark page, card and border. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  --bg: #0b0f19; /* gray-950 */
10
- --surface-0: #0b0f19; /* chrome: tab bar, sidebar, inset boxes */
11
- --surface-1: #101623; /* gray-925: cards */
12
  --surface-2: #141c2e; /* gray-850 */
13
 
14
  --fg: #e5e7eb; /* gray-200 */
@@ -20,23 +65,20 @@
20
  --line-subtle: #141c2e; /* gray-850 */
21
  --line-strong: #374151; /* gray-700 */
22
 
23
- /* Hover / control fills that sit on top of any surface. */
24
  --fill: rgba(255, 255, 255, 0.05);
25
  --fill-strong: rgba(255, 255, 255, 0.1);
26
 
27
- /* single accent (cyan). Orange is reserved for flagged episodes. */
28
- --accent: #38bdf8;
29
- --accent-soft: rgba(56, 189, 248, 0.18);
30
- --accent-ring: rgba(56, 189, 248, 0.55);
31
- --accent-fg: #67e8f9; /* accent as text */
32
- --flag-fg: #fdba74; /* flagged-episode text */
33
-
34
- --radius: 6px;
35
 
36
- /* Playback position, wherever it is drawn (chart cursor, annotation
37
- timeline). Neutral, so it never reads as a series, a role or a flag. */
38
  --playhead: #f1f5f9;
39
  --playhead-glow: rgba(241, 245, 249, 0.45);
 
 
 
 
 
 
40
  }
41
 
42
  @theme inline {
@@ -120,13 +162,13 @@ body {
120
  background: transparent;
121
  }
122
  *::-webkit-scrollbar-thumb {
123
- background: rgba(255, 255, 255, 0.06);
124
  border-radius: 10px;
125
  border: 2px solid transparent;
126
  background-clip: padding-box;
127
  }
128
  *::-webkit-scrollbar-thumb:hover {
129
- background-color: rgba(255, 255, 255, 0.12);
130
  background-clip: padding-box;
131
  }
132
 
 
1
  @import "tailwindcss";
2
 
3
  /* ── Design tokens ────────────────────────────────────────────────
4
+ Surfaces, text and lines follow the Hub (moon-landing): Tailwind's gray
5
+ scale, white pages in light mode and gray-950 / gray-925 / gray-850 in
6
+ dark. <html class="dark"> selects the dark set; see utils/theme.ts. */
7
+ @custom-variant dark (&:where(.dark, .dark *));
8
+
9
  :root {
10
+ color-scheme: light;
11
+
12
+ --bg: #ffffff;
13
+ --surface-0: #ffffff; /* chrome: tab bar, sidebar, inset boxes */
14
+ --surface-1: #f9fafb; /* gray-50: cards */
15
+ --surface-2: #f3f4f6; /* gray-100 */
16
+
17
+ --fg: #111827; /* gray-900 */
18
+ --fg-soft: #374151; /* gray-700 */
19
+ --fg-muted: #6b7280; /* gray-500 */
20
+ --fg-faint: #9ca3af; /* gray-400 */
21
+
22
+ --line: #e5e7eb; /* gray-200 */
23
+ --line-subtle: #f3f4f6; /* gray-100 */
24
+ --line-strong: #d1d5db; /* gray-300 */
25
+
26
+ /* Hover / control fills that sit on top of any surface. */
27
+ --fill: rgba(17, 24, 39, 0.04);
28
+ --fill-strong: rgba(17, 24, 39, 0.08);
29
+
30
+ /* single accent (cyan). Orange is reserved for flagged episodes. */
31
+ --accent: #38bdf8;
32
+ --accent-soft: rgba(56, 189, 248, 0.18);
33
+ --accent-ring: rgba(56, 189, 248, 0.55);
34
+ --accent-fg: #0e7490; /* accent as text: cyan-700 */
35
+ --flag-fg: #c2410c; /* flagged-episode text: orange-700 */
36
+
37
+ --radius: 6px;
38
+
39
+ /* Playback position, wherever it is drawn (chart cursor, annotation
40
+ timeline). Neutral, so it never reads as a series, a role or a flag. */
41
+ --playhead: #111827;
42
+ --playhead-glow: rgba(17, 24, 39, 0.3);
43
+
44
+ --chart-grid: #e5e7eb;
45
+ --chart-axis: #9ca3af;
46
+
47
+ --scrollbar: rgba(17, 24, 39, 0.14);
48
+ --scrollbar-hover: rgba(17, 24, 39, 0.24);
49
+ }
50
+
51
+ :root.dark {
52
+ color-scheme: dark;
53
+
54
  --bg: #0b0f19; /* gray-950 */
55
+ --surface-0: #0b0f19;
56
+ --surface-1: #101623; /* gray-925 */
57
  --surface-2: #141c2e; /* gray-850 */
58
 
59
  --fg: #e5e7eb; /* gray-200 */
 
65
  --line-subtle: #141c2e; /* gray-850 */
66
  --line-strong: #374151; /* gray-700 */
67
 
 
68
  --fill: rgba(255, 255, 255, 0.05);
69
  --fill-strong: rgba(255, 255, 255, 0.1);
70
 
71
+ --accent-fg: #67e8f9; /* cyan-300 */
72
+ --flag-fg: #fdba74; /* orange-300 */
 
 
 
 
 
 
73
 
 
 
74
  --playhead: #f1f5f9;
75
  --playhead-glow: rgba(241, 245, 249, 0.45);
76
+
77
+ --chart-grid: #1f2937;
78
+ --chart-axis: #4b5563;
79
+
80
+ --scrollbar: rgba(255, 255, 255, 0.06);
81
+ --scrollbar-hover: rgba(255, 255, 255, 0.12);
82
  }
83
 
84
  @theme inline {
 
162
  background: transparent;
163
  }
164
  *::-webkit-scrollbar-thumb {
165
+ background: var(--scrollbar);
166
  border-radius: 10px;
167
  border: 2px solid transparent;
168
  background-clip: padding-box;
169
  }
170
  *::-webkit-scrollbar-thumb:hover {
171
+ background-color: var(--scrollbar-hover);
172
  background-clip: padding-box;
173
  }
174
 
src/app/layout.tsx CHANGED
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
2
  import { Inter } from "next/font/google";
3
  import "./globals.css";
4
  import { AuthProvider } from "@/context/auth-context";
 
5
 
6
  const inter = Inter({ subsets: ["latin"] });
7
 
@@ -16,7 +17,11 @@ export default function RootLayout({
16
  children: React.ReactNode;
17
  }) {
18
  return (
19
- <html lang="en">
 
 
 
 
20
  <body className={inter.className}>
21
  <AuthProvider>{children}</AuthProvider>
22
  </body>
 
2
  import { Inter } from "next/font/google";
3
  import "./globals.css";
4
  import { AuthProvider } from "@/context/auth-context";
5
+ import { THEME_INIT_SCRIPT } from "@/utils/theme-init";
6
 
7
  const inter = Inter({ subsets: ["latin"] });
8
 
 
17
  children: React.ReactNode;
18
  }) {
19
  return (
20
+ // The init script sets the theme class before hydration, hence the warning suppression.
21
+ <html lang="en" suppressHydrationWarning>
22
+ <head>
23
+ <script dangerouslySetInnerHTML={{ __html: THEME_INIT_SCRIPT }} />
24
+ </head>
25
  <body className={inter.className}>
26
  <AuthProvider>{children}</AuthProvider>
27
  </body>
src/components/action-insights-panel.tsx CHANGED
@@ -393,27 +393,27 @@ function AutocorrelationSection({
393
  data={chartData}
394
  margin={{ top: 8, right: 16, left: 0, bottom: 16 }}
395
  >
396
- <CartesianGrid strokeDasharray="3 3" stroke="#334155" />
397
  <XAxis
398
  dataKey="lag"
399
- stroke="#94a3b8"
400
  label={{
401
  value: "Lag (steps)",
402
  position: "insideBottom",
403
  offset: -8,
404
- fill: "#94a3b8",
405
  fontSize: 13,
406
  }}
407
  />
408
  <YAxis
409
- stroke="#94a3b8"
410
  domain={yDomain}
411
  tickFormatter={(v) => Number(v.toFixed(2)).toString()}
412
  />
413
  <Tooltip
414
  contentStyle={{
415
- background: "#1e293b",
416
- border: "1px solid #475569",
417
  borderRadius: 6,
418
  }}
419
  labelFormatter={(v) =>
@@ -423,7 +423,7 @@ function AutocorrelationSection({
423
  />
424
  <Line
425
  dataKey={() => 0.5}
426
- stroke="#64748b"
427
  strokeDasharray="6 4"
428
  dot={false}
429
  name="0.5 threshold"
@@ -738,7 +738,11 @@ function ActionVelocitySection({
738
  y={barH - h}
739
  width={0.85}
740
  height={h}
741
- fill={dimmed ? "#475569" : COLORS[si % COLORS.length]}
 
 
 
 
742
  opacity={dimmed ? 0.4 : 0.7}
743
  />
744
  );
@@ -750,7 +754,7 @@ function ActionVelocitySection({
750
  style={{
751
  width: `${Math.min(100, (s.std / maxStd) * 100)}%`,
752
  background: dimmed
753
- ? "#475569"
754
  : s.std / maxStd < 0.4
755
  ? "#22c55e"
756
  : s.std / maxStd < 0.7
@@ -961,7 +965,7 @@ function VarianceHeatmap({
961
  width={cellW}
962
  height={cellH}
963
  fill={varColor(v)}
964
- stroke="#1e293b"
965
  strokeWidth={0.5}
966
  >
967
  <title>{`${shortName(actionNames[di])} @ ${(timeBins[bi] * 100).toFixed(0)}%: var=${v.toFixed(5)}`}</title>
@@ -1469,27 +1473,27 @@ function StateActionAlignmentSection({
1469
  data={ccData}
1470
  margin={{ top: 8, right: 16, left: 0, bottom: 16 }}
1471
  >
1472
- <CartesianGrid strokeDasharray="3 3" stroke="#334155" />
1473
  <XAxis
1474
  dataKey="lag"
1475
- stroke="#94a3b8"
1476
  label={{
1477
  value: "Lag (steps)",
1478
  position: "insideBottom",
1479
  offset: -8,
1480
- fill: "#94a3b8",
1481
  fontSize: 13,
1482
  }}
1483
  />
1484
  <YAxis
1485
- stroke="#94a3b8"
1486
  domain={[-0.5, 1]}
1487
  tickFormatter={(v) => Number(v.toFixed(2)).toString()}
1488
  />
1489
  <Tooltip
1490
  contentStyle={{
1491
- background: "#1e293b",
1492
- border: "1px solid #475569",
1493
  borderRadius: 6,
1494
  }}
1495
  labelFormatter={(v) =>
@@ -1507,7 +1511,7 @@ function StateActionAlignmentSection({
1507
  />
1508
  <Line
1509
  dataKey="mean"
1510
- stroke="#94a3b8"
1511
  dot={false}
1512
  strokeWidth={2}
1513
  isAnimationActive={false}
@@ -1523,7 +1527,7 @@ function StateActionAlignmentSection({
1523
  />
1524
  <Line
1525
  dataKey={() => 0}
1526
- stroke="#64748b"
1527
  strokeDasharray="6 4"
1528
  dot={false}
1529
  name="zero"
 
393
  data={chartData}
394
  margin={{ top: 8, right: 16, left: 0, bottom: 16 }}
395
  >
396
+ <CartesianGrid strokeDasharray="3 3" stroke="var(--chart-grid)" />
397
  <XAxis
398
  dataKey="lag"
399
+ stroke="var(--fg-muted)"
400
  label={{
401
  value: "Lag (steps)",
402
  position: "insideBottom",
403
  offset: -8,
404
+ fill: "var(--fg-muted)",
405
  fontSize: 13,
406
  }}
407
  />
408
  <YAxis
409
+ stroke="var(--fg-muted)"
410
  domain={yDomain}
411
  tickFormatter={(v) => Number(v.toFixed(2)).toString()}
412
  />
413
  <Tooltip
414
  contentStyle={{
415
+ background: "var(--surface-2)",
416
+ border: "1px solid var(--line-strong)",
417
  borderRadius: 6,
418
  }}
419
  labelFormatter={(v) =>
 
423
  />
424
  <Line
425
  dataKey={() => 0.5}
426
+ stroke="var(--chart-axis)"
427
  strokeDasharray="6 4"
428
  dot={false}
429
  name="0.5 threshold"
 
738
  y={barH - h}
739
  width={0.85}
740
  height={h}
741
+ fill={
742
+ dimmed
743
+ ? "var(--line-strong)"
744
+ : COLORS[si % COLORS.length]
745
+ }
746
  opacity={dimmed ? 0.4 : 0.7}
747
  />
748
  );
 
754
  style={{
755
  width: `${Math.min(100, (s.std / maxStd) * 100)}%`,
756
  background: dimmed
757
+ ? "var(--line-strong)"
758
  : s.std / maxStd < 0.4
759
  ? "#22c55e"
760
  : s.std / maxStd < 0.7
 
965
  width={cellW}
966
  height={cellH}
967
  fill={varColor(v)}
968
+ stroke="var(--bg)"
969
  strokeWidth={0.5}
970
  >
971
  <title>{`${shortName(actionNames[di])} @ ${(timeBins[bi] * 100).toFixed(0)}%: var=${v.toFixed(5)}`}</title>
 
1473
  data={ccData}
1474
  margin={{ top: 8, right: 16, left: 0, bottom: 16 }}
1475
  >
1476
+ <CartesianGrid strokeDasharray="3 3" stroke="var(--chart-grid)" />
1477
  <XAxis
1478
  dataKey="lag"
1479
+ stroke="var(--fg-muted)"
1480
  label={{
1481
  value: "Lag (steps)",
1482
  position: "insideBottom",
1483
  offset: -8,
1484
+ fill: "var(--fg-muted)",
1485
  fontSize: 13,
1486
  }}
1487
  />
1488
  <YAxis
1489
+ stroke="var(--fg-muted)"
1490
  domain={[-0.5, 1]}
1491
  tickFormatter={(v) => Number(v.toFixed(2)).toString()}
1492
  />
1493
  <Tooltip
1494
  contentStyle={{
1495
+ background: "var(--surface-2)",
1496
+ border: "1px solid var(--line-strong)",
1497
  borderRadius: 6,
1498
  }}
1499
  labelFormatter={(v) =>
 
1511
  />
1512
  <Line
1513
  dataKey="mean"
1514
+ stroke="var(--fg-muted)"
1515
  dot={false}
1516
  strokeWidth={2}
1517
  isAnimationActive={false}
 
1527
  />
1528
  <Line
1529
  dataKey={() => 0}
1530
+ stroke="var(--chart-axis)"
1531
  strokeDasharray="6 4"
1532
  dot={false}
1533
  name="zero"
src/components/annotations-skin.css CHANGED
@@ -1042,3 +1042,48 @@
1042
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
1043
  line-height: 14px;
1044
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1042
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
1043
  line-height: 14px;
1044
  }
1045
+
1046
+ /* ----- Light theme -----
1047
+ The skin was written for dark surfaces. In light mode, swap its scale to
1048
+ dark-on-light and deepen the role colours, which also serve as text (pills,
1049
+ segment labels, section markers). */
1050
+ :root:not(.dark) .annotations-skin {
1051
+ --hf-yellow: #b45309;
1052
+ --hf-orange: #c2410c;
1053
+ --hf-blue: #2563eb;
1054
+ --hf-cyan: #0284c7;
1055
+ --hf-red: #dc2626;
1056
+ --hf-green: #059669;
1057
+ --hf-purple: #7c3aed;
1058
+
1059
+ --surface-0: rgba(17, 24, 39, 0.02);
1060
+ --surface-1: rgba(17, 24, 39, 0.05);
1061
+ --surface-2: rgba(17, 24, 39, 0.08);
1062
+ --border-1: rgba(17, 24, 39, 0.12);
1063
+ --border-2: rgba(17, 24, 39, 0.2);
1064
+ --fg-1: #111827;
1065
+ --fg-2: #374151;
1066
+ --fg-3: #6b7280;
1067
+ }
1068
+ :root:not(.dark) .annotations-skin .dirty-pill {
1069
+ color: var(--flag-fg);
1070
+ }
1071
+ :root:not(.dark) .annotations-skin .tl-seg.task_aug,
1072
+ :root:not(.dark) .annotations-skin .tl-seg.plan,
1073
+ :root:not(.dark) .annotations-skin .tl-seg.memory,
1074
+ :root:not(.dark) .annotations-skin .tl-seg.task_aug .aug-count {
1075
+ color: var(--fg-1);
1076
+ }
1077
+ :root:not(.dark) .annotations-skin .quick-popup,
1078
+ :root:not(.dark) .annotations-skin .list-head,
1079
+ :root:not(.dark) .annotations-skin .tl-tooltip {
1080
+ background: rgba(255, 255, 255, 0.97);
1081
+ box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
1082
+ }
1083
+ :root:not(.dark) .annotations-skin .quick-popup .popup-btn.primary,
1084
+ :root:not(.dark) .annotations-skin .quick-add .add-btn {
1085
+ color: var(--accent-fg);
1086
+ }
1087
+ :root:not(.dark) .annotations-skin .tl-seg .resize:hover {
1088
+ background: rgba(17, 24, 39, 0.12);
1089
+ }
src/components/annotations-timeline.tsx CHANGED
@@ -786,7 +786,7 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
786
  fontSize: 11,
787
  padding: "4px 8px",
788
  borderRadius: 6,
789
- border: "1px solid rgba(255,255,255,0.12)",
790
  background: "transparent",
791
  color: "var(--fg-2, #cbd5e1)",
792
  cursor: "pointer",
@@ -801,9 +801,9 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
801
  fontSize: 11,
802
  padding: "4px 8px",
803
  borderRadius: 6,
804
- border: "1px solid #5b8cff",
805
- background: "rgba(91,140,255,0.15)",
806
- color: "#c7d6ff",
807
  cursor: "pointer",
808
  opacity: createLabel.trim() ? 1 : 0.4,
809
  }}
 
786
  fontSize: 11,
787
  padding: "4px 8px",
788
  borderRadius: 6,
789
+ border: "1px solid var(--border-1)",
790
  background: "transparent",
791
  color: "var(--fg-2, #cbd5e1)",
792
  cursor: "pointer",
 
801
  fontSize: 11,
802
  padding: "4px 8px",
803
  borderRadius: 6,
804
+ border: "1px solid var(--accent)",
805
+ background: "var(--accent-soft)",
806
+ color: "var(--accent-fg)",
807
  cursor: "pointer",
808
  opacity: createLabel.trim() ? 1 : 0.4,
809
  }}
src/components/data-recharts.tsx CHANGED
@@ -483,7 +483,7 @@ const SingleDataGraph = React.memo(
483
  >
484
  <CartesianGrid
485
  strokeDasharray="3 3"
486
- stroke="#334155"
487
  strokeOpacity={0.6}
488
  />
489
  <XAxis
@@ -493,16 +493,16 @@ const SingleDataGraph = React.memo(
493
  chartData.at(-1)?.timestamp ?? 0,
494
  ]}
495
  tickFormatter={(v: number) => `${v.toFixed(1)}s`}
496
- stroke="#64748b"
497
- tick={{ fontSize: 12, fill: "#94a3b8" }}
498
  minTickGap={30}
499
  height={X_AXIS_HEIGHT}
500
  allowDataOverflow={true}
501
  />
502
  <YAxis
503
  domain={["auto", "auto"]}
504
- stroke="#64748b"
505
- tick={{ fontSize: 12, fill: "#94a3b8" }}
506
  width={Y_AXIS_WIDTH}
507
  allowDataOverflow={true}
508
  tickFormatter={(v: number) => {
 
483
  >
484
  <CartesianGrid
485
  strokeDasharray="3 3"
486
+ stroke="var(--chart-grid)"
487
  strokeOpacity={0.6}
488
  />
489
  <XAxis
 
493
  chartData.at(-1)?.timestamp ?? 0,
494
  ]}
495
  tickFormatter={(v: number) => `${v.toFixed(1)}s`}
496
+ stroke="var(--chart-axis)"
497
+ tick={{ fontSize: 12, fill: "var(--fg-muted)" }}
498
  minTickGap={30}
499
  height={X_AXIS_HEIGHT}
500
  allowDataOverflow={true}
501
  />
502
  <YAxis
503
  domain={["auto", "auto"]}
504
+ stroke="var(--chart-axis)"
505
+ tick={{ fontSize: 12, fill: "var(--fg-muted)" }}
506
  width={Y_AXIS_WIDTH}
507
  allowDataOverflow={true}
508
  tickFormatter={(v: number) => {
src/components/ui.tsx CHANGED
@@ -1,6 +1,7 @@
1
  "use client";
2
 
3
  import React from "react";
 
4
 
5
  /**
6
  * Shared building blocks for the analysis tabs (Statistics, Filtering, Frames, Action Insights), so
@@ -166,3 +167,49 @@ export function EpisodeHeader({
166
  </div>
167
  );
168
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  "use client";
2
 
3
  import React from "react";
4
+ import { setTheme, useTheme } from "@/utils/theme";
5
 
6
  /**
7
  * Shared building blocks for the analysis tabs (Statistics, Filtering, Frames, Action Insights), so
 
167
  </div>
168
  );
169
  }
170
+
171
+ /** Switches between the light and dark theme; the choice is remembered. */
172
+ export function ThemeToggle() {
173
+ const theme = useTheme();
174
+ const next = theme === "dark" ? "light" : "dark";
175
+ return (
176
+ <button
177
+ type="button"
178
+ onClick={() => setTheme(next)}
179
+ title={`Switch to ${next} theme`}
180
+ aria-label={`Switch to ${next} theme`}
181
+ className="flex h-8 w-8 items-center justify-center rounded-md text-fg-muted hover:text-fg hover:bg-fill transition-colors"
182
+ >
183
+ {theme === "dark" ? (
184
+ <svg
185
+ width="15"
186
+ height="15"
187
+ viewBox="0 0 24 24"
188
+ fill="none"
189
+ stroke="currentColor"
190
+ strokeWidth="2"
191
+ strokeLinecap="round"
192
+ strokeLinejoin="round"
193
+ aria-hidden="true"
194
+ >
195
+ <circle cx="12" cy="12" r="4" />
196
+ <path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41" />
197
+ </svg>
198
+ ) : (
199
+ <svg
200
+ width="15"
201
+ height="15"
202
+ viewBox="0 0 24 24"
203
+ fill="none"
204
+ stroke="currentColor"
205
+ strokeWidth="2"
206
+ strokeLinecap="round"
207
+ strokeLinejoin="round"
208
+ aria-hidden="true"
209
+ >
210
+ <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
211
+ </svg>
212
+ )}
213
+ </button>
214
+ );
215
+ }
src/components/urdf-viewer.tsx CHANGED
@@ -29,6 +29,7 @@ import UrdfPlaybackBar from "@/components/urdf-playback-bar";
29
  import { CHART_CONFIG } from "@/utils/constants";
30
  import { getDatasetVersionAndInfo } from "@/utils/versionUtils";
31
  import type { DatasetMetadata } from "@/utils/parquetUtils";
 
32
 
33
  const SERIES_DELIM = CHART_CONFIG.SERIES_NAME_DELIMITER;
34
  const DEG2RAD = Math.PI / 180;
@@ -755,6 +756,8 @@ export default function URDFViewer({
755
  }) {
756
  const { datasetInfo } = data;
757
  const fps = datasetInfo.fps || 30;
 
 
758
  const robotConfig = useMemo(
759
  () => getRobotConfig(datasetInfo.robot_type),
760
  [datasetInfo.robot_type],
@@ -1013,7 +1016,7 @@ export default function URDFViewer({
1013
  toneMappingExposure: 0.9,
1014
  }}
1015
  >
1016
- <color attach="background" args={["#1a2433"]} />
1017
  {/* IBL: procedural studio softboxes give mesh highlights somewhere to
1018
  bounce. Not preset="studio": drei downloads that 1.6 MB HDR from
1019
  raw.githack.com and suspends the canvas until it arrives. */}
@@ -1095,10 +1098,10 @@ export default function URDFViewer({
1095
  args={[10, 10]}
1096
  cellSize={isG1 ? 0.5 : 0.2}
1097
  cellThickness={0.5}
1098
- cellColor="#334155"
1099
  sectionSize={isG1 ? 2 : 1}
1100
  sectionThickness={1}
1101
- sectionColor="#475569"
1102
  fadeDistance={isG1 ? 20 : 10}
1103
  position={[0, 0, 0]}
1104
  />
 
29
  import { CHART_CONFIG } from "@/utils/constants";
30
  import { getDatasetVersionAndInfo } from "@/utils/versionUtils";
31
  import type { DatasetMetadata } from "@/utils/parquetUtils";
32
+ import { useTheme } from "@/utils/theme";
33
 
34
  const SERIES_DELIM = CHART_CONFIG.SERIES_NAME_DELIMITER;
35
  const DEG2RAD = Math.PI / 180;
 
756
  }) {
757
  const { datasetInfo } = data;
758
  const fps = datasetInfo.fps || 30;
759
+ /// Three.js needs real colours, so the scene reads the theme instead of CSS variables.
760
+ const dark = useTheme() === "dark";
761
  const robotConfig = useMemo(
762
  () => getRobotConfig(datasetInfo.robot_type),
763
  [datasetInfo.robot_type],
 
1016
  toneMappingExposure: 0.9,
1017
  }}
1018
  >
1019
+ <color attach="background" args={[dark ? "#141c2e" : "#f3f4f6"]} />
1020
  {/* IBL: procedural studio softboxes give mesh highlights somewhere to
1021
  bounce. Not preset="studio": drei downloads that 1.6 MB HDR from
1022
  raw.githack.com and suspends the canvas until it arrives. */}
 
1098
  args={[10, 10]}
1099
  cellSize={isG1 ? 0.5 : 0.2}
1100
  cellThickness={0.5}
1101
+ cellColor={dark ? "#334155" : "#d1d5db"}
1102
  sectionSize={isG1 ? 2 : 1}
1103
  sectionThickness={1}
1104
+ sectionColor={dark ? "#475569" : "#9ca3af"}
1105
  fadeDistance={isG1 ? 20 : 10}
1106
  position={[0, 0, 0]}
1107
  />
src/utils/theme-init.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /** Shared with utils/theme.ts, which writes the viewer's choice. Kept free of React so the root
2
+ * layout (a server component) can import the script below. */
3
+ export const THEME_STORAGE_KEY = "lerobot-viz-theme";
4
+
5
+ /**
6
+ * Inlined in <head> so the right theme is applied before first paint. Order: the `__theme` query
7
+ * param (HF Spaces passes the Hub's theme to the embedded app that way), then the viewer's own
8
+ * choice, then the OS preference.
9
+ */
10
+ export const THEME_INIT_SCRIPT = `(function(){try{var q=new URLSearchParams(location.search).get("__theme");var s=null;try{s=localStorage.getItem("${THEME_STORAGE_KEY}")}catch(e){}var t=q==="light"||q==="dark"?q:s==="light"||s==="dark"?s:matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";document.documentElement.classList.toggle("dark",t==="dark")}catch(e){}})()`;
src/utils/theme.ts ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client";
2
+
3
+ import { useSyncExternalStore } from "react";
4
+ import { THEME_STORAGE_KEY } from "./theme-init";
5
+
6
+ export type Theme = "light" | "dark";
7
+
8
+ function getTheme(): Theme {
9
+ return document.documentElement.classList.contains("dark") ? "dark" : "light";
10
+ }
11
+
12
+ function subscribe(onChange: () => void): () => void {
13
+ const observer = new MutationObserver(onChange);
14
+ observer.observe(document.documentElement, {
15
+ attributes: true,
16
+ attributeFilter: ["class"],
17
+ });
18
+ return () => observer.disconnect();
19
+ }
20
+
21
+ export function setTheme(theme: Theme) {
22
+ document.documentElement.classList.toggle("dark", theme === "dark");
23
+ try {
24
+ localStorage.setItem(THEME_STORAGE_KEY, theme);
25
+ } catch {
26
+ // Storage blocked (private mode, embedded iframe): the choice lasts for this page only.
27
+ }
28
+ }
29
+
30
+ /** The current theme, for code that needs actual colours (Three.js) rather than CSS variables. */
31
+ export function useTheme(): Theme {
32
+ return useSyncExternalStore(subscribe, getTheme, () => "dark");
33
+ }