diff --git a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts index 9ac48eb878..d66384b629 100644 --- a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts +++ b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts @@ -1013,6 +1013,20 @@ describe("provider update launch notification logic", () => { ).toMatchObject({ kind: "loading" }); }); + it("keeps a non-terminal result on loading even after pending clears", () => { + // The dispatch returned an incomplete ("running") snapshot and pending was + // cleared in finally — the row must not revert to the idle Update button. + expect( + resolveEnvironmentUpdateRowStatus({ + group, + error: undefined, + result: runningResult, + pill: null, + isPending: false, + }), + ).toMatchObject({ kind: "loading" }); + }); + it("lists the providers when idle", () => { expect( resolveEnvironmentUpdateRowStatus({ diff --git a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts index e28fe594f4..2c03637621 100644 --- a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts +++ b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts @@ -749,7 +749,10 @@ export function resolveEnvironmentUpdateRowStatus(input: { return { kind: "loading", text: "Updating…" }; } } - if (input.isPending) { + // A non-terminal result snapshot or the optimistic pending flag means an + // update is still in flight — keep showing the spinner rather than reverting + // to the Update button as if nothing happened. + if (input.result || input.isPending) { return { kind: "loading", text: "Updating…" }; } return { kind: "idle", text: environmentProviderNames(input.group) }; diff --git a/apps/web/src/components/ProviderUpdateLaunchNotification.tsx b/apps/web/src/components/ProviderUpdateLaunchNotification.tsx index 6e40acc76a..fbe9b77d8b 100644 --- a/apps/web/src/components/ProviderUpdateLaunchNotification.tsx +++ b/apps/web/src/components/ProviderUpdateLaunchNotification.tsx @@ -104,22 +104,24 @@ function ProviderUpdateEnvironmentsNotification() { }, [navigate]); useEffect(() => { + // Whether a fresh prompt can actually be shown for the current update set. + const canShowPrompt = + notificationKey !== null && + !isGated && + !dismissedNotificationKeys.has(notificationKey) && + !seenProviderUpdateNotificationKeys.has(notificationKey); + // Replace a prompt the user hasn't acted on yet when the available updates - // change, so a fresh prompt reflects the current versions/environments. - // Once an update is in progress, keep the toast so its rows survive. + // change — but only when a replacement can take its place, so the popover + // never just disappears (e.g. while backends are re-settling). Once an + // update is in progress, keep the toast so its rows survive. const active = activeToastRef.current; - if (active && active.key !== notificationKey && !hasInteractedRef.current) { + if (active && active.key !== notificationKey && !hasInteractedRef.current && canShowPrompt) { toastManager.close(active.toastId); activeToastRef.current = null; } - if ( - !notificationKey || - isGated || - dismissedNotificationKeys.has(notificationKey) || - seenProviderUpdateNotificationKeys.has(notificationKey) || - activeToastRef.current !== null - ) { + if (!notificationKey || !canShowPrompt || activeToastRef.current !== null) { return; }