Skip to content

Commit 98efc7d

Browse files
authored
mode: sync model in file and model picker (microsoft#253071)
1 parent feda8ca commit 98efc7d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/vs/workbench/contrib/chat/browser/chatInputPart.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { KeyCode } from '../../../../base/common/keyCodes.js';
2323
import { Disposable, DisposableStore, IDisposable, MutableDisposable, toDisposable } from '../../../../base/common/lifecycle.js';
2424
import { ResourceSet } from '../../../../base/common/map.js';
2525
import { Schemas } from '../../../../base/common/network.js';
26-
import { IObservable, observableValue } from '../../../../base/common/observable.js';
26+
import { autorun, IObservable, observableValue } from '../../../../base/common/observable.js';
2727
import { isMacintosh } from '../../../../base/common/platform.js';
2828
import { ScrollbarVisibility } from '../../../../base/common/scrollable.js';
2929
import { assertType } from '../../../../base/common/types.js';
@@ -448,6 +448,13 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
448448
}
449449
}));
450450
this._register(this.chatModeService.onDidChangeChatModes(() => this.validateCurrentChatMode()));
451+
this._register(autorun(r => {
452+
const mode = this._currentModeObservable.read(r);
453+
const model = mode.model?.read(r);
454+
if (model) {
455+
this.switchModelByName(model);
456+
}
457+
}));
451458
}
452459

453460
private getSelectedModelStorageKey(): string {
@@ -562,11 +569,6 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
562569
this.chatModeKindKey.set(mode.kind);
563570
this._onDidChangeCurrentChatMode.fire();
564571

565-
const model = mode.model?.get();
566-
if (model) {
567-
this.switchModelByName(model);
568-
}
569-
570572
if (storeSelection) {
571573
this.storageService.store(GlobalLastChatModeKey, mode.kind, StorageScope.APPLICATION, StorageTarget.USER);
572574
}

0 commit comments

Comments
 (0)