mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-11 02:20:48 -07:00
refactor(config): stabilize synchronous experiment access and add real-time updates
- Revert getExperimentValue to a synchronous interface to maintain compatibility with existing callers. - Add Config.updateExperimentalSettings() to support immediate application of /experiment set/unset changes. - Implement CLI argument normalization to handle kebab-case, camelCase, and snake_case consistently. - Enhance getExperimentFlagIdFromName to be more resilient to different naming conventions. - Rename getNumericalRoutingEnabled to isNumericalRoutingEnabled for better idiomatic consistency. - Update documentation in experimentation skill to recommend strongly-typed wrappers in Config.ts. - Add regression tests for CLI overrides and update all relevant routing and command tests. - Fix lint errors by removing unnecessary await/Promise.all for synchronous config methods.
This commit is contained in:
@@ -18,6 +18,7 @@ describe('experimentCommand', () => {
|
||||
services: {
|
||||
config: {
|
||||
getExperimentValue: vi.fn(),
|
||||
updateExperimentalSettings: vi.fn(),
|
||||
},
|
||||
settings: {
|
||||
merged: {
|
||||
|
||||
@@ -107,13 +107,16 @@ const setExperimentCommand: SlashCommand = {
|
||||
value = rawValue;
|
||||
}
|
||||
|
||||
const { settings } = context.services;
|
||||
const { settings, config } = context.services;
|
||||
if (!config) return;
|
||||
|
||||
const currentExperimental = {
|
||||
...((settings.merged.experimental as Record<string, unknown>) || {}),
|
||||
};
|
||||
currentExperimental[name] = value;
|
||||
|
||||
settings.setValue(SettingScope.User, 'experimental', currentExperimental);
|
||||
config.updateExperimentalSettings(currentExperimental);
|
||||
|
||||
context.ui.addItem({
|
||||
type: MessageType.INFO,
|
||||
@@ -138,7 +141,9 @@ const unsetExperimentCommand: SlashCommand = {
|
||||
return;
|
||||
}
|
||||
|
||||
const { settings } = context.services;
|
||||
const { settings, config } = context.services;
|
||||
if (!config) return;
|
||||
|
||||
const currentExperimental = {
|
||||
...((settings.merged.experimental as Record<string, unknown>) || {}),
|
||||
};
|
||||
@@ -153,6 +158,7 @@ const unsetExperimentCommand: SlashCommand = {
|
||||
|
||||
delete currentExperimental[name];
|
||||
settings.setValue(SettingScope.User, 'experimental', currentExperimental);
|
||||
config.updateExperimentalSettings(currentExperimental);
|
||||
|
||||
context.ui.addItem({
|
||||
type: MessageType.INFO,
|
||||
|
||||
Reference in New Issue
Block a user