fix(config):Reviving CustomWitty feature (#8432)

Co-authored-by: Richie Foreman <richie.foreman@gmail.com>
Co-authored-by: Arya Gummadi <aryagummadi@google.com>
This commit is contained in:
JAYADITYA
2025-09-22 21:00:11 +05:30
committed by GitHub
parent 81d03cb524
commit 92543da28c
4 changed files with 43 additions and 7 deletions

View File

@@ -2200,6 +2200,18 @@ describe('Settings Loading and Merging', () => {
allowMCPServers: ['serverA'],
});
});
it('should correctly migrate customWittyPhrases', () => {
const v2Settings: Partial<Settings> = {
ui: {
customWittyPhrases: ['test phrase'],
},
};
const v1Settings = migrateSettingsToV1(v2Settings as Settings);
expect(v1Settings).toEqual({
customWittyPhrases: ['test phrase'],
});
});
});
describe('loadEnvironment', () => {
@@ -2258,7 +2270,7 @@ describe('Settings Loading and Merging', () => {
});
it('should return false for settings that are already in V2 format', () => {
const v2Settings = {
const v2Settings: Partial<Settings> = {
ui: {
theme: 'dark',
},

View File

@@ -28,7 +28,7 @@ import {
getSettingsSchema,
} from './settingsSchema.js';
import { resolveEnvVarsInObject } from '../utils/envVarResolver.js';
import { customDeepMerge } from '../utils/deepMerge.js';
import { customDeepMerge, type MergeableObject } from '../utils/deepMerge.js';
import { updateSettingsFilePreservingFormat } from '../utils/commentJson.js';
import { disableExtension } from './extension.js';
@@ -69,6 +69,7 @@ const MIGRATION_MAP: Record<string, string> = {
coreTools: 'tools.core',
contextFileName: 'context.fileName',
customThemes: 'ui.customThemes',
customWittyPhrases: 'ui.customWittyPhrases',
debugKeystrokeLogging: 'general.debugKeystrokeLogging',
disableAutoUpdate: 'general.disableAutoUpdate',
disableUpdateNag: 'general.disableUpdateNag',
@@ -252,7 +253,28 @@ function migrateSettingsToV2(
// Carry over any unrecognized keys
for (const remainingKey of flatKeys) {
v2Settings[remainingKey] = flatSettings[remainingKey];
const existingValue = v2Settings[remainingKey];
const newValue = flatSettings[remainingKey];
if (
typeof existingValue === 'object' &&
existingValue !== null &&
!Array.isArray(existingValue) &&
typeof newValue === 'object' &&
newValue !== null &&
!Array.isArray(newValue)
) {
const pathAwareGetStrategy = (path: string[]) =>
getMergeStrategyForPath([remainingKey, ...path]);
v2Settings[remainingKey] = customDeepMerge(
pathAwareGetStrategy,
{},
newValue as MergeableObject,
existingValue as MergeableObject,
);
} else {
v2Settings[remainingKey] = newValue;
}
}
return v2Settings;

View File

@@ -833,8 +833,10 @@ Logging in with Google... Please restart Gemini CLI to continue.
[handleSlashCommand, settings],
);
const { elapsedTime, currentLoadingPhrase } =
useLoadingIndicator(streamingState);
const { elapsedTime, currentLoadingPhrase } = useLoadingIndicator(
streamingState,
settings.merged.ui?.customWittyPhrases,
);
const handleExit = useCallback(
(

View File

@@ -6,7 +6,7 @@
import { MergeStrategy } from '../config/settingsSchema.js';
type Mergeable =
export type Mergeable =
| string
| number
| boolean
@@ -15,7 +15,7 @@ type Mergeable =
| object
| Mergeable[];
type MergeableObject = Record<string, Mergeable>;
export type MergeableObject = Record<string, Mergeable>;
function isPlainObject(item: unknown): item is MergeableObject {
return !!item && typeof item === 'object' && !Array.isArray(item);