fix: skills count not displaying when adding (#1295)

* fix: skills count not displaying when adding

* fix: get real skill count by awaiting discovery after adding repo

The previous approach computed count before discovery, so it was always 0.
Now we await refetchDiscoverable() after the mutation, then filter the
fresh skills list to get the actual count for the toast message.

Also reverts the SkillRepo.count field — keep the interface clean since
count is a transient UI concern, not a data model property.

---------

Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
Fan
2026-03-07 21:59:33 +08:00
committed by GitHub
parent 95a74020e1
commit 33d5f6985d

View File

@@ -164,10 +164,20 @@ export const SkillsPage = forwardRef<SkillsPageHandle, SkillsPageProps>(
const handleAddRepo = async (repo: SkillRepo) => {
try {
await addRepoMutation.mutateAsync(repo);
// Await discovery so we can report the real count
const { data: freshSkills } = await refetchDiscoverable();
const count =
freshSkills?.filter(
(s) =>
s.repoOwner === repo.owner &&
s.repoName === repo.name &&
(s.repoBranch || "main") === (repo.branch || "main"),
).length ?? 0;
toast.success(
t("skills.repo.addSuccess", {
owner: repo.owner,
name: repo.name,
count,
}),
{ closeButton: true },
);