Skip to content

Fix Shift+Enter not inserting newline in CLI agents#5

Open
miroSalted wants to merge 1 commit intorustykuntz:mainfrom
miroSalted:fix/shift-enter-newline
Open

Fix Shift+Enter not inserting newline in CLI agents#5
miroSalted wants to merge 1 commit intorustykuntz:mainfrom
miroSalted:fix/shift-enter-newline

Conversation

@miroSalted
Copy link
Copy Markdown

Summary

  • xterm.js sends \r for both Enter and Shift+Enter, making them indistinguishable at the PTY level
  • CLI agents like Claude Code use Shift+Enter for multiline input (newline), but receive a plain Enter instead — causing immediate submission
  • This intercepts Shift+Enter in attachCustomKeyEventHandler and sends the CSI u escape sequence (\x1b[13;2u) via xterm's public input() API, so agents can recognize the modifier and insert a newline

Test plan

  • Open a Claude Code session in CliDeck
  • Press Shift+Enter — should insert a newline, not submit
  • Press Enter — should still submit as before
  • Verify other Shift+ hotkeys still work (e.g. Ctrl+Shift+K for clear)

🤖 Generated with Claude Code

xterm.js sends the same \r for both Enter and Shift+Enter, making it
impossible for CLI agents like Claude Code to distinguish between them.
This intercepts Shift+Enter and sends the CSI u escape sequence
(\x1b[13;2u) so agents can recognize it and insert a newline instead
of submitting input.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants