mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 07:09:07 +03:00
* improve some studio mobile layouts * improve some studio mobile layouts * improve settings * assistant mobile * assistant mobile * assistant mobile * responsive formlayout and new project layout * improve dashboard pages headers * improve dashboard auth pages * mobile org settings * mobile billing fixes * adjust paused project container height * remove comments * triggers * leftovers * ai assistant * fix errors * remove 16px input size * fix test * merge access tokens settings page conflicsts * smol integrations here and there
33 lines
1015 B
TypeScript
33 lines
1015 B
TypeScript
import type { Message as MessageType } from 'ai/react'
|
|
import { uuidv4 } from 'lib/helpers'
|
|
import { useState } from 'react'
|
|
import { useAppStateSnapshot } from 'state/app-state'
|
|
import { cn } from 'ui'
|
|
import { AIAssistant } from './AIAssistant'
|
|
|
|
export const AIAssistantPanel = () => {
|
|
const { aiAssistantPanel, resetAiAssistantPanel } = useAppStateSnapshot()
|
|
const [initialMessages, setInitialMessages] = useState<MessageType[] | undefined>(
|
|
aiAssistantPanel.messages?.length > 0 ? (aiAssistantPanel.messages as any) : undefined
|
|
)
|
|
|
|
const { open } = aiAssistantPanel
|
|
const [chatId, setChatId] = useState(() => uuidv4())
|
|
|
|
const handleReset = () => {
|
|
// reset local and global state
|
|
setChatId(uuidv4())
|
|
setInitialMessages(undefined)
|
|
resetAiAssistantPanel()
|
|
}
|
|
|
|
return !open ? null : (
|
|
<AIAssistant
|
|
initialMessages={initialMessages}
|
|
id={chatId}
|
|
className={cn('w-full h-[100dvh] md:h-full max-h-[100dvh]')}
|
|
onResetConversation={handleReset}
|
|
/>
|
|
)
|
|
}
|