mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 05:39:11 +03:00
* sidebar-manager * storage keys * tests * more ai spots * test fix * revert to default * remove ref * Update apps/studio/state/sidebar-manager-state.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix ts * fix * fux * fux query param * clean * fix * more * mock local storage * simplify * remove provider test * remve useopensidebar * fix(new homepage): open ai assistant on advisor card button clicks * Update apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * Update apps/studio/state/sidebar-manager-state.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * refine * FIX --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { LOCAL_STORAGE_KEYS } from 'common'
|
|
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
|
|
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
|
|
import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state'
|
|
import { AiIconAnimation, KeyboardShortcut } from 'ui'
|
|
import { SIDEBAR_KEYS } from '../ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
|
|
import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
|
|
|
|
export const AssistantButton = () => {
|
|
const { toggleSidebar } = useSidebarManagerSnapshot()
|
|
const [isAIAssistantHotkeyEnabled] = useLocalStorageQuery<boolean>(
|
|
LOCAL_STORAGE_KEYS.HOTKEY_SIDEBAR(SIDEBAR_KEYS.AI_ASSISTANT),
|
|
true
|
|
)
|
|
|
|
return (
|
|
<ButtonTooltip
|
|
type="text"
|
|
size="tiny"
|
|
id="assistant-trigger"
|
|
className="rounded-none w-[32px] h-[30px] flex items-center justify-center p-0 hover:bg-brand-400"
|
|
onClick={() => {
|
|
toggleSidebar(SIDEBAR_KEYS.AI_ASSISTANT)
|
|
}}
|
|
tooltip={{
|
|
content: {
|
|
text: (
|
|
<div className="flex items-center gap-4">
|
|
<span>AI Assistant</span>
|
|
{isAIAssistantHotkeyEnabled && <KeyboardShortcut keys={['Meta', 'i']} />}
|
|
</div>
|
|
),
|
|
},
|
|
}}
|
|
>
|
|
<AiIconAnimation allowHoverEffect={false} size={16} />
|
|
</ButtonTooltip>
|
|
)
|
|
}
|