import type { Flow } from "@yaakapp-internal/proxy-lib"; import { CONTROL_TOOLTIP_DELAY, EventViewer, EventViewerRow, formatMillis, Icon, type IconProps, Tooltip, } from "@yaakapp-internal/ui"; import { useMemo } from "react"; import { type FlowPhase, flowPhases, type PhaseKind } from "../lib/phases"; const ICONS: Record = { start: { icon: "send_horizontal", color: "secondary" }, step: { icon: "arrow_right", color: "secondary" }, end: { icon: "check", color: "success" }, error: { icon: "alert_triangle", color: "danger" }, cancelled: { icon: "circle_off", color: "secondary" }, }; /** Yaak's event list with the flow's phases as rows, each saying how long it took */ export function FlowTimeline({ flow }: { flow: Flow }) { const phases = useMemo(() => flowPhases(flow), [flow]); return ( events={phases} getEventKey={(p) => p.key} splitLayoutStorageKey="proxy_flow_timeline" enableKeyboardNav={false} emptyMessage="No timings recorded" renderRow={({ event, isActive, onClick }) => { const { icon, color } = ICONS[event.kind]; return ( } content={ event.detail == null ? ( {event.label} ) : ( {event.label} {` ${event.detail}`} ) } columns="auto minmax(0,1fr) 6rem 6rem" cells={{ trailing: [ {event.kind === "start" ? "" : `+${formatMillis(event.tookMs)}`} , {formatMillis(event.atMs)} , ], }} /> ); }} /> ); }