diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx index 730aed48..78426aa3 100644 --- a/packages/cli/src/ui/components/InputPrompt.tsx +++ b/packages/cli/src/ui/components/InputPrompt.tsx @@ -74,8 +74,10 @@ export const InputPrompt: React.FC = ({ const handleSubmitAndClear = useCallback( (submittedValue: string) => { - onSubmit(submittedValue); + // Clear the buffer *before* calling onSubmit to prevent potential re-submission + // if onSubmit triggers a re-render while the buffer still holds the old value. buffer.setText(''); + onSubmit(submittedValue); resetCompletionState(); }, [onSubmit, buffer, resetCompletionState],