Compare commits

...

2 Commits

Author SHA1 Message Date
Jason
ebf407e46b 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.
2026-03-07 21:45:54 +08:00
fan
ea13395207 fix: skills count not displaying when adding 2026-03-05 14:50:48 +08:00

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 },
);