@@ -9,6 +9,8 @@ import { useClickAway } from "@/hooks/useClickAway";
99import VisibleKey from "@/components/Common/VisibleKey" ;
1010import { useConnectStore } from "@/stores/connectStore" ;
1111import FontIcon from "@/components/Common/Icons/FontIcon" ;
12+ import { AI_ASSISTANT_PANEL_ID } from "@/constants" ;
13+ import { useShortcutsStore } from "@/stores/shortcutsStore" ;
1214
1315interface AssistantListProps {
1416 showChatHistory ?: boolean ;
@@ -19,17 +21,20 @@ export function AssistantList({ showChatHistory = true }: AssistantListProps) {
1921 const isTauri = useAppStore ( ( state ) => state . isTauri ) ;
2022 const currentService = useConnectStore ( ( state ) => state . currentService ) ;
2123 const currentAssistant = useConnectStore ( ( state ) => state . currentAssistant ) ;
22- const setCurrentAssistant = useConnectStore ( ( state ) => state . setCurrentAssistant ) ;
24+ const setCurrentAssistant = useConnectStore (
25+ ( state ) => state . setCurrentAssistant
26+ ) ;
2327
2428 const [ isOpen , setIsOpen ] = useState ( false ) ;
2529 const [ isRefreshing , setIsRefreshing ] = useState ( false ) ;
26-
30+ const aiAssistant = useShortcutsStore ( ( state ) => {
31+ return state . aiAssistant ;
32+ } ) ;
2733 const menuRef = useRef < HTMLDivElement > ( null ) ;
2834
2935 useClickAway ( menuRef , ( ) => setIsOpen ( false ) ) ;
3036 const [ assistants , setAssistants ] = useState < any [ ] > ( [ ] ) ;
3137
32-
3338 const fetchAssistant = useCallback ( async ( ) => {
3439 if ( ! isTauri ) return ;
3540 if ( ! currentService ?. id ) return ;
@@ -82,16 +87,27 @@ export function AssistantList({ showChatHistory = true }: AssistantListProps) {
8287 { currentAssistant ?. _source ?. name || "Coco AI" }
8388 </ div >
8489 { showChatHistory && isTauri && (
85- < ChevronDownIcon
86- className = { `size-4 text-gray-500 dark:text-gray-400 transition-transform ${
87- isOpen ? "rotate-180" : ""
88- } `}
89- />
90+ < VisibleKey
91+ aria-controls = { isOpen ? AI_ASSISTANT_PANEL_ID : "" }
92+ shortcut = { aiAssistant }
93+ onKeyPress = { ( ) => {
94+ setIsOpen ( ! isOpen ) ;
95+ } }
96+ >
97+ < ChevronDownIcon
98+ className = { `size-4 text-gray-500 dark:text-gray-400 transition-transform ${
99+ isOpen ? "rotate-180" : ""
100+ } `}
101+ />
102+ </ VisibleKey >
90103 ) }
91104 </ button >
92105
93106 { showChatHistory && isTauri && isOpen && (
94- < div className = "absolute z-50 top-full mt-1 left-0 w-64 rounded-xl bg-white dark:bg-[#202126] p-2 text-sm/6 text-gray-800 dark:text-white shadow-lg border border-gray-200 dark:border-gray-700 focus:outline-none max-h-[calc(100vh-80px)] overflow-y-auto" >
107+ < div
108+ id = { isOpen ? AI_ASSISTANT_PANEL_ID : "" }
109+ className = "absolute z-50 top-full mt-1 left-0 w-64 rounded-xl bg-white dark:bg-[#202126] p-2 text-sm/6 text-gray-800 dark:text-white shadow-lg border border-gray-200 dark:border-gray-700 focus:outline-none max-h-[calc(100vh-80px)] overflow-y-auto"
110+ >
95111 < div className = "sticky top-0 mb-2 px-2 py-1 text-sm font-medium text-gray-900 dark:text-white bg-white dark:bg-[#202126] flex justify-between" >
96112 < div > AI Assistant</ div >
97113 < button
0 commit comments