Skip to content

chat: refactor model picker delegate and improve picker UX#300436

Merged
sandy081 merged 9 commits intomainfrom
sandy081/copilot/magnificent-harrier
Mar 10, 2026
Merged

chat: refactor model picker delegate and improve picker UX#300436
sandy081 merged 9 commits intomainfrom
sandy081/copilot/magnificent-harrier

Conversation

@sandy081
Copy link
Copy Markdown
Member

Summary

Refactors IModelPickerDelegate to split canManageModels() into two independent flags and improves the model picker UX with hover position support and increased max height.

Changes

IModelPickerDelegate refactoring

  • useGroupedModelPicker() — controls whether the picker uses grouped layout (promoted/featured/other sections) vs flat list
  • showManageModelsAction() — controls whether the "Manage Models..." link appears

These were previously conflated in a single canManageModels() method. Now they can be independently controlled per caller:

  • chatInputPart.ts: always uses grouped picker (true), manage action gated by session type
  • newChatViewPane.ts: always uses grouped picker (true), manage action disabled (false)

buildModelPickerItems restructuring

  • Replaced canManageModels parameter with useGroupedModelPicker
  • Flipped if/else so the grouped layout (primary path) comes first for readability
  • Properly indented the grouped layout block

Hover position support

  • ModelPickerWidget now accepts hoverPosition and threads it through to buildModelPickerItems, createModelItem, and createUnavailableModelItem
  • EnhancedModelPickerActionItem passes pickerOptions.hoverPosition to the widget

Action list max height

  • Increased viewport max height from 40% to 60% to better accommodate the grouped model picker with many models

Copilot AI review requested due to automatic review settings March 10, 2026 12:21
@sandy081 sandy081 enabled auto-merge (squash) March 10, 2026 12:23
@vs-code-engineering vs-code-engineering bot added this to the 1.112.0 milestone Mar 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the chat model picker delegate API to decouple “grouped layout” from “manage models” affordances, and improves the picker UX by supporting explicit hover positioning and allowing taller action list dropdowns.

Changes:

  • Split IModelPickerDelegate.canManageModels() into useGroupedModelPicker() and showManageModelsAction(), updating callers in workbench chat input and Sessions chat.
  • Thread hoverPosition through the enhanced model picker widget so item hovers can be positioned consistently.
  • Increase the platform ActionList dropdown max height ratio to better accommodate longer grouped pickers.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/widget/input/modelPickerActionItem2.ts Passes hoverPosition into ModelPickerWidget during instantiation.
src/vs/workbench/contrib/chat/browser/widget/input/modelPickerActionItem.ts Refactors IModelPickerDelegate to split grouped layout vs manage action visibility.
src/vs/workbench/contrib/chat/browser/widget/input/chatModelPicker.ts Adds hover-position support, updates delegate usage, and restructures grouped vs flat item building.
src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts Updates delegate implementation to always use grouped picker and gate “Manage Models...” by session type.
src/vs/sessions/contrib/chat/browser/newChatViewPane.ts Updates Sessions’ delegate to use grouped picker but disable the manage action; sets hover position above.
src/vs/platform/actionWidget/browser/actionList.ts Raises dropdown viewport max height cap from 40% to 60%.
Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/browser/widget/input/chatModelPicker.ts:377

  • The flat-list branch (useGroupedModelPicker === false) ignores the manageModelsAction parameter entirely. With the new delegate split (useGroupedModelPicker() vs showManageModelsAction()), this means callers cannot request a flat list and a “Manage Models...” entry even though the API suggests these are independent. Either render manageModelsAction in the flat-list path as well, or document/enforce that it only applies to the grouped picker.
	} else {
		// Flat list: auto first, then all models sorted alphabetically
		const autoModel = models.find(m => m.metadata.id === 'auto' && m.metadata.vendor === 'copilot');
		if (autoModel) {
			items.push(createModelItem(createModelAction(autoModel, selectedModelId, onSelect), autoModel, hoverPosition));
		}
		const sortedModels = models
			.filter(m => m !== autoModel)
			.sort((a, b) => {
				const vendorCmp = a.metadata.vendor.localeCompare(b.metadata.vendor);
				return vendorCmp !== 0 ? vendorCmp : a.metadata.name.localeCompare(b.metadata.name);
			});
		for (const model of sortedModels) {
			items.push(createModelItem(createModelAction(model, selectedModelId, onSelect), model, hoverPosition));
		}
	}

Comment thread src/vs/platform/actionWidget/browser/actionList.ts
Fixes test failure where empty models list didn't include the manage
models entry because it was nested inside the if (models.length) block.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandy081 sandy081 merged commit 526c24b into main Mar 10, 2026
19 checks passed
@sandy081 sandy081 deleted the sandy081/copilot/magnificent-harrier branch March 10, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants