fix(term): emit distinct CSI-u sequence for Ctrl+Enter in terminal blocks#3408
fix(term): emit distinct CSI-u sequence for Ctrl+Enter in terminal blocks#3408Jason-Shen2 wants to merge 2 commits into
Conversation
Send \x1b[13;5u (CSI u) when Ctrl+Enter is pressed in a terminal block, allowing terminal applications to distinguish Ctrl+Enter from plain Enter. Previously both keys produced the same 0x0a (newline) byte, making it impossible to bind Ctrl+Enter separately (e.g. for submit vs newline in multi-line prompts). Enter and Shift+Enter behavior is unchanged. Fixes wavetermdev#3355
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe PR adds a Estimated code review effort: 2 (Simple) | ~10 minutes Related PRs: None identified. Suggested labels: frontend, backend, schema Suggested reviewers: None identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.5.1)frontend/types/gotypes.d.tsFile contains syntax errors that prevent linting: Line 1881: Expected a property, or a signature but instead found '#'.; Line 1881: Expected an expression, or an assignment but instead found ':'.; Line 1881: Expected an expression but instead found ']'.; Line 2194: Expected a statement but instead found '}'. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/app/view/term/term-model.ts`:
- Around line 735-740: The Ctrl+Enter handling in term-model.ts currently sends
the escape sequence unconditionally, which can break normal terminal behavior.
Update the key handling branch in the term model’s input path to mirror the
existing Shift+Enter config gating by checking a new term:ctrlenter toggle
before calling sendDataToController with "\x1b[13;5u". Keep the existing
preventDefault/stopPropagation/return false behavior only when the toggle is
enabled and the Ctrl+Enter sequence is intentionally used.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 31044ca5-55ba-4457-8053-1207c11f8e21
📒 Files selected for processing (1)
frontend/app/view/term/term-model.ts
…g toggle Add term:ctrlenter configuration option (default: true) to control whether Ctrl+Enter sends the CSI-u escape sequence \x1b[13;5u, following the same pattern as term:shiftenternewline. This addresses CodeRabbit review feedback about backward compatibility by allowing users to disable the behavior if it causes issues with applications that don't understand CSI-u sequences. - Add ConfigKey_TermCtrlEnter and MetaKey_TermCtrlEnter constants - Add TermCtrlEnter field to SettingsConfig and Meta structs - Update schema files (settings.json, widgets.json) - Update TypeScript type definitions - Gate Ctrl+Enter handler behind config check in term-model.ts
Summary
This PR adds Ctrl+Enter key handling in terminal blocks to emit the CSI-u modified-key sequence
ESC [ 13 ; 5 u(\x1b[13;5u), allowing terminal applications to distinguish Ctrl+Enter from plain Enter.Problem
Previously, Ctrl+Enter in a terminal block produced the same byte (0x0a / newline) as plain Enter and Shift+Enter, making it impossible for terminal applications (like AI chat CLIs, multi-line editors, etc.) to bind Ctrl+Enter separately from Enter. Alt+Enter was already distinguishable via the ESC prefix, but Ctrl+Enter was collapsed.
Fix
Added a
Ctrl:Enterbranch inhandleTerminalKeydown()that sends the standard CSI-u sequence\x1b[13;5u, following the same pattern as the existingShift:Enterhandling.term:shiftenternewlineis enabled (unchanged)\x1b[13;5u(new)\x1b[0a(unchanged, ESC prefix)Terminal applications that understand CSI-u (such as Pi, as mentioned in the issue) can now bind Ctrl+Enter to submit/send while using Enter/Shift+Enter for newline insertion in multi-line prompts.
Testing
Fixes #3355