mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-15 16:41:11 -07:00
Make merged settings non-nullable and fix all lints related to that. (#16647)
This commit is contained in:
@@ -10,7 +10,6 @@ import {
|
||||
type LoadedSettings,
|
||||
} from '../config/settings.js';
|
||||
import type { ModifiedScope } from './skillSettings.js';
|
||||
import type { AgentOverride } from '@google/gemini-cli-core';
|
||||
|
||||
export type AgentActionStatus = 'success' | 'no-op' | 'error';
|
||||
|
||||
@@ -44,8 +43,8 @@ export function enableAgent(
|
||||
for (const scope of writableScopes) {
|
||||
if (isLoadableSettingScope(scope)) {
|
||||
const scopePath = settings.forScope(scope).path;
|
||||
const agentOverrides = settings.forScope(scope).settings.agents
|
||||
?.overrides as Record<string, AgentOverride> | undefined;
|
||||
const agentOverrides =
|
||||
settings.forScope(scope).settings.agents?.overrides;
|
||||
const isDisabled = agentOverrides?.[agentName]?.disabled === true;
|
||||
|
||||
if (isDisabled) {
|
||||
@@ -105,9 +104,7 @@ export function disableAgent(
|
||||
}
|
||||
|
||||
const scopePath = settings.forScope(scope).path;
|
||||
const agentOverrides = settings.forScope(scope).settings.agents?.overrides as
|
||||
| Record<string, AgentOverride>
|
||||
| undefined;
|
||||
const agentOverrides = settings.forScope(scope).settings.agents?.overrides;
|
||||
const isDisabled = agentOverrides?.[agentName]?.disabled === true;
|
||||
|
||||
if (isDisabled) {
|
||||
@@ -128,8 +125,8 @@ export function disableAgent(
|
||||
const alreadyDisabledInOther: ModifiedScope[] = [];
|
||||
|
||||
if (isLoadableSettingScope(otherScope)) {
|
||||
const otherOverrides = settings.forScope(otherScope).settings.agents
|
||||
?.overrides as Record<string, AgentOverride> | undefined;
|
||||
const otherOverrides =
|
||||
settings.forScope(otherScope).settings.agents?.overrides;
|
||||
if (otherOverrides?.[agentName]?.disabled === true) {
|
||||
alreadyDisabledInOther.push({
|
||||
scope: otherScope,
|
||||
|
||||
@@ -14,6 +14,7 @@ import EventEmitter from 'node:events';
|
||||
import type { ChildProcess } from 'node:child_process';
|
||||
import { handleAutoUpdate, setUpdateHandler } from './handleAutoUpdate.js';
|
||||
import { MessageType } from '../ui/types.js';
|
||||
import { mergeSettings } from '../config/settings.js';
|
||||
|
||||
vi.mock('./installationInfo.js', async () => {
|
||||
const actual = await vi.importActual('./installationInfo.js');
|
||||
@@ -49,12 +50,9 @@ describe('handleAutoUpdate', () => {
|
||||
message: 'An update is available!',
|
||||
};
|
||||
|
||||
const defaultMergedSettings = mergeSettings({}, {}, {}, {}, true);
|
||||
mockSettings = {
|
||||
merged: {
|
||||
general: {
|
||||
disableAutoUpdate: false,
|
||||
},
|
||||
},
|
||||
merged: defaultMergedSettings,
|
||||
} as LoadedSettings;
|
||||
|
||||
mockChildProcess = Object.assign(new EventEmitter(), {
|
||||
@@ -82,7 +80,7 @@ describe('handleAutoUpdate', () => {
|
||||
});
|
||||
|
||||
it('should do nothing if update nag is disabled', () => {
|
||||
mockSettings.merged.general!.disableUpdateNag = true;
|
||||
mockSettings.merged.general.disableUpdateNag = true;
|
||||
handleAutoUpdate(mockUpdateInfo, mockSettings, '/root', mockSpawn);
|
||||
expect(mockGetInstallationInfo).not.toHaveBeenCalled();
|
||||
expect(updateEventEmitter.emit).not.toHaveBeenCalled();
|
||||
@@ -90,7 +88,7 @@ describe('handleAutoUpdate', () => {
|
||||
});
|
||||
|
||||
it('should emit "update-received" but not update if auto-updates are disabled', () => {
|
||||
mockSettings.merged.general!.disableAutoUpdate = true;
|
||||
mockSettings.merged.general.disableAutoUpdate = true;
|
||||
mockGetInstallationInfo.mockReturnValue({
|
||||
updateCommand: 'npm i -g @google/gemini-cli@latest',
|
||||
updateMessage: 'Please update manually.',
|
||||
|
||||
@@ -23,20 +23,20 @@ export function handleAutoUpdate(
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.merged.tools?.sandbox || process.env['GEMINI_SANDBOX']) {
|
||||
if (settings.merged.tools.sandbox || process.env['GEMINI_SANDBOX']) {
|
||||
updateEventEmitter.emit('update-info', {
|
||||
message: `${info.message}\nAutomatic update is not available in sandbox mode.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.merged.general?.disableUpdateNag) {
|
||||
if (settings.merged.general.disableUpdateNag) {
|
||||
return;
|
||||
}
|
||||
|
||||
const installationInfo = getInstallationInfo(
|
||||
projectRoot,
|
||||
settings.merged.general?.disableAutoUpdate ?? false,
|
||||
settings.merged.general.disableAutoUpdate,
|
||||
);
|
||||
|
||||
if (
|
||||
@@ -58,7 +58,7 @@ export function handleAutoUpdate(
|
||||
|
||||
if (
|
||||
!installationInfo.updateCommand ||
|
||||
settings.merged.general?.disableAutoUpdate
|
||||
settings.merged.general.disableAutoUpdate
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,14 +32,14 @@ export async function setupTerminalAndTheme(
|
||||
}
|
||||
|
||||
// Load custom themes from settings
|
||||
themeManager.loadCustomThemes(settings.merged.ui?.customThemes);
|
||||
themeManager.loadCustomThemes(settings.merged.ui.customThemes);
|
||||
|
||||
if (settings.merged.ui?.theme) {
|
||||
if (!themeManager.setActiveTheme(settings.merged.ui?.theme)) {
|
||||
if (settings.merged.ui.theme) {
|
||||
if (!themeManager.setActiveTheme(settings.merged.ui.theme)) {
|
||||
// If the theme is not found during initial load, log a warning and continue.
|
||||
// The useThemeCommand hook in AppContainer.tsx will handle opening the dialog.
|
||||
debugLogger.warn(
|
||||
`Warning: Theme "${settings.merged.ui?.theme}" not found.`,
|
||||
`Warning: Theme "${settings.merged.ui.theme}" not found.`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user