@@ -23,7 +23,7 @@ import { KeyCode } from '../../../../base/common/keyCodes.js';
23
23
import { Disposable , DisposableStore , IDisposable , MutableDisposable , toDisposable } from '../../../../base/common/lifecycle.js' ;
24
24
import { ResourceSet } from '../../../../base/common/map.js' ;
25
25
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' ;
27
27
import { isMacintosh } from '../../../../base/common/platform.js' ;
28
28
import { ScrollbarVisibility } from '../../../../base/common/scrollable.js' ;
29
29
import { assertType } from '../../../../base/common/types.js' ;
@@ -448,6 +448,13 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
448
448
}
449
449
} ) ) ;
450
450
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
+ } ) ) ;
451
458
}
452
459
453
460
private getSelectedModelStorageKey ( ) : string {
@@ -562,11 +569,6 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
562
569
this . chatModeKindKey . set ( mode . kind ) ;
563
570
this . _onDidChangeCurrentChatMode . fire ( ) ;
564
571
565
- const model = mode . model ?. get ( ) ;
566
- if ( model ) {
567
- this . switchModelByName ( model ) ;
568
- }
569
-
570
572
if ( storeSelection ) {
571
573
this . storageService . store ( GlobalLastChatModeKey , mode . kind , StorageScope . APPLICATION , StorageTarget . USER ) ;
572
574
}
0 commit comments