The best way to control Claude Code, Codex and more from any computer or phone
fix(web): confirm before removing a provider instance's saved settings (#29480)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 2, 2026 at 11:43 UTC
a497f7b9a3efab4d0c41c9eabaeea775d751e6e7
2 files changed
+130
-4
apps/web/src/components/settings/ProviderSettingsPanel.environment.browser.test.tsx
+94
@@ -36,6 +36,7 @@ const state = vi.hoisted(() => ({
36
updateModelPreferences: vi.fn(),
37
toggleFavorite: vi.fn(),
38
mutateProviderInstance: vi.fn(),
39
+ confirm: vi.fn<() => Promise<boolean>>(),
40
}));
41
42
vi.mock(import("../../state/server"), async (original) => {
@@ -80,6 +81,14 @@ vi.mock(import("../../state/use-atom-command"), async (original) => ({
81
"accept-url-auth": state.acceptUrlAuth,
82
})[command.label ?? ""] ?? vi.fn()) as never,
83
}));
84
+vi.mock(import("~/localApi"), async (original) => {
85
+ const api = { dialogs: { confirm: state.confirm } };
86
+ return {
87
+ ...(await original()),
88
+ readLocalApi: (() => api) as never,
89
+ ensureLocalApi: (() => api) as never,
90
+ };
91
+});
92
vi.mock(import("../../state/query"), async (original) => ({
93
...(await original()),
94
useEnvironmentQuery: ((query: unknown) => ({
@@ -231,6 +240,7 @@ async function setup() {
240
state.updateModelPreferences.mockReset();
241
state.toggleFavorite.mockReset();
242
state.mutateProviderInstance.mockReset().mockResolvedValue(AsyncResult.success({}));
243
+ state.confirm.mockReset().mockResolvedValue(false);
244
state.refresh.mockReset().mockResolvedValue(AsyncResult.success(undefined));
245
state.updateProvider.mockReset().mockResolvedValue(AsyncResult.success(undefined));
246
state.uninstall.mockReset().mockResolvedValue(AsyncResult.success({}));
@@ -359,6 +369,90 @@ describe("EnvironmentProviderSettings routing", () => {
369
});
370
});
371
372
+describe("EnvironmentProviderSettings instance removal", () => {
373
+ it("resets a configured default instance only once the user confirms", async () => {
374
+ await setup();
375
+ state.settings = {
376
+ ...DEFAULT_UNIFIED_SETTINGS,
377
+ providerInstances: {
378
+ [codexId]: {
379
+ driver: ProviderDriverKind.make("codex"),
380
+ enabled: true,
381
+ config: { binaryPath: "/opt/codex/bin/codex" },
382
+ },
383
+ },
384
+ };
385
+ await setProviders([provider()]);
386
+ await using _screen = await render(panel({ targetInstanceId: codexId }));
387
+ const reset = page.getByRole("button", { name: "Reset Codex provider settings to default" });
388
+ await userEvent.click(reset);
389
+
390
+ expect(state.mutateProviderInstance).not.toHaveBeenCalled();
391
+ expect(state.confirm).toHaveBeenCalledOnce();
392
+
393
+ state.confirm.mockResolvedValue(true);
394
+ await userEvent.click(reset);
395
+ await vi.waitFor(() =>
396
+ expect(state.mutateProviderInstance).toHaveBeenCalledWith({
397
+ operation: "remove",
398
+ instanceId: codexId,
399
+ }),
400
+ );
401
+ });
402
+
403
+ it("warns that resetting an enabled default-off provider turns it off", async () => {
404
+ await setup();
405
+ const antigravityId = ProviderInstanceId.make("antigravity");
406
+ const antigravity = ProviderDriverKind.make("antigravity");
407
+ state.settings = {
408
+ ...DEFAULT_UNIFIED_SETTINGS,
409
+ providerInstances: {
410
+ [antigravityId]: {
411
+ driver: antigravity,
412
+ enabled: true,
413
+ config: { binaryPath: "/opt/antigravity/bin/agy" },
414
+ },
415
+ },
416
+ };
417
+ await setProviders([{ ...provider(), instanceId: antigravityId, driver: antigravity }]);
418
+ await using _screen = await render(panel({ targetInstanceId: antigravityId }));
419
+ await userEvent.click(page.getByRole("button", { name: /^Reset .* provider settings/ }));
420
+
421
+ expect(state.confirm).toHaveBeenCalledWith(
422
+ expect.stringContaining("It will also be turned off."),
423
+ {
424
+ variant: "destructive",
425
+ },
426
+ );
427
+ expect(state.mutateProviderInstance).not.toHaveBeenCalled();
428
+ });
429
+
430
+ it("deletes a custom instance only once the user confirms", async () => {
431
+ await setup();
432
+ state.settings = {
433
+ ...DEFAULT_UNIFIED_SETTINGS,
434
+ providerInstances: {
435
+ [customId]: { driver: ProviderDriverKind.make("codex"), enabled: true },
436
+ },
437
+ };
438
+ await using _screen = await render(panel({ targetInstanceId: customId }));
439
+ const remove = page.getByRole("button", { name: `Delete instance ${customId}` });
440
+ await userEvent.click(remove);
441
+
442
+ expect(state.mutateProviderInstance).not.toHaveBeenCalled();
443
+ expect(state.confirm).toHaveBeenCalledOnce();
444
+
445
+ state.confirm.mockResolvedValue(true);
446
+ await userEvent.click(remove);
447
+ await vi.waitFor(() =>
448
+ expect(state.mutateProviderInstance).toHaveBeenCalledWith({
449
+ operation: "remove",
450
+ instanceId: customId,
451
+ }),
452
+ );
453
+ });
454
+});
455
+
456
describe("EnvironmentProviderSettings health check interval", () => {
457
it("commits interval drafts and allows retrying rejected edits", async () => {
458
await setup();
apps/web/src/components/settings/ProviderSettingsPanel.tsx
+36
-4
@@ -11,6 +11,7 @@ import { connectionStatusTitle } from "@t3tools/client-runtime/connection";
11
import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors";
12
import {
13
isAtomCommandInterrupted,
14
+ settlePromise,
15
squashAtomCommandFailure,
16
} from "@t3tools/client-runtime/state/runtime";
17
import {
@@ -47,6 +48,7 @@ import {
48
useToggleEnvironmentModelFavorite,
49
} from "../../hooks/useSettings";
50
import { useStableCallback } from "../../hooks/useStableCallback";
51
+import { ensureLocalApi } from "../../localApi";
52
import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";
53
import { cn } from "../../lib/utils";
54
import { resolveAppModelSelectionState } from "../../modelSelection";
@@ -127,6 +129,25 @@ import {
129
resolveSelectedProviderEnvironmentId,
130
} from "./ProviderSettingsPanel.logic";
131
132
+function providerInstanceName(instance: ProviderInstanceConfig): string {
133
+ return (
134
+ instance.displayName?.trim() ||
135
+ providerClients.get(instance.driver)?.label ||
136
+ String(instance.driver)
137
+ );
138
+}
139
+
140
+async function confirmProviderInstanceRemoval(
141
+ question: string,
142
+ consequence = "",
143
+): Promise<boolean> {
144
+ const message = `${question}\nIts saved settings, including any custom binary path, will be removed.${consequence}`;
145
+ const confirmed = await settlePromise(() =>
146
+ ensureLocalApi().dialogs.confirm(message, { variant: "destructive" }),
147
+ );
148
+ return confirmed._tag === "Success" && confirmed.value;
149
+}
150
+
151
function modelListChanges(current: ReadonlyArray<string>, next: ReadonlyArray<string>) {
152
const currentSet = new Set(current);
153
const nextSet = new Set(next.map((model) => model.trim()).filter(Boolean));
@@ -830,6 +851,10 @@ export function EnvironmentProviderSettings({
851
852
const deleteInstance = useStableCallback(
853
async (instanceId: ProviderInstanceId, instance: ProviderInstanceConfig) => {
854
+ const confirmed = await confirmProviderInstanceRemoval(
855
+ `Remove the ${providerInstanceName(instance)} provider instance?`,
856
+ );
857
+ if (!confirmed) return;
858
const updateResult = await persistProviderInstance({
859
operation: "remove",
860
instanceId,
@@ -866,10 +891,17 @@ export function EnvironmentProviderSettings({
891
);
892
893
const resetDefaultInstance = useStableCallback(async (driverKind: ProviderDriverKind) => {
869
- const result = await persistProviderInstance({
870
- operation: "remove",
871
- instanceId: defaultInstanceIdForDriver(driverKind),
872
- });
894
+ const instanceId = defaultInstanceIdForDriver(driverKind);
895
+ const instance = settings.providerInstances?.[instanceId] ?? { driver: driverKind };
896
+ const turnsOff =
897
+ resolveProviderInstanceEnabled(instance) &&
898
+ !resolveProviderInstanceEnabled({ driver: driverKind });
899
+ const confirmed = await confirmProviderInstanceRemoval(
900
+ `Reset the ${providerInstanceName(instance)} provider to its defaults?`,
901
+ turnsOff ? " It will also be turned off." : "",
902
+ );
903
+ if (!confirmed) return;
904
+ const result = await persistProviderInstance({ operation: "remove", instanceId });
905
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
906
const error = squashAtomCommandFailure(result);
907
toastManager.add({