From 3291ffbe099f2fdc8f88a0c1bb06fb43b65326a9 Mon Sep 17 00:00:00 2001 From: Allen Hutchison Date: Fri, 30 May 2025 15:16:06 -0700 Subject: [PATCH] fix(cli): Clear input buffer before onSubmit in InputPrompt (#633) --- packages/cli/src/ui/components/InputPrompt.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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],