chat: sort custom modes alphabetically by name in ChatModes - #332354
Open
sundeep8967 wants to merge 3 commits into
Open
chat: sort custom modes alphabetically by name in ChatModes#332354sundeep8967 wants to merge 3 commits into
sundeep8967 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Sorts custom chat modes alphabetically for stable Agent dropdown ordering.
Changes:
- Sorts by name, then URI-backed ID.
- Adds unit coverage for unsorted input.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
chatModes.ts |
Sorts custom modes deterministically. |
chatModeService.test.ts |
Tests alphabetical ordering. |
Suppressed comments (1)
src/vs/workbench/contrib/chat/test/common/chatModeService.test.ts:389
- The test guidance asks tests to minimize fine-grained assertions and prefer one snapshot-style deep equality assertion. Mapping the names into one array also gives a clearer failure diff and removes the redundant length assertion.
assert.strictEqual(modes.custom.length, 3);
assert.strictEqual(modes.custom[0].name.get(), 'Alpha Mode');
assert.strictEqual(modes.custom[1].name.get(), 'Beta Mode');
assert.strictEqual(modes.custom[2].name.get(), 'Zeta Mode');
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+381
to
+382
| // Insert in unsorted order (Zeta, Alpha, Beta) | ||
| promptsService.setCustomModes([modeZ, modeA, modeM]); |
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In multi-root workspaces and dynamic customization updates, custom chat modes retrieved via
ChatModes.getCustomModes()can be enumerated in non-deterministic order or insertion order depending on dictionary/map iteration and asynchronous resolution timing.Solution
Sort custom mode instances in
ChatModes.getCustomModes()deterministically by name (usinglocaleCompare) and tie-break by ID/URI.Fixes #332339
Testing
src/vs/workbench/contrib/chat/test/common/chatModeService.test.tsverifying that custom modes are returned sorted alphabetically by name.