fix: Esc unable to cancel subagent dialog

This commit is contained in:
tanzhenxin
2025-09-16 15:24:58 +08:00
parent 49d7947028
commit 8e2fc76c15
2 changed files with 22 additions and 10 deletions

View File

@@ -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(
() => ({