# Files changed · PR \#23847 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/23847/diffs)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

[fix\(web\): keep unsaved edits to other ACP providers](https://git.cafe/pingdotgg/t3code/pull/23847.md)

Version: 3

Head commit: 291b5f6a2603ebd73950a8b2b4a2ac99bdef5950

Base commit: 2c8bdf6177159d8fcd12a897d7c9311f6eb93237

Comparison base: 05696c636ec2a101a763505d820b83891e529ccd

Showing up to 20 entries from this revision. If the pull request changes, reopen the first page before continuing.

## apps/web/src/components/settings/AcpSessionManagementSection.browser.test.tsx

Status: modified; +37; −0

```diff
@@ -5,8 +5,10 @@
   ProviderInstanceId,
   ThreadId,
   type ServerProvider,
+  type AcpRegistryConfigurableProvider,
 } from "@t3tools/contracts";
 import { expect, it, vi } from "vite-plus/test";
+import { userEvent } from "vite-plus/test/browser";
 
 import { act, render } from "../../../test/render";
 
@@ -169,3 +171,38 @@
   await screen.click("Delete");
   expect(commands.delete).not.toHaveBeenCalled();
 });
+
+it.each(["Save", "Disable"])("keeps other provider edits through a %s refetch", async (action) => {
+  setup();
+  const providers: AcpRegistryConfigurableProvider[] = ["google", "other"].map((providerId) => ({
+    providerId,
+    supported: ["openai"],
+    required: false,
+    current: { apiType: "openai", baseUrl: "https://api.example.test/v1" },
+  }));
+  const response = { _tag: "Success" as const, value: { providers } };
+  commands.listProviders.mockResolvedValue(response);
+  await using screen = await renderSection();
+  await screen.click("List providers");
+  const input = (label: string) =>
+    screen.container.querySelector<HTMLInputElement>(`[aria-label="${label}"]`)!;
+  await userEvent.fill(input("other base URL"), "https://other.example.test/v1");
+  await userEvent.fill(input("other write-only headers JSON"), '{"X-Test":"unsaved"}');
+  await userEvent.fill(input("google write-only headers JSON"), '{"X-Test":"saved"}');
+
+  let resolveReload!: (value: typeof response) => void;
+  const reload = new Promise<typeof response>((resolve) => {
+    resolveReload = resolve;
+  });
+  commands.listProviders.mockReturnValueOnce(reload);
+  await screen.click(action);
+  await userEvent.fill(input("other base URL"), "https://newer.example.test/v1");
+  await act(async () => resolveReload(response));
+
+  expect(input("other base URL").value).toBe("https://newer.example.test/v1");
+  expect(input("other write-only headers JSON").value).toBe('{"X-Test":"unsaved"}');
+  expect(input("google write-only headers JSON").value).toBe("");
+  await screen.click("Refresh");
+  expect(input("other base URL").value).toBe("https://api.example.test/v1");
+  expect(input("other write-only headers JSON").value).toBe("");
+});
```

## apps/web/src/components/settings/AcpSessionManagementSection.tsx

Status: modified; +7; −5

```diff
@@ -211,7 +211,7 @@
     reportFailure("Could not delete ACP session", result);
   };
 
-  const loadProviders = async () => {
+  const loadProviders = async (resetProviderId?: string) => {
     if (projectId === null || loadingProviders) return;
     setLoadingProviders(true);
     const result = await listProviders({
@@ -221,11 +221,13 @@
     setLoadingProviders(false);
     if (result._tag === "Success") {
       setProviders(result.value.providers);
-      setProviderDrafts(
+      setProviderDrafts((current) =>
         Object.fromEntries(
           result.value.providers.map((provider) => [
             provider.providerId,
+            (resetProviderId !== undefined && provider.providerId !== resetProviderId
-            {
+              ? current[provider.providerId]
+              : undefined) ?? {
               apiType: provider.current?.apiType ?? provider.supported[0] ?? "",
               baseUrl: provider.current?.baseUrl ?? "",
               headers: "",
@@ -272,7 +274,7 @@
     setSavingProviderId(null);
     if (result._tag === "Success") {
       toastManager.add({ type: "success", title: "ACP provider configured" });
-      await loadProviders();
+      await loadProviders(provider.providerId);
       return;
     }
     reportFailure("Could not configure ACP provider", result);
@@ -293,7 +295,7 @@
     setSavingProviderId(null);
     if (result._tag === "Success") {
       toastManager.add({ type: "success", title: "ACP provider disabled" });
+      await loadProviders(provider.providerId);
-      await loadProviders();
       return;
     }
     reportFailure("Could not disable ACP provider", result);
```
