'use client'
import { User } from 'lucide-react'
import { Fragment, useCallback, useEffect, useRef, useState } from 'react'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import { useBreakpoint } from 'common'
import {
AiIconAnimation,
Button,
CommandGroup_Shadcn_,
CommandItem_Shadcn_,
CommandList_Shadcn_,
cn,
markdownComponents,
} from 'ui'
import { StatusIcon } from 'ui/src/components/StatusIcon'
import {
Breadcrumb,
CommandHeader,
CommandInput,
CommandWrapper,
generateCommandClassNames,
useHistoryKeys,
useQuery,
useSetCommandMenuSize,
useSetQuery,
} from '../..'
import { AiWarning, Message, MessageRole, MessageStatus, useAiChat } from '../ai'
const questions = [
'How do I get started with Supabase?',
'How do I run Supabase locally?',
'How do I connect to my database?',
'How do I run migrations? ',
'How do I listen to changes in a table?',
'How do I set up authentication?',
]
const DocsAiPage = () => {
const setQuery = useSetQuery()
const isBelowSm = useBreakpoint('sm')
/**
* Interface for AI interaction is larger to allow more reading space.
*/
useSetCommandMenuSize('xlarge')
const [isLoading, setIsLoading] = useState(false)
const { submit, reset, messages, isResponding, hasError } = useAiChat({
setIsLoading,
})
const handleSubmit = useCallback(
(message: string) => {
setQuery('')
submit(message)
},
[submit]
)
const handleReset = useCallback(() => {
setQuery('')
reset()
}, [reset])
return (
{isBelowSm && (
)}