@@ -52,6 +52,12 @@ import {
5252 refreshServerHierarchicalMemory ,
5353 type ModelChangedPayload ,
5454 type MemoryChangedPayload ,
55+ writeToStdout ,
56+ disableMouseEvents ,
57+ enterAlternateScreen ,
58+ enableMouseEvents ,
59+ disableLineWrapping ,
60+ shouldEnterAlternateScreen ,
5561} from '@google/gemini-cli-core' ;
5662import { validateAuthMethod } from '../config/auth.js' ;
5763import process from 'node:process' ;
@@ -92,6 +98,7 @@ import { appEvents, AppEvent } from '../utils/events.js';
9298import { type UpdateObject } from './utils/updateCheck.js' ;
9399import { setUpdateHandler } from '../utils/handleAutoUpdate.js' ;
94100import { registerCleanup , runExitCleanup } from '../utils/cleanup.js' ;
101+ import { RELAUNCH_EXIT_CODE } from '../utils/processUtils.js' ;
95102import { useMessageQueue } from './hooks/useMessageQueue.js' ;
96103import { useAutoAcceptIndicator } from './hooks/useAutoAcceptIndicator.js' ;
97104import { useSessionStats } from './contexts/SessionContext.js' ;
@@ -106,11 +113,9 @@ import { type ExtensionManager } from '../config/extension-manager.js';
106113import { requestConsentInteractive } from '../config/extensions/consent.js' ;
107114import { useIncludeDirsTrust } from './hooks/useIncludeDirsTrust.js' ;
108115import { isWorkspaceTrusted } from '../config/trustedFolders.js' ;
109- import { disableMouseEvents , enableMouseEvents } from './utils/mouse.js' ;
110116import { useAlternateBuffer } from './hooks/useAlternateBuffer.js' ;
111117import { useSettings } from './contexts/SettingsContext.js' ;
112118import { enableSupportedProtocol } from './utils/kittyProtocolDetector.js' ;
113- import { writeToStdout } from '@google/gemini-cli-core' ;
114119
115120const WARNING_PROMPT_DURATION_MS = 1000 ;
116121const QUEUE_ERROR_DISPLAY_DURATION_MS = 3000 ;
@@ -372,16 +377,19 @@ export const AppContainer = (props: AppContainerProps) => {
372377 setHistoryRemountKey ( ( prev ) => prev + 1 ) ;
373378 } , [ setHistoryRemountKey , isAlternateBuffer , stdout ] ) ;
374379 const handleEditorClose = useCallback ( ( ) => {
375- if ( isAlternateBuffer ) {
380+ if (
381+ shouldEnterAlternateScreen ( isAlternateBuffer , config . getScreenReader ( ) )
382+ ) {
376383 // The editor may have exited alternate buffer mode so we need to
377384 // enter it again to be safe.
378- writeToStdout ( ansiEscapes . enterAlternativeScreen ) ;
385+ enterAlternateScreen ( ) ;
379386 enableMouseEvents ( ) ;
387+ disableLineWrapping ( ) ;
380388 app . rerender ( ) ;
381389 }
382390 enableSupportedProtocol ( ) ;
383391 refreshStatic ( ) ;
384- } , [ refreshStatic , isAlternateBuffer , app ] ) ;
392+ } , [ refreshStatic , isAlternateBuffer , app , config ] ) ;
385393
386394 useEffect ( ( ) => {
387395 coreEvents . on ( CoreEvent . ExternalEditorClosed , handleEditorClose ) ;
@@ -458,12 +466,12 @@ export const AppContainer = (props: AppContainerProps) => {
458466 config . isBrowserLaunchSuppressed ( )
459467 ) {
460468 await runExitCleanup ( ) ;
461- debugLogger . log ( `
469+ writeToStdout ( `
462470----------------------------------------------------------------
463- Logging in with Google... Please restart Gemini CLI to continue.
471+ Logging in with Google... Restarting Gemini CLI to continue.
464472----------------------------------------------------------------
465473 ` ) ;
466- process . exit ( 0 ) ;
474+ process . exit ( RELAUNCH_EXIT_CODE ) ;
467475 }
468476 }
469477 setAuthState ( AuthState . Authenticated ) ;
0 commit comments