Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hermes_cli/curses_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def curses_checklist(

def _draw(stdscr):
curses.curs_set(0)
stdscr.keypad(True)
if curses.has_colors():
curses.start_color()
curses.use_default_colors()
Expand Down Expand Up @@ -195,6 +196,7 @@ def curses_radiolist(

def _draw(stdscr):
curses.curs_set(0)
stdscr.keypad(True)
if curses.has_colors():
curses.start_color()
curses.use_default_colors()
Expand Down Expand Up @@ -332,6 +334,7 @@ def curses_single_select(

def _draw(stdscr):
curses.curs_set(0)
stdscr.keypad(True)
if curses.has_colors():
curses.start_color()
curses.use_default_colors()
Expand Down
1 change: 1 addition & 0 deletions hermes_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ def _match(s, query):

def _curses_browse(stdscr):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

keypad(True) alone does not cover the raw CSI/SS3 input described in this PR: merged commit 3463c97a3 verified that terminals can still return 27, '[', 'B' with keypad enabled. The current session loop needs sequence decoding before its ESC-cancel branch.

curses.curs_set(0)
stdscr.keypad(True)
if curses.has_colors():
curses.start_color()
curses.use_default_colors()
Expand Down
20 changes: 20 additions & 0 deletions tests/hermes_cli/test_session_browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,26 @@ def run_inner(func):
with patch("curses.has_colors", return_value=False):
return _session_browse_picker(sessions)

def test_curses_enables_keypad_mode(self):
import curses
sessions = _make_sessions(3)

mock_stdscr = MagicMock()
mock_stdscr.getmaxyx.return_value = (30, 120)
mock_stdscr.getch.side_effect = [10]

with patch("curses.wrapper") as mock_wrapper:
def run_inner(func):
func(mock_stdscr)

mock_wrapper.side_effect = run_inner

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please test the reported behavior rather than only setup: feed raw ESC [ B followed by Enter and assert that the second session is selected. This would fail on current main's direct getch()/ESC-cancel path.

with patch("curses.curs_set"):
with patch("curses.has_colors", return_value=False):
result = _session_browse_picker(sessions)

assert result == sessions[0]["id"]
mock_stdscr.keypad.assert_called_once_with(True)

def test_enter_selects_first_session(self):
sessions = _make_sessions(3)
result = self._run_with_keys(sessions, [10]) # Enter key
Expand Down