do not persist the fallback model (#15483)

This commit is contained in:
Sehoon Shon
2025-12-26 11:08:44 -05:00
committed by GitHub
parent 9cdb267ba5
commit 69fc75c0b2
4 changed files with 34 additions and 4 deletions
+12
View File
@@ -1641,6 +1641,18 @@ describe('Config getHooks', () => {
expect(onModelChange).toHaveBeenCalledWith(DEFAULT_GEMINI_MODEL);
});
it('should NOT call onModelChange when a new model is set as a fallback', () => {
const onModelChange = vi.fn();
const config = new Config({
...baseParams,
onModelChange,
});
config.setModel(DEFAULT_GEMINI_MODEL, true);
expect(onModelChange).not.toHaveBeenCalled();
});
});
});
+2 -2
View File
@@ -877,13 +877,13 @@ export class Config {
return this.model;
}
setModel(newModel: string): void {
setModel(newModel: string, isFallbackModel: boolean = false): void {
if (this.model !== newModel || this._activeModel !== newModel) {
this.model = newModel;
// When the user explicitly sets a model, that becomes the active model.
this._activeModel = newModel;
coreEvents.emitModelChanged(newModel);
if (this.onModelChange) {
if (this.onModelChange && !isFallbackModel) {
this.onModelChange(newModel);
}
}