fix: prevent BYOK model from conflicting with same-named Copilot model in picker#246
fix: prevent BYOK model from conflicting with same-named Copilot model in picker#246rsd-darshan wants to merge 7 commits into
Conversation
…l in picker When a BYOK model is named identically to a Copilot-native model (e.g. GPT-4.1), both dropdown items received the same ID, causing the picker to highlight both as selected simultaneously. Use a provider-prefixed picker ID for BYOK models so each item has a unique identity, and update the selection and lookup logic to match. Fixes microsoft#167
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes model picker selection conflicts when a BYOK model shares the same display name as a Copilot-native model by introducing a unique picker identity and using it consistently across picker item creation, selection display, and model lookup.
Changes:
- Added
ModelUtils.getPickerId()to generate unique IDs for picker items (BYOK:providerName_modelName, native:modelName). - Updated model lookup in
ModelService#setActiveModelto match by picker ID. - Updated picker binding and dropdown item construction to use the new picker ID.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/utils/ModelUtils.java | Adds getPickerId() helper to generate unique picker IDs. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/ModelService.java | Uses picker ID for active model lookup and selected item display. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ModelPickerGroupsBuilder.java | Uses picker ID as dropdown item id to prevent collisions. |
Comments suppressed due to low confidence (1)
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/ModelService.java:1
setActiveModel(String modelName)now effectively expects a picker ID (sometimesproviderName_modelName) rather than a plain model name. This is a behavioral/API contract change that can break existing call sites that passgetModelName(). Consider (a) renaming the parameter/method to reflect the new meaning (e.g.,setActiveModelByPickerId(String pickerId)), or (b) supporting both formats for backward compatibility (first match by picker ID, then fallback match bygetModelName()when no picker-id match is found).
// Copyright (c) Microsoft Corporation.
Existing internal callers pass plain model names (e.g. fallback model, custom mode event). Match by picker ID first, then fall back to model name so both call patterns keep working.
|
Hi @rsd-darshan, thank you for your contribution. Pls check the copilot review first :) |
…concatenation Replaces the custom providerName + "_" + modelName concatenation with the model's existing getModelKey() method, which already produces a stable composite key used throughout the codebase. This avoids potential collisions from naive string concatenation and eliminates the blank-provider-name edge case.
|
@jdneo addressed the Copilot review comments — switched to using the model's existing |
…dules (microsoft#208) Replace getPickerId() wrapper with direct model.getModelKey() calls at each use site, removing the unnecessary indirection.
- setActiveModel now accepts only a composite model key (modelKey), matching the picker ID used throughout the codebase - Custom mode event handler resolves the model name to a key via findModelKeyByName() before calling setActiveModel - ModelHoverContentProvider uses model.getModelKey() directly instead of model.getModelName()
|
@ethanyhou Currently we have fallback model related logics in ModelService. Is it still require after TBB rolls out? |
Summary
GPT-4.1), both dropdown items in the model picker received the same ID, causing both to appear selected simultaneouslyModelUtils.getPickerId()which returnsproviderName_modelNamefor BYOK models andmodelNamefor standard models, ensuring each item has a unique identity in the pickerModelPickerGroupsBuilderandModelServiceto use this unique ID consistently for item construction, selection display, and lookupTest plan
GPT-4.1(same as a Copilot-native model)GPT-4.1— verify the correct model is used and requests succeedGPT-4.1— verify it also works correctly and independently