fix(skills): install correct skill from skills.sh search results (#2784)

* fix(skills): install correct skill from skills.sh search results

When multiple skills share the same directory name across different repos,
SkillCard was passing directory to onInstall/onUninstall, causing handleInstall
to always match the first result. Switch to using the unique key field
(directory:repoOwner:repoName) for precise identification.

* test(skills): add regression test for skills.sh install by key

Verifies that clicking install on the second card when two skills share
the same directory name correctly installs the second skill, not the first.

---------

Co-authored-by: mrzhao <mrzhao@iflytek.com>
This commit is contained in:
mrzhao
2026-05-18 11:45:54 +08:00
committed by GitHub
parent 0977dcd1c1
commit c9efec294b
3 changed files with 166 additions and 11 deletions
+4 -4
View File
@@ -18,8 +18,8 @@ type SkillCardSkill = DiscoverableSkill & { installed: boolean };
interface SkillCardProps {
skill: SkillCardSkill;
onInstall: (directory: string) => Promise<void>;
onUninstall: (directory: string) => Promise<void>;
onInstall: (key: string) => Promise<void>;
onUninstall: (key: string) => Promise<void>;
installs?: number;
}
@@ -35,7 +35,7 @@ export function SkillCard({
const handleInstall = async () => {
setLoading(true);
try {
await onInstall(skill.directory);
await onInstall(skill.key);
} finally {
setLoading(false);
}
@@ -44,7 +44,7 @@ export function SkillCard({
const handleUninstall = async () => {
setLoading(true);
try {
await onUninstall(skill.directory);
await onUninstall(skill.key);
} finally {
setLoading(false);
}
+3 -7
View File
@@ -194,20 +194,16 @@ export const SkillsPage = forwardRef<SkillsPageHandle, SkillsPageProps>(
readmeUrl: s.readmeUrl,
});
const handleInstall = async (directory: string) => {
const handleInstall = async (key: string) => {
let skill: DiscoverableSkill | undefined;
if (searchSource === "skillssh") {
const found = accumulatedResults.find((s) => s.directory === directory);
const found = accumulatedResults.find((s) => s.key === key);
if (found) {
skill = toDiscoverableSkill(found);
}
} else {
skill = discoverableSkills?.find(
(s) =>
s.directory === directory ||
s.directory.split("/").pop() === directory,
);
skill = discoverableSkills?.find((s) => s.key === key);
}
if (!skill) {