From 9a7c008b90dedf864ad72661a7ea073b4a23c32c Mon Sep 17 00:00:00 2001 From: Chuck Date: Thu, 30 Apr 2026 10:34:18 -0400 Subject: [PATCH] fix(plugins): reset pluginsInitialized on HTMX re-swap; use refreshInstalledPlugins in refreshPlugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HTMX's `revealed` trigger fires each time the plugins tab becomes visible (Alpine's x-show toggles display:none which re-triggers the IntersectionObserver). Each re-reveal fetches a fresh empty HTML skeleton via hx-swap="innerHTML". The htmx:afterSwap handler reset window.pluginManager.initialized/initializing but not pluginsInitialized, so initializePlugins() hit its guard and skipped loadInstalledPlugins() and searchPluginStore() — leaving the fresh empty DOM unpopulated. Fix: also reset pluginsInitialized = false in the afterSwap handler. Existing caches (3s for installed plugins, 5min for store) mean tab revisits within the TTL render from cache instantly with no extra API traffic. Also change refreshPlugins() to call refreshInstalledPlugins() (which already exists and explicitly invalidates the cache) instead of the bare loadInstalledPlugins() call that could silently skip the fetch if the 3-second cache happened to still be valid. Co-Authored-By: Claude Sonnet 4.6 --- web_interface/static/v3/plugins_manager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web_interface/static/v3/plugins_manager.js b/web_interface/static/v3/plugins_manager.js index 0f15b33c..bea5f831 100644 --- a/web_interface/static/v3/plugins_manager.js +++ b/web_interface/static/v3/plugins_manager.js @@ -1165,9 +1165,10 @@ function initializePluginPageWhenReady() { if (target.id === 'plugins-content' || target.querySelector('#installed-plugins-grid')) { console.log('HTMX swap detected for plugins, initializing...'); - // Reset initialization flag to allow re-initialization after HTMX swap + // Reset all initialization flags so the fresh empty DOM gets populated window.pluginManager.initialized = false; window.pluginManager.initializing = false; + pluginsInitialized = false; initTimer = setTimeout(attemptInit, 100); } }, { once: false }); // Allow multiple swaps @@ -5127,7 +5128,7 @@ function refreshPlugins() { pluginStoreCache = null; cacheTimestamp = null; - loadInstalledPlugins(); + refreshInstalledPlugins(); // invalidates cache before fetching // Fetch latest metadata from GitHub when refreshing searchPluginStore(true); showNotification('Plugins refreshed with latest metadata from GitHub', 'success');