diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-modal/copilot-modal.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-modal/copilot-modal.tsx index 9b86c2c09..c9454e4dc 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-modal/copilot-modal.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-modal/copilot-modal.tsx @@ -1,10 +1,17 @@ 'use client' import { type KeyboardEvent, useEffect, useRef } from 'react' -import { ArrowUp, Bot, X } from 'lucide-react' +import { ArrowUp, Bot, ChevronDown, MessageSquarePlus, MoreHorizontal, Trash2, X } from 'lucide-react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu' import { createLogger } from '@/lib/logs/console-logger' +import { type CopilotChat } from '@/lib/copilot-api' const logger = createLogger('CopilotModal') @@ -129,6 +136,12 @@ interface CopilotModalProps { messages: Message[] onSendMessage: (message: string) => Promise isLoading: boolean + // Chat management props + chats: CopilotChat[] + currentChat: CopilotChat | null + onSelectChat: (chat: CopilotChat) => void + onStartNewChat: () => void + onDeleteChat: (chatId: string) => void } export function CopilotModal({ @@ -139,6 +152,11 @@ export function CopilotModal({ messages, onSendMessage, isLoading, + chats, + currentChat, + onSelectChat, + onStartNewChat, + onDeleteChat, }: CopilotModalProps) { const messagesEndRef = useRef(null) const messagesContainerRef = useRef(null) @@ -202,9 +220,72 @@ export function CopilotModal({ } `} - {/* Header with title and close button */} -
-

Documentation Copilot

+ {/* Header with chat title, management, and close button */} +
+
+ {/* Chat Title Dropdown */} + + + + + + {chats.map((chat) => ( +
+ onSelectChat(chat)} + className='flex-1 cursor-pointer' + > +
+
+ {chat.title || 'Untitled Chat'} +
+
+ {chat.messageCount} messages •{' '} + {new Date(chat.updatedAt).toLocaleDateString()} +
+
+
+ + + + + + onDeleteChat(chat.id)} + className='cursor-pointer text-destructive' + > + + Delete + + + +
+ ))} +
+
+ + {/* New Chat Button */} + +
+ - - {chats.length > 0 && ( - - - - - - {chats.map((chat) => ( -
- selectChat(chat)} - className='flex-1 cursor-pointer' - > -
-
- {chat.title || 'Untitled Chat'} -
-
- {chat.messageCount} messages •{' '} - {new Date(chat.updatedAt).toLocaleDateString()} -
-
-
- - - - - - handleDeleteChat(chat.id)} - className='cursor-pointer text-destructive' - > - - Delete - - - + {/* Chat Title Dropdown */} + + + + + + {chats.map((chat) => ( +
+ selectChat(chat)} + className='flex-1 cursor-pointer' + > +
+
+ {chat.title || 'Untitled Chat'} +
+
+ {chat.messageCount} messages •{' '} + {new Date(chat.updatedAt).toLocaleDateString()} +
- ))} - - - )} -
+ + + + + + + handleDeleteChat(chat.id)} + className='cursor-pointer text-destructive' + > + + Delete + + + +
+ ))} +
+
+ + {/* New Chat Button */} +
@@ -586,6 +585,11 @@ export const Copilot = forwardRef( messages={modalMessages} onSendMessage={handleModalSendMessage} isLoading={isLoading} + chats={chats} + currentChat={currentChat} + onSelectChat={selectChat} + onStartNewChat={startNewChat} + onDeleteChat={handleDeleteChat} /> )