mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-21 11:30:38 -07:00
feat(ui): improve startup warnings UX with dismissal and show-count limits (#19584)
This commit is contained in:
@@ -7,7 +7,12 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { homedir, getCompatibilityWarnings } from '@google/gemini-cli-core';
|
||||
import {
|
||||
homedir,
|
||||
getCompatibilityWarnings,
|
||||
WarningPriority,
|
||||
type StartupWarning,
|
||||
} from '@google/gemini-cli-core';
|
||||
import type { Settings } from '../config/settingsSchema.js';
|
||||
import {
|
||||
isFolderTrustEnabled,
|
||||
@@ -17,11 +22,13 @@ import {
|
||||
type WarningCheck = {
|
||||
id: string;
|
||||
check: (workspaceRoot: string, settings: Settings) => Promise<string | null>;
|
||||
priority: WarningPriority;
|
||||
};
|
||||
|
||||
// Individual warning checks
|
||||
const homeDirectoryCheck: WarningCheck = {
|
||||
id: 'home-directory',
|
||||
priority: WarningPriority.Low,
|
||||
check: async (workspaceRoot: string, settings: Settings) => {
|
||||
if (settings.ui?.showHomeDirectoryWarning === false) {
|
||||
return null;
|
||||
@@ -53,6 +60,7 @@ const homeDirectoryCheck: WarningCheck = {
|
||||
|
||||
const rootDirectoryCheck: WarningCheck = {
|
||||
id: 'root-directory',
|
||||
priority: WarningPriority.High,
|
||||
check: async (workspaceRoot: string, _settings: Settings) => {
|
||||
try {
|
||||
const workspaceRealPath = await fs.realpath(workspaceRoot);
|
||||
@@ -80,11 +88,21 @@ const WARNING_CHECKS: readonly WarningCheck[] = [
|
||||
export async function getUserStartupWarnings(
|
||||
settings: Settings,
|
||||
workspaceRoot: string = process.cwd(),
|
||||
): Promise<string[]> {
|
||||
): Promise<StartupWarning[]> {
|
||||
const results = await Promise.all(
|
||||
WARNING_CHECKS.map((check) => check.check(workspaceRoot, settings)),
|
||||
WARNING_CHECKS.map(async (check) => {
|
||||
const message = await check.check(workspaceRoot, settings);
|
||||
if (message) {
|
||||
return {
|
||||
id: check.id,
|
||||
message,
|
||||
priority: check.priority,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
);
|
||||
const warnings = results.filter((msg) => msg !== null);
|
||||
const warnings = results.filter((w): w is StartupWarning => w !== null);
|
||||
|
||||
if (settings.ui?.showCompatibilityWarnings !== false) {
|
||||
warnings.push(...getCompatibilityWarnings());
|
||||
|
||||
Reference in New Issue
Block a user