diff --git a/ui/components/MessageInputActions/Copilot.tsx b/ui/components/MessageInputActions/Copilot.tsx index 5a3e476..63f0607 100644 --- a/ui/components/MessageInputActions/Copilot.tsx +++ b/ui/components/MessageInputActions/Copilot.tsx @@ -1,5 +1,6 @@ import { cn } from '@/lib/utils'; import { Switch } from '@headlessui/react'; +import { useEffect } from 'react'; const CopilotToggle = ({ copilotEnabled, @@ -8,11 +9,33 @@ const CopilotToggle = ({ copilotEnabled: boolean; setCopilotEnabled: (enabled: boolean) => void; }) => { + const fetchAndSetCopilotEnabled = async () => { + const res = await fetch( + `${process.env.NEXT_PUBLIC_API_URL}/config/preferences`, + { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }, + ); + + const preferences = await res.json(); + + setCopilotEnabled(preferences.isCopilotEnabled); + }; + + useEffect(() => { + fetchAndSetCopilotEnabled(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + return (
Copilot