Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ILanguageModelChatMetadataAndIdentifier } from '../../common/languageMo
import { localize } from '../../../../../nls.js';
import * as dom from '../../../../../base/browser/dom.js';
import { renderLabelWithIcons } from '../../../../../base/browser/ui/iconLabel/iconLabels.js';
import { IDisposable } from '../../../../../base/common/lifecycle.js';
import { DisposableStore, IDisposable } from '../../../../../base/common/lifecycle.js';
import { ActionWidgetDropdownActionViewItem } from '../../../../../platform/actions/browser/actionWidgetDropdownActionViewItem.js';
import { IActionWidgetService } from '../../../../../platform/actionWidget/browser/actionWidget.js';
import { IActionWidgetDropdownAction, IActionWidgetDropdownActionProvider, IActionWidgetDropdownOptions } from '../../../../../platform/actionWidget/browser/actionWidgetDropdown.js';
Expand All @@ -23,6 +23,7 @@ import { ITelemetryService } from '../../../../../platform/telemetry/common/tele
import { IProductService } from '../../../../../platform/product/common/productService.js';
import { MANAGE_CHAT_COMMAND_ID } from '../../common/constants.js';
import { TelemetryTrustedValue } from '../../../../../platform/telemetry/common/telemetryUtils.js';
import { IHoverService } from '../../../../../platform/hover/browser/hover.js';

export interface IModelPickerDelegate {
readonly onDidChangeModel: Event<ILanguageModelChatMetadataAndIdentifier>;
Expand Down Expand Up @@ -150,6 +151,7 @@ export class ModelPickerActionItem extends ActionWidgetDropdownActionViewItem {
@IKeybindingService keybindingService: IKeybindingService,
@ITelemetryService telemetryService: ITelemetryService,
@IProductService productService: IProductService,
@IHoverService private readonly hoverService: IHoverService,
) {
// Modify the original action with a different label and make it show the current model
const actionWithLabel: IAction = {
Expand All @@ -176,16 +178,24 @@ export class ModelPickerActionItem extends ActionWidgetDropdownActionViewItem {
}

protected override renderLabel(element: HTMLElement): IDisposable | null {
const { name, statusIcon, tooltip } = this.currentModel?.metadata || {};
const disposables = new DisposableStore();
const domChildren = [];
if (this.currentModel?.metadata.statusIcon) {
domChildren.push(...renderLabelWithIcons(`\$(${this.currentModel.metadata.statusIcon.id})`));

if (statusIcon) {
const element = dom.$('span', undefined, ...renderLabelWithIcons(`\$(${statusIcon.id})`));
domChildren.push(element);
if (tooltip) {
disposables.add(this.hoverService.setupDelayedHoverAtMouse(element, () => ({ content: tooltip })));
}
}
domChildren.push(dom.$('span.chat-model-label', undefined, this.currentModel?.metadata.name ?? localize('chat.modelPicker.auto', "Auto")));

domChildren.push(dom.$('span.chat-model-label', undefined, name ?? localize('chat.modelPicker.auto', "Auto")));
domChildren.push(...renderLabelWithIcons(`$(chevron-down)`));

dom.reset(element, ...domChildren);
this.setAriaLabelAttributes(element);
return null;
return disposables;
}

override render(container: HTMLElement): void {
Expand Down
Loading