diff --git a/ui/src/pages/CompanySkills.tsx b/ui/src/pages/CompanySkills.tsx index ca426134977..95e6e76cd9c 100644 --- a/ui/src/pages/CompanySkills.tsx +++ b/ui/src/pages/CompanySkills.tsx @@ -6,6 +6,7 @@ import type { Agent, CatalogSkill, CatalogSkillFileDetail, + CatalogSkillSource, CompanySkillCompatibility, CompanySkillCreateRequest, CompanySkillDetail, @@ -1708,7 +1709,7 @@ function CatalogDetailPane({ cta = ( ); } else if (hashOutOfSync) { @@ -2388,6 +2389,20 @@ function versionLabel(version: CompanySkillVersion | null | undefined) { return `v${version.revisionNumber}${version.label ? ` · ${version.label}` : ""}`; } +export function getSkillVersionDiffSelection(versions: CompanySkillVersion[], targetVersionId?: string | null) { + const sorted = [...versions].sort((a, b) => b.revisionNumber - a.revisionNumber); + const right = targetVersionId + ? sorted.find((version) => version.id === targetVersionId) ?? null + : sorted[0] ?? null; + if (!right) return { leftVersionId: null, rightVersionId: null }; + + const left = sorted.find((version) => version.revisionNumber < right.revisionNumber) ?? null; + return { + leftVersionId: left?.id ?? null, + rightVersionId: right.id, + }; +} + function SkillVersionDiffDialog({ open, onOpenChange, @@ -2406,8 +2421,8 @@ function SkillVersionDiffDialog({ onRightVersionChange: (id: string | null) => void; }) { const sorted = [...versions].sort((a, b) => b.revisionNumber - a.revisionNumber); - const left = sorted.find((version) => version.id === leftVersionId) ?? sorted[1] ?? null; - const right = sorted.find((version) => version.id === rightVersionId) ?? sorted[0] ?? null; + const left = sorted.find((version) => version.id === leftVersionId) ?? null; + const right = sorted.find((version) => version.id === rightVersionId) ?? null; const allPaths = useMemo(() => { const paths = new Set(); for (const file of left?.fileInventory ?? []) paths.add(file.path); @@ -2454,10 +2469,11 @@ function SkillVersionDiffDialog({