feat(ui): improve startup warnings UX with dismissal and show-count limits (#19584)

This commit is contained in:
Spencer
2026-02-20 13:22:45 -05:00
committed by GitHub
parent d24f10b087
commit fe428936d5
12 changed files with 503 additions and 109 deletions

View File

@@ -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());