From 1f0248d8df135d27173d00b23b31a725d9628d48 Mon Sep 17 00:00:00 2001 From: Jarrod Whelan <150866123+jwhelangoog@users.noreply.github.com> Date: Wed, 25 Mar 2026 01:06:07 -0700 Subject: [PATCH] refactor(cli): cleanup and simplify UI components - Simplified tool visibility logic in . - Reduced UI refresh delay in for a more responsive user experience. - Reorder imports and hook definitions within AppContainer.tsx to reduce diff 'noise'. --- packages/cli/src/ui/AppContainer.tsx | 27 +++++++++---------- .../cli/src/ui/components/MainContent.tsx | 1 - packages/cli/src/ui/hooks/useGeminiStream.ts | 5 +--- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/packages/cli/src/ui/AppContainer.tsx b/packages/cli/src/ui/AppContainer.tsx index 28aebcd079..939a0945da 100644 --- a/packages/cli/src/ui/AppContainer.tsx +++ b/packages/cli/src/ui/AppContainer.tsx @@ -167,6 +167,12 @@ import { useIsHelpDismissKey } from './utils/shortcutsHelp.js'; import { useSuspend } from './hooks/useSuspend.js'; import { useRunEventNotifications } from './hooks/useRunEventNotifications.js'; import { isNotificationsEnabled } from '../utils/terminalNotifications.js'; +import { + getLastTurnToolCallIds, + isToolExecuting, + isToolAwaitingConfirmation, + getAllToolCalls, +} from './utils/historyUtils.js'; interface AppContainerProps { config: Config; @@ -182,12 +188,6 @@ import { APPROVAL_MODE_REVEAL_DURATION_MS, } from './hooks/useVisibilityToggle.js'; import { useKeyMatchers } from './hooks/useKeyMatchers.js'; -import { - getLastTurnToolCallIds, - isToolExecuting, - isToolAwaitingConfirmation, - getAllToolCalls, -} from './utils/historyUtils.js'; /** * The fraction of the terminal width to allocate to the shell. @@ -1167,6 +1167,11 @@ Logging in with Google... Restarting Gemini CLI to continue. consumePendingHints, ); + const pendingHistoryItems = useMemo( + () => [...pendingSlashCommandHistoryItems, ...pendingGeminiHistoryItems], + [pendingSlashCommandHistoryItems, pendingGeminiHistoryItems], + ); + toggleBackgroundShellRef.current = toggleBackgroundShell; isBackgroundShellVisibleRef.current = isBackgroundShellVisible; backgroundShellsRef.current = backgroundShells; @@ -1189,11 +1194,6 @@ Logging in with Google... Restarting Gemini CLI to continue. setIsBackgroundShellListOpenRef.current = setIsBackgroundShellListOpen; - const pendingHistoryItems = useMemo( - () => [...pendingSlashCommandHistoryItems, ...pendingGeminiHistoryItems], - [pendingSlashCommandHistoryItems, pendingGeminiHistoryItems], - ); - const lastOutputTimeRef = useRef(0); useEffect(() => { @@ -1815,11 +1815,10 @@ Logging in with Google... Restarting Gemini CLI to continue. toggleLastTurnTools(); // Force layout refresh after a short delay to allow the terminal layout to settle. - // This prevents the "blank screen" issue by ensuring Ink re-measures after - // any async subview updates are complete. + // Minimize "blank screen" issue after any async subview updates are complete. setTimeout(() => { refreshStatic(); - }, 500); + }, 250); return true; } else if ( diff --git a/packages/cli/src/ui/components/MainContent.tsx b/packages/cli/src/ui/components/MainContent.tsx index 98b99d384f..d8656a879c 100644 --- a/packages/cli/src/ui/components/MainContent.tsx +++ b/packages/cli/src/ui/components/MainContent.tsx @@ -88,7 +88,6 @@ export const MainContent = () => { () => augmentedHistory.map( ({ item, isExpandable, isFirstThinking, isFirstAfterThinking }) => ( - // ({ item, isExpandable, isFirstThinking, /* isFirstAfterThinking */ }) => ( 0; - const anyVisibleInPending = remainingTools.some(isToolVisible); - let lastVisibleIsCompact = false; const isCompactModeEnabled = settings.merged.ui?.compactToolOutput === true; for (let i = toolCalls.length - 1; i >= 0; i--) { @@ -653,7 +650,7 @@ export const useGeminiStream = ( if ( toolCalls.length > 0 && !(allTerminal && allPushed) && - (anyVisibleInHistory || anyVisibleInPending) && + toolCalls.some(isToolVisible) && !lastVisibleIsCompact ) { items.push({