44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7- import type { DefaultHookOutput } from '@google/gemini-cli-core' ;
87import {
98 uiTelemetryService ,
109 clearContextBackups ,
1110 clearCollaborativeWriting ,
12- fireSessionEndHook ,
13- fireSessionStartHook ,
1411 SessionEndReason ,
1512 SessionStartSource ,
1613 flushTelemetry ,
@@ -32,12 +29,9 @@ export const clearCommand: SlashCommand = {
3229 ?. getGeminiClient ( )
3330 ?. getChat ( )
3431 . getChatRecordingService ( ) ;
35- const messageBus = config ?. getMessageBus ( ) ;
3632
3733 // Fire SessionEnd hook before clearing
38- if ( config ?. getEnableHooks ( ) && messageBus ) {
39- await fireSessionEndHook ( messageBus , SessionEndReason . Clear ) ;
40- }
34+ await config ?. getHookSystem ( ) ?. fireSessionEndEvent ( SessionEndReason . Clear ) ;
4135
4236 if ( geminiClient ) {
4337 context . ui . setDebugMessage ( 'Clearing terminal and resetting chat.' ) ;
@@ -66,10 +60,9 @@ export const clearCommand: SlashCommand = {
6660 // AUDITARIA_FEATURE_END
6761
6862 // Fire SessionStart hook after clearing
69- let result : DefaultHookOutput | undefined ;
70- if ( config ?. getEnableHooks ( ) && messageBus ) {
71- result = await fireSessionStartHook ( messageBus , SessionStartSource . Clear ) ;
72- }
63+ const result = await config
64+ ?. getHookSystem ( )
65+ ?. fireSessionStartEvent ( SessionStartSource . Clear ) ;
7366
7467 // Give the event loop a chance to process any pending telemetry operations
7568 // This ensures logger.emit() calls have fully propagated to the BatchLogRecordProcessor
@@ -84,11 +77,11 @@ export const clearCommand: SlashCommand = {
8477 uiTelemetryService . setLastPromptTokenCount ( 0 ) ;
8578 context . ui . clear ( ) ;
8679
87- if ( result ?. systemMessage ) {
80+ if ( result ?. finalOutput ?. systemMessage ) {
8881 context . ui . addItem (
8982 {
9083 type : MessageType . INFO ,
91- text : result . systemMessage ,
84+ text : result . finalOutput . systemMessage ,
9285 } ,
9386 Date . now ( ) ,
9487 ) ;
0 commit comments