import { useState, useEffect } from "react"; import ApiKeyInput from "./ApiKeyInput"; import DockerSettings from "./DockerSettings"; import AwsSettings from "./AwsSettings"; import { useSettings } from "../../hooks/useSettings"; import { useUpdates } from "../../hooks/useUpdates"; import ClaudeInstructionsModal from "../projects/ClaudeInstructionsModal"; import EnvVarsModal from "../projects/EnvVarsModal"; import type { EnvVar } from "../../lib/types"; export default function SettingsPanel() { const { appSettings, saveSettings } = useSettings(); const { appVersion, checkForUpdates } = useUpdates(); const [globalInstructions, setGlobalInstructions] = useState(appSettings?.global_claude_instructions ?? ""); const [globalEnvVars, setGlobalEnvVars] = useState(appSettings?.global_custom_env_vars ?? []); const [checkingUpdates, setCheckingUpdates] = useState(false); const [showInstructionsModal, setShowInstructionsModal] = useState(false); const [showEnvVarsModal, setShowEnvVarsModal] = useState(false); // Sync local state when appSettings change useEffect(() => { setGlobalInstructions(appSettings?.global_claude_instructions ?? ""); setGlobalEnvVars(appSettings?.global_custom_env_vars ?? []); }, [appSettings?.global_claude_instructions, appSettings?.global_custom_env_vars]); const handleCheckNow = async () => { setCheckingUpdates(true); try { await checkForUpdates(); } finally { setCheckingUpdates(false); } }; const handleAutoCheckToggle = async () => { if (!appSettings) return; await saveSettings({ ...appSettings, auto_check_updates: !appSettings.auto_check_updates }); }; return (

Settings

{/* Global Claude Instructions */}

Global instructions applied to all projects (written to ~/.claude/CLAUDE.md in containers)

{globalInstructions ? "Configured" : "Not set"}
{/* Global Environment Variables */}

Applied to all project containers. Per-project variables override global ones with the same key.

{globalEnvVars.length > 0 ? `${globalEnvVars.length} variable${globalEnvVars.length === 1 ? "" : "s"}` : "None"}
{/* Updates section */}
{appVersion && (

Current version: {appVersion}

)}
{showInstructionsModal && ( { setGlobalInstructions(instructions); if (appSettings) { await saveSettings({ ...appSettings, global_claude_instructions: instructions || null }); } }} onClose={() => setShowInstructionsModal(false)} /> )} {showEnvVarsModal && ( { setGlobalEnvVars(vars); if (appSettings) { await saveSettings({ ...appSettings, global_custom_env_vars: vars }); } }} onClose={() => setShowEnvVarsModal(false)} /> )}
); }