@@ -41,7 +41,8 @@ import { Help } from './components/Help.js';
4141import { loadHierarchicalGeminiMemory } from '../config/config.js' ;
4242import { LoadedSettings } from '../config/settings.js' ;
4343import { Tips } from './components/Tips.js' ;
44- import { useConsolePatcher } from './components/ConsolePatcher.js' ;
44+ import { ConsolePatcher } from './utils/ConsolePatcher.js' ;
45+ import { registerCleanup } from '../utils/cleanup.js' ;
4546import { DetailedMessagesDisplay } from './components/DetailedMessagesDisplay.js' ;
4647import { HistoryItemDisplay } from './components/HistoryItemDisplay.js' ;
4748import { ContextSummaryDisplay } from './components/ContextSummaryDisplay.js' ;
@@ -111,6 +112,16 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
111112 handleNewMessage,
112113 clearConsoleMessages : clearConsoleMessagesState ,
113114 } = useConsoleMessages ( ) ;
115+
116+ useEffect ( ( ) => {
117+ const consolePatcher = new ConsolePatcher ( {
118+ onNewMessage : handleNewMessage ,
119+ debugMode : config . getDebugMode ( ) ,
120+ } ) ;
121+ consolePatcher . patch ( ) ;
122+ registerCleanup ( consolePatcher . cleanup ) ;
123+ } , [ handleNewMessage , config ] ) ;
124+
114125 const { stats : sessionStats } = useSessionStats ( ) ;
115126 const [ staticNeedsRefresh , setStaticNeedsRefresh ] = useState ( false ) ;
116127 const [ staticKey , setStaticKey ] = useState ( 0 ) ;
@@ -470,11 +481,6 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
470481 }
471482 } ) ;
472483
473- useConsolePatcher ( {
474- onNewMessage : handleNewMessage ,
475- debugMode : config . getDebugMode ( ) ,
476- } ) ;
477-
478484 useEffect ( ( ) => {
479485 if ( config ) {
480486 setGeminiMdFileCount ( config . getGeminiMdFileCount ( ) ) ;
0 commit comments