fix(skill): /skills/counts includes virtual MCP rows in MCP and All badges

This commit is contained in:
matevip 2026-05-01 09:51:58 +08:00
parent 9b9d0c8006
commit f8069b1b5d

View File

@ -99,7 +99,20 @@ public class SkillController {
@Operation(summary = "获取各类型技能计数tab 徽章用)")
@GetMapping("/counts")
public R<Map<String, Long>> counts() {
return R.ok(skillService.countByType());
Map<String, Long> result = skillService.countByType();
// RFC-090 §3.2 virtual MCP-derived skills aren't in mate_skill,
// so countByType() misses them. Fold in the live count so the
// "MCP" and "all" tab badges match what the list endpoint shows.
try {
long virtualMcp = mcpSkillBridge.listMcpDerivedSkillEntities().size();
if (virtualMcp > 0) {
result.merge("mcp", virtualMcp, Long::sum);
result.merge("all", virtualMcp, Long::sum);
}
} catch (Exception ignored) {
// Bridge failure must not break the badge fetch.
}
return R.ok(result);
}
@Operation(summary = "重新扫描单个技能RFC-042 §2.3.4")