'use client' import { useEffect, useRef } from 'react' import type { AdvisorTurn } from './useAdvisorStream' import { StickyQuestion } from './StickyQuestion' import { TurnView } from './TurnView' import { AdvisorEmptyState } from './EmptyState' /** * The Evidence Workspace body: a pinned "last question" + a scrollable history of turns, each * showing the answer alongside its sources / figures / footnotes. Scroll up to revisit a past * answer with its full evidence. */ export function EvidenceWorkspace({ turns, exampleQuestions, onExample, }: { turns: AdvisorTurn[] exampleQuestions: string[] onExample: (q: string) => void }) { const endRef = useRef(null) const latest = turns[turns.length - 1] // Scroll to the newest turn when a question is added (not on every streamed token, // so the user can scroll up to review history while the answer streams). useEffect(() => { endRef.current?.scrollIntoView({ behavior: 'smooth' }) }, [turns.length]) if (turns.length === 0) { return (
) } return (
{latest && }
{turns.map((t, i) => ( ))}
) }