From a6026d1484be5d4fb67ec0e523f08c192eca9756 Mon Sep 17 00:00:00 2001 From: Zaki Ali Date: Thu, 24 Apr 2025 14:53:52 -0700 Subject: [PATCH] fix: only remove toolshim paths that we know of to preserve full paths to extension binaries (#2325) --- .../settings_v2/extensions/utils.ts | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/ui/desktop/src/components/settings_v2/extensions/utils.ts b/ui/desktop/src/components/settings_v2/extensions/utils.ts index 5626d9cc..3c93f3ba 100644 --- a/ui/desktop/src/components/settings_v2/extensions/utils.ts +++ b/ui/desktop/src/components/settings_v2/extensions/utils.ts @@ -167,9 +167,25 @@ export async function replaceWithShims(cmd: string) { } export function removeShims(cmd: string) { - const segments = cmd.split('/'); - // Filter out any empty segments (which can happen with trailing slashes) - const nonEmptySegments = segments.filter((segment) => segment.length > 0); - // Return the last segment or empty string if there are no segments - return nonEmptySegments.length > 0 ? nonEmptySegments[nonEmptySegments.length - 1] : ''; + // Only remove shims if the path matches our known shim patterns + const shimPatterns = [ + /\/goose-shims\/goosed$/, + /\/goose-shims\/jbang$/, + /\/goose-shims\/npx$/, + /\/goose-shims\/uvx$/, + ]; + + // Check if the command matches any shim pattern + const isShim = shimPatterns.some((pattern) => pattern.test(cmd)); + + if (isShim) { + const segments = cmd.split('/'); + // Filter out any empty segments (which can happen with trailing slashes) + const nonEmptySegments = segments.filter((segment) => segment.length > 0); + // Return the last segment or empty string if there are no segments + return nonEmptySegments.length > 0 ? nonEmptySegments[nonEmptySegments.length - 1] : ''; + } + + // If it's not a shim, return the original command + return cmd; }