fix(web): use window.installedPlugins for bulk update button (#250)

The previous fix (#249) wired window.updateAllPlugins to
PluginInstallManager.updateAll(), but that method reads from
PluginStateManager.installedPlugins which is never populated on
page load — only after individual install/update operations.

Meanwhile, base.html already defined a working updateAllPlugins
using window.installedPlugins (reliably populated by plugins_manager.js).
The override from install_manager.js masked this working version.

Fix: revert install_manager.js changes and rewrite runUpdateAllPlugins
to iterate window.installedPlugins directly, calling the API endpoint
without any middleman. Adds per-plugin progress in button text and
a summary notification on completion.

Co-authored-by: Chuck <chuck@example.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Chuck
2026-02-15 15:28:51 -05:00
committed by GitHub
parent 22c495ea7c
commit 963c4d3b91
2 changed files with 55 additions and 60 deletions

View File

@@ -81,10 +81,9 @@ const PluginInstallManager = {
/**
* Update all plugins.
*
* @param {Function} onProgress - Optional callback(index, total, pluginId) for progress updates
* @returns {Promise<Array>} Update results
*/
async updateAll(onProgress) {
async updateAll() {
if (!window.PluginStateManager || !window.PluginStateManager.installedPlugins) {
throw new Error('Installed plugins not loaded');
}
@@ -92,22 +91,15 @@ const PluginInstallManager = {
const plugins = window.PluginStateManager.installedPlugins;
const results = [];
for (let i = 0; i < plugins.length; i++) {
const plugin = plugins[i];
if (onProgress) onProgress(i + 1, plugins.length, plugin.id);
for (const plugin of plugins) {
try {
const result = await window.PluginAPI.updatePlugin(plugin.id);
const result = await this.update(plugin.id);
results.push({ pluginId: plugin.id, success: true, result });
} catch (error) {
results.push({ pluginId: plugin.id, success: false, error });
}
}
// Reload plugin list once at the end
if (window.PluginStateManager) {
await window.PluginStateManager.loadInstalledPlugins();
}
return results;
}
};
@@ -117,6 +109,5 @@ if (typeof module !== 'undefined' && module.exports) {
module.exports = PluginInstallManager;
} else {
window.PluginInstallManager = PluginInstallManager;
window.updateAllPlugins = (onProgress) => PluginInstallManager.updateAll(onProgress);
}