fix(ui/mcp): refresh parent on OAuth token persist failure during server edit

The server config is already saved by updateMCPServer when the subsequent
per-user token persist throws, so returning early without onSuccess(updated)
left the edit form open and the parent list stale despite a committed change.
Call onSuccess(updated) before returning so the UI matches DB state; the
warning toast still replaces the success toast.
This commit is contained in:
Tin Chi Lo 2026-06-12 17:59:22 -07:00
parent 465ab30cf2
commit 21ea4f90f3
2 changed files with 3 additions and 2 deletions

View file

@ -846,7 +846,7 @@ describe("MCPServerEdit (OAuth token persistence on save)", () => {
expect(mockSetToken).not.toHaveBeenCalled();
});
it("does not show success when OBO token persistence fails after update", async () => {
it("warns but still refreshes the parent via onSuccess when OBO token persistence fails after update", async () => {
mockOauth.tokenResponse = {
access_token: "obo-tok",
refresh_token: "obo-refresh",
@ -879,7 +879,7 @@ describe("MCPServerEdit (OAuth token persistence on save)", () => {
"MCP Server updated, but failed to persist OAuth token: write failed",
);
expect(NotificationsManager.success).not.toHaveBeenCalledWith("MCP Server updated successfully");
expect(onSuccess).not.toHaveBeenCalled();
expect(onSuccess).toHaveBeenCalledWith(expect.objectContaining({ server_id: interactiveOAuthServer.server_id }));
});
it("persists the passthrough token to sessionStorage on save after authorize", async () => {

View file

@ -713,6 +713,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
NotificationsManager.fromBackend(
"MCP Server updated, but failed to persist OAuth token" + (message ? `: ${message}` : ""),
);
onSuccess(updated);
return;
}
}