mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 15:21:01 -07:00
feat(ui): add visual indicators for hook execution (#15408)
This commit is contained in:
@@ -11,6 +11,7 @@ import type { HookRunner } from './hookRunner.js';
|
||||
import type { HookAggregator, AggregatedHookResult } from './hookAggregator.js';
|
||||
import { HookEventName } from './types.js';
|
||||
import type {
|
||||
HookConfig,
|
||||
HookInput,
|
||||
BeforeToolInput,
|
||||
AfterToolInput,
|
||||
@@ -507,17 +508,38 @@ export class HookEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
const onHookStart = (config: HookConfig, index: number) => {
|
||||
coreEvents.emitHookStart({
|
||||
hookName: this.getHookName(config),
|
||||
eventName,
|
||||
hookIndex: index + 1,
|
||||
totalHooks: plan.hookConfigs.length,
|
||||
});
|
||||
};
|
||||
|
||||
const onHookEnd = (config: HookConfig, result: HookExecutionResult) => {
|
||||
coreEvents.emitHookEnd({
|
||||
hookName: this.getHookName(config),
|
||||
eventName,
|
||||
success: result.success,
|
||||
});
|
||||
};
|
||||
|
||||
// Execute hooks according to the plan's strategy
|
||||
const results = plan.sequential
|
||||
? await this.hookRunner.executeHooksSequential(
|
||||
plan.hookConfigs,
|
||||
eventName,
|
||||
input,
|
||||
onHookStart,
|
||||
onHookEnd,
|
||||
)
|
||||
: await this.hookRunner.executeHooksParallel(
|
||||
plan.hookConfigs,
|
||||
eventName,
|
||||
input,
|
||||
onHookStart,
|
||||
onHookEnd,
|
||||
);
|
||||
|
||||
// Aggregate results
|
||||
@@ -659,11 +681,18 @@ export class HookEventHandler {
|
||||
// Other common fields like decision/reason are handled by specific hook output classes
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hook name from config for display or telemetry
|
||||
*/
|
||||
private getHookName(config: HookConfig): string {
|
||||
return config.name || config.command || 'unknown-command';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hook name from execution result for telemetry
|
||||
*/
|
||||
private getHookNameFromResult(result: HookExecutionResult): string {
|
||||
return result.hookConfig.command || 'unknown-command';
|
||||
return this.getHookName(result.hookConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user