sort default question options to the top#305696
Merged
meganrogge merged 7 commits intomainfrom Mar 27, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses chat question carousel UX by ensuring predefined default option(s) are moved to the top of the option list, so the initially selected/checked answers are always the first visible choices (per #293080).
Changes:
- Re-sorts
singleSelectoptions so the default option is rendered first. - Re-sorts
multiSelectoptions so all default options are rendered first. - Updates unit tests to reflect the new visual ordering/selection state.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.ts | Re-sorts option rendering for single- and multi-select questions to move default option(s) to the top. |
| src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatQuestionCarouselPart.test.ts | Adjusts assertions to expect default option(s) to appear first and be selected/checked. |
Comments suppressed due to low confidence (2)
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.ts:1212
- Same indexing issue as single-select: checkboxes are created in the sorted
optionsorder, butgetCurrentAnswer()later usesquestion.options?.[index](original order) when collecting checked values. After this re-sort, submittedselectedValueswill no longer correspond to what the user checked. Fix by keeping the rendered/sorted options array (or a parallel value list) and using it when translating checkbox indices back to option values.
// Re-sort options so default options appear first
const options = defaultOptionIds.length > 0
? [...originalOptions].sort((a, b) => {
const aIsDefault = defaultOptionIds.includes(a.id);
const bIsDefault = defaultOptionIds.includes(b.id);
return aIsDefault === bIsDefault ? 0 : aIsDefault ? -1 : 1;
})
: originalOptions;
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatQuestionCarouselPart.test.ts:395
- This test checks that default options appear checked after re-sorting, but it doesn’t validate that the collected
selectedValueson submit match the checked options (especially important now that UI order no longer matchesquestion.optionsorder). Consider submitting and assertingsubmittedAnswers.get('q1')contains values for 'a' and 'c' only.
// Default options 'a' and 'c' are re-sorted to appear first
const listItems = widget.domNode.querySelectorAll('.chat-question-list-item') as NodeListOf<HTMLElement>;
assert.strictEqual(listItems[0].classList.contains('checked'), true, 'First default option should be checked');
assert.strictEqual(listItems[1].classList.contains('checked'), true, 'Second default option should be checked (re-sorted from third)');
assert.strictEqual(listItems[2].classList.contains('checked'), false, 'Non-default option should not be checked');
…chatQuestionCarouselPart.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
bpasero
previously approved these changes
Mar 27, 2026
…chatQuestionCarouselPart.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
eleanorjboyd
approved these changes
Mar 27, 2026
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.
fixes #293080