diff --git a/packages/cli/src/ui/components/subagents/create/AgentCreationWizard.tsx b/packages/cli/src/ui/components/subagents/create/AgentCreationWizard.tsx index 6756856b..11c47a45 100644 --- a/packages/cli/src/ui/components/subagents/create/AgentCreationWizard.tsx +++ b/packages/cli/src/ui/components/subagents/create/AgentCreationWizard.tsx @@ -5,7 +5,7 @@ */ import { useReducer, useCallback, useMemo } from 'react'; -import { Box, Text, useInput } from 'ink'; +import { Box, Text } from 'ink'; import { wizardReducer, initialWizardState } from '../reducers.js'; import { LocationSelector } from './LocationSelector.js'; import { GenerationMethodSelector } from './GenerationMethodSelector.js'; @@ -20,6 +20,7 @@ import { Config } from '@qwen-code/qwen-code-core'; import { Colors } from '../../../colors.js'; import { theme } from '../../../semantic-colors.js'; import { TextEntryStep } from './TextEntryStep.js'; +import { useKeypress } from '../../../hooks/useKeypress.js'; interface AgentCreationWizardProps { onClose: () => void; @@ -49,8 +50,12 @@ export function AgentCreationWizard({ }, [onClose]); // Centralized ESC key handling for the entire wizard - useInput((input, key) => { - if (key.escape) { + useKeypress( + (key) => { + if (key.name !== 'escape') { + return; + } + // LLM DescriptionInput handles its own ESC logic when generating const kind = getStepKind(state.generationMethod, state.currentStep); if (kind === 'LLM_DESC' && state.isGenerating) { @@ -64,8 +69,9 @@ export function AgentCreationWizard({ // On other steps, ESC goes back to previous step handlePrevious(); } - } - }); + }, + { isActive: true }, + ); const stepProps: WizardStepProps = useMemo( () => ({ diff --git a/packages/cli/src/ui/components/subagents/manage/AgentsManagerDialog.tsx b/packages/cli/src/ui/components/subagents/manage/AgentsManagerDialog.tsx index e68167d4..d3be1a4b 100644 --- a/packages/cli/src/ui/components/subagents/manage/AgentsManagerDialog.tsx +++ b/packages/cli/src/ui/components/subagents/manage/AgentsManagerDialog.tsx @@ -5,7 +5,7 @@ */ import { useState, useCallback, useMemo, useEffect } from 'react'; -import { Box, Text, useInput } from 'ink'; +import { Box, Text } from 'ink'; import { AgentSelectionStep } from './AgentSelectionStep.js'; import { ActionSelectionStep } from './ActionSelectionStep.js'; import { AgentViewerStep } from './AgentViewerStep.js'; @@ -18,6 +18,7 @@ import { Colors } from '../../../colors.js'; import { theme } from '../../../semantic-colors.js'; import { getColorForDisplay, shouldShowColor } from '../utils.js'; import { Config, SubagentConfig } from '@qwen-code/qwen-code-core'; +import { useKeypress } from '../../../hooks/useKeypress.js'; interface AgentsManagerDialogProps { onClose: () => void; @@ -122,8 +123,12 @@ export function AgentsManagerDialog({ ); // Centralized ESC key handling for the entire dialog - useInput((input, key) => { - if (key.escape) { + useKeypress( + (key) => { + if (key.name !== 'escape') { + return; + } + const currentStep = getCurrentStep(); if (currentStep === MANAGEMENT_STEPS.AGENT_SELECTION) { // On first step, ESC cancels the entire dialog @@ -132,8 +137,9 @@ export function AgentsManagerDialog({ // On other steps, ESC goes back to previous step in navigation stack handleNavigateBack(); } - } - }); + }, + { isActive: true }, + ); // Props for child components - now using direct state and callbacks const commonProps = useMemo(