fix(cli): check NEWLINE before SUBMIT in TextInput multiline mode#3094
fix(cli): check NEWLINE before SUBMIT in TextInput multiline mode#3094tanzhenxin wants to merge 1 commit intomainfrom
Conversation
…nput (#3068) The `|| key.name === 'return'` fallback in TextInput matched every Return keypress (Shift+Enter, Ctrl+Enter, etc.) and routed them all to the submit path, making the NEWLINE handler dead code. Multiline inputs like the agent creation description step could not insert newlines via keyboard. Reorder checks so NEWLINE is evaluated first in multiline mode, and restrict the broad return fallback to single-line inputs only.
📋 Review SummaryThis PR fixes a critical input handling bug in 🔍 General Feedback
🎯 Specific Feedback🔵 Low
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
TLDR
Fixes the
/agent createwizard (Step 3: Describe Your Subagent) treating the editor newline keypress (Shift+Enter, Ctrl+Enter) as a submit instead of inserting a newline.The root cause was in
TextInput.tsx— the submit branch hadkeyMatchers[Command.SUBMIT](key) || key.name === 'return', where thekey.name === 'return'fallback matched every Return keypress regardless of modifiers, making the NEWLINE handler below it dead code.The fix reorders checks so NEWLINE is evaluated before SUBMIT in multiline mode, and restricts the broad
key.name === 'return'fallback to single-line inputs only (where there is no newline concept).Screenshots / Video Demo
N/A — this is a keyboard input handling fix that's hard to capture in a screenshot. Reproduction: run
/agent create, select "Generate with Qwen Code", then press Shift+Enter in the description prompt. Before: submits. After: inserts a newline.Dive Deeper
The
TextInputcomponent is used across the CLI for various input prompts (auth dialogs, settings, permissions, agent wizard). The fix preserves existing behavior for single-line inputs (height=1) where any Return variant submits, while correctly handling multiline inputs (height > 1) where Shift+Enter/Ctrl+Enter should insert newlines.The backslash-escape workaround (
\+ Enter → newline) that was part of the old code has been removed since it was a workaround for the broken NEWLINE handling and is no longer needed.For reference, claw-code's
useTextInput.tshandles this by checkingkey.shift || key.metabefore falling through to submit — same logic, different implementation.Reviewer Test Plan
npm run dev/agent create→ select location → select "Generate with Qwen Code"/config seta non-sensitive setting, press Enter → should submitTesting Matrix
Linked issues / bugs
Fixes #3068