Skip to content

Agent Zero AI framework

Fix plugin reload toast behavior

Alessandro4b5077c493cb
diff --git a/helpers/plugins.py b/helpers/plugins.py
index e2c69be85..faf4e7e2e 100644
--- a/helpers/plugins.py
+++ b/helpers/plugins.py
@@ -840,7 +840,7 @@ def send_frontend_reload_notification(plugin_names: list[str] | None = None):
type=notification.NotificationType.INFO,
priority=notification.NotificationPriority.NORMAL,
title="Plugins with frontend extensions updated, page reload recommended",
- message="""<button type="button" class="button confirm" onclick="window.location.reload()"><span class="icon material-symbols-outlined">refresh</span>Reload page</button>""",
+ message="""<div class="toast-action-row"><button type="button" class="button confirm" @click.stop="$store.notificationStore.dismissToastAndReload(toast.toastId)"><span class="icon material-symbols-outlined">refresh</span>Reload page</button></div>""",
detail="",
display_time=0,
group="plugins_changed",
diff --git a/helpers/plugins.py.dox.md b/helpers/plugins.py.dox.md
index 59bdb54bf..0a8ac5c74 100644
--- a/helpers/plugins.py.dox.md
+++ b/helpers/plugins.py.dox.md
@@ -40,7 +40,7 @@
- `find_plugin_asset(plugin_name: str, *subpaths, project_name=..., agent_profile=...)`
- `find_plugin_assets(*subpaths, plugin_name: str=..., project_name: str=..., agent_profile: str=..., only_first: bool=...) -> list[PluginAssetFile]`
- `determine_plugin_asset_path(plugin_name: str, project_name: str, agent_profile: str, *subpaths)`
-- `send_frontend_reload_notification(plugin_names: list[str] | None=...)`: If the plugin changed has webui extensions, show a persistent reload notification
+- `send_frontend_reload_notification(plugin_names: list[str] | None=...)`: If the plugin changed has webui extensions, show a persistent reload notification that marks itself read before refreshing
- `call_plugin_hook(plugin_name: str, hook_name: str, default: Any=..., *args, **kwargs)`
- `_apply_defaults_from_env(plugin_name: str, config: dict[str, Any])`
- Notable constants/configuration names: `_META_TARGET_RE`, `META_FILE_NAME`, `CONFIG_FILE_NAME`, `CONFIG_DEFAULT_FILE_NAME`, `DISABLED_FILE_NAME`, `ENABLED_FILE_NAME`, `TOGGLE_FILE_PATTERN`, `HOOKS_SCRIPT`, `HOOKS_CACHE_AREA`, `PLUGINS_LIST_CACHE_AREA`, `ENABLED_PLUGINS_LIST_CACHE_AREA`, `ENABLED_PLUGINS_PATHS_CACHE_AREA`.
diff --git a/tests/test_download_toast_regressions.py b/tests/test_download_toast_regressions.py
index 291050e6e..b733bebab 100644
--- a/tests/test_download_toast_regressions.py
+++ b/tests/test_download_toast_regressions.py
@@ -101,13 +101,20 @@ def test_notification_store_supports_persistent_grouped_toasts():
assert "if display_time < 0:" in api
assert "if display_time <= 0:" not in api
assert 'id="plugins_frontend_reload",' in plugins
+ assert "$store.notificationStore.dismissToastAndReload(toast.toastId)" in plugins
+ assert "onclick=\"window.location.reload()\"" not in plugins
assert 'id=notif.get("id", "update_check_available"),' in update_check
assert "display_time=0," in plugins
assert "display_time=0," in update_check
+ assert 'class="toast-action-row"' in plugins
assert 'class="toast-action-row"' in update_check
assert 'class="button confirm"' in update_check
assert "$store.notificationStore.dismissToast(toast.toastId)" in update_check
assert ".toast-action-row" in toast_stack
+ assert "margin-top: var(--spacing-sm);" in toast_stack
+ assert "async dismissToastAndReload(toastId)" in store
+ assert 'await API.callJsonApi("notifications_mark_read"' in store
+ assert "if (response?.success) window.location.reload();" in store
def test_backup_zip_downloads_emit_grouped_preparing_and_downloading_toasts():
diff --git a/webui/components/notifications/AGENTS.md b/webui/components/notifications/AGENTS.md
index 4e958d3c1..ca359b919 100644
--- a/webui/components/notifications/AGENTS.md
+++ b/webui/components/notifications/AGENTS.md
@@ -16,6 +16,7 @@
- Use the notification system for user-facing success, warning, info, and error feedback.
- Keep public helper names stable for core and plugin callers.
- Keep the toast stack visible above normal and legacy modal overlays while staying below confirmation dialogs.
+- Reload actions must persist their notification as read before refreshing the page.
- Avoid exposing secrets or raw auth payloads in notification text.
## Work Guidance
diff --git a/webui/components/notifications/notification-store.js b/webui/components/notifications/notification-store.js
index baa765aef..24e61b9b4 100644
--- a/webui/components/notifications/notification-store.js
+++ b/webui/components/notifications/notification-store.js
@@ -200,6 +200,16 @@ const model = {
this.removeFromToastStack(toastId, true);
},
+ async dismissToastAndReload(toastId) {
+ const toast = this.toastStack.find((item) => item.toastId === toastId);
+ if (!toast?.id) return;
+
+ const response = await API.callJsonApi("notifications_mark_read", {
+ notification_ids: [toast.id],
+ });
+ if (response?.success) window.location.reload();
+ },
+
async afterToastRemoved(toast, removedByUser = false) {
// if the toast is closed by the user OR timed out with normal priority, mark it as read
if (removedByUser || toast.priority <= NotificationPriority.NORMAL) {
diff --git a/webui/components/notifications/notification-toast-stack.html b/webui/components/notifications/notification-toast-stack.html
index 7a002c6fc..019d8d073 100644
--- a/webui/components/notifications/notification-toast-stack.html
+++ b/webui/components/notifications/notification-toast-stack.html
@@ -151,7 +151,7 @@
}
.toast-action-row {
- margin-top: 10px;
+ margin-top: var(--spacing-sm);
}
.toast-timestamp {