From a45f9ae5e662241ae6f369455bf3f8709ebb166b Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Thu, 13 Nov 2025 13:37:50 +0100 Subject: [PATCH] Fix script slug matching to prevent false positives - Remove normalized slug/name matching fallback that caused false matches - Use exact slug-to-slug matching as primary method - Only use install basename matching for edge cases - Prevents 'docker-vm' from appearing when only 'docker' is downloaded --- src/app/_components/DownloadedScriptsTab.tsx | 16 +++++++++++----- src/app/_components/ScriptsGrid.tsx | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/app/_components/DownloadedScriptsTab.tsx b/src/app/_components/DownloadedScriptsTab.tsx index 94552c0..a2e3331 100644 --- a/src/app/_components/DownloadedScriptsTab.tsx +++ b/src/app/_components/DownloadedScriptsTab.tsx @@ -185,13 +185,19 @@ export function DownloadedScriptsTab({ onInstallScript }: DownloadedScriptsTabPr // Check if there's a corresponding local script const hasLocalVersion = localScriptsData?.scripts?.some(local => { if (!local?.name) return false; + + // Primary: Exact slug-to-slug matching (most reliable, prevents false positives) + if (local.slug && script.slug) { + if (local.slug.toLowerCase() === script.slug.toLowerCase()) { + return true; + } + } + + // Secondary: Check install basenames (for edge cases where install script names differ from slugs) + // Only use normalized matching for install basenames, not for slug/name matching const normalizedLocal = normalizeId(local.name); - const matchesNameOrSlug = ( - normalizedLocal === normalizeId(script.name) || - normalizedLocal === normalizeId(script.slug) - ); const matchesInstallBasename = (script as any)?.install_basenames?.some((base: string) => normalizeId(base) === normalizedLocal) ?? false; - return matchesNameOrSlug || matchesInstallBasename; + return matchesInstallBasename; }) ?? false; return { diff --git a/src/app/_components/ScriptsGrid.tsx b/src/app/_components/ScriptsGrid.tsx index 0a4fbdf..bb8d9bd 100644 --- a/src/app/_components/ScriptsGrid.tsx +++ b/src/app/_components/ScriptsGrid.tsx @@ -216,13 +216,19 @@ export function ScriptsGrid({ onInstallScript }: ScriptsGridProps) { // Check if there's a corresponding local script const hasLocalVersion = localScriptsData?.scripts?.some(local => { if (!local?.name) return false; + + // Primary: Exact slug-to-slug matching (most reliable, prevents false positives) + if (local.slug && script.slug) { + if (local.slug.toLowerCase() === script.slug.toLowerCase()) { + return true; + } + } + + // Secondary: Check install basenames (for edge cases where install script names differ from slugs) + // Only use normalized matching for install basenames, not for slug/name matching const normalizedLocal = normalizeId(local.name); - const matchesNameOrSlug = ( - normalizedLocal === normalizeId(script.name) || - normalizedLocal === normalizeId(script.slug) - ); const matchesInstallBasename = (script as any)?.install_basenames?.some((base: string) => normalizeId(base) === normalizedLocal) ?? false; - return matchesNameOrSlug || matchesInstallBasename; + return matchesInstallBasename; }) ?? false; return {