Add toggle: Rich Input submit on Ctrl+Enter (vs Enter)
Description
Adds a user-facing toggle in Settings → Agents → Third Party Agents that switches the Rich Input editor's submit binding from Enter (default) to Ctrl+Enter. When the toggle is on, Enter inserts a newline and Ctrl+Enter submits — the IDE-style convention that makes multi-line prompt composition for CLI agents much less awkward.
Default is false (current behavior preserved). The setting syncs globally and persists across restarts through the standard AI-settings path.
Linked Issue
Closes #11588
- [x] The linked issue is labeled
ready-to-specorready-to-implement. (ready-to-implement) - [x] Where appropriate, screenshots or a short video of the implementation are included below.
Testing
Automated tests
Unit tests — app/src/terminal/input_tests.rs (new file, ~531 lines). Covers the 2×2 keystroke × setting-state matrix plus shell-mode and keymap-context regressions:
submit_on_ctrl_enter_setting_defaults_to_false_and_round_tripsenter_submits_when_submit_on_ctrl_enter_is_falsectrl_enter_emits_ctrl_enter_event_when_submit_on_ctrl_enter_is_falseenter_inserts_newline_when_submit_on_ctrl_enter_is_truectrl_enter_submits_when_submit_on_ctrl_enter_is_true(asserts buffer is cleared after submit)ctrl_enter_with_shell_mode_locked_prepends_prefix_and_exits_shell_mode_when_setting_true- Keymap-context tests covering the Ctrl+Enter suppression fix
Integration tests — crates/integration/src/test/rich_input_ctrl_enter.rs (new file, 4 tests). These drive real keystrokes through the editor event-dispatch pipeline rather than calling input_ctrl_enter directly, which is what the editor's InsertNewLineIfMultiLine-then-backspace sequence actually needs to be exercised against:
test_rich_input_enter_submits_when_ctrl_enter_setting_is_falsetest_rich_input_ctrl_enter_passthrough_when_ctrl_enter_setting_is_falsetest_rich_input_enter_inserts_newline_when_ctrl_enter_setting_is_truetest_rich_input_ctrl_enter_submits_when_ctrl_enter_setting_is_true
Caveat for reviewers: I developed this on Windows, and the integration-test harness panics with
not implemented: Need to add support for hermetic integration tests for the current platform(pre-existing#[cfg(not(unix))]guard atintegration.rs:103) — this affects everyui_teston Windows, not just the new ones. The new tests passcargo check,cargo clippy --all-targets --tests -- -D warnings,cargo nextest list, andcargo fmt --check, but they have not been executed end-to-end locally. They will run for the first time on CI's Linux/macOS runners. If they fail there, that's the test doing its job — happy to address whatever comes up.
Manual testing
- [x] I have manually tested my changes locally with
./script/run
Screenshots / Videos
https://github.com/user-attachments/assets/188ba876-14a6-41e1-9344-953fba01530f
Agent Mode
- [ ] Warp Agent Mode - This PR was created via Warp's AI Agent Mode
CHANGELOG-IMPROVEMENT: Added a setting to submit Rich Input on Ctrl+Enter, so Enter inserts a newline for easier multi-line prompt composition with CLI agents.
🤖 Generated by Claude Code on behalf of @cbeaulieu-gt
@cbeaulieu-gt
I'm starting a first review of this pull request.
You can view the conversation on Warp.
I completed the review and no human review was requested for this pull request.
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
/oz-review
@cbeaulieu-gt
I'm re-reviewing this pull request in response to a review request.
You can view the conversation on Warp.
I completed the review and no human review was requested for this pull request.
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
@oz-for-oss thanks — good catch, this was a real silent data-loss bug.
Fixed in 15b4fe35.
Root cause (matching your trace): the editor's default ctrl_enter action was EnterAction::InsertNewLineIfMultiLine, which calls editor_model.insert("\n", ...). insert replaces the current selection with the new content, so by the time the handler ran editor.backspace(ctx), the selected text was already gone — backspace only removed the \n, leaving the buffer minus the selection.
Fix: stopped using the backspace pattern entirely. Added EditorView::set_enter_settings and a new Input::update_cli_agent_enter_settings helper that's called reactively on (a) CLI-agent input session state changes and (b) the SubmitRichInputOnCtrlEnter settings event. The helper sets:
ctrl_enter→ alwaysEnterAction::Emitfor Rich Input — Ctrl+Enter never touches the buffer, so selections are preserved.enter→InsertNewLineIfMultiLinewhen the toggle is on (Enter inserts a newline),Emitotherwise (current Enter-submits behavior preserved).
The 15-line backspace block in app/src/terminal/input.rs collapsed to a single dispatch line: EditorEvent::CtrlEnter => self.input_ctrl_enter(ctx).
Regression coverage:
- New unit test
ctrl_enter_with_selection_preserves_selection_in_submit_when_setting_is_trueinapp/src/terminal/input_tests.rs— would have failed under the old implementation. - New integration test
test_rich_input_ctrl_enter_preserves_selectionincrates/integration/src/test/rich_input_ctrl_enter.rs— exercises the full editor event-dispatch path with a selection (selects all viactrl-a, then Ctrl+Enter, asserts the full buffer was submitted).
🤖 Generated by Claude Code on behalf of @cbeaulieu-gt
/oz-review
@cbeaulieu-gt
I'm re-reviewing this pull request in response to a review request.
You can view the conversation on Warp.
I completed the review and no human review was requested for this pull request.
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
@oz-for-oss good catch again — this was caused by my previous Ctrl+Enter fix and mirrors the same shape.
Fixed in c1cd11dd.
Root cause (matching your trace): the prior fix set enter_settings.enter = EnterAction::InsertNewLineIfMultiLine when the toggle was on, but the editor's enter() matches on that arm and calls newline_internal without emitting Event::Enter. So Input::input_enter — which contains the inline-menu acceptance branches (AIContextMenu, prompts, skills, slash commands) — never ran.
Fix (same principle as the Ctrl+Enter fix): stop having the editor consume Enter. enter_settings.enter is now always EnterAction::Emit for Rich Input, regardless of the toggle. The toggle-aware newline-insertion moves into Input::input_enter itself, placed after all four menu-acceptance early-returns so menus get first crack at Enter:
input_enter:
→ AIContextMenu open? accept item; return
→ prompts menu open? accept item; return
→ skill menu open? accept item; return
→ slash commands open? accept item; return
→ submit_on_ctrl_enter? insert "\n"; return
→ submit
Selection semantics are intentionally asymmetric:
- Ctrl+Enter preserves selections (it's a submit, not an edit) — the previous fix.
- Enter does not preserve selections, because the user explicitly asked for a newline edit and replacing the selection is the expected editor behavior. There's now a code comment in
input_enternoting this.
Regression coverage:
- Unit test
enter_accepts_inline_menu_item_when_submit_on_ctrl_enter_is_trueinapp/src/terminal/input_tests.rs— programmatically opens the slash commands menu, presses Enter, asserts the buffer does not contain a newline (proving the menu-acceptance branch was taken). Would have failed under the previous implementation. - Integration test
test_rich_input_enter_accepts_menu_item_when_toggle_is_trueincrates/integration/src/test/rich_input_ctrl_enter.rs— exercises the same flow end-to-end through the editor event-dispatch pipeline.
7/7 unit tests pass; full verification suite green.
🤖 Generated by Claude Code on behalf of @cbeaulieu-gt
/oz-review
@cbeaulieu-gt
I'm re-reviewing this pull request in response to a review request.
You can view the conversation on Warp.
I completed the review and no human review was requested for this pull request.
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
@oz-for-oss good catch — third in a row. This was a side effect of the helper introduced in the previous fix.
Fixed in 993327dd.
Root cause (matching your trace): the editor view is shared between Rich Input (CLI agent) mode and normal terminal mode. The update_cli_agent_enter_settings helper was applying {enter: Emit, ctrl_enter: Emit} unconditionally — fine on Rich Input open, but on close it left the now-normal terminal editor with ctrl_enter: Emit instead of its InsertNewLineIfMultiLine default. So Ctrl+Enter in the normal input no longer inserted a newline after any Rich Input session.
Fix: branch the helper on CLIAgentSessionsModel::is_input_open(self.terminal_view_id):
if Rich Input is open → enter_settings = { enter: Emit, ctrl_enter: Emit, .. }
if Rich Input is closed → enter_settings = EnterSettings::default()
EnterSettings::default() is the existing impl at app/src/editor/view/mod.rs:1286-1294 — restoring it means Ctrl+Enter in the normal input is back to InsertNewLineIfMultiLine.
Regression coverage (unit): ctrl_enter_inserts_newline_in_normal_input_after_rich_input_closes opens Rich Input, closes it via CLIAgentSessionsModel::close_input (the same path production uses), then reads editor.enter_settings().ctrl_enter and asserts it equals InsertNewLineIfMultiLine. Would have failed under the previous implementation.
I added a small pub fn enter_settings(&self) -> EnterSettings getter on EditorView for the test to inspect the field without simulating a full keystroke dispatch — minimal addition, mirror of the existing setter.
Integration coverage was omitted for this specific case because closing Rich Input cleanly from the integration harness isn't an existing exposed transition; the unit test is the load-bearing regression here.
11/11 unit tests pass; full verification suite green.
🤖 Generated by Claude Code on behalf of @cbeaulieu-gt
/oz-review
@advait-m
I'm re-reviewing this pull request in response to a review request.
You can view the conversation on Warp.
I completed the review and no human review was requested for this pull request.
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
@advait-m Hey, just seeing if there was anything else needed from me before this could move to the next stage?
@advait-m Hey, just seeing if there was anything else needed from me before this could move to the next stage?
ah sorry, wasn't getting pings since I wasn't assigned as a reviewer. Added this to my todo list, should get to it later today/tomorrow to take a look!
(I tested the core behavior with the setting, looking good there!)
@advait-m I updated the change to have the following behaviour:
Toggle Off Ctrl/Shift + Enter = Newline Enter = Submit
Toggle On Shift + Enter = Newline Enter = Newline Ctrl + Enter = Submit
Also trimmed the comments and tests to a more concise set. Let me know if you more trimming or any other changes.
Saw a formatting failure from CI - pushed up a commit to fix
Looking otherwise
and a slight test trimming fix, it should pass CI now