Skip to content

Commit 530d1dd

Browse files
authored
Allow rendering a theme icon with a chat model (microsoft#264061)
1 parent 45340c9 commit 530d1dd

File tree

7 files changed

+24
-4
lines changed

7 files changed

+24
-4
lines changed

src/vs/platform/actionWidget/browser/actionWidgetDropdown.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { IListAccessibilityProvider } from '../../../base/browser/ui/list/listWi
1515

1616
export interface IActionWidgetDropdownAction extends IAction {
1717
category?: { label: string; order: number };
18+
icon?: ThemeIcon;
1819
description?: string;
1920
}
2021

@@ -84,7 +85,7 @@ export class ActionWidgetDropdown extends BaseDropdown {
8485
description: action.description,
8586
kind: ActionListItemKind.Action,
8687
canPreview: false,
87-
group: { title: '', icon: ThemeIcon.fromId(action.checked ? Codicon.check.id : Codicon.blank.id) },
88+
group: { title: '', icon: action.icon ?? ThemeIcon.fromId(action.checked ? Codicon.check.id : Codicon.blank.id) },
8889
disabled: false,
8990
hideIcon: false,
9091
label: action.label,

src/vs/platform/extensions/common/extensionsApiProposals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const _allApiProposals = {
5252
},
5353
chatProvider: {
5454
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.chatProvider.d.ts',
55-
version: 3
55+
version: 4
5656
},
5757
chatReferenceBinaryData: {
5858
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.chatReferenceBinaryData.d.ts',

src/vs/workbench/api/common/extHostLanguageModels.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ export class ExtHostLanguageModels implements ExtHostLanguageModelsShape {
194194
auth,
195195
isDefault: m.isDefault,
196196
isUserSelectable: m.isUserSelectable,
197+
statusIcon: m.statusIcon,
197198
modelPickerCategory: m.category ?? DEFAULT_MODEL_PICKER_CATEGORY,
198199
capabilities: m.capabilities ? {
199200
vision: m.capabilities.imageInput,

src/vs/workbench/contrib/chat/browser/media/chat.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,12 @@ have to be updated for changes to the rules above, or to support more deeply nes
11301130
overflow: hidden;
11311131
text-overflow: ellipsis;
11321132
}
1133+
.codicon-warning {
1134+
color: var(--vscode-problemsWarningIcon-foreground);
1135+
}
1136+
span + .chat-model-label {
1137+
margin-left: 2px;
1138+
}
11331139
}
11341140

11351141
.codicon {

src/vs/workbench/contrib/chat/browser/modelPicker/modelPickerActionItem.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function modelDelegateToWidgetActionsProvider(delegate: IModelPickerDelegate): I
3535
return {
3636
id: model.metadata.id,
3737
enabled: true,
38+
icon: model.metadata.statusIcon,
3839
checked: model.identifier === delegate.getCurrentModel()?.identifier,
3940
category: model.metadata.modelPickerCategory || DEFAULT_MODEL_PICKER_CATEGORY,
4041
class: undefined,
@@ -134,7 +135,14 @@ export class ModelPickerActionItem extends ActionWidgetDropdownActionViewItem {
134135
}
135136

136137
protected override renderLabel(element: HTMLElement): IDisposable | null {
137-
dom.reset(element, dom.$('span.chat-model-label', undefined, this.currentModel?.metadata.name ?? localize('chat.modelPicker.label', "Pick Model")), ...renderLabelWithIcons(`$(chevron-down)`));
138+
const domChildren = [];
139+
if (this.currentModel?.metadata.statusIcon) {
140+
domChildren.push(...renderLabelWithIcons(`\$(${this.currentModel.metadata.statusIcon.id})`));
141+
}
142+
domChildren.push(dom.$('span.chat-model-label', undefined, this.currentModel?.metadata.name ?? localize('chat.modelPicker.label', "Pick Model")));
143+
domChildren.push(...renderLabelWithIcons(`$(chevron-down)`));
144+
145+
dom.reset(element, ...domChildren);
138146
this.setAriaLabelAttributes(element);
139147
return null;
140148
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Iterable } from '../../../../base/common/iterator.js';
1010
import { IJSONSchema } from '../../../../base/common/jsonSchema.js';
1111
import { DisposableStore, IDisposable, toDisposable } from '../../../../base/common/lifecycle.js';
1212
import { isFalsyOrWhitespace } from '../../../../base/common/strings.js';
13+
import { ThemeIcon } from '../../../../base/common/themables.js';
1314
import { URI } from '../../../../base/common/uri.js';
1415
import { localize } from '../../../../nls.js';
1516
import { IContextKey, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
@@ -165,6 +166,7 @@ export interface ILanguageModelChatMetadata {
165166

166167
readonly isDefault?: boolean;
167168
readonly isUserSelectable?: boolean;
169+
readonly statusIcon?: ThemeIcon;
168170
readonly modelPickerCategory: { label: string; order: number } | undefined;
169171
readonly auth?: {
170172
readonly providerLabel: string;

src/vscode-dts/vscode.proposed.chatProvider.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
// version: 3
6+
// version: 4
77

88
declare module 'vscode' {
99

@@ -52,6 +52,8 @@ declare module 'vscode' {
5252
* WONT BE FINALIZED
5353
*/
5454
readonly category?: { label: string; order: number };
55+
56+
readonly statusIcon?: ThemeIcon;
5557
}
5658

5759
export type LanguageModelResponsePart2 = LanguageModelResponsePart | LanguageModelDataPart | LanguageModelThinkingPart;

0 commit comments

Comments
 (0)