mirror of
https://github.com/microsoft/vscode.git
synced 2026-06-13 01:14:42 -05:00
chat: avoid reverting model to auto when editing messages (#319063)
When editing a message in inline mode, a new ChatInputPart is created for the inline editor. It would initialize its model from persisted storage (often 'auto') and on finish that selection was copied back over the user's main-input selection. Now seed the inline edit input from the edited request's modelId when it is known, and stop copying the inline input's model back to the main input on finishedEditing. Agent host requests don't carry a modelId, so in that case the inline input is left alone and the main input keeps its selection.
This commit is contained in:
@@ -1686,6 +1686,9 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
||||
this.createInput(this.inputContainer);
|
||||
this.input.setChatMode(this.inputPart.currentModeObs.get().id);
|
||||
this.input.setPermissionLevel(this.inputPart.currentModeInfo.permissionLevel ?? ChatPermissionLevel.Default);
|
||||
if (currentElement.modelId) {
|
||||
this.input.switchModelByIdentifier(currentElement.modelId);
|
||||
}
|
||||
this.input.setEditing(true, isEditingSentRequest);
|
||||
this._onDidChangeActiveInputEditor.fire();
|
||||
} else {
|
||||
@@ -1787,10 +1790,6 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
||||
if (!isInput) {
|
||||
this.inputPart.setChatMode(this.input.currentModeObs.get().id);
|
||||
this.inputPart.setPermissionLevel(this.input.currentModeInfo.permissionLevel ?? ChatPermissionLevel.Default);
|
||||
const currentModel = this.input.selectedLanguageModel.get();
|
||||
if (currentModel) {
|
||||
this.inputPart.switchModel(currentModel.metadata);
|
||||
}
|
||||
|
||||
this.inputPart?.toggleChatInputOverlay(false);
|
||||
try {
|
||||
|
||||
@@ -850,6 +850,20 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to a model by its identifier. Returns true if a matching model
|
||||
* was found and applied.
|
||||
*/
|
||||
public switchModelByIdentifier(identifier: string): boolean {
|
||||
const models = this.getModels();
|
||||
const model = models.find(m => m.identifier === identifier);
|
||||
if (model) {
|
||||
this.setCurrentLanguageModel(model);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public switchModelByQualifiedName(qualifiedModelNames: readonly string[]): boolean {
|
||||
const models = this.getModels();
|
||||
for (const qualifiedModelName of qualifiedModelNames) {
|
||||
|
||||
Reference in New Issue
Block a user