mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-02 07:11:49 +00:00
fix: preserve Ctrl+J newlines in Ghostty
This commit is contained in:
parent
1386a7e478
commit
cf8862cfa3
5 changed files with 82 additions and 8 deletions
|
|
@ -180,9 +180,9 @@ class TestPromptToolkitTerminalCompatibility:
|
|||
def test_lf_enter_binds_to_submit_handler_posix(self):
|
||||
"""Some thin PTYs deliver Enter as LF/c-j instead of CR/enter.
|
||||
|
||||
On a bare local POSIX TTY (no SSH/WSL/WT) we keep c-j → submit so
|
||||
On a bare local POSIX TTY (no SSH/WSL/WT/Ghostty) we keep c-j → submit so
|
||||
Enter works on thin PTYs (docker exec, certain ssh configurations).
|
||||
On Windows, WSL, SSH sessions, and Windows Terminal we leave c-j
|
||||
On Windows, WSL, SSH sessions, Windows Terminal, and Ghostty we leave c-j
|
||||
unbound here so it can be used as the Ctrl+Enter newline keystroke
|
||||
without conflicting with submit. See issue #22379.
|
||||
"""
|
||||
|
|
@ -217,6 +217,17 @@ class TestPromptToolkitTerminalCompatibility:
|
|||
assert bindings[("c-m",)] is submit_handler
|
||||
assert ("c-j",) not in bindings
|
||||
|
||||
# Ghostty through tmux: TERM_PROGRAM is tmux, but Ghostty exports a
|
||||
# stable env marker. Keep c-j free so Ctrl+J inserts a newline.
|
||||
with _patch.object(_sys, "platform", "linux"), \
|
||||
_patch.dict(_os.environ, {"TERM": "tmux-256color", "TERM_PROGRAM": "tmux", "GHOSTTY_RESOURCES_DIR": "/usr/share/ghostty"}, clear=True), \
|
||||
_patch("builtins.open", side_effect=OSError("no /proc")):
|
||||
kb = KeyBindings()
|
||||
_bind_prompt_submit_keys(kb, submit_handler)
|
||||
bindings = {tuple(key.value for key in binding.keys): binding.handler for binding in kb.bindings}
|
||||
assert bindings[("c-m",)] is submit_handler
|
||||
assert ("c-j",) not in bindings
|
||||
|
||||
# Windows: only enter submits; c-j is free for the newline binding
|
||||
# added separately in the prompt setup.
|
||||
with _patch.object(_sys, "platform", "win32"):
|
||||
|
|
|
|||
|
|
@ -51,8 +51,20 @@ def test_windows_terminal_session_preserves_newline():
|
|||
assert cli_mod._preserve_ctrl_enter_newline() is True
|
||||
|
||||
|
||||
def test_ghostty_tmux_session_preserves_ctrl_j_newline():
|
||||
"""Ghostty-inherited env survives tmux even when TERM_PROGRAM becomes tmux."""
|
||||
import cli as cli_mod
|
||||
with patch.object(sys, "platform", "linux"):
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{"TERM": "tmux-256color", "TERM_PROGRAM": "tmux", "GHOSTTY_RESOURCES_DIR": "/usr/share/ghostty"},
|
||||
clear=True,
|
||||
):
|
||||
assert cli_mod._preserve_ctrl_enter_newline() is True
|
||||
|
||||
|
||||
def test_pure_local_linux_does_not_preserve():
|
||||
"""A bare local Linux TTY (no SSH/WSL/WT) keeps c-j → submit so docker exec
|
||||
"""A bare local Linux TTY (no SSH/WSL/WT/Ghostty) keeps c-j → submit so docker exec
|
||||
style Enter-as-LF stays usable."""
|
||||
import cli as cli_mod
|
||||
# Stub out /proc reads — those are the WSL fallback signal.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue