import { memo, useCallback } from 'react'; import type { WireEntry } from '../../types'; import { formatDuration, formatWallClock } from '../../util/time'; import { TypeBadge } from './TypeBadge'; import { renderHeadline } from './WireHeadline'; import { WireRowDetail } from './WireRowDetail'; /** Pairing hint for a `tool.call` ↔ `tool.result` row. Computed by the * parent (WireTab) from the full record list and threaded down here so * the row can render an inline cross-reference and participate in the * hover-highlight protocol. */ export interface PairHint { toolCallId: string; kind: 'call' | 'result'; callLineNo: number | null; resultLineNo: number | null; /** result.time − call.time, when both records carry a timestamp. */ durationMs: number | null; } interface WireRowProps { entry: WireEntry; expanded: boolean; onToggle: () => void; /** Scroll to a line and expand it — wired by the Wire tab via the virtualizer. */ onJumpTo?: (lineNo: number) => void; /** Set when this entry is a tool.call/tool.result; carries the matching counterpart's line. */ pair?: PairHint; /** True when another row from this pair is currently hovered. */ highlighted: boolean; /** Notify the parent that this row's pair group is being hovered. */ onHoverPair?: (toolCallId: string | null) => void; } export const WireRow = memo(function WireRow({ entry, expanded, onToggle, onJumpTo, pair, highlighted, onHoverPair, }: WireRowProps) { const record = entry.data; const h = renderHeadline(record); const timeTitle = formatTimeTitle(record.time); const handleEnter = useCallback(() => { if (pair !== undefined && onHoverPair !== undefined) { onHoverPair(pair.toolCallId); } }, [pair, onHoverPair]); const handleLeave = useCallback(() => { if (pair !== undefined && onHoverPair !== undefined) { onHoverPair(null); } }, [pair, onHoverPair]); return (