Skip to content

fix(cli): preserve LF as newline in Warp terminal (Shift+Enter regression #22908)#23921

Open
MrFrogIsMe wants to merge 1 commit into
NousResearch:mainfrom
MrFrogIsMe:fix/shift-enter-warp-lf-newline
Open

fix(cli): preserve LF as newline in Warp terminal (Shift+Enter regression #22908)#23921
MrFrogIsMe wants to merge 1 commit into
NousResearch:mainfrom
MrFrogIsMe:fix/shift-enter-warp-lf-newline

Conversation

@MrFrogIsMe

Copy link
Copy Markdown

Problem

Warp terminal sends Shift+Enter as bare LF (c-j), exactly the same byte that Windows Terminal sends for Ctrl+Enter. On macOS, _preserve_ctrl_enter_newline() returns False, so _bind_prompt_submit_keys() binds c-j to submit — meaning Shift+Enter submits the message instead of inserting a newline.

This is a regression from commit 5044e1cbf (fix(cli): submit LF enter in thin PTYs), which was correct for docker-exec / thin PTY environments, but inadvertently broke Warp users.

Fixes #22908.

Root Cause

_preserve_ctrl_enter_newline()
  → False  (macOS, no SSH/WSL/WT_SESSION detected)

_bind_prompt_submit_keys(kb, handle_enter)
  → kb.add('enter')(handler)
  → kb.add('c-j')(handler)   ← LF now submits

Warp sets TERM_PROGRAM=WarpTerminal for every shell session. Checking this env var is the same pattern already used for WT_SESSION (Windows Terminal).

Fix

Add a Warp detection branch to _preserve_ctrl_enter_newline():

# Warp terminal sends Shift+Enter as bare LF (c-j), same as Ctrl+Enter on
# Windows Terminal. Preserve c-j as newline so Shift+Enter works.
if os.environ.get("TERM_PROGRAM") == "WarpTerminal":
    return True

When this returns True, _bind_prompt_submit_keys() skips the c-j → submit binding, and the separately registered @kb.add('c-j') newline handler fires for Shift+Enter instead.

Testing

  • Added test_warp_terminal_preserves_newline — asserts the fix triggers for TERM_PROGRAM=WarpTerminal
  • Added test_non_warp_macos_does_not_preserve — asserts other macOS terminals (Terminal.app, iTerm2) are unaffected
  • All 11 tests in tests/cli/test_ctrl_enter_newline.py pass

Affected Terminals

Terminal Before After
Warp (macOS) Shift+Enter submits ❌ Shift+Enter inserts newline ✅
Terminal.app / iTerm2 unchanged (Alt+Enter works) unchanged
Windows Terminal unchanged ✅ unchanged ✅
SSH / WSL unchanged ✅ unchanged ✅
docker exec / thin PTY unchanged ✅ unchanged ✅

…sion)

Warp sends Shift+Enter as bare LF (c-j), identical to Ctrl+Enter on
Windows Terminal. Without this fix, _preserve_ctrl_enter_newline()
returns False on macOS and _bind_prompt_submit_keys() binds c-j to
submit — making Shift+Enter submit the message instead of inserting
a newline.

Fix: detect TERM_PROGRAM=WarpTerminal (set by Warp for all sessions)
and treat it the same as WT_SESSION / SSH / WSL — preserve c-j as the
newline keybinding so Shift+Enter works as expected.

Fixes NousResearch#22908
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Shift+Enter no longer inserts a newline in classic Hermes CLI

2 participants