fix(web): close the per-environment update toast when its updates clear

The previous review fix gated closing a stale, un-acted prompt on
canShowPrompt, which is false once notificationKey becomes null (all updates
cleared) — so the toast could linger empty after the updates disappeared.
Close it when the update set clears (key null) or a fresh set can replace it,
and keep it only while a backend is re-settling (updates still exist, just
gated) or an update is already in progress.
This commit is contained in:
Josh Gratton committed 2026-06-13 20:03:47 -04:00
1 parent 1d2ac7ff65
commit 003d03ff9e
1 file changed
+11 -5
@@ -111,12 +111,18 @@ function ProviderUpdateEnvironmentsNotification() {
!dismissedNotificationKeys.has(notificationKey) &&
!seenProviderUpdateNotificationKeys.has(notificationKey);
// Replace a prompt the user hasn't acted on yet when the available updates
// 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.
// Close a prompt the user hasn't acted on yet when the available updates
// change: when they clear entirely (key null) so the toast doesn't linger,
// and when a fresh set is ready to replace it. Keep it only while a backend
// is re-settling (updates still exist, just gated) — and once an update is
// in progress, so its rows survive.
const active = activeToastRef.current;
if (active && active.key !== notificationKey && !hasInteractedRef.current && canShowPrompt) {
if (
active &&
active.key !== notificationKey &&
!hasInteractedRef.current &&
(notificationKey === null || !isGated)
) {
toastManager.close(active.toastId);
activeToastRef.current = null;
}