fix(mcode): refresh provider state after removal (#7578)

Co-authored-by: thisTom <19346741+thisTom@users.noreply.github.com>
This commit is contained in:
thisTomandthisTom authored and GitHub committed 2026-09-22 17:37:23 +08:00
1 parent 6f6087cdba
commit 09c5d39d8c
2 files changed
+59

No files matched your search

+4
View File
@@ -777,6 +777,10 @@ function App() {
await queryClient.invalidateQueries({
queryKey: hermesKeys.liveProviderIds,
});
} else if (activeApp === "mcode") {
await queryClient.invalidateQueries({
queryKey: ["providers", "mcode"],
});
}
toast.success(
activeApp === "pi"
+55
View File
@@ -390,6 +390,61 @@ describe("App integration with MSW", () => {
);
});
it("refreshes MiniMax Code provider membership after removing it from live config", async () => {
localStorage.setItem("cc-switch-last-app", "mcode");
let liveConfigManaged = true;
let providerRequests = 0;
server.use(
http.post("http://tauri.local/get_providers", async ({ request }) => {
const { app } = (await request.json()) as { app: string };
if (app !== "mcode") return;
providerRequests += 1;
return HttpResponse.json({
custom: {
id: "custom",
name: "Custom MiniMax Code",
settingsConfig: {},
meta: { liveConfigManaged },
},
});
}),
http.post(
"http://tauri.local/remove_provider_from_live_config",
async ({ request }) => {
expect(await request.json()).toEqual({ id: "custom", app: "mcode" });
liveConfigManaged = false;
return HttpResponse.json(true);
},
),
);
const { default: App } = await import("@/App");
renderApp(App);
await waitFor(() =>
expect(screen.getByTestId("provider-list")).toHaveTextContent(
'"liveConfigManaged":true',
),
);
const requestsBeforeRemoval = providerRequests;
fireEvent.click(screen.getByText("remove"));
fireEvent.click(screen.getByText("confirm-delete"));
await waitFor(() =>
expect(screen.queryByTestId("confirm-dialog")).not.toBeInTheDocument(),
);
expect(liveConfigManaged).toBe(false);
await waitFor(() =>
expect(screen.getByTestId("provider-list")).toHaveTextContent(
'"liveConfigManaged":false',
),
);
expect(providerRequests).toBeGreaterThan(requestsBeforeRemoval);
expect(screen.getByTestId("provider-list")).toHaveTextContent(
"Custom MiniMax Code",
);
});
it("warns without blocking when removing Pi's global default provider", async () => {
localStorage.setItem("cc-switch-last-app", "pi");
setProviders("pi", {