Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -266,7 +266,6 @@ export function buildModelPickerItems(
}

// Render promoted section: available first, then sorted alphabetically by name
let hasShownActionLink = false;
if (promotedItems.length > 0) {
promotedItems.sort((a, b) => {
const aAvail = a.kind === 'available' ? 0 : 1;
Expand All @@ -283,11 +282,7 @@ export function buildModelPickerItems(
if (item.kind === 'available') {
items.push(createModelItem(createModelAction(item.model, selectedModelId, onSelect), item.model));
} else {
const showActionLink = item.reason === 'upgrade' ? !hasShownActionLink : true;
if (showActionLink && item.reason === 'upgrade') {
hasShownActionLink = true;
}
items.push(createUnavailableModelItem(item.id, item.entry, item.reason, manageSettingsUrl, updateStateType, undefined, showActionLink));
items.push(createUnavailableModelItem(item.id, item.entry, item.reason, manageSettingsUrl, updateStateType));
}
}
}
Expand Down Expand Up @@ -336,7 +331,7 @@ export function buildModelPickerItems(
for (const model of otherModels) {
const entry = controlModels[model.metadata.id] ?? controlModels[model.identifier];
if (entry?.minVSCodeVersion && !isVersionAtLeast(currentVSCodeVersion, entry.minVSCodeVersion)) {
items.push(createUnavailableModelItem(model.metadata.id, entry, 'update', manageSettingsUrl, updateStateType, ModelPickerSection.Other, true));
items.push(createUnavailableModelItem(model.metadata.id, entry, 'update', manageSettingsUrl, updateStateType, ModelPickerSection.Other));
} else {
items.push(createModelItem(createModelAction(model, selectedModelId, onSelect, ModelPickerSection.Other), model));
}
Expand Down Expand Up @@ -398,14 +393,11 @@ function createUnavailableModelItem(
manageSettingsUrl: string | undefined,
updateStateType: StateType,
section?: string,
showActionLink: boolean = true,
): IActionListItem<IActionWidgetDropdownAction> {
let description: string | MarkdownString | undefined;

if (reason === 'upgrade') {
description = showActionLink
? new MarkdownString(localize('chat.modelPicker.upgradeLink', "[Upgrade your plan](command:workbench.action.chat.upgradePlan \" \")"), { isTrusted: true })
: undefined;
description = new MarkdownString(localize('chat.modelPicker.upgradeLink', "[Upgrade your plan](command:workbench.action.chat.upgradePlan \" \")"), { isTrusted: true });
} else if (reason === 'update') {
description = localize('chat.modelPicker.updateDescription', "Update VS Code");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ suite('buildModelPickerItems', () => {
assert.strictEqual(unavailable.group?.icon?.id, Codicon.blank.id);
});

test('anonymous user sees upgrade description only on first unavailable model', () => {
test('anonymous user sees upgrade description on each unavailable model', () => {
const auto = createAutoModel();
const items = callBuild([auto], {
recentModelIds: ['model-a', 'model-b'],
Expand All @@ -596,10 +596,11 @@ suite('buildModelPickerItems', () => {
assert.strictEqual(disabledItems.length, 2);
assert.ok(disabledItems[0].description instanceof MarkdownString);
assert.ok(disabledItems[0].description.value.includes('Upgrade'));
assert.strictEqual(disabledItems[1].description, undefined);
assert.ok(disabledItems[1].description instanceof MarkdownString);
assert.ok(disabledItems[1].description.value.includes('Upgrade'));
});

test('free user sees upgrade description only on first unavailable model', () => {
test('free user sees upgrade description on each unavailable model', () => {
const auto = createAutoModel();
const items = callBuild([auto], {
recentModelIds: ['model-a', 'model-b'],
Expand All @@ -614,7 +615,8 @@ suite('buildModelPickerItems', () => {
assert.strictEqual(disabledItems.length, 2);
assert.ok(disabledItems[0].description instanceof MarkdownString);
assert.ok(disabledItems[0].description.value.includes('Upgrade'));
assert.strictEqual(disabledItems[1].description, undefined);
assert.ok(disabledItems[1].description instanceof MarkdownString);
assert.ok(disabledItems[1].description.value.includes('Upgrade'));
});

test('anonymous user model selection triggers onSelect normally', () => {
Expand Down
Loading