2026-02-28 20:42:40 +00:00
|
|
|
import { useState, useEffect } from "react";
|
2026-02-27 04:29:51 +00:00
|
|
|
import ApiKeyInput from "./ApiKeyInput";
|
|
|
|
|
import DockerSettings from "./DockerSettings";
|
2026-02-27 15:22:49 +00:00
|
|
|
import AwsSettings from "./AwsSettings";
|
2026-02-27 18:39:20 -08:00
|
|
|
import { useSettings } from "../../hooks/useSettings";
|
2026-02-28 21:18:33 +00:00
|
|
|
import { useUpdates } from "../../hooks/useUpdates";
|
2026-02-27 04:29:51 +00:00
|
|
|
|
|
|
|
|
export default function SettingsPanel() {
|
2026-02-27 18:39:20 -08:00
|
|
|
const { appSettings, saveSettings } = useSettings();
|
2026-02-28 21:18:33 +00:00
|
|
|
const { appVersion, checkForUpdates } = useUpdates();
|
2026-02-28 20:42:40 +00:00
|
|
|
const [globalInstructions, setGlobalInstructions] = useState(appSettings?.global_claude_instructions ?? "");
|
2026-02-28 21:18:33 +00:00
|
|
|
const [checkingUpdates, setCheckingUpdates] = useState(false);
|
2026-02-28 20:42:40 +00:00
|
|
|
|
|
|
|
|
// Sync local state when appSettings change
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setGlobalInstructions(appSettings?.global_claude_instructions ?? "");
|
|
|
|
|
}, [appSettings?.global_claude_instructions]);
|
|
|
|
|
|
|
|
|
|
const handleInstructionsBlur = async () => {
|
|
|
|
|
if (!appSettings) return;
|
|
|
|
|
await saveSettings({ ...appSettings, global_claude_instructions: globalInstructions || null });
|
|
|
|
|
};
|
2026-02-27 18:39:20 -08:00
|
|
|
|
2026-02-28 21:18:33 +00:00
|
|
|
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 });
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-27 04:29:51 +00:00
|
|
|
return (
|
|
|
|
|
<div className="p-4 space-y-6">
|
|
|
|
|
<h2 className="text-xs font-semibold uppercase text-[var(--text-secondary)]">
|
|
|
|
|
Settings
|
|
|
|
|
</h2>
|
|
|
|
|
<ApiKeyInput />
|
|
|
|
|
<DockerSettings />
|
2026-02-27 15:22:49 +00:00
|
|
|
<AwsSettings />
|
2026-02-27 18:39:20 -08:00
|
|
|
<div>
|
|
|
|
|
<label className="block text-sm font-medium mb-2">Claude Instructions</label>
|
|
|
|
|
<p className="text-xs text-[var(--text-secondary)] mb-1.5">
|
|
|
|
|
Global instructions applied to all projects (written to ~/.claude/CLAUDE.md in containers)
|
|
|
|
|
</p>
|
|
|
|
|
<textarea
|
2026-02-28 20:42:40 +00:00
|
|
|
value={globalInstructions}
|
|
|
|
|
onChange={(e) => setGlobalInstructions(e.target.value)}
|
|
|
|
|
onBlur={handleInstructionsBlur}
|
2026-02-27 18:39:20 -08:00
|
|
|
placeholder="Instructions for Claude Code in all project containers..."
|
|
|
|
|
rows={4}
|
|
|
|
|
className="w-full px-2 py-1.5 text-xs bg-[var(--bg-primary)] border border-[var(--border-color)] rounded focus:outline-none focus:border-[var(--accent)] resize-y font-mono"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2026-02-28 21:18:33 +00:00
|
|
|
|
|
|
|
|
{/* Updates section */}
|
|
|
|
|
<div>
|
|
|
|
|
<label className="block text-sm font-medium mb-2">Updates</label>
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
{appVersion && (
|
|
|
|
|
<p className="text-xs text-[var(--text-secondary)]">
|
|
|
|
|
Current version: <span className="text-[var(--text-primary)] font-mono">{appVersion}</span>
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<label className="text-xs text-[var(--text-secondary)]">Auto-check for updates</label>
|
|
|
|
|
<button
|
|
|
|
|
onClick={handleAutoCheckToggle}
|
|
|
|
|
className={`px-2 py-0.5 text-xs rounded transition-colors ${
|
|
|
|
|
appSettings?.auto_check_updates !== false
|
|
|
|
|
? "bg-[var(--success)] text-white"
|
|
|
|
|
: "bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-secondary)]"
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{appSettings?.auto_check_updates !== false ? "ON" : "OFF"}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<button
|
|
|
|
|
onClick={handleCheckNow}
|
|
|
|
|
disabled={checkingUpdates}
|
|
|
|
|
className="px-3 py-1.5 text-xs bg-[var(--bg-primary)] border border-[var(--border-color)] rounded hover:bg-[var(--border-color)] disabled:opacity-50 transition-colors"
|
|
|
|
|
>
|
|
|
|
|
{checkingUpdates ? "Checking..." : "Check now"}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-02-27 04:29:51 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|