diff --git a/packages/cli/src/ui/components/SettingsDialog.tsx b/packages/cli/src/ui/components/SettingsDialog.tsx index 97ae3939fb..55e46632d1 100644 --- a/packages/cli/src/ui/components/SettingsDialog.tsx +++ b/packages/cli/src/ui/components/SettingsDialog.tsx @@ -29,7 +29,7 @@ import { isDefaultValue, requiresRestart, getRestartRequiredFromModified, - getDefaultValue, + getEffectiveDefaultValue, setPendingSettingValueAny, getNestedValue, getEffectiveValue, @@ -743,7 +743,10 @@ export function SettingsDialog({ // Ctrl+C or Ctrl+L: Clear current setting and reset to default const currentSetting = items[activeSettingIndex]; if (currentSetting) { - const defaultValue = getDefaultValue(currentSetting.value); + const defaultValue = getEffectiveDefaultValue( + currentSetting.value, + config, + ); const defType = currentSetting.type; if (defType === 'boolean') { const booleanDefaultValue = @@ -963,7 +966,10 @@ export function SettingsDialog({ const path = item.value.split('.'); const currentValue = getNestedValue(pendingSettings, path); - const defaultValue = getDefaultValue(item.value); + const defaultValue = getEffectiveDefaultValue( + item.value, + config, + ); if (currentValue !== undefined && currentValue !== null) { displayValue = String(currentValue); diff --git a/packages/cli/src/utils/settingsUtils.ts b/packages/cli/src/utils/settingsUtils.ts index 69530e6dda..7a0a4cd84b 100644 --- a/packages/cli/src/utils/settingsUtils.ts +++ b/packages/cli/src/utils/settingsUtils.ts @@ -16,6 +16,8 @@ import type { SettingsValue, } from '../config/settingsSchema.js'; import { getSettingsSchema } from '../config/settingsSchema.js'; +import type { Config } from '@google/gemini-cli-core'; +import { ExperimentFlags } from '@google/gemini-cli-core'; // The schema is now nested, but many parts of the UI and logic work better // with a flattened structure and dot-notation keys. This section flattens the @@ -96,6 +98,28 @@ export function getDefaultValue(key: string): SettingsValue { return getFlattenedSchema()[key]?.default; } +/** + * Get the effective default value for a setting, checking experiment values when available. + * For settings like compressionThreshold, this will return the experiment value if set, + * otherwise falls back to the schema default. + */ +export function getEffectiveDefaultValue( + key: string, + config?: Config, +): SettingsValue { + if (key === 'model.compressionThreshold' && config) { + const experiments = config.getExperiments(); + const experimentValue = + experiments?.flags[ExperimentFlags.CONTEXT_COMPRESSION_THRESHOLD] + ?.floatValue; + if (experimentValue !== undefined && experimentValue !== 0) { + return experimentValue; + } + } + + return getDefaultValue(key); +} + /** * Get all setting keys that require restart */ diff --git a/packages/core/index.ts b/packages/core/index.ts index e9f6bebac4..dfbf08336c 100644 --- a/packages/core/index.ts +++ b/packages/core/index.ts @@ -49,4 +49,5 @@ export * from './src/utils/googleQuotaErrors.js'; export type { GoogleApiError } from './src/utils/googleErrors.js'; export { getCodeAssistServer } from './src/code_assist/codeAssist.js'; export { getExperiments } from './src/code_assist/experiments/experiments.js'; +export { ExperimentFlags } from './src/code_assist/experiments/flagNames.js'; export { getErrorStatus, ModelNotFoundError } from './src/utils/httpErrors.js'; diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index ff9dc47ea2..0cb3c7a8cc 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -1585,8 +1585,6 @@ export class Config { return this.compressionThreshold; } - await this.ensureExperimentsLoaded(); - const remoteThreshold = this.experiments?.flags[ExperimentFlags.CONTEXT_COMPRESSION_THRESHOLD] ?.floatValue;