mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-14 16:10:59 -07:00
feat(core): centralize compatibility checks and add TrueColor detection (#19478)
This commit is contained in:
@@ -485,6 +485,15 @@ const SETTINGS_SCHEMA = {
|
||||
'Show a warning when running Gemini CLI in the home directory.',
|
||||
showInDialog: true,
|
||||
},
|
||||
showCompatibilityWarnings: {
|
||||
type: 'boolean',
|
||||
label: 'Show Compatibility Warnings',
|
||||
category: 'UI',
|
||||
requiresRestart: true,
|
||||
default: true,
|
||||
description: 'Show warnings about terminal or OS compatibility issues.',
|
||||
showInDialog: true,
|
||||
},
|
||||
hideTips: {
|
||||
type: 'boolean',
|
||||
label: 'Hide Tips',
|
||||
|
||||
@@ -88,17 +88,16 @@ export const Notifications = () => {
|
||||
)}
|
||||
{updateInfo && <UpdateNotification message={updateInfo.message} />}
|
||||
{showStartupWarnings && (
|
||||
<Box
|
||||
borderStyle="round"
|
||||
borderColor={theme.status.warning}
|
||||
paddingX={1}
|
||||
marginY={1}
|
||||
flexDirection="column"
|
||||
>
|
||||
<Box marginY={1} flexDirection="column">
|
||||
{startupWarnings.map((warning, index) => (
|
||||
<Text key={index} color={theme.status.warning}>
|
||||
{warning}
|
||||
</Text>
|
||||
<Box key={index} flexDirection="row">
|
||||
<Box width={3}>
|
||||
<Text color={theme.status.warning}>⚠ </Text>
|
||||
</Box>
|
||||
<Box flexGrow={1}>
|
||||
<Text color={theme.status.warning}>{warning}</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
))}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
isFolderTrustEnabled,
|
||||
isWorkspaceTrusted,
|
||||
} from '../config/trustedFolders.js';
|
||||
import { getCompatibilityWarnings } from '@google/gemini-cli-core';
|
||||
|
||||
// Mock os.homedir to control the home directory in tests
|
||||
vi.mock('os', async (importOriginal) => {
|
||||
@@ -29,6 +30,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
return {
|
||||
...actual,
|
||||
homedir: () => os.homedir(),
|
||||
getCompatibilityWarnings: vi.fn().mockReturnValue([]),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -51,11 +53,12 @@ describe('getUserStartupWarnings', () => {
|
||||
isTrusted: false,
|
||||
source: undefined,
|
||||
});
|
||||
vi.mocked(getCompatibilityWarnings).mockReturnValue([]);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await fs.rm(testRootDir, { recursive: true, force: true });
|
||||
vi.clearAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('home directory check', () => {
|
||||
@@ -135,4 +138,27 @@ describe('getUserStartupWarnings', () => {
|
||||
expect(warnings).toEqual([expectedWarning, expectedWarning]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('compatibility warnings', () => {
|
||||
it('should include compatibility warnings by default', async () => {
|
||||
vi.mocked(getCompatibilityWarnings).mockReturnValue(['Comp warning 1']);
|
||||
const projectDir = path.join(testRootDir, 'project');
|
||||
await fs.mkdir(projectDir);
|
||||
|
||||
const warnings = await getUserStartupWarnings({}, projectDir);
|
||||
expect(warnings).toContain('Comp warning 1');
|
||||
});
|
||||
|
||||
it('should not include compatibility warnings when showCompatibilityWarnings is false', async () => {
|
||||
vi.mocked(getCompatibilityWarnings).mockReturnValue(['Comp warning 1']);
|
||||
const projectDir = path.join(testRootDir, 'project');
|
||||
await fs.mkdir(projectDir);
|
||||
|
||||
const warnings = await getUserStartupWarnings(
|
||||
{ ui: { showCompatibilityWarnings: false } },
|
||||
projectDir,
|
||||
);
|
||||
expect(warnings).not.toContain('Comp warning 1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { homedir } from '@google/gemini-cli-core';
|
||||
import { homedir, getCompatibilityWarnings } from '@google/gemini-cli-core';
|
||||
import type { Settings } from '../config/settingsSchema.js';
|
||||
import {
|
||||
isFolderTrustEnabled,
|
||||
@@ -84,5 +84,11 @@ export async function getUserStartupWarnings(
|
||||
const results = await Promise.all(
|
||||
WARNING_CHECKS.map((check) => check.check(workspaceRoot, settings)),
|
||||
);
|
||||
return results.filter((msg) => msg !== null);
|
||||
const warnings = results.filter((msg) => msg !== null);
|
||||
|
||||
if (settings.ui?.showCompatibilityWarnings !== false) {
|
||||
warnings.push(...getCompatibilityWarnings());
|
||||
}
|
||||
|
||||
return warnings;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user