Skip to content

fix(term): emit distinct CSI-u sequence for Ctrl+Enter in terminal blocks#3408

Open
Jason-Shen2 wants to merge 2 commits into
wavetermdev:mainfrom
Jason-Shen2:fix/ctrl-enter-csi-u-sequence
Open

fix(term): emit distinct CSI-u sequence for Ctrl+Enter in terminal blocks#3408
Jason-Shen2 wants to merge 2 commits into
wavetermdev:mainfrom
Jason-Shen2:fix/ctrl-enter-csi-u-sequence

Conversation

@Jason-Shen2

Copy link
Copy Markdown

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:Enter branch in handleTerminalKeydown() that sends the standard CSI-u sequence \x1b[13;5u, following the same pattern as the existing Shift:Enter handling.

  • Enter → 0x0a (unchanged)
  • Shift+Enter → 0x0a when term:shiftenternewline is enabled (unchanged)
  • Ctrl+Enter\x1b[13;5u (new)
  • Alt+Enter\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

  • TypeScript compiles without new errors.
  • Enter and Shift+Enter behavior remains unchanged.

Fixes #3355

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
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 55c96bff-7fab-4993-8a4f-9f55f3418403

📥 Commits

Reviewing files that changed from the base of the PR and between d9b3c86 and d7dfec9.

📒 Files selected for processing (9)
  • cmd/generateschema/main-generateschema.go
  • frontend/app/view/term/term-model.ts
  • frontend/types/gotypes.d.ts
  • pkg/waveobj/metaconsts.go
  • pkg/waveobj/wtypemeta.go
  • pkg/wconfig/metaconsts.go
  • pkg/wconfig/settingsconfig.go
  • schema/settings.json
  • schema/widgets.json
✅ Files skipped from review due to trivial changes (2)
  • frontend/types/gotypes.d.ts
  • pkg/waveobj/metaconsts.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/app/view/term/term-model.ts

Walkthrough

The PR adds a term:ctrlenter boolean setting and threads it through generated schemas, config structs, metadata types, and TypeScript declarations. The terminal keydown handler now recognizes Ctrl+Enter, checks the override, and sends \x1b[13;5u to the terminal controller when enabled.

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)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding distinct Ctrl+Enter CSI-u handling in terminal blocks.
Description check ✅ Passed The description matches the implemented Ctrl+Enter terminal handling and the new optional toggle.
Linked Issues check ✅ Passed The PR emits �[13;5u for Ctrl+Enter and leaves Enter/Shift+Enter behavior unchanged, satisfying the linked issue.
Out of Scope Changes check ✅ Passed The schema, types, and config additions directly support the new Ctrl+Enter setting and are in scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.ts

File 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between c99022c and d9b3c86.

📒 Files selected for processing (1)
  • frontend/app/view/term/term-model.ts

Comment thread 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
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.

Feature request: emit a distinct CSI-u sequence for Ctrl+Enter in terminal blocks

1 participant