Skip to content

feat: TUI arrow-key cursor navigation and Enter selection in menus#2105

Open
Andersson007 wants to merge 11 commits intoansible:mainfrom
Andersson007:add_arrows1
Open

feat: TUI arrow-key cursor navigation and Enter selection in menus#2105
Andersson007 wants to merge 11 commits intoansible:mainfrom
Andersson007:add_arrows1

Conversation

@Andersson007
Copy link
Copy Markdown
Contributor

Fixes #1564
feat: TUI arrow-key cursor navigation and Enter selection in menus

It's a copy of #2103 that got impossible to re-open after closing to trigger CI

TUI: Enable arrow-key cursor navigation and Enter selection in menus: Assisted by AI

  • I tested it manually and the arrow-keys navigation works seemingly perfectly
  • It doesn't introduce new dependencies
  • The old way of entering line numbers also works

@Andersson007 Andersson007 requested a review from a team as a code owner March 20, 2026 09:40
@github-actions github-actions Bot added the feat label Mar 20, 2026
@Andersson007 Andersson007 marked this pull request as draft March 20, 2026 09:50
@Andersson007 Andersson007 marked this pull request as ready for review March 20, 2026 09:55
@Andersson007
Copy link
Copy Markdown
Contributor Author

ready for review

ssbarnea
ssbarnea previously approved these changes Apr 1, 2026
@ssbarnea
Copy link
Copy Markdown
Member

ssbarnea commented Apr 1, 2026

@Andersson007 I am afraid I cannot merge this due to lack of signature.

@ssbarnea ssbarnea marked this pull request as draft April 1, 2026 13:33
@ssbarnea
Copy link
Copy Markdown
Member

ssbarnea commented Apr 1, 2026

Also add some # pragma: no cover lines to make the coverage requirement pass.

Andersson007 and others added 6 commits April 9, 2026 11:00
tmux's send_keys("Enter") sends two Enter key presses (the key name
and the enter=True suffix). The first is consumed by the warning form;
the second was being picked up by _show_menu and accidentally selecting
item 0.

Fix: _menu_cursor_pos now starts as None (inactive). The cursor only
activates after the user explicitly presses UP or DOWN, so stray Enter
presses are ignored.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
When cursor is None (not yet activated by arrow keys), any Enter press
must be silently ignored rather than falling through to
_template_match_action, which would show a spurious 'Could not find a
match for :CURSOR_ENTER' warning dialog and cause integration tests to
hang waiting for dismissal.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- _show_menu(): change `if` to `elif` so the first KEY_DOWN activates
  the cursor at item 0 without also incrementing it to item 1
- _display(): gate KEY_DOWN/KEY_UP scroll on `not indent_heading` so
  menu mode (_show_menu) owns scrolling exclusively, preventing the
  viewport from advancing twice per keypress
- Update test to assert cursor lands at 0 (not 1) on first DOWN press

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
_show_menu() now resets _menu_cursor_pos to None on entry so the
cursor does not carry over from a previously visited screen.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous reset (unconditional at _show_menu() entry) wiped the
cursor on every KEY_F(5) refresh timeout because the refresh action
causes _show_menu() to return and be immediately re-called.

Track _menu_current_id = id(current): reset _menu_cursor_pos only
when the menu data object changes (new screen), preserving it across
refresh cycles on the same screen.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exclude curses-dependent code paths from coverage measurement
so the CodeCov patch-coverage check passes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover the __init__ instance-variable lines and the highlight-offset
if-block that Codecov still flagged as uncovered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Place pragma on _display, _show_obj_from_list, and _show_menu
method definitions so the entire body is excluded from coverage.
Remove redundant per-line pragmas inside those methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Andersson007
Copy link
Copy Markdown
Contributor Author

Andersson007 commented Apr 9, 2026

@ssbarnea hi, thanks for reviewing!

  • Signed, is it OK now?
  • Claude suggested adding those pragma comments like in the last commit. If it doesn't make sense I could try to add them manually to the affected lines. Please let me know UPDATE: Added to individual lines

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Andersson007 Andersson007 marked this pull request as ready for review April 10, 2026 07:44
@Andersson007
Copy link
Copy Markdown
Contributor Author

@ssbarnea ready for review , I don't think the CI failures are related
please take a look

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

Labels

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

TUI mode to use arrows for moving cursor to choose tasks

2 participants