/** * @license * Copyright 2026 Qwen Team * SPDX-License-Identifier: Apache-2.0 */ import { Box, Text } from 'ink'; import { theme } from '../../semantic-colors.js'; import { useTerminalSize } from '../../hooks/useTerminalSize.js'; import type { HookConfigDisplayInfo, HookEventDisplayInfo } from './types.js'; import { HooksConfigSource } from '@qwen-code/qwen-code-core'; import { t } from '../../../i18n/index.js'; interface HookConfigDetailStepProps { hookEvent: HookEventDisplayInfo; hookConfig: HookConfigDisplayInfo; } export function HookConfigDetailStep({ hookEvent, hookConfig, }: HookConfigDetailStepProps): React.JSX.Element { const { columns: terminalWidth } = useTerminalSize(); // Get source display const getSourceDisplay = (): string => { switch (hookConfig.source) { case HooksConfigSource.Project: return t('Local Settings'); case HooksConfigSource.User: return t('User Settings'); case HooksConfigSource.System: return t('System Settings'); case HooksConfigSource.Extensions: return t('Extensions'); default: return hookConfig.source; } }; // Check if this is from an extension const isFromExtension = hookConfig.source === HooksConfigSource.Extensions; // Get hook type display const getHookTypeDisplay = (): string => { switch (hookConfig.config.type) { case 'command': return 'command'; default: return hookConfig.config.type; } }; // Get command to display const getCommand = (): string => { if (hookConfig.config.type === 'command') { return hookConfig.config.command; } return ''; }; // Calculate box width for command display const commandBoxWidth = Math.min(terminalWidth - 6, 80); // Label width for alignment (Extension: is the longest label) const labelWidth = 12; return ( {/* Title */} {t('Hook details')} {/* Event */} {t('Event:')} {hookEvent.event} {/* Type */} {t('Type:')} {getHookTypeDisplay()} {/* Source */} {t('Source:')} {getSourceDisplay()} {hookConfig.sourcePath && ( ({hookConfig.sourcePath}) )} {/* Extension name (only for extensions) */} {isFromExtension && hookConfig.sourceDisplay && ( {t('Extension:')} {hookConfig.sourceDisplay} )} {/* Name (if exists) */} {hookConfig.config.name && ( {t('Name:')} {hookConfig.config.name} )} {/* Description (if exists) */} {hookConfig.config.description && ( {t('Desc:')} {hookConfig.config.description} )} {/* Command */} {t('Command:')} {/* Command box */} {getCommand()} {/* Help text */} {t( 'To modify or remove this hook, edit settings.json directly or ask Qwen to help.', )} {/* Footer hint */} {t('Esc to go back')} ); }