mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
fix: model persistence for all scenarios (#21051)
This commit is contained in:
@@ -2198,6 +2198,23 @@ describe('Config getHooks', () => {
|
||||
|
||||
expect(onModelChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call onModelChange when persisting a model that was previously temporary', () => {
|
||||
const onModelChange = vi.fn();
|
||||
const config = new Config({
|
||||
...baseParams,
|
||||
model: 'some-other-model',
|
||||
onModelChange,
|
||||
});
|
||||
|
||||
// Temporary selection
|
||||
config.setModel(DEFAULT_GEMINI_MODEL, true);
|
||||
expect(onModelChange).not.toHaveBeenCalled();
|
||||
|
||||
// Persist selection of the same model
|
||||
config.setModel(DEFAULT_GEMINI_MODEL, false);
|
||||
expect(onModelChange).toHaveBeenCalledWith(DEFAULT_GEMINI_MODEL);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1403,9 +1403,9 @@ export class Config implements McpContext {
|
||||
// When the user explicitly sets a model, that becomes the active model.
|
||||
this._activeModel = newModel;
|
||||
coreEvents.emitModelChanged(newModel);
|
||||
if (this.onModelChange && !isTemporary) {
|
||||
this.onModelChange(newModel);
|
||||
}
|
||||
}
|
||||
if (this.onModelChange && !isTemporary) {
|
||||
this.onModelChange(newModel);
|
||||
}
|
||||
this.modelAvailabilityService.reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user