feat(ui): add visual indicators for hook execution (#15408)

This commit is contained in:
Abhi
2026-01-06 15:52:12 -05:00
committed by GitHub
parent 86b5995f12
commit 61dbab03e0
27 changed files with 1124 additions and 73 deletions

View File

@@ -31,6 +31,8 @@ const mockDebugLogger = vi.hoisted(() => ({
// Mock coreEvents
const mockCoreEvents = vi.hoisted(() => ({
emitFeedback: vi.fn(),
emitHookStart: vi.fn(),
emitHookEnd: vi.fn(),
}));
vi.mock('../utils/debugLogger.js', () => ({
@@ -158,8 +160,31 @@ describe('HookEventHandler', () => {
tool_name: 'EditTool',
tool_input: { file: 'test.txt' },
}),
expect.any(Function),
expect.any(Function),
);
// Verify event emission via callbacks
const onHookStart = vi.mocked(mockHookRunner.executeHooksParallel).mock
.calls[0][3];
const onHookEnd = vi.mocked(mockHookRunner.executeHooksParallel).mock
.calls[0][4];
if (onHookStart) onHookStart(mockPlan[0].hookConfig, 0);
expect(mockCoreEvents.emitHookStart).toHaveBeenCalledWith({
hookName: './test.sh',
eventName: HookEventName.BeforeTool,
hookIndex: 1,
totalHooks: 1,
});
if (onHookEnd) onHookEnd(mockPlan[0].hookConfig, mockResults[0]);
expect(mockCoreEvents.emitHookEnd).toHaveBeenCalledWith({
hookName: './test.sh',
eventName: HookEventName.BeforeTool,
success: true,
});
expect(result).toBe(mockAggregated);
});
@@ -294,6 +319,8 @@ describe('HookEventHandler', () => {
tool_input: toolInput,
tool_response: toolResponse,
}),
expect.any(Function),
expect.any(Function),
);
expect(result).toBe(mockAggregated);
@@ -352,6 +379,8 @@ describe('HookEventHandler', () => {
expect.objectContaining({
prompt,
}),
expect.any(Function),
expect.any(Function),
);
expect(result).toBe(mockAggregated);
@@ -415,6 +444,8 @@ describe('HookEventHandler', () => {
notification_type: 'ToolPermission',
details: { type: 'ToolPermission', title: 'Test Permission' },
}),
expect.any(Function),
expect.any(Function),
);
expect(result).toBe(mockAggregated);
@@ -478,6 +509,8 @@ describe('HookEventHandler', () => {
expect.objectContaining({
source: 'startup',
}),
expect.any(Function),
expect.any(Function),
);
expect(result).toBe(mockAggregated);
@@ -548,6 +581,8 @@ describe('HookEventHandler', () => {
]),
}),
}),
expect.any(Function),
expect.any(Function),
);
expect(result).toBe(mockAggregated);
@@ -591,6 +626,8 @@ describe('HookEventHandler', () => {
hook_event_name: 'BeforeTool',
timestamp: expect.any(String),
}),
expect.any(Function),
expect.any(Function),
);
});
});