add singal abort for hooks

This commit is contained in:
DennisYu07 2026-03-23 16:02:54 +08:00
parent a0041191a7
commit 8bd7cf2cda
16 changed files with 344 additions and 52 deletions

View file

@ -41,6 +41,7 @@ import {
Storage,
SessionEndReason,
SessionStartSource,
type PermissionMode,
} from '@qwen-code/qwen-code-core';
import { buildResumedHistoryItems } from './utils/resumeHistoryUtils.js';
import { validateAuthMethod } from '../config/auth.js';
@ -308,7 +309,11 @@ export const AppContainer = (props: AppContainerProps) => {
if (hookSystem) {
hookSystem
.fireSessionStartEvent(sessionStartSource, config.getModel() ?? '')
.fireSessionStartEvent(
sessionStartSource,
config.getModel() ?? '',
String(config.getApprovalMode()) as PermissionMode,
)
.then(() => {
debugLogger.debug('SessionStart event completed successfully');
})

View file

@ -59,6 +59,7 @@ describe('clearCommand', () => {
}),
getModel: () => 'test-model',
getToolRegistry: () => undefined,
getApprovalMode: () => 'default',
},
},
session: {
@ -108,6 +109,7 @@ describe('clearCommand', () => {
expect(mockFireSessionStartEvent).toHaveBeenCalledWith(
SessionStartSource.Clear,
'test-model',
expect.any(String), // permissionMode
);
// SessionEnd should be called before SessionStart

View file

@ -13,6 +13,7 @@ import {
SessionStartSource,
ToolNames,
SkillTool,
type PermissionMode,
} from '@qwen-code/qwen-code-core';
export const clearCommand: SlashCommand = {
@ -72,6 +73,7 @@ export const clearCommand: SlashCommand = {
?.fireSessionStartEvent(
SessionStartSource.Clear,
config.getModel() ?? '',
String(config.getApprovalMode()) as PermissionMode,
);
} catch (err) {
config.getDebugLogger().warn(`SessionStart hook failed: ${err}`);

View file

@ -9,6 +9,7 @@ import {
SessionService,
type Config,
SessionStartSource,
type PermissionMode,
} from '@qwen-code/qwen-code-core';
import { buildResumedHistoryItems } from '../utils/resumeHistoryUtils.js';
import type { UseHistoryManagerReturn } from './useHistoryManager.js';
@ -78,6 +79,7 @@ export function useResumeCommand(
?.fireSessionStartEvent(
SessionStartSource.Resume,
config.getModel() ?? '',
String(config.getApprovalMode()) as PermissionMode,
);
} catch (err) {
config.getDebugLogger().warn(`SessionStart hook failed: ${err}`);