From 4050ac0229ce7ed2bebf989059d2ad4dc02067a2 Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Sat, 31 Oct 2026 11:08:10 -0400 Subject: [PATCH] fix: sort skills alphabetically in the /skills panel The /skills view rendered skills in discovery order because the catalog sort groups by location (.skills last) and returns 0 for every pair when all skills share a location. Sort the normalized items by label in the panel, matching the slash-command autocomplete ordering. --- coverage.txt | 4 ++-- src/tui/skillsPanel.js | 26 +++++++++++++++----------- tests/unit/tui/skillsPanel.test.js | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/coverage.txt b/coverage.txt index 7eb9a9dfa..227360eee 100644 --- a/coverage.txt +++ b/coverage.txt @@ -216,7 +216,7 @@ ℹ selectionLayout.js | 100.00 | 95.00 | 100.00 | ℹ sessionsPanel.js | 83.91 | 41.86 | 92.31 | 67-70 101-102 118-119 123-125 132-136 153-155 169-171 180-181 196-202 205-211 222-225 ℹ settingsPanel.js | 75.31 | 83.87 | 76.47 | 78-92 118-144 181-189 195-199 205-207 -ℹ skillsPanel.js | 89.69 | 71.43 | 71.43 | 67-69 75-81 +ℹ skillsPanel.js | 90.10 | 73.33 | 75.00 | 71-73 79-85 ℹ statusBar.js | 99.06 | 98.11 | 100.00 | 29-30 ℹ subagentsPanel.js | 95.35 | 72.41 | 85.71 | 54-56 81-85 ℹ subagentStore.js | 100.00 | 82.61 | 100.00 | @@ -231,6 +231,6 @@ ℹ loadAgents.js | 88.00 | 42.86 | 100.00 | 17-18 32-33 38-39 ℹ project.js | 100.00 | 100.00 | 100.00 | ℹ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -ℹ all files | 91.53 | 87.53 | 86.85 | +ℹ all files | 91.54 | 87.53 | 86.86 | ℹ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ℹ end of coverage report diff --git a/src/tui/skillsPanel.js b/src/tui/skillsPanel.js index 01a159736..6fb138f32 100644 --- a/src/tui/skillsPanel.js +++ b/src/tui/skillsPanel.js @@ -45,19 +45,23 @@ export function SkillsPanel({ skills = [], onViewChange, onSelectSkill, activeVi const limit = Math.max(1, rows - 4); // Normalize skills to { name, description } — accept either string names - // or catalog entries from registry.getCatalog(). + // or catalog entries from registry.getCatalog(). Sort alphabetically + // (case-insensitive) so the view reads cleanly, matching the slash-command + // autocomplete ordering in app.js. const items = useMemo( () => - skills.map((s) => { - const name = typeof s === "string" ? s : s.name; - const description = typeof s === "string" ? "" : s.description || ""; - return { - label: name, - description, - value: name, - key: name, - }; - }), + skills + .map((s) => { + const name = typeof s === "string" ? s : s.name; + const description = typeof s === "string" ? "" : s.description || ""; + return { + label: name, + description, + value: name, + key: name, + }; + }) + .sort((a, b) => a.label.localeCompare(b.label)), [skills], ); diff --git a/tests/unit/tui/skillsPanel.test.js b/tests/unit/tui/skillsPanel.test.js index 26bc62e19..eb56075a5 100644 --- a/tests/unit/tui/skillsPanel.test.js +++ b/tests/unit/tui/skillsPanel.test.js @@ -52,4 +52,22 @@ describe("SkillsPanel", () => { assert.ok(!result.includes("Alpha description.")); assert.ok(!result.includes("Beta description.")); }); + + it("sorts skills alphabetically regardless of input order", () => { + const result = renderToString( + React.createElement(SkillsPanel, { + skills: [ + { name: "zeta-skill", description: "Zeta description." }, + { name: "alpha-skill", description: "Alpha description." }, + { name: "mid-skill", description: "Mid description." }, + ], + activeView: "skills", + }), + ); + const alphaIdx = result.indexOf("alpha-skill"); + const midIdx = result.indexOf("mid-skill"); + const zetaIdx = result.indexOf("zeta-skill"); + assert.ok(alphaIdx !== -1 && midIdx !== -1 && zetaIdx !== -1); + assert.ok(alphaIdx < midIdx && midIdx < zetaIdx); + }); });