fix(web): follow-up review fixes for the per-environment update popover
- A non-terminal ("running") dispatch result now keeps the environment row on
the loading spinner instead of falling through to the idle Update button once
pending clears in finally. A terminal server-state pill still overrides it,
so the original "stale result blocks live status" case stays fixed.
- The stale-prompt replacement now only closes the active toast when a fresh
prompt can actually be shown, so the popover no longer disappears when the
update set changes while backends are re-settling (gated).
This commit is contained in:
1 parent
e1021b9000
commit
1d2ac7ff65
3 files changed
+30
-11
No files matched your search
@@ -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({
|
||||
|
||||
@@ -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) };
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user