fix(cli): enable arrow-key navigation in sessions browser - #16370
fix(cli): enable arrow-key navigation in sessions browser#16370suryanshsrivastava wants to merge 1 commit into
Conversation
- enable curses keypad mode in session browser and shared pickers - add regression coverage for keypad initialization - preserves existing fallback behavior for non-curses terminals
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the session-browser failure mode. The issue remains on current main, but this patch needs a different fix path.
Problems
stdscr.keypad(True)athermes_cli/main.py:403does not handle the rawESC [ B/ESC O Bsequences described in the PR. Currenthermes_cli/main.py:1083-1104still reads a raw first byte and treats27as cancellation.- Merged commit
3463c97a3established that this raw-input behavior can occur even with keypad mode enabled, and addedread_menu_key()inhermes_cli/curses_ui.py:276-340to decode it. - The added test asserts keypad initialization only; it does not reproduce raw arrow input or verify session selection.
Suggested changes
- Route the session picker through the existing raw-sequence decoder before its ESC-cancel branch, preserving its type-to-filter behavior.
- Add a regression case for
ESC [ Bfollowed by Enter selecting the second session.
The shared-picker changes also need rework because current main consolidated those loops into _run_curses_menu() at hermes_cli/curses_ui.py:364-523.
Automated hermes-sweeper review.
| @@ -402,6 +402,7 @@ def _match(s, query): | |||
|
|
|||
| def _curses_browse(stdscr): | |||
There was a problem hiding this comment.
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.
| def run_inner(func): | ||
| func(mock_stdscr) | ||
|
|
||
| mock_wrapper.side_effect = run_inner |
There was a problem hiding this comment.
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.
Summary
curseskeypad mode in the interactive session browsertests/hermes_cli/test_session_browse.pyProblem
hermes sessions browsecould not be navigated with arrow keys in some terminals. Pressing an arrow key would immediately exit the picker and leave raw escape-sequence fragments in the shell, which users reported as strings like27D,26B, or similar junk.Root cause: the curses UI was reading from
stdscr.getch()without first enablingstdscr.keypad(True), so arrow keys were delivered as raw escape sequences instead ofcurses.KEY_UP/curses.KEY_DOWN.Exact reproduction steps
27D,26B,^[sequences, or similar random-looking strings may appearTest plan
source venv/bin/activate && pytest -o addopts='' tests/hermes_cli/test_session_browse.py -qNotes
This patch intentionally keeps the numbered fallback path unchanged for environments where curses is unavailable.