'use client'; import { Loader2, CheckCircle2, Circle, Search, Globe, Brain, Package, BookOpen } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { ThinkingMessageMetadata } from '@/hooks/use-chat'; import { SourcesCompact } from './sources-compact'; interface ReasoningChainProps { steps: ThinkingMessageMetadata[]; searchQueries?: string[]; className?: string; } export function ReasoningChain({ steps, searchQueries = [], className }: ReasoningChainProps) { const hasActiveStep = steps.some(step => step.status === 'running'); const allSources = steps .flatMap(step => step.sources || []) .filter((source, index, self) => index === self.findIndex(s => s.url === source.url) ); const getStepIcon = (step: ThinkingMessageMetadata) => { const isRunning = step.status === 'running'; const isCompleted = step.status === 'completed'; const isError = step.status === 'error'; if (isError) { return null; // Não mostrar ícone para erros, apenas texto } if (isCompleted) { return ; } if (isRunning) { return ; } // Ícone baseado no tipo de step switch (step.stepType) { case 'preprocessing': return ; case 'web-research': return ; case 'sources-found': return ; case 'processing': return ; case 'response-generation': return ; default: return ; } }; return (
{/* Header: "Working..." com spinner sutil */}
Working...
{/* Lista vertical de steps - texto simples */}
{steps.map((step, index) => { const isRunning = step.status === 'running'; const isCompleted = step.status === 'completed'; const isError = step.status === 'error'; return (
{getStepIcon(step)} {step.label} {step.details && ( {step.details} )}
); })}
{/* Pills de busca - cápsulas sutis */} {searchQueries.length > 0 && (
Searching: {searchQueries.map((query, index) => ( {query} ))}
)} {/* Fontes em revisão */} {allSources.length > 0 && (
Reviewing sources - {allSources.length}
)}
); }