mishig HF Staff commited on
Commit
d3c7d9b
·
verified ·
1 Parent(s): 707ca99

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

Browse files
src/app/[org]/[dataset]/[episode]/episode-viewer.tsx CHANGED
@@ -834,32 +834,23 @@ function EpisodeViewerInner({
834
  repoId={datasetInfo.repoId}
835
  episodeId={episodeId}
836
  />
837
- {videosInfo.length > 0 && (
838
- <SimpleVideosPlayer
839
- videosInfo={videosInfo}
840
- onVideosReady={() => setVideosReady(true)}
841
- />
842
- )}
843
- <div className="grounding-intro">
844
- <span className="section-kicker">Grounded VQA</span>
845
- <ul>
846
- <li>
847
- Draw directly on the active video to create visual
848
- questions. Drag for a bounding box, click for a point. The
849
- camera is detected from the video you draw on.
850
- </li>
851
- <li>
852
- Drag on any video to add a bbox question. Click any video to
853
- add a keypoint question. Confirm the popup with <kbd>↵</kbd>
854
- , or cancel with <kbd>Esc</kbd>.
855
- </li>
856
- </ul>
857
- </div>
858
- <PlaybackBar />
859
- <AnnotationsTimeline duration={data.duration} />
860
- <AnnotationsPanel
861
- cameraKeys={videosInfo.map((v) => v.filename)}
862
- />
863
  </div>
864
  )}
865
 
 
834
  repoId={datasetInfo.repoId}
835
  episodeId={episodeId}
836
  />
837
+ <AnnotationsPanel cameraKeys={videosInfo.map((v) => v.filename)}>
838
+ {task && (
839
+ <div className="annotation-task">
840
+ <span className="section-kicker">Task</span>
841
+ <p>{task}</p>
842
+ </div>
843
+ )}
844
+ {videosInfo.length > 0 && (
845
+ <div className="annotation-videos">
846
+ <SimpleVideosPlayer
847
+ videosInfo={videosInfo}
848
+ onVideosReady={() => setVideosReady(true)}
849
+ />
850
+ </div>
851
+ )}
852
+ <AnnotationsTimeline duration={data.duration} />
853
+ </AnnotationsPanel>
 
 
 
 
 
 
 
 
 
854
  </div>
855
  )}
856
 
src/components/annotations-panel.tsx CHANGED
@@ -5,12 +5,8 @@ import "./annotations-skin.css";
5
  /**
6
  * Editor UI for v3.1 language atoms.
7
  *
8
- * Three vertical sections:
9
- * 1. Inline quick-add bar above the timeline (style picker + label + Add).
10
- * 2. Annotations timeline (in `annotations-timeline.tsx`).
11
- * 3. Workspace below the timeline:
12
- * - Left rail: full atom list grouped by style; click to select.
13
- * - Right pane: editor for the selected atom (or empty state).
14
  *
15
  * Bbox / keypoint VQA atoms are still added through the canvas overlay's
16
  * quick-label popup; the inline quick-add covers subtask / plan / memory /
@@ -35,6 +31,7 @@ import {
35
 
36
  interface Props {
37
  cameraKeys: string[];
 
38
  }
39
 
40
  function fmtTime(s: number): string {
@@ -441,7 +438,7 @@ function useJump(): (ts: number) => void {
441
  );
442
  }
443
 
444
- export const AnnotationsPanel: React.FC<Props> = ({ cameraKeys }) => {
445
  const {
446
  atoms,
447
  addAtoms,
@@ -459,7 +456,9 @@ export const AnnotationsPanel: React.FC<Props> = ({ cameraKeys }) => {
459
  selectAtom,
460
  ident,
461
  } = useAnnotations();
462
- const { currentTime } = useTime();
 
 
463
 
464
  // ============ Inline quick-add state ============
465
  const [qaKind, setQaKind] = useState<QuickAddKind>("subtask");
@@ -559,6 +558,46 @@ export const AnnotationsPanel: React.FC<Props> = ({ cameraKeys }) => {
559
  selectedIdx != null && selectedIdx >= 0 && selectedIdx < atoms.length
560
  ? atoms[selectedIdx]
561
  : null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
562
 
563
  // ============ Render ============
564
  return (
@@ -569,15 +608,11 @@ export const AnnotationsPanel: React.FC<Props> = ({ cameraKeys }) => {
569
  Language annotations
570
  {dirty && <span className="dirty-pill">unsaved</span>}
571
  </h3>
572
- <p>
573
- Select an atom from the timeline or list, then edit it in the
574
- inspector.
575
- </p>
576
  </div>
577
  <div className="actionbar-actions">
578
  {!backendEnabled && (
579
  <span className="backend-offline">
580
- backend offline — edits saved to sessionStorage only
581
  </span>
582
  )}
583
  <button
@@ -599,66 +634,88 @@ export const AnnotationsPanel: React.FC<Props> = ({ cameraKeys }) => {
599
 
600
  {exportStatus && <div className="save-status">{exportStatus}</div>}
601
 
602
- <section className="annotation-composer">
603
- <div className="composer-copy">
604
- <span className="section-kicker">Add text annotation</span>
605
- <p>
606
- Adds task phrasing, subtask, plan, memory, speech, or non-spatial
607
- VQA atoms. Task phrasings are saved at episode start.
608
- </p>
609
- </div>
610
- <div className="quick-add">
611
- <span className="ts-pill">
612
- t = {qaDef.atEpisodeStart ? fmtTime(0) : fmtTime(currentTime)}
613
- </span>
614
- <select
615
- value={qaKind}
616
- onChange={(e) => {
617
- setQaKind(e.target.value as QuickAddKind);
618
- setQaValues({});
619
- }}
620
- >
621
- {QUICK_ADD_DEFS.map((d) => (
622
- <option key={d.kind} value={d.kind}>
623
- {d.label}
624
- </option>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
625
  ))}
626
- </select>
627
- {qaDef.fields.map((f, i) => (
628
- <input
629
- key={f.name}
630
- type={f.type === "number" ? "number" : "text"}
631
- placeholder={f.placeholder}
632
- className={f.grow ? "grow" : undefined}
633
- style={f.width ? { width: f.width } : undefined}
634
- value={qaValues[f.name] ?? ""}
635
- onChange={(e) =>
636
- setQaValues((v) => ({ ...v, [f.name]: e.target.value }))
637
- }
638
- onKeyDown={
639
- i === qaDef.fields.length - 1
640
- ? (e) => e.key === "Enter" && handleQuickAdd()
641
- : undefined
642
- }
643
- />
644
- ))}
645
- <button className="add-btn" onClick={handleQuickAdd}>
646
- + Add at frame
647
- </button>
648
  </div>
649
- </section>
650
 
651
  <div className="workspace inspector-workspace">
652
  <div className="rail annotation-list">
653
  <div className="list-head">
654
  <div>
655
- <span className="section-kicker">Annotations</span>
 
 
 
656
  <p>
657
  {atoms.length} {atoms.length === 1 ? "atom" : "atoms"} in this
658
  episode
659
  </p>
660
  </div>
661
- <span className="ts-pill">{fmtTime(currentTime)}</span>
 
 
 
 
 
 
 
662
  </div>
663
  {atoms.length === 0 && (
664
  <div className="rail-empty">
@@ -682,8 +739,8 @@ export const AnnotationsPanel: React.FC<Props> = ({ cameraKeys }) => {
682
  </span>
683
  <span className="rail-column-sub">
684
  {column === "persistent"
685
- ? "language_persistent · broadcast across every frame"
686
- : "language_events · fire on a single frame"}
687
  </span>
688
  </div>
689
  {colGroups.map(({ def, entries }) => (
@@ -693,6 +750,8 @@ export const AnnotationsPanel: React.FC<Props> = ({ cameraKeys }) => {
693
  dotClass={def.dotClass}
694
  entries={entries}
695
  currentTime={currentTime}
 
 
696
  />
697
  ))}
698
  </div>
@@ -711,7 +770,18 @@ export const AnnotationsPanel: React.FC<Props> = ({ cameraKeys }) => {
711
  </div>
712
  ) : (
713
  <AtomEditor
 
714
  atom={selectedAtom}
 
 
 
 
 
 
 
 
 
 
715
  cameraKeys={cameraKeys}
716
  onChange={(updates) => updateAtom(selectedIdx as number, updates)}
717
  onDelete={() => deleteAtom(selectedAtom)}
@@ -732,10 +802,17 @@ const RailGroup: React.FC<{
732
  dotClass: string;
733
  entries: { atom: LanguageAtom; idx: number; label: string }[];
734
  currentTime: number;
735
- }> = ({ title, dotClass, entries, currentTime }) => {
 
 
736
  const { selectedIdx, selectAtom } = useAnnotations();
737
  const jump = useJump();
738
  if (entries.length === 0) return null;
 
 
 
 
 
739
  return (
740
  <div className="rail-group">
741
  <div className="rail-group-head">
@@ -745,23 +822,39 @@ const RailGroup: React.FC<{
745
  </span>
746
  <span className="count">{entries.length}</span>
747
  </div>
748
- {entries.map(({ atom, idx, label }) => {
749
  const sel = idx === selectedIdx;
750
- const active = isActiveAt(atom.timestamp, currentTime);
 
 
 
 
751
  return (
752
- <div
 
753
  key={idx}
 
754
  className={`rail-row ${sel ? "selected" : ""} ${active ? "active-now" : ""}`}
755
  onClick={() => {
756
  selectAtom(idx);
757
  jump(atom.timestamp);
758
  }}
759
  >
760
- <span className="ts">{fmtTime(atom.timestamp)}</span>
 
 
761
  <span className="body">{label}</span>
762
- </div>
 
763
  );
764
  })}
 
 
 
 
 
 
 
765
  </div>
766
  );
767
  };
@@ -772,10 +865,23 @@ const RailGroup: React.FC<{
772
 
773
  const AtomEditor: React.FC<{
774
  atom: LanguageAtom;
 
 
 
 
775
  cameraKeys: string[];
776
  onChange: (updates: Partial<LanguageAtom>) => void;
777
  onDelete: () => void;
778
- }> = ({ atom, cameraKeys, onChange, onDelete }) => {
 
 
 
 
 
 
 
 
 
779
  const jump = useJump();
780
  const { snap } = useAnnotations();
781
  const isSpeech = isSpeechAtom(atom);
@@ -818,13 +924,33 @@ const AtomEditor: React.FC<{
818
  <div className="inspector-title">
819
  <StylePill style={atom.style} />
820
  <div>
821
- <strong>{fmtTime(atom.timestamp)}</strong>
 
 
822
  <span>
823
  {roleLabel} · {cameraLabel}
824
  </span>
825
  </div>
826
  </div>
827
  <div className="right">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
828
  <button
829
  className="icon-btn"
830
  title="Jump to this atom's frame"
@@ -842,11 +968,14 @@ const AtomEditor: React.FC<{
842
  </div>
843
  </div>
844
 
845
- <div className="field">
846
- <label className="field-label">Timestamp (s)</label>
 
 
847
  <div className="ts-row">
848
  <input
849
  type="text"
 
850
  inputMode="decimal"
851
  value={timestampDraft}
852
  onChange={(e) => setTimestampDraft(e.target.value)}
@@ -874,6 +1003,19 @@ const AtomEditor: React.FC<{
874
  snap to frame
875
  </button>
876
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
877
  </div>
878
 
879
  {/* Content / role-specific fields */}
