diff --git a/apps/studio/components/ui/AIAssistantPanel/AIAssistantChatSelector.tsx b/apps/studio/components/ui/AIAssistantPanel/AIAssistantChatSelector.tsx index 9e648c51b69..e5631c81b38 100644 --- a/apps/studio/components/ui/AIAssistantPanel/AIAssistantChatSelector.tsx +++ b/apps/studio/components/ui/AIAssistantPanel/AIAssistantChatSelector.tsx @@ -1,4 +1,4 @@ -import { Check, ChevronDown, Edit, Plus, Trash, X } from 'lucide-react' +import { Check, Edit, History, Plus, Trash, X } from 'lucide-react' import { useState } from 'react' import { Button, @@ -17,7 +17,10 @@ import { ScrollArea, } from 'ui' +import { ShortcutTooltip } from '../ShortcutTooltip' import { useAiAssistantStateSnapshot } from '@/state/ai-assistant-state' +import { SHORTCUT_IDS } from '@/state/shortcuts/registry' +import { useShortcut } from '@/state/shortcuts/useShortcut' interface AIAssistantChatSelectorProps { disabled?: boolean @@ -25,7 +28,6 @@ interface AIAssistantChatSelectorProps { export const AIAssistantChatSelector = ({ disabled = false }: AIAssistantChatSelectorProps) => { const snap = useAiAssistantStateSnapshot() - const currentChat = snap.activeChat?.name const [chatSelectorOpen, setChatSelectorOpen] = useState(false) const [editingChatId, setEditingChatId] = useState(null) @@ -33,6 +35,8 @@ export const AIAssistantChatSelector = ({ disabled = false }: AIAssistantChatSel const chats = Object.entries(snap.chats) + useShortcut(SHORTCUT_IDS.AI_ASSISTANT_TOGGLE_HISTORY, () => setChatSelectorOpen((prev) => !prev)) + const handleSelectChat = (id: string) => { snap.selectChat(id) setChatSelectorOpen(false) @@ -78,17 +82,22 @@ export const AIAssistantChatSelector = ({ disabled = false }: AIAssistantChatSel return ( - - - - + + + + )} -
+ +
+ + } + icon={} onClick={onNewChat} className="h-7 w-7 p-0" /> - -
+ {showMetadataWarning && (
How can I assist you? + {suggestions?.prompts?.length ? (
diff --git a/apps/studio/components/ui/ShortcutTooltip.tsx b/apps/studio/components/ui/ShortcutTooltip.tsx index 5b8c3b70889..23bc80df5b7 100644 --- a/apps/studio/components/ui/ShortcutTooltip.tsx +++ b/apps/studio/components/ui/ShortcutTooltip.tsx @@ -1,3 +1,4 @@ +import { HotkeySequence } from '@tanstack/react-hotkeys' import { TooltipContentProps } from '@ui/components/shadcn/ui/tooltip' import { Fragment, useState, type ReactNode } from 'react' import { KeyboardShortcut, Tooltip, TooltipContent, TooltipTrigger } from 'ui' @@ -65,15 +66,21 @@ export const ShortcutTooltip = ({ className="flex items-center gap-2" > {label} - - {def.sequence.map((step, i) => ( - - {i > 0 && then} - - - ))} - + ) } + +export const ShortcutPills = ({ sequence }: { sequence: HotkeySequence }) => { + return ( + + {sequence.map((step, i) => ( + + {i > 0 && then} + + + ))} + + ) +} diff --git a/apps/studio/state/shortcuts/registry.ts b/apps/studio/state/shortcuts/registry.ts index 9945b09edf4..6f9ddc54950 100644 --- a/apps/studio/state/shortcuts/registry.ts +++ b/apps/studio/state/shortcuts/registry.ts @@ -71,6 +71,8 @@ export const SHORTCUT_IDS = { COMMAND_MENU_OPEN: 'command-menu.open', AI_ASSISTANT_TOGGLE: 'ai-assistant.toggle', AI_ASSISTANT_NEW_CHAT: 'ai-assistant.new-chat', + AI_ASSISTANT_COPY_CHAT_ID: 'ai-assistant.copy-chat-id', + AI_ASSISTANT_TOGGLE_HISTORY: 'ai-assistant.toggle-history', AI_ASSISTANT_OPEN_PERMISSIONS: 'ai-assistant.open-permissions', AI_ASSISTANT_CANCEL_EDIT: 'ai-assistant.cancel-edit', INLINE_EDITOR_TOGGLE: 'inline-editor.toggle', @@ -261,6 +263,18 @@ export const SHORTCUT_DEFINITIONS: Record = { sequence: ['A', 'N'], showInSettings: false, }, + [SHORTCUT_IDS.AI_ASSISTANT_COPY_CHAT_ID]: { + id: SHORTCUT_IDS.AI_ASSISTANT_COPY_CHAT_ID, + label: 'Copy chat ID', + sequence: ['A', 'C'], + showInSettings: false, + }, + [SHORTCUT_IDS.AI_ASSISTANT_TOGGLE_HISTORY]: { + id: SHORTCUT_IDS.AI_ASSISTANT_TOGGLE_HISTORY, + label: 'Toggle chat history', + sequence: ['A', 'Y'], + showInSettings: false, + }, [SHORTCUT_IDS.AI_ASSISTANT_OPEN_PERMISSIONS]: { id: SHORTCUT_IDS.AI_ASSISTANT_OPEN_PERMISSIONS, label: 'Permission settings',