Skip to content

fix(cli): preserve Ctrl+Enter newline over SSH/WSL, submit on pure POSIX#22495

Closed
liuhao1024 wants to merge 3 commits into
NousResearch:mainfrom
liuhao1024:fix/issue-22379-ctrl-enter-newline-ssh
Closed

fix(cli): preserve Ctrl+Enter newline over SSH/WSL, submit on pure POSIX#22495
liuhao1024 wants to merge 3 commits into
NousResearch:mainfrom
liuhao1024:fix/issue-22379-ctrl-enter-newline-ssh

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

Summary

Fix Ctrl+Enter inserting a newline instead of submitting on pure POSIX terminals, and conversely, submitting instead of inserting a newline on WSL/SSH/Windows Terminal.

Root Cause

The c-j key binding (which most terminals send for Ctrl+Enter) was unconditionally mapped to insert a newline. This breaks two scenarios:

  1. Pure POSIX thin PTYs: Some terminal multiplexers and minimal PTY implementations send LF (c-j) for the Enter key. With c-j bound to newline, these PTYs cannot submit input.
  2. WSL/SSH/Windows Terminal: Users expect Ctrl+Enter to insert a newline for multiline input. This works, but the binding was not context-aware.

Fix

  • Platform detection: Add _is_wsl() (checks /proc/version for microsoft) and _preserve_ctrl_enter_newline() predicates that detect WSL, SSH (SSH_CONNECTION/SSH_CLIENT/SSH_TTY), and Windows Terminal (WT_SESSION).
  • Conditional c-j binding: On WSL/SSH/Windows Terminal, c-j inserts a newline. On pure POSIX (local terminal), c-j submits (thin PTY fallback).
  • Enhanced terminal protocols: Create hermes_cli/pt_input_extras.py with CSI-u (Kitty) and modifyOtherKeys (xterm) sequence handlers, so Ctrl+Enter works even when terminals send escape sequences instead of raw LF.

Regression Coverage

9 new tests in tests/hermes_cli/test_prompt_submit_keys.py:

  • Platform detection: native win32, SSH env vars, WT_SESSION, pure POSIX
  • Key binding behavior: newline on SSH, submit on pure POSIX
  • Module import and binding registration for enhanced sequences

Testing

tests/hermes_cli/test_prompt_submit_keys.py: 9 passed
tests/cli/: 518 passed (zero regressions)

Fixes Ctrl+Enter newline submits prompt over SSH/WSL because c-j is bound as submit #22379

…INSTALL_TIMEOUT

Increase the default npm install timeout for WhatsApp bridge from 60s
to 300s (5 minutes) to accommodate slower systems like Unraid NAS.
Make it configurable via WHATSAPP_NPM_INSTALL_TIMEOUT environment variable
for users who need even longer timeouts.

Closes NousResearch#14980
- Add 'path', 'old_string', 'new_string', and 'patch' to required list
- Update description to clarify mode-specific parameter requirements
- This addresses issue where LLMs would omit these parameters because
  they were not marked as required in the schema, even though they
  are required depending on the mode

Fixes NousResearch#15524
On WSL, SSH, and Windows Terminal, Ctrl+Enter arrives as c-j (LF) and
should insert a newline for multiline input. On pure POSIX local
terminals, c-j is the literal Enter key for thin PTYs and must submit.

Changes:
- Add _is_wsl() and _preserve_ctrl_enter_newline() predicates to detect
  platform context (Windows, WSL, SSH, Windows Terminal)
- Make c-j binding conditional: newline on WSL/SSH/Windows, submit on
  pure POSIX (thin PTY fallback)
- Create hermes_cli/pt_input_extras.py with CSI-u and modifyOtherKeys
  sequence handlers for enhanced terminal protocols (Kitty, iTerm2,
  WezTerm, xterm)
- Add regression tests for platform detection and key binding behavior

Fixes Ctrl+Enter newline submits prompt over SSH/WSL because c-j is
bound as submit NousResearch#22379
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists labels May 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #22777 (merged 2026-05-09). The Ctrl+Enter/c-j WSL/SSH fix is already in main. This PR also bundles unrelated changes to whatsapp.py and file_tools.py.

@liuhao1024

Copy link
Copy Markdown
Contributor Author

Closing — @alt-glitch confirmed this is a duplicate of #22777 (merged 2026-05-09). The Ctrl+Enter/c-j WSL/SSH fix is already in main.

@liuhao1024 liuhao1024 closed this May 11, 2026
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 duplicate This issue or pull request already exists 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.

2 participants