Skip to content

feat(web): sort the Tools list by displayed label (#2782) - #2798

Merged
cliffhall merged 2 commits into
v2/mainfrom
v2/feat/2782-sort-tools-list
Oct 25, 2026
Merged

cliffhall merged 2 commits into
v2/mainfrom
v2/feat/2782-sort-tools-list

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2782

What changed

The Tools sidebar used to list tools in whatever order the server returned from tools/list. It now sorts them alphabetically by the label each row shows: the title when the tool has one, otherwise the name.

  • compareToolsByLabel (clients/web/src/utils/toolUtils.ts): a pure comparator built on resolveDisplayLabel and an Intl.Collator with sensitivity: "base" and numeric: true. Sorting ignores case and compares numbers by value, so tool_2 comes before tool_10. Labels that differ only in case count as equal, and because Array.prototype.sort is stable, they keep the server's order.
  • ToolControls: sorts after filtering. The listed tools and the "Excluded (SEP-2243)" section are both sorted.

Selection is unaffected

Each row key is still taken from the tool's position in the server's original list, before filtering and sorting. So toolRowKey, findToolByRowKey and the duplicate-name handling (#1957, #2001) behave exactly as before. A new test clicks a tool that moved from source index 3 to the top of the list and checks that it still reports 3:git_commit.

Tests

  • toolUtils.test.ts: sorts by title when present, otherwise by name; ignores case; compares numbers by value; equal labels compare as 0.
  • ToolControls.test.tsx: rows render in sorted order; the order holds while a search narrows the list; a moved row reports its source-position key; excluded tools are sorted too.

npm run local:gate passes.

Screenshots

Both screenshots use a test server that returns 10 tools in shuffled order (1280×900).

Before (server order):

Tools list in server order

After (sorted):

Tools list sorted alphabetically

🤖 Generated with Claude Code

Rows in the Tools sidebar now sort alphabetically by the label they show
(title, else name), case-insensitively and with numeric digit runs, so a
20-30 tool list can be scanned. Row keys are still stamped from source
position before filtering and sorting, so selection and duplicate-name
handling (#1957, #2001) are unaffected. Excluded tools sort the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Oct 25, 2026
@cliffhall cliffhall linked an issue Oct 25, 2026 that may be closed by this pull request
2 tasks done
@cliffhall
cliffhall requested a balanced review from Copilot October 25, 2026 03:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Excluded rows sort by title but display only names, so their visible ordering can remain nonalphabetical.

1 open issue
What changed in this PR

Adds alphabetical sorting to the web Tools sidebar for #2782, while preserving source-position row keys used to select duplicate-name tools.

Changes:

  • Adds a label comparator with case-insensitive, numeric-aware ordering.
  • Sorts regular and excluded tools after filtering.
  • Adds tests for ordering, filtered results, and selection identity.
File Description
clients/​web/​src/​utils/​toolUtils.ts Adds the displayed-label comparator.
clients/​web/​src/​utils/​toolUtils.test.ts Tests label precedence, case handling, and numeric ordering.
clients/​web/​src/​components/​groups/​ToolControls/​ToolControls.tsx Sorts filtered rows while retaining source-position keys.
clients/​web/​src/​components/​groups/​ToolControls/​ToolControls.test.tsx Tests rendered order and selection after sorting.

Review effort: Balanced

Comment thread clients/web/src/components/groups/ToolControls/ToolControls.tsx Outdated
Excluded rows render only tool.name, so sorting them by the resolved
title could leave the visible list out of order. Expose the collator as
compareToolLabels and sort excluded rows by name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused changes match displayed labels, preserve selection identity, and include targeted regression coverage with no unresolved findings.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review loop closed — round 2 came back clean.

  • Round 1: one finding. Excluded rows were sorted by their resolved title but display only tool.name, so the visible order could be wrong. Fixed in 8e789d7: excluded rows now sort by name through a new compareToolLabels helper, and a regression test uses titles that would reverse the order.
  • Round 2: no inline comments, nothing suppressed, approval recommended. Per the review procedure, a clean round ends the loop.

@cliffhall
cliffhall merged commit 621ca30 into v2/main Oct 25, 2026
11 checks passed
@cliffhall
cliffhall deleted the v2/feat/2782-sort-tools-list branch October 25, 2026 03:52
@cliffhall cliffhall mentioned this pull request Oct 25, 2026
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sort tools listing by selector or title

2 participants