Skip to content

Commit 532e9e6

Browse files
authored
Bring back context key for model picker (microsoft#258876)
1 parent 4a6f814 commit 532e9e6

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ class OpenModelPickerAction extends Action2 {
359359
when:
360360
ContextKeyExpr.and(
361361
ChatContextKeys.lockedToCodingAgent.negate(),
362+
ChatContextKeys.languageModelsAreUserSelectable,
362363
ContextKeyExpr.or(
363364
ContextKeyExpr.equals(ChatContextKeys.location.key, ChatAgentLocation.Panel),
364365
ContextKeyExpr.equals(ChatContextKeys.location.key, ChatAgentLocation.Editor),

src/vs/workbench/contrib/chat/browser/chatInputPart.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
278278
private _onDidChangeCurrentLanguageModel: Emitter<ILanguageModelChatMetadataAndIdentifier>;
279279

280280
private _currentLanguageModel: ILanguageModelChatMetadataAndIdentifier | undefined;
281+
private readonly _hasUserSelectableModels: IContextKey<boolean>;
281282
get currentLanguageModel() {
282283
return this._currentLanguageModel?.identifier;
283284
}
@@ -423,6 +424,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
423424
this.inputEditorHasFocus = ChatContextKeys.inputHasFocus.bindTo(contextKeyService);
424425
this.promptFileAttached = ChatContextKeys.hasPromptFile.bindTo(contextKeyService);
425426
this.chatModeKindKey = ChatContextKeys.chatModeKind.bindTo(contextKeyService);
427+
this._hasUserSelectableModels = ChatContextKeys.languageModelsAreUserSelectable.bindTo(contextKeyService);
426428
const chatToolCount = ChatContextKeys.chatToolCount.bindTo(contextKeyService);
427429

428430
this._register(autorun(reader => {
@@ -620,7 +622,6 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
620622
.map(modelId => ({ identifier: modelId, metadata: this.languageModelsService.lookupLanguageModel(modelId)! }))
621623
.filter(entry => entry.metadata?.isUserSelectable && this.modelSupportedForDefaultAgent(entry));
622624
models.sort((a, b) => a.metadata.name.localeCompare(b.metadata.name));
623-
624625
return models;
625626
}
626627

@@ -640,6 +641,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
640641

641642
private setCurrentLanguageModel(model: ILanguageModelChatMetadataAndIdentifier) {
642643
this._currentLanguageModel = model;
644+
this._hasUserSelectableModels.set(true);
643645

644646
if (this.cachedDimensions) {
645647
// For quick chat and editor chat, relayout because the input may need to shrink to accomodate the model name

src/vs/workbench/contrib/chat/common/chatContextKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export namespace ChatContextKeys {
5151
export const panelParticipantRegistered = new RawContextKey<boolean>('chatPanelParticipantRegistered', false, { type: 'boolean', description: localize('chatParticipantRegistered', "True when a default chat participant is registered for the panel.") });
5252
export const chatEditingCanUndo = new RawContextKey<boolean>('chatEditingCanUndo', false, { type: 'boolean', description: localize('chatEditingCanUndo', "True when it is possible to undo an interaction in the editing panel.") });
5353
export const chatEditingCanRedo = new RawContextKey<boolean>('chatEditingCanRedo', false, { type: 'boolean', description: localize('chatEditingCanRedo', "True when it is possible to redo an interaction in the editing panel.") });
54+
export const languageModelsAreUserSelectable = new RawContextKey<boolean>('chatModelsAreUserSelectable', false, { type: 'boolean', description: localize('chatModelsAreUserSelectable', "True when the chat model can be selected manually by the user.") });
5455
export const extensionInvalid = new RawContextKey<boolean>('chatExtensionInvalid', false, { type: 'boolean', description: localize('chatExtensionInvalid', "True when the installed chat extension is invalid and needs to be updated.") });
5556
export const inputCursorAtTop = new RawContextKey<boolean>('chatCursorAtTop', false);
5657
export const inputHasAgent = new RawContextKey<boolean>('chatInputHasAgent', false);

0 commit comments

Comments
 (0)