diff --git a/packages/client/ui-trajectory/src/client/TrajectoryTimeline.tsx b/packages/client/ui-trajectory/src/client/TrajectoryTimeline.tsx index 0bf7e9b6db..8ad1afefc1 100644 --- a/packages/client/ui-trajectory/src/client/TrajectoryTimeline.tsx +++ b/packages/client/ui-trajectory/src/client/TrajectoryTimeline.tsx @@ -7,6 +7,7 @@ import { import type { TrajectoryTurnModel } from './layout.ts' import { deriveTrajectoryTimeline, + formatTimelineOffset, type TrajectoryTimelineMode, type TrajectoryTimeRange, } from './timeline.ts' @@ -81,6 +82,18 @@ export const TrajectoryTimeline = memo(function TrajectoryTimeline({ onRecordFocus, }: TrajectoryTimelineProps) { const model = useMemo(() => deriveTrajectoryTimeline(turns, mode), [mode, turns]) + const durationByIndex = useMemo( + () => new Map(turns.flatMap(turn => + turn.groups.flatMap(group => + group.cells.flatMap(cell => + cell.timeSeconds === null || !Number.isFinite(cell.timeSeconds) + ? [] + : [[cell.index, Math.max(0, cell.timeSeconds * 1_000)] as const], + ), + ), + )), + [turns], + ) const dragRef = useRef<{ pointerId: number; anchor: number; width: number } | null>(null) const [draft, setDraft] = useState(null) const [hover, setHover] = useState(null) @@ -324,6 +337,7 @@ export const TrajectoryTimeline = memo(function TrajectoryTimeline({ .map((span) => { const left = (span.start - domainStart) / domainDuration const width = (span.end - span.start) / domainDuration + const durationMs = durationByIndex.get(span.index) return ( = 10 ? `${Math.round(seconds)} s` : `${seconds.toFixed(1)} s` +} + function laneFor(kind: TrajectoryCellKind): number { if (kind === 'tool' || kind === 'subtool') return 2 if (kind === 'message' || kind === 'compacted') return 1