diff --git a/src/components/settings/ApiKeyConfiguration.tsx b/src/components/settings/ApiKeyConfiguration.tsx index 800fd18..07bfb56 100644 --- a/src/components/settings/ApiKeyConfiguration.tsx +++ b/src/components/settings/ApiKeyConfiguration.tsx @@ -1,4 +1,4 @@ -import { Info, KeyRound, Trash2 } from "lucide-react"; +import { Info, KeyRound, Trash2, Clipboard } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Accordion, @@ -11,6 +11,8 @@ import { VertexConfiguration } from "./VertexConfiguration"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { UserSettings } from "@/lib/schemas"; +import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; +import { showError } from "@/lib/toast"; // Helper function to mask ENV API keys (move or duplicate if needed elsewhere) const maskEnvApiKey = (key: string | undefined): string => { @@ -29,7 +31,7 @@ interface ApiKeyConfigurationProps { saveError: string | null; apiKeyInput: string; onApiKeyInputChange: (value: string) => void; - onSaveKey: () => Promise; + onSaveKey: (value: string) => Promise; onDeleteKey: () => Promise; isDyad: boolean; updateSettings: (settings: Partial) => Promise; @@ -144,7 +146,36 @@ export function ApiKeyConfiguration({ placeholder={`Enter new ${providerDisplayName} API Key here`} className={`flex-grow ${saveError ? "border-red-500" : ""}`} /> - + + Paste from clipboard and save + + + diff --git a/src/components/settings/ProviderSettingsHeader.tsx b/src/components/settings/ProviderSettingsHeader.tsx index e463f7e..ff8ff9d 100644 --- a/src/components/settings/ProviderSettingsHeader.tsx +++ b/src/components/settings/ProviderSettingsHeader.tsx @@ -1,14 +1,20 @@ import { ArrowLeft, + ArrowUp, Circle, ExternalLink, GiftIcon, KeyRound, - Settings as SettingsIcon, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import { IpcClient } from "@/ipc/ipc_client"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import {} from "react"; interface ProviderSettingsHeaderProps { providerDisplayName: string; @@ -51,6 +57,17 @@ export function ProviderSettingsHeader({ } }; + const ConfigureButton = ( + + ); + return ( <> - )} + {providerWebsiteUrl && + !isLoading && + (!isConfigured ? ( + + {ConfigureButton} + +
+ Create your API key with {providerDisplayName} +
+
+
+ ) : ( + ConfigureButton + ))} ); } diff --git a/src/components/settings/ProviderSettingsPage.tsx b/src/components/settings/ProviderSettingsPage.tsx index c3f586c..970f699 100644 --- a/src/components/settings/ProviderSettingsPage.tsx +++ b/src/components/settings/ProviderSettingsPage.tsx @@ -118,8 +118,8 @@ export function ProviderSettingsPage({ provider }: ProviderSettingsPageProps) { : isValidUserKey || hasEnvKey; // Configured if either is set // --- Save Handler --- - const handleSaveKey = async () => { - if (!apiKeyInput) { + const handleSaveKey = async (value: string) => { + if (!value.trim()) { setSaveError("API Key cannot be empty."); return; } @@ -132,7 +132,7 @@ export function ProviderSettingsPage({ provider }: ProviderSettingsPageProps) { [provider]: { ...settings?.providerSettings?.[provider], apiKey: { - value: apiKeyInput, + value, }, }, },