import { CircleCheckIcon, Loader2Icon, PlayIcon } from 'lucide-react' import type { ComponentProps, ReactNode } from 'react' import { cn } from 'ui' import { type SqlSnippetSource } from '../../SQLEditor/querySource' import { type QueryResult } from '../types' import { QueryResultChart } from './QueryResultChart' import { QueryResultError } from './QueryResultError' import { DataGridResults } from '@/components/ui/DataGridResults' import { type ChartConfig } from '@/data/content/notebooks/notebook-schema' interface QueryResultRendererProps { result?: QueryResult /** * While a run is in flight the results region shows a running state. Previous rows stay * visible underneath, dimmed, so notebook cells keep their height instead of collapsing. */ isExecuting?: boolean view?: 'table' | 'chart' chart?: ChartConfig /** The query that produced `result`, used to build the "Debug with Assistant" prompt on error. */ sql?: string source?: SqlSnippetSource onDebug?: (prompt: string) => void } interface QueryResultStateProps extends ComponentProps<'div'> { icon: ReactNode children: ReactNode } /** Centered icon-over-label state for the results region (idle, running, empty). */ const QueryResultState = ({ icon, children, className, ...props }: QueryResultStateProps) => (
{children}
{getRunAnnouncement(props)}