The best way to control Claude Code, Codex and more from any computer or phone
fix(web): keep unsaved edits to other ACP providers (#23847)
Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 30, 2026 at 16:00 UTC
975059a7182e84956355a45a36a5ec5d130ebd42
2 files changed
+73
-9
apps/web/src/components/settings/AcpSessionManagementSection.browser.test.tsx
+55
@@ -5,8 +5,10 @@ import {
5
ProviderInstanceId,
6
ThreadId,
7
type ServerProvider,
8
+ type AcpRegistryConfigurableProvider,
9
} from "@t3tools/contracts";
10
import { expect, it, vi } from "vite-plus/test";
11
+import { userEvent } from "vite-plus/test/browser";
12
13
import { act, render } from "../../../test/render";
14
@@ -169,3 +171,56 @@ it("rechecks task access after confirming deletion", async () => {
171
await screen.click("Delete");
172
expect(commands.delete).not.toHaveBeenCalled();
173
});
174
+
175
+it.each(["Save", "Disable"])("keeps other provider edits through a %s refetch", async (action) => {
176
+ setup();
177
+ const providers: AcpRegistryConfigurableProvider[] = ["google", "other"].map((providerId) => ({
178
+ providerId,
179
+ supported: ["openai"],
180
+ required: false,
181
+ current: { apiType: "openai", baseUrl: "https://api.example.test/v1" },
182
+ }));
183
+ const response = { _tag: "Success" as const, value: { providers } };
184
+ commands.listProviders.mockResolvedValue(response);
185
+ await using screen = await renderSection();
186
+ await screen.click("List providers");
187
+ const input = (label: string) =>
188
+ screen.container.querySelector<HTMLInputElement>(`[aria-label="${label}"]`)!;
189
+ await userEvent.fill(input("other base URL"), "https://other.example.test/v1");
190
+ await userEvent.fill(input("other write-only headers JSON"), '{"X-Test":"unsaved"}');
191
+ await userEvent.fill(input("google write-only headers JSON"), '{"X-Test":"saved"}');
192
+
193
+ let resolveReload!: (value: typeof response) => void;
194
+ const reload = new Promise<typeof response>((resolve) => {
195
+ resolveReload = resolve;
196
+ });
197
+ commands.listProviders.mockReturnValueOnce(reload);
198
+ let resolveMutation!: () => void;
199
+ const mutation = new Promise<void>((resolve) => {
200
+ resolveMutation = resolve;
201
+ });
202
+ const command = action === "Save" ? commands.setProvider : commands.disableProvider;
203
+ command.mockReturnValueOnce(
204
+ mutation.then(() => ({
205
+ _tag: "Success",
206
+ value: action === "Save" ? { configured: true } : { disabled: true },
207
+ })),
208
+ );
209
+ await screen.click(action);
210
+ expect(screen.button("Refresh").disabled).toBe(true);
211
+ await act(async () => resolveMutation());
212
+ for (const button of screen.container.querySelectorAll<HTMLButtonElement>("button")) {
213
+ if (button.textContent === "Save" || button.textContent === "Disable") {
214
+ expect(button.disabled).toBe(true);
215
+ }
216
+ }
217
+ await userEvent.fill(input("other base URL"), "https://newer.example.test/v1");
218
+ await act(async () => resolveReload(response));
219
+
220
+ expect(input("other base URL").value).toBe("https://newer.example.test/v1");
221
+ expect(input("other write-only headers JSON").value).toBe('{"X-Test":"unsaved"}');
222
+ expect(input("google write-only headers JSON").value).toBe("");
223
+ await screen.click("Refresh");
224
+ expect(input("other base URL").value).toBe("https://api.example.test/v1");
225
+ expect(input("other write-only headers JSON").value).toBe("");
226
+});
apps/web/src/components/settings/AcpSessionManagementSection.tsx
+18
-9
@@ -211,7 +211,7 @@ export function AcpSessionManagementSection(props: {
211
reportFailure("Could not delete ACP session", result);
212
};
213
214
- const loadProviders = async () => {
214
+ const loadProviders = async (resetProviderId?: string) => {
215
if (projectId === null || loadingProviders) return;
216
setLoadingProviders(true);
217
const result = await listProviders({
@@ -221,11 +221,13 @@ export function AcpSessionManagementSection(props: {
221
setLoadingProviders(false);
222
if (result._tag === "Success") {
223
setProviders(result.value.providers);
224
- setProviderDrafts(
224
+ setProviderDrafts((current) =>
225
Object.fromEntries(
226
result.value.providers.map((provider) => [
227
provider.providerId,
228
- {
228
+ (resetProviderId !== undefined && provider.providerId !== resetProviderId
229
+ ? current[provider.providerId]
230
+ : undefined) ?? {
231
apiType: provider.current?.apiType ?? provider.supported[0] ?? "",
232
baseUrl: provider.current?.baseUrl ?? "",
233
headers: "",
@@ -242,7 +244,8 @@ export function AcpSessionManagementSection(props: {
244
if (
245
!readEnvironmentScope(props.environmentId, AuthProvidersManageScope) ||
246
projectId === null ||
245
- savingProviderId !== null
247
+ savingProviderId !== null ||
248
+ loadingProviders
249
)
250
return;
251
const draft = providerDrafts[provider.providerId];
@@ -272,14 +275,15 @@ export function AcpSessionManagementSection(props: {
275
setSavingProviderId(null);
276
if (result._tag === "Success") {
277
toastManager.add({ type: "success", title: "ACP provider configured" });
275
- await loadProviders();
278
+ await loadProviders(provider.providerId);
279
return;
280
}
281
reportFailure("Could not configure ACP provider", result);
282
};
283
284
const disableConfiguredProvider = async (provider: AcpRegistryConfigurableProvider) => {
282
- if (projectId === null || savingProviderId !== null || provider.required) return;
285
+ if (projectId === null || savingProviderId !== null || loadingProviders || provider.required)
286
+ return;
287
const confirmed = await ensureLocalApi().dialogs.confirm(
288
`Disable ACP provider "${provider.providerId}"?`,
289
{ variant: "destructive" },
@@ -293,7 +297,7 @@ export function AcpSessionManagementSection(props: {
297
setSavingProviderId(null);
298
if (result._tag === "Success") {
299
toastManager.add({ type: "success", title: "ACP provider disabled" });
296
- await loadProviders();
300
+ await loadProviders(provider.providerId);
301
return;
302
}
303
reportFailure("Could not disable ACP provider", result);
@@ -466,7 +470,9 @@ export function AcpSessionManagementSection(props: {
470
type="button"
471
size="xs"
472
variant="outline"
469
- disabled={!canRead || loadingProviders || projectId === null}
473
+ disabled={
474
+ !canRead || loadingProviders || savingProviderId !== null || projectId === null
475
+ }
476
onClick={() => void loadProviders()}
477
>
478
{loadingProviders ? "Loading" : providers.length === 0 ? "List providers" : "Refresh"}
@@ -532,6 +538,7 @@ export function AcpSessionManagementSection(props: {
538
disabled={
539
props.readOnly ||
540
savingProviderId !== null ||
541
+ loadingProviders ||
542
draft.apiType.length === 0 ||
543
draft.baseUrl.length === 0
544
}
@@ -544,7 +551,9 @@ export function AcpSessionManagementSection(props: {
551
type="button"
552
size="xs"
553
variant="ghost-muted"
547
- disabled={props.readOnly || savingProviderId !== null}
554
+ disabled={
555
+ props.readOnly || savingProviderId !== null || loadingProviders
556
+ }
557
onClick={() => void disableConfiguredProvider(provider)}
558
>
559
Disable