diff --git a/webui/src/components/thread/PromptRail.tsx b/webui/src/components/thread/PromptRail.tsx index 52e6cf6f..dbc87b34 100644 --- a/webui/src/components/thread/PromptRail.tsx +++ b/webui/src/components/thread/PromptRail.tsx @@ -12,7 +12,6 @@ import { interface PromptRailProps { bottomOffset: number; - contentRef: RefObject; messages: UIMessage[]; scrollRef: RefObject; } @@ -43,19 +42,9 @@ const MARKER_STACK_GAP_PX = 16; const RAIL_FALLBACK_HEIGHT_PX = 300; const MEASURE_RETRY_FRAMES = 4; const HOVER_MARKER_WIDTHS_PX = [28, 22, 16, 11]; -const RAIL_WIDTH_PX = 36; -const RAIL_MIN_EDGE_GAP_PX = 12; -const RAIL_COLUMN_GAP_PX = 20; -const RAIL_REQUIRED_GUTTER_PX = RAIL_MIN_EDGE_GAP_PX + RAIL_WIDTH_PX + RAIL_COLUMN_GAP_PX; - -interface RailLayout { - visible: boolean; - left: number | null; -} export function PromptRail({ bottomOffset, - contentRef, messages, scrollRef, }: PromptRailProps) { @@ -64,41 +53,12 @@ export function PromptRail({ const [markers, setMarkers] = useState([]); const [activePromptId, setActivePromptId] = useState(null); const [focusedMarkerIndex, setFocusedMarkerIndex] = useState(null); - const [railLayout, setRailLayout] = useState({ visible: true, left: null }); - - const measureRailLayout = useCallback((): RailLayout => { - const scrollEl = scrollRef.current; - const contentEl = contentRef.current; - if (!scrollEl || !contentEl) return { visible: true, left: null }; - - const scrollRect = scrollEl.getBoundingClientRect(); - const contentRect = contentEl.getBoundingClientRect(); - if (scrollRect.width <= 0 || contentRect.width <= 0) { - return { visible: true, left: null }; - } - - const leftGutter = contentRect.left - scrollRect.left; - if (leftGutter < RAIL_REQUIRED_GUTTER_PX) { - return { visible: false, left: null }; - } - - return { - visible: true, - left: Math.round(leftGutter - RAIL_WIDTH_PX - RAIL_COLUMN_GAP_PX), - }; - }, [contentRef, scrollRef]); const updateMarkers = useCallback(() => { const scrollEl = scrollRef.current; const nextRailHeight = railRef.current?.clientHeight ?? 0; - const nextRailLayout = measureRailLayout(); - setRailLayout((current) => - current.visible === nextRailLayout.visible && current.left === nextRailLayout.left - ? current - : nextRailLayout, - ); - if (!nextRailLayout.visible || !scrollEl || promptAnchors.length < MIN_PROMPTS_FOR_RAIL) { + if (!scrollEl || promptAnchors.length < MIN_PROMPTS_FOR_RAIL) { setMarkers([]); setActivePromptId(null); return; @@ -115,7 +75,7 @@ export function PromptRail({ const grouped = groupPromptMarkers(measured, nextRailHeight); setMarkers(distributeMarkerPositions(grouped, nextRailHeight)); setActivePromptId(activePromptForScroll(measured, scrollEl.scrollTop)); - }, [measureRailLayout, promptAnchors, scrollRef]); + }, [promptAnchors, scrollRef]); useEffect(() => { let frame = 0; @@ -156,26 +116,22 @@ export function PromptRail({ const observer = new ResizeObserver(() => updateMarkers()); observer.observe(scrollEl); if (scrollEl.firstElementChild) observer.observe(scrollEl.firstElementChild); - if (contentRef.current) observer.observe(contentRef.current); return () => observer.disconnect(); - }, [contentRef, scrollRef, updateMarkers]); + }, [scrollRef, updateMarkers]); - if (!railLayout.visible || markers.length === 0) return null; + if (markers.length === 0) return null; return (