mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-14 16:10:59 -07:00
refactor: migrate chatCompressionService to use HookSystem (#16259)
Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
@@ -159,6 +159,7 @@ describe('ChatCompressionService', () => {
|
||||
}),
|
||||
getEnableHooks: vi.fn().mockReturnValue(false),
|
||||
getMessageBus: vi.fn().mockReturnValue(undefined),
|
||||
getHookSystem: () => undefined,
|
||||
} as unknown as Config;
|
||||
|
||||
vi.mocked(tokenLimit).mockReturnValue(1000);
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
PREVIEW_GEMINI_MODEL,
|
||||
PREVIEW_GEMINI_FLASH_MODEL,
|
||||
} from '../config/models.js';
|
||||
import { firePreCompressHook } from '../core/sessionHookTriggers.js';
|
||||
import { PreCompressTrigger } from '../hooks/types.js';
|
||||
|
||||
/**
|
||||
@@ -128,16 +127,10 @@ export class ChatCompressionService {
|
||||
};
|
||||
}
|
||||
|
||||
// Fire PreCompress hook before compression (only if hooks are enabled)
|
||||
// Fire PreCompress hook before compression
|
||||
// This fires for both manual and auto compression attempts
|
||||
const hooksEnabled = config.getEnableHooks();
|
||||
const messageBus = config.getMessageBus();
|
||||
if (hooksEnabled && messageBus) {
|
||||
const trigger = force
|
||||
? PreCompressTrigger.Manual
|
||||
: PreCompressTrigger.Auto;
|
||||
await firePreCompressHook(messageBus, trigger);
|
||||
}
|
||||
const trigger = force ? PreCompressTrigger.Manual : PreCompressTrigger.Auto;
|
||||
await config.getHookSystem()?.firePreCompressEvent(trigger);
|
||||
|
||||
const originalTokenCount = chat.getLastPromptTokenCount();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user