mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Qwen
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { Box, Text } from 'ink';
|
|
import { SubagentConfig } from '@qwen-code/qwen-code-core';
|
|
import { StepNavigationProps } from '../types.js';
|
|
import { theme } from '../../../semantic-colors.js';
|
|
import { useKeypress } from '../../../hooks/useKeypress.js';
|
|
|
|
interface AgentDeleteStepProps extends StepNavigationProps {
|
|
selectedAgent: SubagentConfig | null;
|
|
onDelete: (agent: SubagentConfig) => Promise<void>;
|
|
}
|
|
|
|
export function AgentDeleteStep({
|
|
selectedAgent,
|
|
onDelete,
|
|
onNavigateBack,
|
|
}: AgentDeleteStepProps) {
|
|
useKeypress(
|
|
async (key) => {
|
|
if (!selectedAgent) return;
|
|
|
|
if (key.name === 'y' || key.name === 'return') {
|
|
try {
|
|
await onDelete(selectedAgent);
|
|
// Navigation will be handled by the parent component after successful deletion
|
|
} catch (error) {
|
|
console.error('Failed to delete agent:', error);
|
|
}
|
|
} else if (key.name === 'n') {
|
|
onNavigateBack();
|
|
}
|
|
},
|
|
{ isActive: true },
|
|
);
|
|
|
|
if (!selectedAgent) {
|
|
return (
|
|
<Box>
|
|
<Text color={theme.status.error}>No agent selected</Text>
|
|
</Box>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Box flexDirection="column" gap={1}>
|
|
<Text color={theme.status.error}>
|
|
Are you sure you want to delete agent “{selectedAgent.name}
|
|
”?
|
|
</Text>
|
|
</Box>
|
|
);
|
|
}
|