fix: Show experiment values in settings UI for compressionThreshold (#16267)

Co-authored-by: Vedant Mahajan <vedant.04.mahajan@gmail.com>
This commit is contained in:
Ishaan Gupta
2026-01-17 08:48:34 +05:30
committed by GitHub
parent a76946189a
commit 86dbf2013e
4 changed files with 34 additions and 5 deletions

View File

@@ -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);

View File

@@ -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
*/

View File

@@ -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';

View File

@@ -1585,8 +1585,6 @@ export class Config {
return this.compressionThreshold;
}
await this.ensureExperimentsLoaded();
const remoteThreshold =
this.experiments?.flags[ExperimentFlags.CONTEXT_COMPRESSION_THRESHOLD]
?.floatValue;