@@ -883,7 +1025,7 @@ const AtomEditor: React.FC<{
883
  atom.style === "memory" ||
884
  atom.style === "interjection") && (
885
  <div className="field">
886
- <label className="field-label">
887
  {atom.style === "subtask"
888
  ? "Subtask"
889
  : atom.style === "task_aug"
@@ -898,12 +1040,14 @@ const AtomEditor: React.FC<{
898
  atom.style === "subtask" ||
899
  atom.style === "interjection" ? (
900
  <textarea
 
901
  rows={3}
902
  value={atom.content || ""}
903
  onChange={(e) => onChange({ content: e.target.value })}
904
  />
905
  ) : (
906
  <textarea
 
907
  rows={4}
908
  value={atom.content || ""}
909
  onChange={(e) => onChange({ content: e.target.value })}
 
5
  /**
6
  * Editor UI for v3.1 language atoms.
7
  *
8
+ * Save actions, synchronized videos and timeline, followed by a collapsible
9
+ * composer and a paired annotation list / inspector.
 
 
 
 
10
  *
11
  * Bbox / keypoint VQA atoms are still added through the canvas overlay's
12
  * quick-label popup; the inline quick-add covers subtask / plan / memory /
 
31
 
32
  interface Props {
33
  cameraKeys: string[];
34
+ children?: React.ReactNode;
35
  }
36
 
37
  function fmtTime(s: number): string {
 
438
  );
439
  }
440
 
441
+ export const AnnotationsPanel: React.FC<Props> = ({ cameraKeys, children }) => {
442
  const {
443
  atoms,
444
  addAtoms,
 
456
  selectAtom,
457
  ident,
458
  } = useAnnotations();
459
+ const { currentTime, duration } = useTime();
460
+ const jump = useJump();
461
+ const [showAll, setShowAll] = useState(false);
462
 
463
  // ============ Inline quick-add state ============
464
  const [qaKind, setQaKind] = useState<QuickAddKind>("subtask");
 
558
  selectedIdx != null && selectedIdx >= 0 && selectedIdx < atoms.length
559
  ? atoms[selectedIdx]
560
  : null;
561
+ const chronological = useMemo(
562
+ () =>
563
+ atoms
564
+ .map((atom, idx) => ({ atom, idx }))
565
+ .sort((a, b) => a.atom.timestamp - b.atom.timestamp),
566
+ [atoms],
567
+ );
568
+ // Numbered like the list and the timeline: by position in its group, not
569
+ // in `atoms`.
570
+ const selectedNumber = groups
571
+ .map(({ entries }) => entries.findIndex(({ idx }) => idx === selectedIdx))
572
+ .find((position) => position >= 0);
573
+ const selectedPosition = chronological.findIndex(
574
+ ({ idx }) => idx === selectedIdx,
575
+ );
576
+ const endTimestamp =
577
+ selectedAtom?.style === "subtask" || selectedAtom?.style === "plan"
578
+ ? (chronological
579
+ .slice(selectedPosition + 1)
580
+ .find(({ atom }) => atom.style === selectedAtom.style)?.atom
581
+ .timestamp ?? duration)
582
+ : undefined;
583
+
584
+ React.useEffect(() => {
585
+ if (selectedIdx != null || chronological.length === 0) return;
586
+ const active = chronological
587
+ .filter(
588
+ ({ atom }) => atom.style === "subtask" && atom.timestamp <= currentTime,
589
+ )
590
+ .at(-1);
591
+ selectAtom((active ?? chronological[0]).idx);
592
+ }, [chronological, currentTime, selectedIdx, selectAtom]);
593
+
594
+ const selectAdjacent = (offset: number) => {
595
+ const entry = chronological[selectedPosition + offset];
596
+ if (entry) {
597
+ selectAtom(entry.idx);
598
+ jump(entry.atom.timestamp);
599
+ }
600
+ };
601
 
602
  // ============ Render ============
603
  return (
 
608
  Language annotations
609
  {dirty && <span className="dirty-pill">unsaved</span>}
610
  </h3>
 
 
 
 
611
  </div>
612
  <div className="actionbar-actions">
613
  {!backendEnabled && (
614
  <span className="backend-offline">
615
+ Local session · Backend not connected
616
  </span>
617
  )}
618
  <button
 
634
 
635
  {exportStatus && <div className="save-status">{exportStatus}</div>}
636
 
637
+ {children}
638
+
639
+ <details className="annotation-composer">
640
+ <summary>Add annotation</summary>
641
+ <div className="composer-content">
642
+ <div className="composer-copy">
643
+ <span className="section-kicker">Add text annotation</span>
644
+ <p>
645
+ Adds task phrasing, subtask, plan, memory, speech, or non-spatial
646
+ VQA atoms. Task phrasings are saved at episode start.
647
+ </p>
648
+ </div>
649
+ <div className="quick-add">
650
+ <span className="ts-pill">
651
+ t = {qaDef.atEpisodeStart ? fmtTime(0) : fmtTime(currentTime)}
652
+ </span>
653
+ <select
654
+ aria-label="Annotation type"
655
+ value={qaKind}
656
+ onChange={(e) => {
657
+ setQaKind(e.target.value as QuickAddKind);
658
+ setQaValues({});
659
+ }}
660
+ >
661
+ {QUICK_ADD_DEFS.map((d) => (
662
+ <option key={d.kind} value={d.kind}>
663
+ {d.label}
664
+ </option>
665
+ ))}
666
+ </select>
667
+ {qaDef.fields.map((f, i) => (
668
+ <input
669
+ key={f.name}
670
+ type={f.type === "number" ? "number" : "text"}
671
+ placeholder={f.placeholder}
672
+ aria-label={f.placeholder}
673
+ className={f.grow ? "grow" : undefined}
674
+ style={f.width ? { width: f.width } : undefined}
675
+ value={qaValues[f.name] ?? ""}
676
+ onChange={(e) =>
677
+ setQaValues((v) => ({ ...v, [f.name]: e.target.value }))
678
+ }
679
+ onKeyDown={
680
+ i === qaDef.fields.length - 1
681
+ ? (e) => e.key === "Enter" && handleQuickAdd()
682
+ : undefined
683
+ }
684
+ />
685
  ))}
686
+ <button className="add-btn" onClick={handleQuickAdd}>
687
+ + Add at frame
688
+ </button>
689
+ </div>
690
+ <p className="drawing-hint">
691
+ For visual questions, drag on a video to draw a box or click to
692
+ place a point. Confirm with <kbd>↵</kbd> or cancel with{" "}
693
+ <kbd>Esc</kbd>.
694
+ </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
695
  </div>
696
+ </details>
697
 
698
  <div className="workspace inspector-workspace">
699
  <div className="rail annotation-list">
700
  <div className="list-head">
701
  <div>
702
+ <h3>
703
+ Annotations{" "}
704
+ <span className="annotation-count">{atoms.length}</span>
705
+ </h3>
706
  <p>
707
  {atoms.length} {atoms.length === 1 ? "atom" : "atoms"} in this
708
  episode
709
  </p>
710
  </div>
711
+ <button
712
+ type="button"
713
+ className="btn"
714
+ onClick={() => setShowAll(!showAll)}
715
+ aria-pressed={showAll}
716
+ >
717
+ {showAll ? "Near selection" : "Show all"}
718
+ </button>
719
  </div>
720
  {atoms.length === 0 && (
721
  <div className="rail-empty">
 
739
  </span>
740
  <span className="rail-column-sub">
741
  {column === "persistent"
742
+ ? "Active across frames"
743
+ : "At a single frame"}
744
  </span>
745
  </div>
746
  {colGroups.map(({ def, entries }) => (
 
750
  dotClass={def.dotClass}
751
  entries={entries}
752
  currentTime={currentTime}
753
+ showAll={showAll}
754
+ persistent={column === "persistent"}
755
  />
756
  ))}
757
  </div>
 
770
  </div>
771
  ) : (
772
  <AtomEditor
773
+ key={selectedIdx}
774
  atom={selectedAtom}
775
+ number={selectedNumber}
776
+ endTimestamp={endTimestamp}
777
+ onPrevious={
778
+ selectedPosition > 0 ? () => selectAdjacent(-1) : undefined
779
+ }
780
+ onNext={
781
+ selectedPosition < chronological.length - 1
782
+ ? () => selectAdjacent(1)
783
+ : undefined
784
+ }
785
  cameraKeys={cameraKeys}
786
  onChange={(updates) => updateAtom(selectedIdx as number, updates)}
787
  onDelete={() => deleteAtom(selectedAtom)}
 
802
  dotClass: string;
803
  entries: { atom: LanguageAtom; idx: number; label: string }[];
804
  currentTime: number;
805
+ showAll: boolean;
806
+ persistent: boolean;
807
+ }> = ({ title, dotClass, entries, currentTime, showAll, persistent }) => {
808
  const { selectedIdx, selectAtom } = useAnnotations();
809
  const jump = useJump();
810
  if (entries.length === 0) return null;
811
+ const selected = entries.findIndex(({ idx }) => idx === selectedIdx);
812
+ const start = showAll
813
+ ? 0
814
+ : Math.max(0, Math.min(entries.length - 5, selected - 2));
815
+ const visible = showAll ? entries : entries.slice(start, start + 5);
816
  return (
817
  <div className="rail-group">
818
  <div className="rail-group-head">
 
822
  </span>
823
  <span className="count">{entries.length}</span>
824
  </div>
825
+ {visible.map(({ atom, idx, label }, position) => {
826
  const sel = idx === selectedIdx;
827
+ const nextTime =
828
+ entries[start + position + 1]?.atom.timestamp ?? Infinity;
829
+ const active = persistent
830
+ ? atom.timestamp <= currentTime && currentTime < nextTime
831
+ : isActiveAt(atom.timestamp, currentTime);
832
  return (
833
+ <button
834
+ type="button"
835
  key={idx}
836
+ aria-pressed={sel}
837
  className={`rail-row ${sel ? "selected" : ""} ${active ? "active-now" : ""}`}
838
  onClick={() => {
839
  selectAtom(idx);
840
  jump(atom.timestamp);
841
  }}
842
  >
843
+ <span className="annotation-index">
844
+ {String(start + position).padStart(2, "0")}
845
+ </span>
846
  <span className="body">{label}</span>
847
+ <span className="ts">{fmtTime(atom.timestamp)}</span>
848
+ </button>
849
  );
850
  })}
851
+ {!showAll && entries.length > 5 && (
852
+ <div className="rail-range">
853
+ {String(start).padStart(2, "0")}–
854
+ {String(start + visible.length - 1).padStart(2, "0")} of{" "}
855
+ {entries.length}
856
+ </div>
857
+ )}
858
  </div>
859
  );
860
  };
 
865
 
866
  const AtomEditor: React.FC<{
867
  atom: LanguageAtom;
868
+ number?: number;
869
+ endTimestamp?: number;
870
+ onPrevious?: () => void;
871
+ onNext?: () => void;
872
  cameraKeys: string[];
873
  onChange: (updates: Partial<LanguageAtom>) => void;
874
  onDelete: () => void;
875
+ }> = ({
876
+ atom,
877
+ number,
878
+ endTimestamp,
879
+ onPrevious,
880
+ onNext,
881
+ cameraKeys,
882
+ onChange,
883
+ onDelete,
884
+ }) => {
885
  const jump = useJump();
886
  const { snap } = useAnnotations();
887
  const isSpeech = isSpeechAtom(atom);
 
924
  <div className="inspector-title">
925
  <StylePill style={atom.style} />
926
  <div>
927
+ {number != null && (
928
+ <strong>#{String(number).padStart(2, "0")}</strong>
929
+ )}
930
  <span>
931
  {roleLabel} · {cameraLabel}
932
  </span>
933
  </div>
934
  </div>
935
  <div className="right">
936
+ <button
937
+ type="button"
938
+ className="icon-btn"
939
+ aria-label="Previous annotation"
940
+ disabled={!onPrevious}
941
+ onClick={onPrevious}
942
+ >
943
+ ‹
944
+ </button>
945
+ <button
946
+ type="button"
947
+ className="icon-btn"
948
+ aria-label="Next annotation"
949
+ disabled={!onNext}
950
+ onClick={onNext}
951
+ >
952
+ ›
953
+ </button>
954
  <button
955
  className="icon-btn"
956
  title="Jump to this atom's frame"
 
968
  </div>
969
  </div>
970
 
971
+ <div className="field timestamp-field">
972
+ <label className="field-label" htmlFor="annotation-timestamp">
973
+ Starts at (s)
974
+ </label>
975
  <div className="ts-row">
976
  <input
977
  type="text"
978
+ id="annotation-timestamp"
979
  inputMode="decimal"
980
  value={timestampDraft}
981
  onChange={(e) => setTimestampDraft(e.target.value)}
 
1003
  snap to frame
1004
  </button>
1005
  </div>
1006
+ {endTimestamp != null && (
1007
+ <div className="annotation-duration">
1008
+ <span>
1009
+ Until next {atom.style}: <strong>{fmtTime(endTimestamp)}</strong>
1010
+ </span>
1011
+ <span>
1012
+ Duration:{" "}
1013
+ <strong>
1014
+ {Math.max(0, endTimestamp - atom.timestamp).toFixed(2)}s
1015
+ </strong>
1016
+ </span>
1017
+ </div>
1018
+ )}
1019
  </div>
1020
 
1021
  {/* Content / role-specific fields */}
 
1025
  atom.style === "memory" ||
1026
  atom.style === "interjection") && (
1027
  <div className="field">
1028
+ <label className="field-label" htmlFor="annotation-content">
1029
  {atom.style === "subtask"
1030
  ? "Subtask"
1031
  : atom.style === "task_aug"
 
1040
  atom.style === "subtask" ||
1041
  atom.style === "interjection" ? (
1042
  <textarea
1043
+ id="annotation-content"
1044
  rows={3}
1045
  value={atom.content || ""}
1046
  onChange={(e) => onChange({ content: e.target.value })}
1047
  />
1048
  ) : (
1049
  <textarea
1050
+ id="annotation-content"
1051
  rows={4}
1052
  value={atom.content || ""}
1053
  onChange={(e) => onChange({ content: e.target.value })}
src/components/annotations-skin.css CHANGED
@@ -1,11 +1,4 @@
1
- /* ==========================================================================
2
- Annotations tab — dark-mode skin scoped under .annotations-skin.
3
- Borrows the *functional* patterns from the Claude Design handoff
4
- (per-style pill colors, row layout, timeline shapes) but recolored to
5
- match the visualizer's existing dark theme. The complaint we're fixing
6
- here is contrast — earlier inputs were near-black on near-black; these
7
- are still dark but legible.
8
- ========================================================================== */
9
 
10
  .annotations-skin {
11
  /* Brand accents (kept bright; visible on dark) */
@@ -17,20 +10,17 @@
17
  --hf-green: #34d399;
18
  --hf-purple: #b78bff;
19
 
20
- /* Dark surface scale */
21
- --surface-0: rgba(255, 255, 255, 0.02);
22
- --surface-1: rgba(255, 255, 255, 0.06);
23
- --surface-2: rgba(255, 255, 255, 0.1);
24
- --border-1: rgba(255, 255, 255, 0.12);
25
- --border-2: rgba(255, 255, 255, 0.2);
26
- --fg-1: #f1f5f9;
27
- --fg-2: #cbd5e1;
28
- --fg-3: #94a3b8;
29
 
30
  --radius-xs: 4px;
31
  --radius-sm: 6px;
32
  --radius-md: 8px;
33
- --radius-lg: 12px;
34
  }
35
 
36
  /* All form controls in the annotations area: brighter than the rest of the
@@ -81,8 +71,8 @@
81
  text-transform: uppercase;
82
  letter-spacing: 0.04em;
83
  padding: 2px 8px;
84
- border-radius: 999px;
85
- border: 1px solid currentColor;
86
  }
87
  .annotations-skin .style-pill.subtask {
88
  color: var(--hf-yellow);
@@ -267,7 +257,8 @@
267
  align-items: center;
268
  justify-content: space-between;
269
  gap: 16px;
270
- padding: 12px 14px;
 
271
  }
272
  .annotations-skin .annotation-actionbar h3 {
273
  display: flex;
@@ -293,10 +284,10 @@
293
  justify-content: flex-end;
294
  }
295
  .annotations-skin .dirty-pill {
296
- border: 1px solid rgba(251, 146, 60, 0.35);
297
  border-radius: 999px;
298
- background: rgba(251, 146, 60, 0.12);
299
- color: #fdba74;
300
  font-size: 10px;
301
  font-weight: 700;
302
  letter-spacing: 0.04em;
@@ -317,11 +308,48 @@
317
  text-transform: uppercase;
318
  }
319
  .annotations-skin .annotation-composer {
 
 
 
 
 
 
 
 
 
320
  display: grid;
321
- grid-template-columns: minmax(180px, 260px) 1fr;
322
  gap: 12px;
323
- padding: 12px;
324
- align-items: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  }
326
  .annotations-skin .camera-picker {
327
  display: flex;
@@ -337,17 +365,28 @@
337
  background: var(--surface-0);
338
  border: 1px solid var(--border-1);
339
  border-radius: var(--radius-lg);
340
- padding: 10px 12px;
 
341
  }
342
  .annotations-skin .tl-head {
343
  display: flex;
344
  align-items: center;
345
  justify-content: space-between;
346
- font-size: 11px;
 
 
 
 
 
 
 
 
 
 
 
347
  color: var(--fg-3);
348
- text-transform: uppercase;
349
- letter-spacing: 0.04em;
350
- margin-bottom: 8px;
351
  }
352
  .annotations-skin .tl-head .ts-display {
353
  font-family: var(--font-mono);
@@ -360,15 +399,14 @@
360
  display: flex;
361
  align-items: center;
362
  gap: 10px;
363
- height: 24px;
364
- margin-bottom: 4px;
365
  }
366
  .annotations-skin .tl-row .label {
367
  width: 84px;
368
  flex: none;
369
  font-size: 10.5px;
370
- text-transform: uppercase;
371
- letter-spacing: 0.04em;
372
  color: var(--fg-2);
373
  font-weight: 600;
374
  display: flex;
@@ -378,26 +416,27 @@
378
  .annotations-skin .tl-row .track {
379
  position: relative;
380
  flex: 1;
381
- height: 20px;
 
382
  background: var(--surface-1);
383
- border: 1px solid var(--border-1);
384
- border-radius: 3px;
385
  }
386
  .annotations-skin .tl-seg {
387
  position: absolute;
388
- top: 1px;
389
- bottom: 1px;
390
- border-radius: 2px;
391
- font-size: 10px;
392
- line-height: 16px;
393
- padding: 0 6px;
394
  cursor: pointer;
395
  overflow: hidden;
396
  text-overflow: ellipsis;
397
  white-space: nowrap;
398
  display: flex;
399
- align-items: center;
400
- gap: 4px;
401
  user-select: none;
402
  font-weight: 500;
403
  }
@@ -407,9 +446,26 @@
407
  color: #bae6fd;
408
  }
409
  .annotations-skin .tl-seg.subtask {
410
- background: rgba(255, 210, 30, 0.25);
411
- border: 1px solid var(--hf-yellow);
 
 
 
 
 
 
 
412
  color: var(--hf-yellow);
 
 
 
 
 
 
 
 
 
 
413
  }
414
  .annotations-skin .tl-seg.plan {
415
  background: rgba(91, 140, 255, 0.25);
@@ -470,20 +526,97 @@
470
  }
471
  .annotations-skin .tl-ruler {
472
  position: relative;
473
- height: 16px;
474
  margin-left: 94px;
475
- border-bottom: 1px solid var(--border-1);
476
- margin-bottom: 6px;
477
  }
478
  .annotations-skin .tl-ruler .tick-mark {
479
  position: absolute;
480
  top: 0;
481
  bottom: 0;
482
- border-left: 1px solid var(--border-1);
483
  font-family: var(--font-mono);
484
  font-size: 10px;
485
  color: var(--fg-3);
486
- padding-left: 3px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  }
488
 
489
  /* ----- Persistent / Events section banding (timeline + rail) ----- */
@@ -497,7 +630,7 @@
497
  gap: 8px;
498
  padding: 4px 0 4px 2px;
499
  margin-bottom: 4px;
500
- border-left: 3px solid var(--border-2, #2a3344);
501
  padding-left: 8px;
502
  }
503
  .annotations-skin .tl-section-head.persistent,
@@ -519,7 +652,6 @@
519
  .annotations-skin .tl-section-sub,
520
  .annotations-skin .rail-column-sub {
521
  font-size: 10px;
522
- font-family: var(--font-mono);
523
  color: var(--fg-3);
524
  }
525
  .annotations-skin .rail-column {
@@ -533,7 +665,7 @@
533
  .annotations-skin .quick-popup {
534
  position: absolute;
535
  z-index: 30;
536
- background: rgba(15, 23, 42, 0.96);
537
  border: 1px solid var(--border-2);
538
  border-radius: var(--radius-md);
539
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
@@ -654,12 +786,12 @@
654
 
655
  /* ----- Workspace: annotation list + inspector ----- */
656
  .annotations-skin .workspace.inspector-workspace {
657
- grid-template-columns: minmax(300px, 34%) minmax(0, 1fr);
658
- gap: 12px;
659
  }
660
  .annotations-skin .rail.annotation-list {
661
  padding: 0;
662
- max-height: min(60vh, 560px);
663
  overflow-y: auto;
664
  overscroll-behavior: contain;
665
  }
@@ -673,15 +805,25 @@
673
  position: sticky;
674
  top: 0;
675
  z-index: 2;
676
- background: rgba(15, 23, 42, 0.96);
677
- backdrop-filter: blur(6px);
 
 
 
 
 
 
 
 
 
 
678
  }
679
  .annotations-skin .rail.annotation-list .rail-group {
680
- margin: 8px;
681
  }
682
  .annotations-skin .rail.annotation-list .rail-row {
683
  align-items: flex-start;
684
- padding: 7px 8px;
685
  }
686
  .annotations-skin .rail.annotation-list .rail-row .body {
687
  white-space: normal;
@@ -694,12 +836,11 @@
694
  box-shadow: inset 3px 0 0 var(--accent);
695
  }
696
  .annotations-skin .rail.annotation-list .rail-row.active-now:not(.selected) {
697
- border-color: var(--playhead-glow);
698
  outline: none;
699
  }
700
  .annotations-skin .inspector {
701
- position: sticky;
702
- top: 8px;
703
  }
704
  .annotations-skin .inspector .editor-empty {
705
  min-height: 220px;
@@ -714,7 +855,26 @@
714
  .annotations-skin .inspector-body {
715
  display: flex;
716
  flex-direction: column;
717
- gap: 10px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
718
  }
719
  .annotations-skin .inspector-head {
720
  align-items: flex-start;
@@ -838,13 +998,29 @@
838
  .annotations-skin .rail-row {
839
  display: flex;
840
  align-items: center;
841
- gap: 6px;
 
 
 
842
  padding: 5px 8px;
843
- border-radius: var(--radius-sm);
844
  cursor: pointer;
845
  font-size: 12px;
846
  color: var(--fg-1);
847
- border: 1px solid transparent;
 
 
 
 
 
 
 
 
 
 
 
 
 
848
  }
849
  .annotations-skin .rail-row:hover {
850
  background: var(--surface-1);
@@ -998,7 +1174,7 @@
998
  width: 14px;
999
  height: 14px;
1000
  background: var(--playhead);
1001
- border: 2px solid #0b0e14;
1002
  border-radius: 999px;
1003
  transform: translate(-7px, 0);
1004
  cursor: ew-resize;
@@ -1008,7 +1184,7 @@
1008
  .annotations-skin .tl-tooltip {
1009
  position: fixed;
1010
  z-index: 1000;
1011
- background: rgba(15, 23, 42, 0.96);
1012
  color: var(--fg-1);
1013
  border: 1px solid var(--border-2);
1014
  border-radius: var(--radius-sm);
@@ -1048,25 +1224,16 @@
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,
 
1
+ /* Annotation roles have their own colours; UI chrome inherits the app theme. */
 
 
 
 
 
 
 
2
 
3
  .annotations-skin {
4
  /* Brand accents (kept bright; visible on dark) */
 
10
  --hf-green: #34d399;
11
  --hf-purple: #b78bff;
12
 
13
+ --border-1: var(--line);
14
+ --border-2: var(--line-strong);
15
+ --fg-1: var(--fg);
16
+ --fg-2: var(--fg-soft);
17
+ --fg-3: var(--fg-muted);
18
+ min-width: 0;
 
 
 
19
 
20
  --radius-xs: 4px;
21
  --radius-sm: 6px;
22
  --radius-md: 8px;
23
+ --radius-lg: 8px;
24
  }
25
 
26
  /* All form controls in the annotations area: brighter than the rest of the
 
71
  text-transform: uppercase;
72
  letter-spacing: 0.04em;
73
  padding: 2px 8px;
74
+ border-radius: var(--radius-xs);
75
+ border: 1px solid transparent;
76
  }
77
  .annotations-skin .style-pill.subtask {
78
  color: var(--hf-yellow);
 
257
  align-items: center;
258
  justify-content: space-between;
259
  gap: 16px;
260
+ padding: 0;
261
+ border: 0;
262
  }
263
  .annotations-skin .annotation-actionbar h3 {
264
  display: flex;
 
284
  justify-content: flex-end;
285
  }
286
  .annotations-skin .dirty-pill {
287
+ border: 1px solid var(--accent-ring);
288
  border-radius: 999px;
289
+ background: var(--accent-soft);
290
+ color: var(--accent-fg);
291
  font-size: 10px;
292
  font-weight: 700;
293
  letter-spacing: 0.04em;
 
308
  text-transform: uppercase;
309
  }
310
  .annotations-skin .annotation-composer {
311
+ padding: 10px 14px;
312
+ font-size: 12px;
313
+ }
314
+ .annotations-skin .annotation-composer summary {
315
+ cursor: pointer;
316
+ color: var(--fg-2);
317
+ font-weight: 600;
318
+ }
319
+ .annotations-skin .composer-content {
320
  display: grid;
 
321
  gap: 12px;
322
+ margin-top: 12px;
323
+ }
324
+ .annotations-skin .drawing-hint {
325
+ color: var(--fg-3);
326
+ }
327
+ .annotations-skin .annotation-task {
328
+ display: flex;
329
+ align-items: baseline;
330
+ gap: 12px;
331
+ padding: 10px 14px;
332
+ border: 1px solid var(--border-1);
333
+ border-radius: var(--radius-md);
334
+ }
335
+ .annotations-skin .annotation-task p {
336
+ margin: 0;
337
+ font-size: 13px;
338
+ white-space: pre-line;
339
+ }
340
+ .annotations-skin .annotation-videos > .flex {
341
+ display: grid;
342
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
343
+ gap: 12px;
344
+ }
345
+ .annotations-skin .annotation-videos > .flex > :not(.fixed) {
346
+ max-width: none;
347
+ min-width: 0;
348
+ }
349
+ .annotations-skin .annotation-videos > .flex > :not(.fixed) video {
350
+ aspect-ratio: 4 / 3;
351
+ max-height: 260px;
352
+ background: var(--surface-2);
353
  }
354
  .annotations-skin .camera-picker {
355
  display: flex;
 
365
  background: var(--surface-0);
366
  border: 1px solid var(--border-1);
367
  border-radius: var(--radius-lg);
368
+ padding: 0 16px;
369
+ overflow: hidden;
370
  }
371
  .annotations-skin .tl-head {
372
  display: flex;
373
  align-items: center;
374
  justify-content: space-between;
375
+ gap: 12px;
376
+ padding: 12px 0;
377
+ flex-wrap: wrap;
378
+ }
379
+ .annotations-skin .tl-head h3 {
380
+ font-size: 14px;
381
+ font-weight: 600;
382
+ color: var(--fg-1);
383
+ margin: 0;
384
+ }
385
+ .annotations-skin .tl-head h3 span {
386
+ margin-left: 8px;
387
  color: var(--fg-3);
388
+ font-size: 12px;
389
+ font-weight: 400;
 
390
  }
391
  .annotations-skin .tl-head .ts-display {
392
  font-family: var(--font-mono);
 
399
  display: flex;
400
  align-items: center;
401
  gap: 10px;
402
+ min-height: 48px;
403
+ margin-bottom: 8px;
404
  }
405
  .annotations-skin .tl-row .label {
406
  width: 84px;
407
  flex: none;
408
  font-size: 10.5px;
409
+ text-transform: capitalize;
 
410
  color: var(--fg-2);
411
  font-weight: 600;
412
  display: flex;
 
416
  .annotations-skin .tl-row .track {
417
  position: relative;
418
  flex: 1;
419
+ min-width: 0;
420
+ height: 48px;
421
  background: var(--surface-1);
422
+ border-radius: var(--radius-xs);
423
+ touch-action: none;
424
  }
425
  .annotations-skin .tl-seg {
426
  position: absolute;
427
+ top: 3px;
428
+ bottom: 3px;
429
+ border-radius: var(--radius-xs);
430
+ font-size: 12px;
431
+ line-height: 1.35;
432
+ padding: 6px 8px;
433
  cursor: pointer;
434
  overflow: hidden;
435
  text-overflow: ellipsis;
436
  white-space: nowrap;
437
  display: flex;
438
+ align-items: flex-start;
439
+ gap: 6px;
440
  user-select: none;
441
  font-weight: 500;
442
  }
 
446
  color: #bae6fd;
447
  }
448
  .annotations-skin .tl-seg.subtask {
449
+ background: rgba(255, 210, 30, 0.16);
450
+ border: 1px solid color-mix(in srgb, var(--hf-yellow) 30%, transparent);
451
+ color: var(--fg-1);
452
+ }
453
+ .annotations-skin .tl-seg.selected {
454
+ outline: 2px solid var(--accent);
455
+ outline-offset: -2px;
456
+ }
457
+ .annotations-skin .tl-seg-number {
458
  color: var(--hf-yellow);
459
+ font-family: var(--font-mono);
460
+ font-size: 10px;
461
+ flex: none;
462
+ }
463
+ .annotations-skin .tl-seg-label {
464
+ white-space: normal;
465
+ overflow: hidden;
466
+ display: -webkit-box;
467
+ -webkit-box-orient: vertical;
468
+ -webkit-line-clamp: 2;
469
  }
470
  .annotations-skin .tl-seg.plan {
471
  background: rgba(91, 140, 255, 0.25);
 
526
  }
527
  .annotations-skin .tl-ruler {
528
  position: relative;
529
+ height: 22px;
530
  margin-left: 94px;
531
+ margin-top: 12px;
532
+ margin-bottom: 4px;
533
  }
534
  .annotations-skin .tl-ruler .tick-mark {
535
  position: absolute;
536
  top: 0;
537
  bottom: 0;
 
538
  font-family: var(--font-mono);
539
  font-size: 10px;
540
  color: var(--fg-3);
541
+ transform: translateX(-50%);
542
+ }
543
+ .annotations-skin .tl-transport {
544
+ margin: 0 -16px 12px;
545
+ background: var(--surface-1);
546
+ border-block: 1px solid var(--border-1);
547
+ }
548
+ .annotations-skin .tl-transport > div {
549
+ position: static;
550
+ margin: 0;
551
+ max-width: none;
552
+ border: 0;
553
+ border-radius: 0;
554
+ background: transparent;
555
+ backdrop-filter: none;
556
+ }
557
+ .annotations-skin .tl-overview-head {
558
+ display: flex;
559
+ justify-content: space-between;
560
+ flex-wrap: wrap;
561
+ gap: 8px;
562
+ margin-bottom: 6px;
563
+ color: var(--fg-3);
564
+ font-size: 11px;
565
+ }
566
+ .annotations-skin .ts-display {
567
+ font-family: var(--font-mono);
568
+ font-variant-numeric: tabular-nums;
569
+ }
570
+ .annotations-skin .tl-overview {
571
+ position: relative;
572
+ height: 22px;
573
+ background: var(--surface-1);
574
+ border-radius: var(--radius-xs);
575
+ cursor: pointer;
576
+ }
577
+ .annotations-skin .tl-overview button {
578
+ position: absolute;
579
+ top: 4px;
580
+ bottom: 4px;
581
+ padding: 0;
582
+ background: rgba(255, 210, 30, 0.2);
583
+ border: 0;
584
+ border-radius: 2px;
585
+ cursor: pointer;
586
+ }
587
+ .annotations-skin .tl-overview button[aria-pressed="true"] {
588
+ background: var(--hf-yellow);
589
+ }
590
+ .annotations-skin .tl-overview-window {
591
+ position: absolute;
592
+ inset-block: 0;
593
+ border: 1px solid var(--fg-3);
594
+ border-radius: var(--radius-xs);
595
+ pointer-events: none;
596
+ }
597
+ .annotations-skin .tl-overview-cursor {
598
+ position: absolute;
599
+ inset-block: 0;
600
+ width: 1px;
601
+ background: var(--playhead);
602
+ pointer-events: none;
603
+ }
604
+ .annotations-skin .tl-footer {
605
+ display: flex;
606
+ align-items: center;
607
+ justify-content: space-between;
608
+ flex-wrap: wrap;
609
+ gap: 8px;
610
+ margin: 12px -16px 0;
611
+ padding: 8px 16px;
612
+ border-top: 1px solid var(--border-1);
613
+ font-size: 11px;
614
+ color: var(--fg-3);
615
+ }
616
+ .annotations-skin .tl-footer .btn {
617
+ background: transparent;
618
+ border-color: transparent;
619
+ padding-left: 0;
620
  }
621
 
622
  /* ----- Persistent / Events section banding (timeline + rail) ----- */
 
630
  gap: 8px;
631
  padding: 4px 0 4px 2px;
632
  margin-bottom: 4px;
633
+ border-left: 0;
634
  padding-left: 8px;
635
  }
636
  .annotations-skin .tl-section-head.persistent,
 
652
  .annotations-skin .tl-section-sub,
653
  .annotations-skin .rail-column-sub {
654
  font-size: 10px;
 
655
  color: var(--fg-3);
656
  }
657
  .annotations-skin .rail-column {
 
665
  .annotations-skin .quick-popup {
666
  position: absolute;
667
  z-index: 30;
668
+ background: var(--surface-0);
669
  border: 1px solid var(--border-2);
670
  border-radius: var(--radius-md);
671
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
 
786
 
787
  /* ----- Workspace: annotation list + inspector ----- */
788
  .annotations-skin .workspace.inspector-workspace {
789
+ grid-template-columns: repeat(2, minmax(0, 1fr));
790
+ gap: 16px;
791
  }
792
  .annotations-skin .rail.annotation-list {
793
  padding: 0;
794
+ max-height: 560px;
795
  overflow-y: auto;
796
  overscroll-behavior: contain;
797
  }
 
805
  position: sticky;
806
  top: 0;
807
  z-index: 2;
808
+ background: var(--surface-0);
809
+ }
810
+ .annotations-skin .list-head h3 {
811
+ margin: 0;
812
+ font-size: 14px;
813
+ font-weight: 600;
814
+ }
815
+ .annotations-skin .annotation-count {
816
+ color: var(--fg-3);
817
+ font-size: 12px;
818
+ font-weight: 400;
819
+ margin-left: 6px;
820
  }
821
  .annotations-skin .rail.annotation-list .rail-group {
822
+ margin: 0;
823
  }
824
  .annotations-skin .rail.annotation-list .rail-row {
825
  align-items: flex-start;
826
+ padding: 12px;
827
  }
828
  .annotations-skin .rail.annotation-list .rail-row .body {
829
  white-space: normal;
 
836
  box-shadow: inset 3px 0 0 var(--accent);
837
  }
838
  .annotations-skin .rail.annotation-list .rail-row.active-now:not(.selected) {
839
+ background: var(--fill);
840
  outline: none;
841
  }
842
  .annotations-skin .inspector {
843
+ min-width: 0;
 
844
  }
845
  .annotations-skin .inspector .editor-empty {
846
  min-height: 220px;
 
855
  .annotations-skin .inspector-body {
856
  display: flex;
857
  flex-direction: column;
858
+ gap: 12px;
859
+ }
860
+ .annotations-skin .timestamp-field {
861
+ order: 1;
862
+ }
863
+ .annotations-skin .annotation-duration {
864
+ display: flex;
865
+ justify-content: space-between;
866
+ flex-wrap: wrap;
867
+ gap: 8px;
868
+ margin-top: 16px;
869
+ padding-top: 12px;
870
+ border-top: 1px solid var(--border-1);
871
+ font-size: 11px;
872
+ color: var(--fg-3);
873
+ }
874
+ .annotations-skin .annotation-duration strong {
875
+ font-family: var(--font-mono);
876
+ font-weight: 400;
877
+ color: var(--fg-2);
878
  }
879
  .annotations-skin .inspector-head {
880
  align-items: flex-start;
 
998
  .annotations-skin .rail-row {
999
  display: flex;
1000
  align-items: center;
1001
+ gap: 10px;
1002
+ width: 100%;
1003
+ text-align: left;
1004
+ background: transparent;
1005
  padding: 5px 8px;
1006
+ border-radius: 0;
1007
  cursor: pointer;
1008
  font-size: 12px;
1009
  color: var(--fg-1);
1010
+ border: 0;
1011
+ border-bottom: 1px solid var(--border-1);
1012
+ }
1013
+ .annotations-skin .annotation-index {
1014
+ font-family: var(--font-mono);
1015
+ font-size: 10px;
1016
+ color: var(--fg-3);
1017
+ min-width: 22px;
1018
+ }
1019
+ .annotations-skin .rail-range {
1020
+ padding: 8px 12px;
1021
+ font-size: 11px;
1022
+ color: var(--fg-3);
1023
+ background: var(--surface-1);
1024
  }
1025
  .annotations-skin .rail-row:hover {
1026
  background: var(--surface-1);
 
1174
  width: 14px;
1175
  height: 14px;
1176
  background: var(--playhead);
1177
+ border: 2px solid var(--surface-0);
1178
  border-radius: 999px;
1179
  transform: translate(-7px, 0);
1180
  cursor: ew-resize;
 
1184
  .annotations-skin .tl-tooltip {
1185
  position: fixed;
1186
  z-index: 1000;
1187
+ background: var(--surface-0);
1188
  color: var(--fg-1);
1189
  border: 1px solid var(--border-2);
1190
  border-radius: var(--radius-sm);
 
1224
  dark-on-light and deepen the role colours, which also serve as text (pills,
1225
  segment labels, section markers). */
1226
  :root:not(.dark) .annotations-skin {
1227
+ --hf-yellow: #836500;
1228
  --hf-orange: #c2410c;
1229
  --hf-blue: #2563eb;
1230
  --hf-cyan: #0284c7;
1231
  --hf-red: #dc2626;
1232
  --hf-green: #059669;
1233
  --hf-purple: #7c3aed;
 
 
 
 
 
 
 
 
 
1234
  }
1235
  :root:not(.dark) .annotations-skin .dirty-pill {
1236
+ color: var(--accent-fg);
1237
  }
1238
  :root:not(.dark) .annotations-skin .tl-seg.task_aug,
1239
  :root:not(.dark) .annotations-skin .tl-seg.plan,
src/components/annotations-timeline.tsx CHANGED
@@ -6,7 +6,7 @@
6
  * sections that mirror the two language columns:
7
  *
8
  * PERSISTENT (language_persistent — broadcast across every frame):
9
- * - task_aug: task phrasings shown as point-in-time ticks at episode start.
10
  * - subtask: filled spans from each emit time until the next subtask emit
11
  * (or episode end). Numbered. Resizable edges; the empty subtask track
12
  * also accepts drag-to-create.
@@ -35,6 +35,12 @@
35
  import React, { useEffect, useMemo, useRef, useState } from "react";
36
  import { useTime } from "../context/time-context";
37
  import { useAnnotations } from "../context/annotations-context";
 
 
 
 
 
 
38
  import {
39
  classifyVqa,
40
  isSpeechAtom,
@@ -52,7 +58,7 @@ const TRACK_GROUPS = [
52
  {
53
  column: "persistent",
54
  title: "Persistent",
55
- sub: "language_persistent · broadcast across every frame",
56
  tracks: [
57
  // task_aug applies to the whole episode (it's a rephrasing of the task,
58
  // stored at t0 but persistent across every frame), so it reads as a
@@ -78,7 +84,7 @@ const TRACK_GROUPS = [
78
  {
79
  column: "events",
80
  title: "Events",
81
- sub: "language_events · fire on a single frame",
82
  tracks: [
83
  {
84
  key: "interjection",
@@ -125,7 +131,8 @@ interface PendingCreate {
125
  }
126
 
127
  export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
128
- const { atoms, addAtom, updateAtom, snap, selectAtom } = useAnnotations();
 
129
  const { currentTime, seek, setIsPlaying } = useTime();
130
  const trackBandRef = useRef<HTMLDivElement | null>(null);
131
 
@@ -135,6 +142,24 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
135
  null,
136
  );
137
  const [createLabel, setCreateLabel] = useState("");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  // Pause + select helper
140
  const jumpAndSelect = React.useCallback(
@@ -267,13 +292,16 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
267
 
268
  // ============ Pixel <-> time mapping ============
269
  // The full-width track band (no label margin) is `trackBandRef`. Convert
270
- // mouse client.x to a 0..duration timestamp.
271
- const trackXToTs = (clientX: number): number => {
272
- const r = trackBandRef.current?.getBoundingClientRect();
273
- if (!r || !duration) return 0;
274
- const frac = Math.max(0, Math.min(1, (clientX - r.left) / r.width));
275
- return frac * duration;
276
- };
 
 
 
277
 
278
  // ============ Event-track click → seek + select ============
279
  const onTickClick = (e: React.MouseEvent, atomIdx: number, t: number) => {
@@ -386,7 +414,7 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
386
  if (drag.kind === "create") {
387
  const a = Math.min(drag.startTs ?? 0, drag.endTs ?? 0);
388
  const b = Math.max(drag.startTs ?? 0, drag.endTs ?? 0);
389
- const distFrac = Math.abs(b - a) / Math.max(0.001, duration);
390
  // Need at least a few px of drag to count, otherwise treat as click.
391
  const trackWidth =
392
  trackBandRef.current?.getBoundingClientRect().width ?? 1;
@@ -394,7 +422,7 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
394
  // Anchor the label popup at the upper-right of the new span.
395
  const r = trackBandRef.current?.getBoundingClientRect();
396
  if (r) {
397
- const xFrac = b / Math.max(0.001, duration);
398
  setPendingCreate({
399
  start: a,
400
  end: b,
@@ -421,7 +449,17 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
421
  window.removeEventListener("pointermove", move);
422
  window.removeEventListener("pointerup", up);
423
  };
424
- }, [drag, duration, seek, setIsPlaying, snap, updateAtom]);
 
 
 
 
 
 
 
 
 
 
425
 
426
  // ============ Tooltip helpers ============
427
  const showTip = (e: React.MouseEvent, meta: string, text: string) => {
@@ -466,15 +504,89 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
466
 
467
  // ============ Render ============
468
  if (!duration) return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
 
470
  return (
471
- <div className="tl">
472
  <div className="tl-head">
473
- <span>Annotations timeline</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
  <span className="ts-display">
475
  {currentTime.toFixed(2)}s / {duration.toFixed(2)}s
476
  </span>
477
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
 
479
  {/* Time-axis ruler — clicking it scrubs */}
480
  <div
@@ -486,11 +598,10 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
486
  setIsPlaying(false);
487
  }}
488
  >
489
- {Array.from({ length: Math.floor(duration / 5) + 1 }).map((_, i) => {
490
- const t = i * 5;
491
- const left = (t / duration) * 100;
492
  return (
493
- <div key={i} className="tick-mark" style={{ left: `${left}%` }}>
494
  {t}s
495
  </div>
496
  );
@@ -506,11 +617,13 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
506
  {(() => {
507
  const bandLeft = `${LABEL_WIDTH + 10}px`;
508
  const playheadLeft = `calc(${bandLeft} + ${
509
- duration ? currentTime / duration : 0
 
 
510
  } * (100% - ${bandLeft}))`;
511
  return (
512
  <div className="tl-tracks" style={{ position: "relative" }}>
513
- {TRACK_GROUPS.map((group) => (
514
  <div className="tl-section" key={group.column}>
515
  <div className={`tl-section-head ${group.column}`}>
516
  <span className="tl-section-title">{group.title}</span>
@@ -519,7 +632,9 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
519
  {group.tracks.map((tk) => (
520
  <div className="tl-row" key={tk.key}>
521
  <div className="label">
522
- <span className={`style-dot dot-${tk.key}`} />
 
 
523
  {tk.label}
524
  </div>
525
  <div
@@ -539,15 +654,25 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
539
  {/* Editable subtask spans (resize + drag-to-create) */}
540
  {tk.render === "span-edit" &&
541
  lanes.subtask.map((s, k) => {
542
- const left = (s.start / duration) * 100;
543
- const width = Math.max(
544
- 0.3,
545
- ((s.end - s.start) / duration) * 100,
546
- );
547
  return (
548
  <div
549
  key={k}
550
- className={`tl-seg subtask ${drag?.kind === "edge" && drag.atomIdx === s.atomIdx ? "dragging" : ""}`}
 
 
 
 
 
 
 
 
 
 
 
 
551
  style={{ left: `${left}%`, width: `${width}%` }}
552
  onClick={(e) =>
553
  onSpanBodyClick(e, s.atomIdx, s.start)
@@ -562,28 +687,21 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
562
  onMouseMove={moveTip}
563
  onMouseLeave={hideTip}
564
  >
565
- <span style={{ opacity: 0.7, fontSize: 10 }}>
566
- {k}
567
- </span>
568
- <span
569
- style={{
570
- whiteSpace: "nowrap",
571
- overflow: "hidden",
572
- textOverflow: "ellipsis",
573
- }}
574
- >
575
- {s.label}
576
- </span>
577
- <div
578
- className="resize l"
579
- onPointerDown={(e) => onEdgeDown(e, "l", k)}
580
- />
581
- {k + 1 < lanes.subtask.length && (
582
  <div
583
- className="resize r"
584
- onPointerDown={(e) => onEdgeDown(e, "r", k)}
585
  />
586
  )}
 
 
 
 
 
 
 
587
  </div>
588
  );
589
  })}
@@ -593,8 +711,8 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
593
  <div
594
  className="tl-create-preview"
595
  style={{
596
- left: `${(Math.min(drag.startTs ?? 0, drag.endTs ?? 0) / duration) * 100}%`,
597
- width: `${(Math.abs((drag.endTs ?? 0) - (drag.startTs ?? 0)) / duration) * 100}%`,
598
  }}
599
  />
600
  )}
@@ -655,15 +773,13 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
655
  atomIdx: number;
656
  }>
657
  ).map((s, k) => {
658
- const left = (s.start / duration) * 100;
659
- const width = Math.max(
660
- 0.3,
661
- ((s.end - s.start) / duration) * 100,
662
- );
663
  return (
664
  <div
665
  key={k}
666
- className={`tl-seg ${tk.key}`}
667
  style={{ left: `${left}%`, width: `${width}%` }}
668
  onClick={(e) =>
669
  onSpanBodyClick(e, s.atomIdx, s.start)
@@ -706,7 +822,8 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
706
  subtype?: string;
707
  }>
708
  ).map((m, i) => {
709
- const left = (m.t / duration) * 100;
 
710
  return (
711
  <div
712
  key={i}
@@ -743,6 +860,20 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
743
  );
744
  })()}
745
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
746
  {/* Tooltip */}
747
  {tooltip && (
748
  <div className="tl-tooltip" style={{ left: tooltip.x, top: tooltip.y }}>
@@ -813,6 +944,6 @@ export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
813
  </div>
814
  </div>
815
  )}
816
- </div>
817
  );
818
  };
 
6
  * sections that mirror the two language columns:
7
  *
8
  * PERSISTENT (language_persistent — broadcast across every frame):
9
+ * - task_aug: task phrasings collapsed into one full-episode span.
10
  * - subtask: filled spans from each emit time until the next subtask emit
11
  * (or episode end). Numbered. Resizable edges; the empty subtask track
12
  * also accepts drag-to-create.
 
35
  import React, { useEffect, useMemo, useRef, useState } from "react";
36
  import { useTime } from "../context/time-context";
37
  import { useAnnotations } from "../context/annotations-context";
38
+ import PlaybackBar from "./playback-bar";
39
+ import {
40
+ timelineTicks,
41
+ timelineWindow,
42
+ visibleSpan,
43
+ } from "../utils/annotationTimeline";
44
  import {
45
  classifyVqa,
46
  isSpeechAtom,
 
58
  {
59
  column: "persistent",
60
  title: "Persistent",
61
+ sub: "Active across frames",
62
  tracks: [
63
  // task_aug applies to the whole episode (it's a rephrasing of the task,
64
  // stored at t0 but persistent across every frame), so it reads as a
 
84
  {
85
  column: "events",
86
  title: "Events",
87
+ sub: "At a single frame",
88
  tracks: [
89
  {
90
  key: "interjection",
 
131
  }
132
 
133
  export const AnnotationsTimeline: React.FC<Props> = ({ duration }) => {
134
+ const { atoms, addAtom, updateAtom, snap, selectAtom, selectedIdx } =
135
+ useAnnotations();
136
  const { currentTime, seek, setIsPlaying } = useTime();
137
  const trackBandRef = useRef<HTMLDivElement | null>(null);
138
 
 
142
  null,
143
  );
144
  const [createLabel, setCreateLabel] = useState("");
145
+ const [zoom, setZoom] = useState<"detail" | "full">("detail");
146
+ const [windowStart, setWindowStart] = useState(0);
147
+ const [showEmpty, setShowEmpty] = useState(false);
148
+ const viewWidth = zoom === "full" ? duration : Math.min(duration, 40);
149
+ const viewStart =
150
+ zoom === "full"
151
+ ? 0
152
+ : Math.min(windowStart, Math.max(0, duration - viewWidth));
153
+ const view = { start: viewStart, end: viewStart + viewWidth };
154
+
155
+ // Keep the viewport stable while scrubbing/resizing. Follow playback only
156
+ // when it leaves the visible window, rather than moving the axis every frame.
157
+ useEffect(() => {
158
+ if (drag || pendingCreate || zoom === "full") return;
159
+ if (currentTime < viewStart || currentTime > viewStart + viewWidth) {
160
+ setWindowStart(timelineWindow(duration, currentTime).start);
161
+ }
162
+ }, [currentTime, duration, drag, pendingCreate, zoom, viewStart, viewWidth]);
163
 
164
  // Pause + select helper
165
  const jumpAndSelect = React.useCallback(
 
292
 
293
  // ============ Pixel <-> time mapping ============
294
  // The full-width track band (no label margin) is `trackBandRef`. Convert
295
+ // mouse client.x to a timestamp inside the visible window.
296
+ const trackXToTs = React.useCallback(
297
+ (clientX: number): number => {
298
+ const r = trackBandRef.current?.getBoundingClientRect();
299
+ if (!r || !duration) return 0;
300
+ const frac = Math.max(0, Math.min(1, (clientX - r.left) / r.width));
301
+ return viewStart + frac * viewWidth;
302
+ },
303
+ [duration, viewStart, viewWidth],
304
+ );
305
 
306
  // ============ Event-track click → seek + select ============
307
  const onTickClick = (e: React.MouseEvent, atomIdx: number, t: number) => {
 
414
  if (drag.kind === "create") {
415
  const a = Math.min(drag.startTs ?? 0, drag.endTs ?? 0);
416
  const b = Math.max(drag.startTs ?? 0, drag.endTs ?? 0);
417
+ const distFrac = Math.abs(b - a) / Math.max(0.001, viewWidth);
418
  // Need at least a few px of drag to count, otherwise treat as click.
419
  const trackWidth =
420
  trackBandRef.current?.getBoundingClientRect().width ?? 1;
 
422
  // Anchor the label popup at the upper-right of the new span.
423
  const r = trackBandRef.current?.getBoundingClientRect();
424
  if (r) {
425
+ const xFrac = (b - viewStart) / Math.max(0.001, viewWidth);
426
  setPendingCreate({
427
  start: a,
428
  end: b,
 
449
  window.removeEventListener("pointermove", move);
450
  window.removeEventListener("pointerup", up);
451
  };
452
+ }, [
453
+ drag,
454
+ duration,
455
+ seek,
456
+ setIsPlaying,
457
+ snap,
458
+ updateAtom,
459
+ viewStart,
460
+ viewWidth,
461
+ trackXToTs,
462
+ ]);
463
 
464
  // ============ Tooltip helpers ============
465
  const showTip = (e: React.MouseEvent, meta: string, text: string) => {
 
504
 
505
  // ============ Render ============
506
  if (!duration) return null;
507
+ const emptyCount = TRACK_GROUPS.reduce(
508
+ (count, group) =>
509
+ count +
510
+ group.tracks.filter(
511
+ (track) => track.key !== "subtask" && lanes[track.key].length === 0,
512
+ ).length,
513
+ 0,
514
+ );
515
+ const overviewSpans = lanes.subtask.length ? lanes.subtask : lanes.plan;
516
+ const visibleGroups = TRACK_GROUPS.map((group) => ({
517
+ ...group,
518
+ tracks: group.tracks.filter(
519
+ (track) =>
520
+ track.key === "subtask" || showEmpty || lanes[track.key].length > 0,
521
+ ),
522
+ })).filter((group) => group.tracks.length > 0);
523
 
524
  return (
525
+ <section className="tl" aria-label="Annotation timeline">
526
  <div className="tl-head">
527
+ <h3>
528
+ Timeline <span>{atoms.length} annotations</span>
529
+ </h3>
530
+ <select
531
+ aria-label="Timeline zoom"
532
+ value={zoom}
533
+ onChange={(e) => {
534
+ setWindowStart(timelineWindow(duration, currentTime).start);
535
+ setZoom(e.target.value as "detail" | "full");
536
+ }}
537
+ >
538
+ <option value="detail">40-second window</option>
539
+ <option value="full">Full episode</option>
540
+ </select>
541
+ </div>
542
+ <div className="tl-transport">
543
+ <PlaybackBar />
544
+ </div>
545
+
546
+ <div className="tl-overview-head">
547
+ <span className="section-kicker">Episode overview</span>
548
  <span className="ts-display">
549
  {currentTime.toFixed(2)}s / {duration.toFixed(2)}s
550
  </span>
551
  </div>
552
+ <div
553
+ className="tl-overview"
554
+ onClick={(e) => {
555
+ const rect = e.currentTarget.getBoundingClientRect();
556
+ jumpAndSelect(
557
+ ((e.clientX - rect.left) / rect.width) * duration,
558
+ null,
559
+ );
560
+ }}
561
+ >
562
+ {overviewSpans.map((span, i) => (
563
+ <button
564
+ type="button"
565
+ key={span.atomIdx}
566
+ aria-label={`Annotation ${i}: ${span.label}`}
567
+ aria-pressed={selectedIdx === span.atomIdx}
568
+ style={{
569
+ left: `${(span.start / duration) * 100}%`,
570
+ width: `calc(${((span.end - span.start) / duration) * 100}% - 2px)`,
571
+ }}
572
+ onClick={(e) => {
573
+ e.stopPropagation();
574
+ jumpAndSelect(span.start, span.atomIdx);
575
+ }}
576
+ />
577
+ ))}
578
+ <div
579
+ className="tl-overview-window"
580
+ style={{
581
+ left: `${(view.start / duration) * 100}%`,
582
+ width: `${(viewWidth / duration) * 100}%`,
583
+ }}
584
+ />
585
+ <div
586
+ className="tl-overview-cursor"
587
+ style={{ left: `${(currentTime / duration) * 100}%` }}
588
+ />
589
+ </div>
590
 
591
  {/* Time-axis ruler — clicking it scrubs */}
592
  <div
 
598
  setIsPlaying(false);
599
  }}
600
  >
601
+ {timelineTicks(view).map((t) => {
602
+ const left = ((t - view.start) / viewWidth) * 100;
 
603
  return (
604
+ <div key={t} className="tick-mark" style={{ left: `${left}%` }}>
605
  {t}s
606
  </div>
607
  );
 
617
  {(() => {
618
  const bandLeft = `${LABEL_WIDTH + 10}px`;
619
  const playheadLeft = `calc(${bandLeft} + ${
620
+ viewWidth
621
+ ? Math.max(0, Math.min(1, (currentTime - viewStart) / viewWidth))
622
+ : 0
623
  } * (100% - ${bandLeft}))`;
624
  return (
625
  <div className="tl-tracks" style={{ position: "relative" }}>
626
+ {visibleGroups.map((group) => (
627
  <div className="tl-section" key={group.column}>
628
  <div className={`tl-section-head ${group.column}`}>
629
  <span className="tl-section-title">{group.title}</span>
 
632
  {group.tracks.map((tk) => (
633
  <div className="tl-row" key={tk.key}>
634
  <div className="label">
635
+ <span
636
+ className={`style-dot dot-${tk.key.replace("_", "-")}`}
637
+ />
638
  {tk.label}
639
  </div>
640
  <div
 
654
  {/* Editable subtask spans (resize + drag-to-create) */}
655
  {tk.render === "span-edit" &&
656
  lanes.subtask.map((s, k) => {
657
+ const position = visibleSpan(s.start, s.end, view);
658
+ if (!position) return null;
659
+ const { left, width } = position;
 
 
660
  return (
661
  <div
662
  key={k}
663
+ className={`tl-seg subtask ${selectedIdx === s.atomIdx ? "selected" : ""} ${drag?.kind === "edge" && drag.atomIdx === s.atomIdx ? "dragging" : ""}`}
664
+ role="button"
665
+ tabIndex={0}
666
+ aria-pressed={selectedIdx === s.atomIdx}
667
+ aria-label={`Subtask ${k}: ${s.label}`}
668
+ onPointerDown={(e) => e.stopPropagation()}
669
+ onKeyDown={(e) => {
670
+ if (e.key === "Enter" || e.key === " ") {
671
+ e.preventDefault();
672
+ e.stopPropagation();
673
+ jumpAndSelect(s.start, s.atomIdx);
674
+ }
675
+ }}
676
  style={{ left: `${left}%`, width: `${width}%` }}
677
  onClick={(e) =>
678
  onSpanBodyClick(e, s.atomIdx, s.start)
 
687
  onMouseMove={moveTip}
688
  onMouseLeave={hideTip}
689
  >
690
+ <span className="tl-seg-number">{k}</span>
691
+ <span className="tl-seg-label">{s.label}</span>
692
+ {s.start >= view.start && (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
693
  <div
694
+ className="resize l"
695
+ onPointerDown={(e) => onEdgeDown(e, "l", k)}
696
  />
697
  )}
698
+ {s.end <= view.end &&
699
+ k + 1 < lanes.subtask.length && (
700
+ <div
701
+ className="resize r"
702
+ onPointerDown={(e) => onEdgeDown(e, "r", k)}
703
+ />
704
+ )}
705
  </div>
706
  );
707
  })}
 
711
  <div
712
  className="tl-create-preview"
713
  style={{
714
+ left: `${((Math.min(drag.startTs ?? 0, drag.endTs ?? 0) - view.start) / viewWidth) * 100}%`,
715
+ width: `${(Math.abs((drag.endTs ?? 0) - (drag.startTs ?? 0)) / viewWidth) * 100}%`,
716
  }}
717
  />
718
  )}
 
773
  atomIdx: number;
774
  }>
775
  ).map((s, k) => {
776
+ const position = visibleSpan(s.start, s.end, view);
777
+ if (!position) return null;
778
+ const { left, width } = position;
 
 
779
  return (
780
  <div
781
  key={k}
782
+ className={`tl-seg ${tk.key} ${selectedIdx === s.atomIdx ? "selected" : ""}`}
783
  style={{ left: `${left}%`, width: `${width}%` }}
784
  onClick={(e) =>
785
  onSpanBodyClick(e, s.atomIdx, s.start)
 
822
  subtype?: string;
823
  }>
824
  ).map((m, i) => {
825
+ if (m.t < view.start || m.t > view.end) return null;
826
+ const left = ((m.t - view.start) / viewWidth) * 100;
827
  return (
828
  <div
829
  key={i}
 
860
  );
861
  })()}
862
 
863
+ <div className="tl-footer">
864
+ {emptyCount > 0 && (
865
+ <button
866
+ type="button"
867
+ className="btn"
868
+ aria-expanded={showEmpty}
869
+ onClick={() => setShowEmpty(!showEmpty)}
870
+ >
871
+ {showEmpty ? "Hide empty tracks" : `${emptyCount} empty tracks`}
872
+ </button>
873
+ )}
874
+ <span>Select a span to inspect · Drag its edges to retime</span>
875
+ </div>
876
+
877
  {/* Tooltip */}
878
  {tooltip && (
879
  <div className="tl-tooltip" style={{ left: tooltip.x, top: tooltip.y }}>
 
944
  </div>
945
  </div>
946
  )}
947
+ </section>
948
  );
949
  };
src/utils/__tests__/annotationTimeline.test.ts ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, test } from "bun:test";
2
+ import {
3
+ timelineTicks,
4
+ timelineWindow,
5
+ visibleSpan,
6
+ } from "../annotationTimeline";
7
+
8
+ describe("annotation timeline windows", () => {
9
+ test("keeps the full final interval visible when inspecting 99 seconds", () => {
10
+ const view = timelineWindow(110.97, 99);
11
+ expect(view.start).toBeCloseTo(70.97);
12
+ expect(view.end).toBe(110.97);
13
+ });
14
+
15
+ test("fits short and empty episodes without negative bounds", () => {
16
+ expect(timelineWindow(12, 10)).toEqual({ start: 0, end: 12 });
17
+ expect(timelineWindow(0, 0)).toEqual({ start: 0, end: 0 });
18
+ expect(timelineWindow(120, 0)).toEqual({ start: 0, end: 40 });
19
+ });
20
+
21
+ test("clips partially visible spans and excludes adjacent offscreen spans", () => {
22
+ const view = { start: 40, end: 60 };
23
+ expect(visibleSpan(30, 45, view)).toEqual({ left: 0, width: 25 });
24
+ expect(visibleSpan(55, 75, view)).toEqual({ left: 75, width: 25 });
25
+ expect(visibleSpan(0, 40, view)).toBeNull();
26
+ expect(visibleSpan(60, 80, view)).toBeNull();
27
+ expect(visibleSpan(0, 1, { start: 0, end: 0 })).toBeNull();
28
+ });
29
+
30
+ test("uses round, bounded ticks for fractional and long episodes", () => {
31
+ expect(timelineTicks(timelineWindow(110.97, 99))).toEqual([
32
+ 80, 90, 100, 110,
33
+ ]);
34
+ for (const end of [0.3, 12, 110.97, 3600]) {
35
+ const ticks = timelineTicks({ start: 0, end });
36
+ expect(ticks.length).toBeLessThanOrEqual(6);
37
+ expect(ticks.every((t) => t >= 0 && t <= end)).toBe(true);
38
+ }
39
+ expect(timelineTicks({ start: 0, end: 0 })).toEqual([]);
40
+ });
41
+ });
src/utils/annotationTimeline.ts ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export interface TimelineWindow {
2
+ start: number;
3
+ end: number;
4
+ }
5
+
6
+ /** Keep a fixed-size window inside the episode, including its final frame. */
7
+ export function timelineWindow(
8
+ duration: number,
9
+ time: number,
10
+ seconds = 40,
11
+ ): TimelineWindow {
12
+ const width = Math.min(Math.max(0, duration), seconds);
13
+ const start = Math.max(0, Math.min(duration - width, time - width / 2));
14
+ return { start, end: start + width };
15
+ }
16
+
17
+ /** Clip spans before positioning them so offscreen boundaries cannot be resized. */
18
+ export function visibleSpan(start: number, end: number, view: TimelineWindow) {
19
+ const from = Math.max(start, view.start);
20
+ const to = Math.min(end, view.end);
21
+ if (to <= from || view.end <= view.start) return null;
22
+ return {
23
+ left: ((from - view.start) / (view.end - view.start)) * 100,
24
+ width: ((to - from) / (view.end - view.start)) * 100,
25
+ };
26
+ }
27
+
28
+ /** Use a handful of evenly spaced, round timestamps at any zoom level. */
29
+ export function timelineTicks({ start, end }: TimelineWindow): number[] {
30
+ const rawStep = (end - start) / 5;
31
+ if (rawStep <= 0) return [];
32
+ const magnitude = 10 ** Math.floor(Math.log10(rawStep));
33
+ const step = [1, 2, 5, 10].find((n) => n * magnitude >= rawStep)! * magnitude;
34
+ const first = Math.ceil(start / step) * step;
35
+ return Array.from(
36
+ { length: Math.max(0, Math.floor((end - first) / step) + 1) },
37
+ (_, i) => Number((first + i * step).toPrecision(12)),
38
+ );
39
+ }