Skip to content

Commit 3556809

Browse files
committed
🤖 feat: add Clear button for Base URL field
1 parent 5b773d7 commit 3556809

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

src/browser/components/Settings/sections/ProvidersSection.tsx

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ export function ProvidersSection() {
5757
}
5858
}, [editingField, editValue]);
5959

60+
const handleClearBaseUrl = useCallback(async (provider: string) => {
61+
setSaving(true);
62+
try {
63+
await window.api.providers.setProviderConfig(provider, ["baseUrl"], "");
64+
const cfg = await window.api.providers.getConfig();
65+
setConfig(cfg);
66+
} finally {
67+
setSaving(false);
68+
}
69+
}, []);
70+
6071
const isConfigured = (provider: string) => {
6172
return config[provider]?.apiKeySet ?? false;
6273
};
@@ -192,13 +203,25 @@ export function ProvidersSection() {
192203
<span className="text-foreground font-mono text-xs">
193204
{providerConfig?.baseUrl ?? "Default"}
194205
</span>
195-
<button
196-
type="button"
197-
onClick={() => handleStartEdit(provider, "baseUrl")}
198-
className="text-accent hover:text-accent-light text-xs"
199-
>
200-
{providerConfig?.baseUrl ? "Change" : "Set"}
201-
</button>
206+
<div className="flex gap-2">
207+
{providerConfig?.baseUrl && (
208+
<button
209+
type="button"
210+
onClick={() => void handleClearBaseUrl(provider)}
211+
disabled={saving}
212+
className="text-muted hover:text-error text-xs"
213+
>
214+
Clear
215+
</button>
216+
)}
217+
<button
218+
type="button"
219+
onClick={() => handleStartEdit(provider, "baseUrl")}
220+
className="text-accent hover:text-accent-light text-xs"
221+
>
222+
{providerConfig?.baseUrl ? "Change" : "Set"}
223+
</button>
224+
</div>
202225
</div>
203226
)}
204227
</div>

src/node/services/ipcMain.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,13 @@ export class IpcMain {
14831483
}
14841484

14851485
if (keyPath.length > 0) {
1486-
current[keyPath[keyPath.length - 1]] = value;
1486+
const lastKey = keyPath[keyPath.length - 1];
1487+
// Delete key if value is empty string, otherwise set it
1488+
if (value === "") {
1489+
delete current[lastKey];
1490+
} else {
1491+
current[lastKey] = value;
1492+
}
14871493
}
14881494

14891495
// Save updated config

0 commit comments

Comments
 (0)