From 05b1c8101fdb253b4e58ee7cff218dd3713a63a4 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Fri, 20 Jun 2025 05:27:03 +0000 Subject: [PATCH] Turn off debug logging of MaxSizedBox errors by default. (#1228) --- packages/cli/src/gemini.tsx | 3 +++ .../cli/src/ui/components/shared/MaxSizedBox.test.tsx | 8 +++++++- packages/cli/src/ui/components/shared/MaxSizedBox.tsx | 6 +++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx index 10352f0b..4f16f0b0 100644 --- a/packages/cli/src/gemini.tsx +++ b/packages/cli/src/gemini.tsx @@ -28,6 +28,7 @@ import { AuthType, } from '@gemini-cli/core'; import { validateAuthMethod } from './config/auth.js'; +import { setMaxSizedBoxDebugging } from './ui/components/shared/MaxSizedBox.js'; export async function main() { const workspaceRoot = process.cwd(); @@ -49,6 +50,8 @@ export async function main() { const extensions = loadExtensions(workspaceRoot); const config = await loadCliConfig(settings.merged, extensions, sessionId); + setMaxSizedBoxDebugging(config.getDebugMode()); + // Initialize centralized FileDiscoveryService config.getFileService(); if (config.getCheckpointingEnabled()) { diff --git a/packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx b/packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx index 23ef98cd..7abd19a2 100644 --- a/packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx +++ b/packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx @@ -5,11 +5,17 @@ */ import { render } from 'ink-testing-library'; -import { MaxSizedBox } from './MaxSizedBox.js'; +import { MaxSizedBox, setMaxSizedBoxDebugging } from './MaxSizedBox.js'; import { Box, Text } from 'ink'; import { describe, it, expect } from 'vitest'; describe('', () => { + // Make sure MaxSizedBox logs errors on invalid configurations. + // This is useful for debugging issues with the component. + // It should be set to false in production for perfornance and to avoid + // cluttering the console if there are ignoreable issues. + setMaxSizedBoxDebugging(true); + it('renders children without truncation when they fit', () => { const { lastFrame } = render( diff --git a/packages/cli/src/ui/components/shared/MaxSizedBox.tsx b/packages/cli/src/ui/components/shared/MaxSizedBox.tsx index fe73c250..1b5b90aa 100644 --- a/packages/cli/src/ui/components/shared/MaxSizedBox.tsx +++ b/packages/cli/src/ui/components/shared/MaxSizedBox.tsx @@ -10,7 +10,11 @@ import stringWidth from 'string-width'; import { Colors } from '../../colors.js'; import { toCodePoints } from '../../utils/textUtils.js'; -const enableDebugLog = true; +let enableDebugLog = false; + +export function setMaxSizedBoxDebugging(value: boolean) { + enableDebugLog = value; +} function debugReportError(message: string, element: React.ReactNode) { if (!enableDebugLog) return;