Avoid triggering refreshStatic unless there really is a banner to display. (#14328)

This commit is contained in:
Jacob Richman
2025-12-03 09:08:32 -08:00
committed by GitHub
parent 1c12da1fad
commit 08067acc71
2 changed files with 58 additions and 7 deletions
+26 -7
View File
@@ -125,6 +125,7 @@ import { useSettings } from './contexts/SettingsContext.js';
import { enableSupportedProtocol } from './utils/kittyProtocolDetector.js';
import { useInputHistoryStore } from './hooks/useInputHistoryStore.js';
import { enableBracketedPaste } from './utils/bracketedPaste.js';
import { useBanner } from './hooks/useBanner.js';
const WARNING_PROMPT_DURATION_MS = 1000;
const QUEUE_ERROR_DISPLAY_DURATION_MS = 3000;
@@ -203,6 +204,16 @@ export const AppContainer = (props: AppContainerProps) => {
const [warningBannerText, setWarningBannerText] = useState('');
const [bannerVisible, setBannerVisible] = useState(true);
const bannerData = useMemo(
() => ({
defaultText: defaultBannerText,
warningText: warningBannerText,
}),
[defaultBannerText, warningBannerText],
);
const { bannerText } = useBanner(bannerData, config);
const extensionManager = config.getExtensionLoader() as ExtensionManager;
// We are in the interactive CLI, update how we request consent and settings.
extensionManager.setRequestConsent((description) =>
@@ -380,6 +391,7 @@ export const AppContainer = (props: AppContainerProps) => {
}
setHistoryRemountKey((prev) => prev + 1);
}, [setHistoryRemountKey, isAlternateBuffer, stdout]);
const handleEditorClose = useCallback(() => {
if (
shouldEnterAlternateScreen(isAlternateBuffer, config.getScreenReader())
@@ -403,6 +415,18 @@ export const AppContainer = (props: AppContainerProps) => {
};
}, [handleEditorClose]);
useEffect(() => {
if (
!(settings.merged.ui?.hideBanner || config.getScreenReader()) &&
bannerVisible &&
bannerText
) {
// The header should show a banner but the Header is rendered in static
// so we must trigger a static refresh for it to be visible.
refreshStatic();
}
}, [bannerVisible, bannerText, settings, config, refreshStatic]);
const {
isThemeDialogOpen,
openThemeDialog,
@@ -1388,7 +1412,6 @@ Logging in with Google... Restarting Gemini CLI to continue.
setDefaultBannerText(defaultBanner);
setWarningBannerText(warningBanner);
setBannerVisible(true);
refreshStatic();
const authType = config.getContentGeneratorConfig()?.authType;
if (
authType === AuthType.USE_GEMINI ||
@@ -1497,10 +1520,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
customDialog,
copyModeEnabled,
warningMessage,
bannerData: {
defaultText: defaultBannerText,
warningText: warningBannerText,
},
bannerData,
bannerVisible,
}),
[
@@ -1591,8 +1611,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
authState,
copyModeEnabled,
warningMessage,
defaultBannerText,
warningBannerText,
bannerData,
bannerVisible,
],
);