44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7- import type { DefaultHookOutput } from '@google/gemini-cli-core' ;
87import {
98 uiTelemetryService ,
10- fireSessionEndHook ,
11- fireSessionStartHook ,
129 SessionEndReason ,
1310 SessionStartSource ,
1411 flushTelemetry ,
@@ -30,12 +27,9 @@ export const clearCommand: SlashCommand = {
3027 ?. getGeminiClient ( )
3128 ?. getChat ( )
3229 . getChatRecordingService ( ) ;
33- const messageBus = config ?. getMessageBus ( ) ;
3430
3531 // Fire SessionEnd hook before clearing
36- if ( config ?. getEnableHooks ( ) && messageBus ) {
37- await fireSessionEndHook ( messageBus , SessionEndReason . Clear ) ;
38- }
32+ await config ?. getHookSystem ( ) ?. fireSessionEndEvent ( SessionEndReason . Clear ) ;
3933
4034 if ( geminiClient ) {
4135 context . ui . setDebugMessage ( 'Clearing terminal and resetting chat.' ) ;
@@ -54,10 +48,9 @@ export const clearCommand: SlashCommand = {
5448 }
5549
5650 // Fire SessionStart hook after clearing
57- let result : DefaultHookOutput | undefined ;
58- if ( config ?. getEnableHooks ( ) && messageBus ) {
59- result = await fireSessionStartHook ( messageBus , SessionStartSource . Clear ) ;
60- }
51+ const result = await config
52+ ?. getHookSystem ( )
53+ ?. fireSessionStartEvent ( SessionStartSource . Clear ) ;
6154
6255 // Give the event loop a chance to process any pending telemetry operations
6356 // This ensures logger.emit() calls have fully propagated to the BatchLogRecordProcessor
@@ -72,11 +65,11 @@ export const clearCommand: SlashCommand = {
7265 uiTelemetryService . setLastPromptTokenCount ( 0 ) ;
7366 context . ui . clear ( ) ;
7467
75- if ( result ?. systemMessage ) {
68+ if ( result ?. finalOutput ?. systemMessage ) {
7669 context . ui . addItem (
7770 {
7871 type : MessageType . INFO ,
79- text : result . systemMessage ,
72+ text : result . finalOutput . systemMessage ,
8073 } ,
8174 Date . now ( ) ,
8275 ) ;
0 commit comments