import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Switch } from "@/components/ui/switch"; import { Label } from "@/components/ui/label"; import { Sparkles, Info } from "lucide-react"; import { useSettings } from "@/hooks/useSettings"; import { IpcClient } from "@/ipc/ipc_client"; import { hasDyadProKey, type UserSettings } from "@/lib/schemas"; export function ProModeSelector() { const { settings, updateSettings } = useSettings(); const toggleLazyEdits = () => { updateSettings({ enableProLazyEditsMode: !settings?.enableProLazyEditsMode, }); }; const handleSmartContextChange = ( newValue: "off" | "conservative" | "balanced", ) => { if (newValue === "off") { updateSettings({ enableProSmartFilesContextMode: false, proSmartContextOption: undefined, }); } else if (newValue === "conservative") { updateSettings({ enableProSmartFilesContextMode: true, proSmartContextOption: "conservative", }); } else if (newValue === "balanced") { updateSettings({ enableProSmartFilesContextMode: true, proSmartContextOption: "balanced", }); } }; const toggleProEnabled = () => { updateSettings({ enableDyadPro: !settings?.enableDyadPro, }); }; const hasProKey = settings ? hasDyadProKey(settings) : false; const proModeTogglable = hasProKey && Boolean(settings?.enableDyadPro); return ( Configure Dyad Pro settings

Dyad Pro

{!hasProKey && (
{ IpcClient.getInstance().openExternalUrl( "https://dyad.sh/pro#ai", ); }} > Unlock Pro modes
)}
); } function SelectorRow({ id, label, description, tooltip, isTogglable, settingEnabled, toggle, }: { id: string; label: string; description: string; tooltip: string; isTogglable: boolean; settingEnabled: boolean; toggle: () => void; }) { return (
{tooltip}

{description}

); } function SmartContextSelector({ isTogglable, settings, onValueChange, }: { isTogglable: boolean; settings: UserSettings | null; onValueChange: (value: "off" | "conservative" | "balanced") => void; }) { // Determine current value based on settings const getCurrentValue = (): "off" | "conservative" | "balanced" => { if (!settings?.enableProSmartFilesContextMode) { return "off"; } if (settings?.proSmartContextOption === "balanced") { return "balanced"; } if (settings?.proSmartContextOption === "conservative") { return "conservative"; } // Keep in sync with getModelClient in get_model_client.ts // If enabled but no option set (undefined/falsey), it's balanced return "balanced"; }; const currentValue = getCurrentValue(); return (
Improve efficiency and save credits working on large codebases.

Optimizes your AI's code context

); }