Skip to content
Open
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 @@ -388,6 +388,26 @@ class SwitchToNextModelAction extends Action2 {
}
}

class SwitchToPreviousModelAction extends Action2 {
static readonly ID = 'workbench.action.chat.switchToPreviousModel';

constructor() {
super({
id: SwitchToPreviousModelAction.ID,
title: localize2('interactive.switchToPreviousModel.label', "Switch to Previous Model"),
category: CHAT_CATEGORY,
f1: true,
precondition: ChatContextKeys.enabled,
});
}

override run(accessor: ServicesAccessor, ...args: unknown[]): void {
const widgetService = accessor.get(IChatWidgetService);
const widget = widgetService.lastFocusedWidget;
widget?.input.switchToPreviousModel();
}
}

export class OpenModelPickerAction extends Action2 {
static readonly ID = 'workbench.action.chat.openModelPicker';

Expand Down Expand Up @@ -916,6 +936,7 @@ export function registerChatExecuteActions() {
registerAction2(ChatSubmitWithCodebaseAction);
registerAction2(ToggleChatModeAction);
registerAction2(SwitchToNextModelAction);
registerAction2(SwitchToPreviousModelAction);
registerAction2(OpenModelPickerAction);
registerAction2(OpenModePickerAction);
registerAction2(OpenSessionTargetPickerAction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,15 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
}
}

public switchToPreviousModel(): void {
const models = this.getModels();
if (models.length > 0) {
const currentIndex = models.findIndex(model => model.identifier === this._currentLanguageModel.get()?.identifier);
const previousIndex = (currentIndex - 1 + models.length) % models.length;
this.setCurrentLanguageModel(models[previousIndex]);
}
}

public openModelPicker(): void {
this.modelWidget?.show();
}
Expand Down