diff --git a/ui/litellm-dashboard/src/components/claude_code_plugins/helpers.test.ts b/ui/litellm-dashboard/src/components/claude_code_plugins/helpers.test.ts index 4c84db2a97d..c7ae6592196 100644 --- a/ui/litellm-dashboard/src/components/claude_code_plugins/helpers.test.ts +++ b/ui/litellm-dashboard/src/components/claude_code_plugins/helpers.test.ts @@ -128,9 +128,15 @@ describe("getSourceLink", () => { expect(getSourceLink({ source: "url", url: "https://example.com" })).toBe("https://example.com"); }); - it("returns the repo url for a github git-subdir source", () => { + it("uses the default branch for a github git-subdir source", () => { expect(getSourceLink({ source: "git-subdir", url: "https://github.com/org/repo", path: "plugins/x" })).toBe( - "https://github.com/org/repo", + "https://github.com/org/repo/tree/HEAD/plugins/x", + ); + }); + + it("strips the clone suffix from a github git-subdir link", () => { + expect(getSourceLink({ source: "git-subdir", url: "https://github.com/org/repo.git", path: "plugins/x" })).toBe( + "https://github.com/org/repo/tree/HEAD/plugins/x", ); }); diff --git a/ui/litellm-dashboard/src/components/claude_code_plugins/helpers.ts b/ui/litellm-dashboard/src/components/claude_code_plugins/helpers.ts index cab3c5cba3c..fe450270744 100644 --- a/ui/litellm-dashboard/src/components/claude_code_plugins/helpers.ts +++ b/ui/litellm-dashboard/src/components/claude_code_plugins/helpers.ts @@ -239,6 +239,15 @@ export const getSourceDisplayText = (source: PluginSource): string => { return "Unknown source"; }; +const getGitHubSubdirLink = (repoUrl: string, path: string): string | null => { + const url = parseRepoUrl(repoUrl); + if (!url || url.hostname.replace(/^www\./, "") !== GITHUB_HOST) { + return null; + } + const repoPath = url.pathname.replace(/\.git\/?$/, "").replace(/\/+$/, ""); + return `${url.origin}${repoPath}/tree/HEAD/${path}`; +}; + /** * Get clickable link for plugin source */ @@ -246,7 +255,10 @@ export const getSourceLink = (source: PluginSource): string | null => { if (source.source === "github" && source.repo) { return `https://github.com/${source.repo}`; } - if ((source.source === "url" || source.source === "git-subdir") && source.url) { + if (source.source === "git-subdir" && source.url) { + return source.path ? getGitHubSubdirLink(source.url, source.path) ?? source.url : source.url; + } + if (source.source === "url" && source.url) { return source.url; } return null; diff --git a/ui/litellm-dashboard/src/components/skill_hub_table_columns.tsx b/ui/litellm-dashboard/src/components/skill_hub_table_columns.tsx index 8fc9adc75a2..d12e4a1441e 100644 --- a/ui/litellm-dashboard/src/components/skill_hub_table_columns.tsx +++ b/ui/litellm-dashboard/src/components/skill_hub_table_columns.tsx @@ -3,6 +3,7 @@ import { Badge, Text } from "@tremor/react"; import { Tooltip } from "antd"; import { CopyOutlined, LinkOutlined } from "@ant-design/icons"; import { Plugin } from "./claude_code_plugins/types"; +import { getSourceLink } from "./claude_code_plugins/helpers"; import { StatusBadge } from "@/components/shared/table_cells"; export const skillHubColumns = ( @@ -79,8 +80,8 @@ export const skillHubColumns = ( url = `https://github.com/${src.repo}`; label = src.repo; } else if (src?.source === "git-subdir" && src.url) { - url = src.path ? `${src.url}/tree/main/${src.path}` : src.url; - label = url.replace("https://github.com/", ""); + url = getSourceLink(src); + label = (url ?? src.url).replace("https://github.com/", ""); } else if (src?.source === "url" && src.url) { url = src.url; label = src.url.replace(/^https?:\/\//, "");