feat: Add auto update functionality (#4686)

This commit is contained in:
Gal Zahavi
2025-07-28 17:56:52 -07:00
committed by GitHub
parent 83c4dddb7e
commit 871e0dfab8
12 changed files with 1023 additions and 20 deletions

View File

@@ -83,11 +83,12 @@ import {
isGenericQuotaExceededError,
UserTierId,
} from '@google/gemini-cli-core';
import { checkForUpdates } from './utils/updateCheck.js';
import { UpdateObject } from './utils/updateCheck.js';
import ansiEscapes from 'ansi-escapes';
import { OverflowProvider } from './contexts/OverflowContext.js';
import { ShowMoreLines } from './components/ShowMoreLines.js';
import { PrivacyNotice } from './privacy/PrivacyNotice.js';
import { setUpdateHandler } from '../utils/handleAutoUpdate.js';
import { appEvents, AppEvent } from '../utils/events.js';
const CTRL_EXIT_PROMPT_DURATION_MS = 1000;
@@ -110,15 +111,16 @@ export const AppWrapper = (props: AppProps) => (
const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
const isFocused = useFocus();
useBracketedPaste();
const [updateMessage, setUpdateMessage] = useState<string | null>(null);
const [updateInfo, setUpdateInfo] = useState<UpdateObject | null>(null);
const { stdout } = useStdout();
const nightly = version.includes('nightly');
const { history, addItem, clearItems, loadHistory } = useHistory();
useEffect(() => {
checkForUpdates().then(setUpdateMessage);
}, []);
const cleanup = setUpdateHandler(addItem, setUpdateInfo);
return cleanup;
}, [addItem]);
const { history, addItem, clearItems, loadHistory } = useHistory();
const {
consoleMessages,
handleNewMessage,
@@ -757,9 +759,6 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
return (
<StreamingContext.Provider value={streamingState}>
<Box flexDirection="column" width="90%">
{/* Move UpdateNotification outside Static so it can re-render when updateMessage changes */}
{updateMessage && <UpdateNotification message={updateMessage} />}
{/*
* The Static component is an Ink intrinsic in which there can only be 1 per application.
* Because of this restriction we're hacking it slightly by having a 'header' item here to
@@ -822,6 +821,8 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
{showHelp && <Help commands={slashCommands} />}
<Box flexDirection="column" ref={mainControlsRef}>
{/* Move UpdateNotification to render update notification above input area */}
{updateInfo && <UpdateNotification message={updateInfo.message} />}
{startupWarnings.length > 0 && (
<Box
borderStyle="round"