Skip to content
TypeScript

fix(web): skill labels show the skill's own name (#27741)

juuulianxaa8dbbe54f6e
diff --git a/packages/shared/src/inlineSkills.test.ts b/packages/shared/src/inlineSkills.test.ts
new file mode 100644
index 00000000000..9413148cee9
--- /dev/null
+++ b/packages/shared/src/inlineSkills.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from "vite-plus/test";
+import { formatProviderSkillDisplayName } from "./inlineSkills.ts";
+
+describe("formatProviderSkillDisplayName", () => {
+ it.each([
+ ["mca_lab_status", "mca_lab_status"],
+ ["frontend-design:frontend-design", "frontend-design:frontend-design"],
+ ["superpowers:brainstorming", "superpowers:brainstorming"],
+ ["DesignSync", "DesignSync"],
+ ])("shows %s as its skill name when the provider sets no display name", (name, label) => {
+ expect(formatProviderSkillDisplayName({ name })).toBe(label);
+ });
+
+ it("prefers the provider display name", () => {
+ expect(formatProviderSkillDisplayName({ name: "gh-fix-ci", displayName: " Fix CI " })).toBe(
+ "Fix CI",
+ );
+ });
+});
diff --git a/packages/shared/src/inlineSkills.ts b/packages/shared/src/inlineSkills.ts
index 4898d037682..7a8c05f4e2b 100644
--- a/packages/shared/src/inlineSkills.ts
+++ b/packages/shared/src/inlineSkills.ts
@@ -2,23 +2,10 @@ import type { ServerProviderSkill } from "@t3tools/contracts";
export type InlineSkill = Pick<ServerProviderSkill, "name" | "displayName">;
-function titleCaseWords(value: string): string {
- const words: string[] = [];
- for (const segment of value.split(/[\s:_-]+/)) {
- if (segment.length === 0) continue;
- words.push(segment.charAt(0).toUpperCase() + segment.slice(1));
- }
- return words.join(" ");
-}
-
export function formatProviderSkillDisplayName(
skill: Pick<ServerProviderSkill, "name" | "displayName">,
): string {
- const displayName = skill.displayName?.trim();
- if (displayName) {
- return displayName;
- }
- return titleCaseWords(skill.name);
+ return skill.displayName?.trim() || skill.name;
}
const SKILL_TOKEN_REGEX =