diff options
| author | Clawd <ai@clawd.bot> | 2026-03-01 08:31:52 -0800 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-03-01 08:31:52 -0800 |
| commit | d44d0f61e4026da35c0d1a4acb87ba71ed6cd599 (patch) | |
| tree | 4d3eb7c1db6d71e25634848078ad1cfde57bad6d /renderer/src/components | |
| parent | afdf3d57cb7ae4cbf0a519d1b53872f151ecba87 (diff) | |
feat(settings): add configurable model selection
- Add Model settings section with free-text input for model override
- Pass configured model through to SDK query() calls
- Display active model badge in ActionBar next to token usage
- Seed model state from DB on mount, update from system:init events
- Empty/unset value uses SDK default (no breaking change)
Diffstat (limited to 'renderer/src/components')
| -rw-r--r-- | renderer/src/components/ActionBar.tsx | 9 | ||||
| -rw-r--r-- | renderer/src/components/SettingsPage.tsx | 14 | ||||
| -rw-r--r-- | renderer/src/components/settings/ModelSettings.tsx | 94 |
3 files changed, 115 insertions, 2 deletions
diff --git a/renderer/src/components/ActionBar.tsx b/renderer/src/components/ActionBar.tsx index 22f34b4..d270583 100644 --- a/renderer/src/components/ActionBar.tsx +++ b/renderer/src/components/ActionBar.tsx | |||
| @@ -11,6 +11,7 @@ interface ActionBarProps { | |||
| 11 | onSubmit: () => void; | 11 | onSubmit: () => void; |
| 12 | onPermissionModeChange: (mode: PermissionMode) => void; | 12 | onPermissionModeChange: (mode: PermissionMode) => void; |
| 13 | disabled: boolean; | 13 | disabled: boolean; |
| 14 | modelName?: string | null; | ||
| 14 | } | 15 | } |
| 15 | 16 | ||
| 16 | export function ActionBar({ | 17 | export function ActionBar({ |
| @@ -23,6 +24,7 @@ export function ActionBar({ | |||
| 23 | onSubmit, | 24 | onSubmit, |
| 24 | onPermissionModeChange, | 25 | onPermissionModeChange, |
| 25 | disabled, | 26 | disabled, |
| 27 | modelName, | ||
| 26 | }: ActionBarProps) { | 28 | }: ActionBarProps) { |
| 27 | const totalTokens = tokenUsage.inputTokens + tokenUsage.outputTokens; | 29 | const totalTokens = tokenUsage.inputTokens + tokenUsage.outputTokens; |
| 28 | const maxTokens = 200000; | 30 | const maxTokens = 200000; |
| @@ -52,6 +54,13 @@ export function ActionBar({ | |||
| 52 | </span> | 54 | </span> |
| 53 | </div> | 55 | </div> |
| 54 | 56 | ||
| 57 | {/* ── Model badge ── */} | ||
| 58 | {modelName && ( | ||
| 59 | <span className="model-badge" title="Active model"> | ||
| 60 | {modelName} | ||
| 61 | </span> | ||
| 62 | )} | ||
| 63 | |||
| 55 | {phase === "implement" && ( | 64 | {phase === "implement" && ( |
| 56 | <label className="permission-toggle"> | 65 | <label className="permission-toggle"> |
| 57 | <input | 66 | <input |
diff --git a/renderer/src/components/SettingsPage.tsx b/renderer/src/components/SettingsPage.tsx index 9ebde44..d3ff4bf 100644 --- a/renderer/src/components/SettingsPage.tsx +++ b/renderer/src/components/SettingsPage.tsx | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | import React, { useState } from "react"; | 1 | import React, { useState } from "react"; |
| 2 | import { SystemPromptsSettings } from "./settings/SystemPromptsSettings"; | 2 | import { SystemPromptsSettings } from "./settings/SystemPromptsSettings"; |
| 3 | import { GitSettings } from "./settings/GitSettings"; | 3 | import { GitSettings } from "./settings/GitSettings"; |
| 4 | import { ModelSettings } from "./settings/ModelSettings"; | ||
| 4 | 5 | ||
| 5 | type SettingsSection = "system-prompts" | "git"; | 6 | type SettingsSection = "model" | "system-prompts" | "git"; |
| 6 | 7 | ||
| 7 | interface SettingsPageProps { | 8 | interface SettingsPageProps { |
| 8 | onClose: () => void; | 9 | onClose: () => void; |
| @@ -10,7 +11,7 @@ interface SettingsPageProps { | |||
| 10 | 11 | ||
| 11 | export function SettingsPage({ onClose }: SettingsPageProps) { | 12 | export function SettingsPage({ onClose }: SettingsPageProps) { |
| 12 | const [activeSection, setActiveSection] = | 13 | const [activeSection, setActiveSection] = |
| 13 | useState<SettingsSection>("system-prompts"); | 14 | useState<SettingsSection>("model"); |
| 14 | 15 | ||
| 15 | return ( | 16 | return ( |
| 16 | <div className="settings-overlay"> | 17 | <div className="settings-overlay"> |
| @@ -33,6 +34,14 @@ export function SettingsPage({ onClose }: SettingsPageProps) { | |||
| 33 | <nav className="settings-nav"> | 34 | <nav className="settings-nav"> |
| 34 | <button | 35 | <button |
| 35 | className={`settings-nav-item${ | 36 | className={`settings-nav-item${ |
| 37 | activeSection === "model" ? " active" : "" | ||
| 38 | }`} | ||
| 39 | onClick={() => setActiveSection("model")} | ||
| 40 | > | ||
| 41 | Model | ||
| 42 | </button> | ||
| 43 | <button | ||
| 44 | className={`settings-nav-item${ | ||
| 36 | activeSection === "system-prompts" ? " active" : "" | 45 | activeSection === "system-prompts" ? " active" : "" |
| 37 | }`} | 46 | }`} |
| 38 | onClick={() => setActiveSection("system-prompts")} | 47 | onClick={() => setActiveSection("system-prompts")} |
| @@ -51,6 +60,7 @@ export function SettingsPage({ onClose }: SettingsPageProps) { | |||
| 51 | 60 | ||
| 52 | {/* Content */} | 61 | {/* Content */} |
| 53 | <div className="settings-content"> | 62 | <div className="settings-content"> |
| 63 | {activeSection === "model" && <ModelSettings />} | ||
| 54 | {activeSection === "system-prompts" && <SystemPromptsSettings />} | 64 | {activeSection === "system-prompts" && <SystemPromptsSettings />} |
| 55 | {activeSection === "git" && <GitSettings />} | 65 | {activeSection === "git" && <GitSettings />} |
| 56 | </div> | 66 | </div> |
diff --git a/renderer/src/components/settings/ModelSettings.tsx b/renderer/src/components/settings/ModelSettings.tsx new file mode 100644 index 0000000..ecfc12c --- /dev/null +++ b/renderer/src/components/settings/ModelSettings.tsx | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | import React, { useState, useEffect } from "react"; | ||
| 2 | |||
| 3 | const api = window.api; | ||
| 4 | |||
| 5 | export function ModelSettings() { | ||
| 6 | // null = not yet loaded from DB | ||
| 7 | const [model, setModel] = useState<string | null>(null); | ||
| 8 | const [draft, setDraft] = useState(""); | ||
| 9 | const [saveStatus, setSaveStatus] = useState<"idle" | "saved">("idle"); | ||
| 10 | |||
| 11 | useEffect(() => { | ||
| 12 | api.getSettings(["model"]).then((settings) => { | ||
| 13 | const saved = settings["model"] ?? ""; | ||
| 14 | setModel(saved); | ||
| 15 | setDraft(saved); | ||
| 16 | }); | ||
| 17 | }, []); | ||
| 18 | |||
| 19 | const handleSave = async () => { | ||
| 20 | const trimmed = draft.trim(); | ||
| 21 | if (trimmed) { | ||
| 22 | await api.setSetting("model", trimmed); | ||
| 23 | setModel(trimmed); | ||
| 24 | } else { | ||
| 25 | await api.deleteSetting("model"); | ||
| 26 | setModel(""); | ||
| 27 | } | ||
| 28 | setSaveStatus("saved"); | ||
| 29 | setTimeout(() => setSaveStatus("idle"), 1500); | ||
| 30 | }; | ||
| 31 | |||
| 32 | const handleReset = async () => { | ||
| 33 | await api.deleteSetting("model"); | ||
| 34 | setModel(""); | ||
| 35 | setDraft(""); | ||
| 36 | setSaveStatus("saved"); | ||
| 37 | setTimeout(() => setSaveStatus("idle"), 1500); | ||
| 38 | }; | ||
| 39 | |||
| 40 | if (model === null) { | ||
| 41 | return ( | ||
| 42 | <div style={{ color: "var(--text-secondary)", fontSize: 12 }}> | ||
| 43 | Loading... | ||
| 44 | </div> | ||
| 45 | ); | ||
| 46 | } | ||
| 47 | |||
| 48 | const isDirty = draft.trim() !== model; | ||
| 49 | |||
| 50 | return ( | ||
| 51 | <div> | ||
| 52 | <div className="settings-section-title">Model</div> | ||
| 53 | <div className="settings-section-desc"> | ||
| 54 | Claude model to use for all phases. Leave blank to use the SDK's | ||
| 55 | default model. Takes effect on the next message sent in any session. | ||
| 56 | </div> | ||
| 57 | |||
| 58 | <div className="settings-toggle-row"> | ||
| 59 | <input | ||
| 60 | className="settings-model-input" | ||
| 61 | type="text" | ||
| 62 | value={draft} | ||
| 63 | placeholder="Default (e.g. claude-sonnet-4-5)" | ||
| 64 | onChange={(e) => { | ||
| 65 | setDraft(e.target.value); | ||
| 66 | setSaveStatus("idle"); | ||
| 67 | }} | ||
| 68 | onKeyDown={(e) => { | ||
| 69 | if (e.key === "Enter") handleSave(); | ||
| 70 | }} | ||
| 71 | spellCheck={false} | ||
| 72 | /> | ||
| 73 | </div> | ||
| 74 | |||
| 75 | <div className="settings-actions"> | ||
| 76 | {model && ( | ||
| 77 | <button className="btn-secondary" onClick={handleReset}> | ||
| 78 | Reset to Default | ||
| 79 | </button> | ||
| 80 | )} | ||
| 81 | <button | ||
| 82 | className="btn-primary" | ||
| 83 | onClick={handleSave} | ||
| 84 | disabled={!isDirty} | ||
| 85 | > | ||
| 86 | {saveStatus === "saved" ? "Saved \u2713" : "Save"} | ||
| 87 | </button> | ||
| 88 | {model && ( | ||
| 89 | <span className="settings-custom-badge">custom</span> | ||
| 90 | )} | ||
| 91 | </div> | ||
| 92 | </div> | ||
| 93 | ); | ||
| 94 | } | ||
