mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-02-01 22:48:03 +00:00
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:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -1585,8 +1585,6 @@ export class Config {
|
||||
return this.compressionThreshold;
|
||||
}
|
||||
|
||||
await this.ensureExperimentsLoaded();
|
||||
|
||||
const remoteThreshold =
|
||||
this.experiments?.flags[ExperimentFlags.CONTEXT_COMPRESSION_THRESHOLD]
|
||||
?.floatValue;
|
||||
|
||||
Reference in New Issue
Block a user