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
+13 -1
View File
@@ -2200,6 +2200,18 @@ describe('Settings Loading and Merging', () => {
allowMCPServers: ['serverA'], 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', () => { describe('loadEnvironment', () => {
@@ -2258,7 +2270,7 @@ describe('Settings Loading and Merging', () => {
}); });
it('should return false for settings that are already in V2 format', () => { it('should return false for settings that are already in V2 format', () => {
const v2Settings = { const v2Settings: Partial<Settings> = {
ui: { ui: {
theme: 'dark', theme: 'dark',
}, },
+24 -2
View File
@@ -28,7 +28,7 @@ import {
getSettingsSchema, getSettingsSchema,
} from './settingsSchema.js'; } from './settingsSchema.js';
import { resolveEnvVarsInObject } from '../utils/envVarResolver.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 { updateSettingsFilePreservingFormat } from '../utils/commentJson.js';
import { disableExtension } from './extension.js'; import { disableExtension } from './extension.js';
@@ -69,6 +69,7 @@ const MIGRATION_MAP: Record<string, string> = {
coreTools: 'tools.core', coreTools: 'tools.core',
contextFileName: 'context.fileName', contextFileName: 'context.fileName',
customThemes: 'ui.customThemes', customThemes: 'ui.customThemes',
customWittyPhrases: 'ui.customWittyPhrases',
debugKeystrokeLogging: 'general.debugKeystrokeLogging', debugKeystrokeLogging: 'general.debugKeystrokeLogging',
disableAutoUpdate: 'general.disableAutoUpdate', disableAutoUpdate: 'general.disableAutoUpdate',
disableUpdateNag: 'general.disableUpdateNag', disableUpdateNag: 'general.disableUpdateNag',
@@ -252,7 +253,28 @@ function migrateSettingsToV2(
// Carry over any unrecognized keys // Carry over any unrecognized keys
for (const remainingKey of flatKeys) { 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; return v2Settings;
+4 -2
View File
@@ -833,8 +833,10 @@ Logging in with Google... Please restart Gemini CLI to continue.
[handleSlashCommand, settings], [handleSlashCommand, settings],
); );
const { elapsedTime, currentLoadingPhrase } = const { elapsedTime, currentLoadingPhrase } = useLoadingIndicator(
useLoadingIndicator(streamingState); streamingState,
settings.merged.ui?.customWittyPhrases,
);
const handleExit = useCallback( const handleExit = useCallback(
( (
+2 -2
View File
@@ -6,7 +6,7 @@
import { MergeStrategy } from '../config/settingsSchema.js'; import { MergeStrategy } from '../config/settingsSchema.js';
type Mergeable = export type Mergeable =
| string | string
| number | number
| boolean | boolean
@@ -15,7 +15,7 @@ type Mergeable =
| object | object
| Mergeable[]; | Mergeable[];
type MergeableObject = Record<string, Mergeable>; export type MergeableObject = Record<string, Mergeable>;
function isPlainObject(item: unknown): item is MergeableObject { function isPlainObject(item: unknown): item is MergeableObject {
return !!item && typeof item === 'object' && !Array.isArray(item); return !!item && typeof item === 'object' && !Array.isArray(item);