import { useEffect, useRef } from 'react'; import { Card } from '@/components/ui/card'; import { Alert, AlertDescription } from '@/components/ui/alert'; import { AlertCircle } from 'lucide-react'; import { Skeleton } from '@/components/ui/skeleton'; import { cn } from '@/lib/utils'; import { motion } from 'framer-motion'; import { SourceList } from '@/components/SourceList'; import { Logo } from '@/components/Logo'; interface SearchResultsProps { query: string; results: any; isLoading: boolean; error?: Error; isFollowUp?: boolean; originalQuery?: string; } export function SearchResults({ query, results, isLoading, error, isFollowUp, originalQuery }: SearchResultsProps) { const contentRef = useRef(null); useEffect(() => { if (results && contentRef.current) { contentRef.current.scrollIntoView({ behavior: 'smooth' }); } }, [results]); if (error) { return ( {error.message || 'An error occurred while searching. Please try again.'} ); } if (isLoading) { return (
); } if (!results) return null; return (
{/* Search Query Display */} {isFollowUp && originalQuery && ( <>
Original search: "{originalQuery}"
)}
{isFollowUp ? 'Follow-up question:' : ''}

"{query}"

{/* Sources Section */} {results.sources && results.sources.length > 0 && ( )} {/* Main Content */}
); }