fix(store): fix installed status detection for plugins with path-derived IDs (#270)

The plugin registry uses short IDs (e.g. "weather", "stocks") but
plugin_path points to the actual installed directory name (e.g.
"plugins/ledmatrix-weather"). isStorePluginInstalled() was only
comparing registry IDs, causing all monorepo plugins with mismatched
IDs to show as not installed in the store UI.

- Updated isStorePluginInstalled() to also check the last segment of
  plugin_path against installed plugin IDs
- Updated all 3 call sites to pass the full plugin object instead of
  just plugin.id
- Fixed the same bug in renderCustomRegistryPlugins() which used the
  same direct ID comparison

Co-authored-by: Chuck <chuck@example.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chuck
2026-02-24 17:35:08 -05:00
committed by GitHub
parent 976c10c4ac
commit 9465fcda6e

View File

@@ -5251,8 +5251,17 @@ function showStoreLoading(show) {
// ── Plugin Store: Client-Side Filter/Sort/Pagination ──────────────────────── // ── Plugin Store: Client-Side Filter/Sort/Pagination ────────────────────────
function isStorePluginInstalled(pluginId) { function isStorePluginInstalled(pluginIdOrPlugin) {
return (window.installedPlugins || installedPlugins || []).some(p => p.id === pluginId); const installed = window.installedPlugins || installedPlugins || [];
// Accept either a plain ID string or a store plugin object (which may have plugin_path)
if (typeof pluginIdOrPlugin === 'string') {
return installed.some(p => p.id === pluginIdOrPlugin);
}
const storeId = pluginIdOrPlugin.id;
// Derive the actual installed directory name from plugin_path (e.g. "plugins/ledmatrix-weather" → "ledmatrix-weather")
const pluginPath = pluginIdOrPlugin.plugin_path || '';
const pathDerivedId = pluginPath ? pluginPath.split('/').pop() : null;
return installed.some(p => p.id === storeId || (pathDerivedId && p.id === pathDerivedId));
} }
function applyStoreFiltersAndSort(skipPageReset) { function applyStoreFiltersAndSort(skipPageReset) {
@@ -5282,9 +5291,9 @@ function applyStoreFiltersAndSort(skipPageReset) {
// Installed filter // Installed filter
if (st.filterInstalled === true) { if (st.filterInstalled === true) {
list = list.filter(plugin => isStorePluginInstalled(plugin.id)); list = list.filter(plugin => isStorePluginInstalled(plugin));
} else if (st.filterInstalled === false) { } else if (st.filterInstalled === false) {
list = list.filter(plugin => !isStorePluginInstalled(plugin.id)); list = list.filter(plugin => !isStorePluginInstalled(plugin));
} }
// Sort // Sort
@@ -5531,7 +5540,7 @@ function renderPluginStore(plugins) {
}; };
container.innerHTML = plugins.map(plugin => { container.innerHTML = plugins.map(plugin => {
const installed = isStorePluginInstalled(plugin.id); const installed = isStorePluginInstalled(plugin);
return ` return `
<div class="plugin-card"> <div class="plugin-card">
<div class="flex items-start justify-between mb-4"> <div class="flex items-start justify-between mb-4">
@@ -6093,7 +6102,7 @@ function renderCustomRegistryPlugins(plugins, registryUrl) {
}; };
container.innerHTML = plugins.map(plugin => { container.innerHTML = plugins.map(plugin => {
const isInstalled = installedPlugins.some(p => p.id === plugin.id); const isInstalled = isStorePluginInstalled(plugin);
const pluginIdJs = escapeJs(plugin.id); const pluginIdJs = escapeJs(plugin.id);
const escapedUrlJs = escapeJs(registryUrl); const escapedUrlJs = escapeJs(registryUrl);
const pluginPathJs = escapeJs(plugin.plugin_path || ''); const pluginPathJs = escapeJs(plugin.plugin_path || '');