mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
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:
@@ -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',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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(
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user