diff --git a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx index 640b511c37c..afcbae6011e 100644 --- a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx +++ b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx @@ -1,7 +1,7 @@ import type { Message as MessageType } from 'ai/react' import { useChat } from 'ai/react' import { AnimatePresence, motion } from 'framer-motion' -import { ArrowDown, FileText, Info, RefreshCw, X } from 'lucide-react' +import { ArrowDown, FileText, Info, RefreshCw, Settings, X } from 'lucide-react' import { useRouter } from 'next/router' import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' @@ -312,56 +312,40 @@ export const AIAssistant = ({ className }: AIAssistantProps) => {
-
- - +
- Assistant - - - - - - The Assistant is in Alpha and your prompts might be rate limited.{' '} - {aiOptInLevel === 'schema_and_log_and_data' && - 'Schema, logs, and query data are being shared to improve Assistant responses.'} - {aiOptInLevel === 'schema_and_log' && - 'Schema and logs are being shared to improve Assistant responses.'} - {aiOptInLevel === 'schema' && - 'Only schema metadata is being shared to improve Assistant responses.'} - {aiOptInLevel === 'disabled' && - 'Project metadata is not being shared. Opt in to improve Assistant responses.'} - - +
- - -

- {currentChat} -

-
- Current chat: {currentChat} -
-
- +
} + icon={} + onClick={() => setIsConfirmOptInModalOpen(true)} + className="h-7 w-7 p-0" + disabled={isChatLoading} + tooltip={{ + content: { + side: 'bottom', + text: 'Permission settings', + }, + }} + /> + } onClick={handleClearMessages} className="h-7 w-7 p-0" disabled={isChatLoading} tooltip={{ content: { side: 'bottom', text: 'Clear messages' } }} /> } + icon={} tooltip={{ content: { side: 'bottom', text: 'Close assistant' } }} />
@@ -410,7 +394,7 @@ export const AIAssistant = ({ className }: AIAssistantProps) => {
)} {hasMessages ? ( -
+
{renderedMessages} {isChatLoading && ( @@ -576,9 +560,9 @@ export const AIAssistant = ({ className }: AIAssistantProps) => { )} -
+
{snap.sqlSnippets && snap.sqlSnippets.length > 0 && ( -
+
{snap.sqlSnippets.map((snippet: string, index: number) => ( { newSnippets.splice(index, 1) snap.setSqlSnippets(newSnippets) }} - className="text-xs" + className="text-xs rounded-b-none" /> ))}
diff --git a/apps/studio/components/ui/AIAssistantPanel/AIAssistantChatSelector.tsx b/apps/studio/components/ui/AIAssistantPanel/AIAssistantChatSelector.tsx index 1f332d3b1e2..9ced2b9cf20 100644 --- a/apps/studio/components/ui/AIAssistantPanel/AIAssistantChatSelector.tsx +++ b/apps/studio/components/ui/AIAssistantPanel/AIAssistantChatSelector.tsx @@ -1,4 +1,4 @@ -import { Check, Edit, MessageSquare, Plus, Trash, X } from 'lucide-react' +import { Check, ChevronDown, Edit, MessageSquare, Plus, Trash, X } from 'lucide-react' import { useState } from 'react' import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state' @@ -30,6 +30,7 @@ export const AIAssistantChatSelector = ({ disabled = false, }: AIAssistantChatSelectorProps) => { const snap = useAiAssistantStateSnapshot() + const currentChat = snap.activeChat?.name const [chatSelectorOpen, setChatSelectorOpen] = useState(false) const [editingChatId, setEditingChatId] = useState(null) @@ -91,15 +92,11 @@ export const AIAssistantChatSelector = ({ return ( - } - className={cn('h-7 w-7', className)} - tooltip={{ content: { side: 'bottom', text: 'View chats' } }} - /> + - + diff --git a/apps/studio/components/ui/AIAssistantPanel/CollapsibleCodeBlock.tsx b/apps/studio/components/ui/AIAssistantPanel/CollapsibleCodeBlock.tsx index 92e83becffb..77a8a1e6bce 100644 --- a/apps/studio/components/ui/AIAssistantPanel/CollapsibleCodeBlock.tsx +++ b/apps/studio/components/ui/AIAssistantPanel/CollapsibleCodeBlock.tsx @@ -1,49 +1,47 @@ -import { ChevronDown, ChevronUp, X } from 'lucide-react' -import { useState } from 'react' +import { Code, X } from 'lucide-react' -import { Button, CodeBlock, CodeBlockProps, cn } from 'ui' +import { + Button, + CodeBlock, + CodeBlockProps, + cn, + HoverCard_Shadcn_, + HoverCardContent_Shadcn_, + HoverCardTrigger_Shadcn_, +} from 'ui' interface CollapsibleCodeBlockProps extends CodeBlockProps { onRemove?: () => void } export const CollapsibleCodeBlock = ({ onRemove, ...props }: CollapsibleCodeBlockProps) => { - const [isExpanded, setIsExpanded] = useState(false) - const codeString = (props.value || props.children) as string - const firstLine = isExpanded - ? codeString - : codeString?.substring(0, codeString.indexOf('\n')) || codeString + const firstLine = codeString?.substring(0, codeString.indexOf('\n')) || codeString return (
-