'use client' import { useEffect, useRef } from 'react' import type { AdvisorCase, AdvisorThread } from './useAdvisorCase' import { StickyQuestion } from './StickyQuestion' import { AdvisorEmptyState } from './EmptyState' import { CaseView, LoadingDots, ErrorBox } from './CaseView' import { ClarifyView } from './ClarifyView' import { EvidenceSummary } from './EvidenceSummary' import { EvidencePane } from './EvidencePane' import { VisualEvidencePane } from './VisualEvidencePane' import { FootnotesPane } from './FootnotesPane' import { Markdown } from './Markdown' import { ThreadMenu } from './ThreadMenu' import { useCitationHighlight } from './useCitationHighlight' /** * Advisor body as topic THREADS of cases. * - Narrow: stacked cases with a pinned last question; per-case copy + delete. * - Wide/fullscreen: 3-column Case Workspace — topic tree (left) | answer/clarify (center) | evidence (right). */ export function EvidenceWorkspace({ cases, threads, expanded, busy, activeCaseId, exampleQuestions, onExample, onSelectContext, onSelectCase, onRemove, }: { cases: AdvisorCase[] threads: AdvisorThread[] expanded: boolean busy: boolean activeCaseId: string | null exampleQuestions: string[] onExample: (q: string) => void onSelectContext: (caseId: string, ctx: string) => void onSelectCase: (id: string) => void onRemove: (id: string) => void }) { const endRef = useRef(null) const latest = cases[cases.length - 1] const active = cases.find((c) => c.id === activeCaseId) ?? latest useEffect(() => { if (!expanded) endRef.current?.scrollIntoView({ behavior: 'smooth' }) }, [cases.length, expanded]) const answer = active?.response?.mode === 'answer' ? active.response : null const { highlightedId, cite } = useCitationHighlight(answer?.citations ?? []) if (cases.length === 0) { return (
) } if (!expanded) { return (
{latest && }
{cases.map((c, i) => ( onSelectContext(c.id, ctx)} onRemove={() => onRemove(c.id)} /> ))}
) } const r = active?.response return (
{active?.status === 'loading' && } {active?.status === 'error' && } {r?.mode === 'clarify' && ( active && onSelectContext(active.id, ctx)} /> )} {r?.mode === 'answer' && (
)}
) }