import { useParams } from 'common' import { motion } from 'framer-motion' import { BarChart, FileText, Shield } from 'lucide-react' import { Button, Skeleton } from 'ui' import { codeSnippetPrompts, defaultPrompts } from './AIAssistant.prompts' import type { SqlSnippet } from './AIAssistant.types' import { LINTER_LEVELS } from '@/components/interfaces/Linter/Linter.constants' import { createLintSummaryPrompt } from '@/components/interfaces/Linter/Linter.utils' import { useProjectLintsQuery, type Lint } from '@/data/lint/lint-query' interface AIOnboardingProps { sqlSnippets?: SqlSnippet[] suggestions?: { title?: string prompts?: { label: string; description: string }[] } onValueChange: (value: string) => void onFocusInput?: () => void } export const AIOnboarding = ({ sqlSnippets, suggestions, onValueChange, onFocusInput, }: AIOnboardingProps) => { const prompts = suggestions?.prompts ? suggestions.prompts.map((suggestion) => ({ title: suggestion.label, prompt: suggestion.description, icon: , })) : sqlSnippets && sqlSnippets.length > 0 ? codeSnippetPrompts : defaultPrompts const { ref: projectRef } = useParams() const { data: lints, isPending: isLoadingLints, isFetching: isFetchingLints, } = useProjectLintsQuery({ projectRef }) const isLintsLoading = isLoadingLints || isFetchingLints const errorLints: Lint[] = (lints?.filter((lint) => lint.level === LINTER_LEVELS.ERROR) ?? []) as Lint[] const securityErrorLints = errorLints.filter((lint) => lint.categories?.[0] === 'SECURITY') const performanceErrorLints = errorLints.filter((lint) => lint.categories?.[0] !== 'SECURITY') return (

How can I assist you?

{suggestions?.prompts?.length ? (

Suggestions

{prompts.map((item, index) => ( ))}
) : ( <> {isLintsLoading ? (
{Array.from({ length: 6 }).map((_, index) => ( ))}
) : ( <> {performanceErrorLints.length > 0 && (

Improve Performance

{performanceErrorLints.map((lint, index) => { return ( ) })}
)} {securityErrorLints.length > 0 && (

Improve Security

{securityErrorLints.map((lint, index) => { return ( ) })}
)}

Ideas

{prompts.map((item, index) => ( ))}
)} )}
) }