'use client' import { useEffect, useRef, useState } from 'react' import type { AdvisorTurn } from './useAdvisorStream' import { StickyQuestion } from './StickyQuestion' import { TurnView } from './TurnView' import { EvidenceSummary } from './EvidenceSummary' import { AnswerPane } from './AnswerPane' import { EvidencePane } from './EvidencePane' import { FiguresPane } from './FiguresPane' import { FootnotesPane } from './FootnotesPane' import { AdvisorEmptyState } from './EmptyState' /** * The Evidence Workspace body. * - Narrow (collapsed): stacked panels with a pinned last question + scrollable turn history. * - Wide (expanded): a 3-column Compliance Case Workspace — question + summary (left, with a * history switcher), answer (center scroll), evidence (right scroll) — each column scrolls * independently so the user never loses the question or the evidence. */ export function EvidenceWorkspace({ turns, expanded, exampleQuestions, onExample, }: { turns: AdvisorTurn[] expanded: boolean exampleQuestions: string[] onExample: (q: string) => void }) { const [activeId, setActiveId] = useState(null) const endRef = useRef(null) const latest = turns[turns.length - 1] const active = turns.find((t) => t.id === activeId) ?? latest // A new turn refocuses the latest (null = follow latest). useEffect(() => { setActiveId(null) }, [turns.length]) // Autoscroll the stacked view to the newest turn (narrow mode only). useEffect(() => { if (!expanded) endRef.current?.scrollIntoView({ behavior: 'smooth' }) }, [turns.length, expanded]) if (turns.length === 0) { return (
) } if (!expanded) { return (
{latest && }
{turns.map((t, i) => ( ))}
) } return (
{/* Left rail: question + summary + history */} {/* Center: answer */}
{active && ( )}
{/* Right: evidence */}
) }