@@ -63,8 +63,6 @@ import {
6363 startupProfiler ,
6464 SessionStartSource ,
6565 SessionEndReason ,
66- fireSessionStartHook ,
67- fireSessionEndHook ,
6866 generateSummary ,
6967} from '@google/gemini-cli-core' ;
7068import { validateAuthMethod } from '../config/auth.js' ;
@@ -310,38 +308,31 @@ export const AppContainer = (props: AppContainerProps) => {
310308 setConfigInitialized ( true ) ;
311309 startupProfiler . flush ( config ) ;
312310
313- // Fire SessionStart hook through MessageBus (only if hooks are enabled)
314- // Must be called AFTER config.initialize() to ensure HookRegistry is loaded
315- const hooksEnabled = config . getEnableHooks ( ) ;
316- const hookMessageBus = config . getMessageBus ( ) ;
317- if ( hooksEnabled && hookMessageBus ) {
318- const sessionStartSource = resumedSessionData
319- ? SessionStartSource . Resume
320- : SessionStartSource . Startup ;
321- const result = await fireSessionStartHook (
322- hookMessageBus ,
323- sessionStartSource ,
324- ) ;
311+ const sessionStartSource = resumedSessionData
312+ ? SessionStartSource . Resume
313+ : SessionStartSource . Startup ;
314+ const result = await config
315+ . getHookSystem ( )
316+ ?. fireSessionStartEvent ( sessionStartSource ) ;
317+
318+ if ( result ?. finalOutput ) {
319+ if ( result . finalOutput ?. systemMessage ) {
320+ historyManager . addItem (
321+ {
322+ type : MessageType . INFO ,
323+ text : result . finalOutput . systemMessage ,
324+ } ,
325+ Date . now ( ) ,
326+ ) ;
327+ }
325328
326- if ( result ) {
327- if ( result . systemMessage ) {
328- historyManager . addItem (
329- {
330- type : MessageType . INFO ,
331- text : result . systemMessage ,
332- } ,
333- Date . now ( ) ,
334- ) ;
335- }
336-
337- const additionalContext = result . getAdditionalContext ( ) ;
338- const geminiClient = config . getGeminiClient ( ) ;
339- if ( additionalContext && geminiClient ) {
340- await geminiClient . addHistory ( {
341- role : 'user' ,
342- parts : [ { text : additionalContext } ] ,
343- } ) ;
344- }
329+ const additionalContext = result . finalOutput . getAdditionalContext ( ) ;
330+ const geminiClient = config . getGeminiClient ( ) ;
331+ if ( additionalContext && geminiClient ) {
332+ await geminiClient . addHistory ( {
333+ role : 'user' ,
334+ parts : [ { text : additionalContext } ] ,
335+ } ) ;
345336 }
346337 }
347338
@@ -357,11 +348,7 @@ export const AppContainer = (props: AppContainerProps) => {
357348 await ideClient . disconnect ( ) ;
358349
359350 // Fire SessionEnd hook on cleanup (only if hooks are enabled)
360- const hooksEnabled = config . getEnableHooks ( ) ;
361- const hookMessageBus = config . getMessageBus ( ) ;
362- if ( hooksEnabled && hookMessageBus ) {
363- await fireSessionEndHook ( hookMessageBus , SessionEndReason . Exit ) ;
364- }
351+ await config ?. getHookSystem ( ) ?. fireSessionEndEvent ( SessionEndReason . Exit ) ;
365352 } ) ;
366353 // Disable the dependencies check here. historyManager gets flagged
367354 // but we don't want to react to changes to it because each new history
0 commit comments