Skip to content

Menu navigation UX#19

Merged
finityfly merged 1 commit intomainfrom
feat-menu-nav
Jul 30, 2025
Merged

Menu navigation UX#19
finityfly merged 1 commit intomainfrom
feat-menu-nav

Conversation

@finityfly
Copy link
Owner

@finityfly finityfly commented Jul 30, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced menu navigation with support for arrow keys and selection using the Enter key, in addition to hotkey selection.
    • Menu now visually highlights the currently selected option and updates instructions to reflect new controls.
  • Style

    • Updated instruction text in both menu and settings screens for improved clarity and consistency, using bracketed arrow symbols and clearer key names.
  • Refactor

    • Streamlined input handling and menu rendering for a more interactive and user-friendly experience.
    • Simplified quit logic in settings by removing redundant code.

@coderabbitai
Copy link

coderabbitai bot commented Jul 30, 2025

Walkthrough

The menu interface was updated to support keyboard navigation using arrow keys and Enter for selection, with visual highlighting of the current selection and updated instructions. In the settings UI, the quit-checking lambda was removed in favor of direct key comparisons, and instruction text was modernized.

Changes

Cohort / File(s) Change Summary
Menu Navigation Enhancements
src/Menu.cpp
Refactored menu rendering into a lambda; added arrow key and Enter key navigation; introduced visual highlighting of the selected option; updated instruction text; replaced hotkey-only selection with interactive navigation and selection.
Settings Quit Logic & Instructions
src/Settings.cpp
Removed the quit-checking lambda; replaced with direct key comparisons for quitting; updated instruction text to use bracketed key names and removed ESC from quit instructions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • FinityFly/clitris#9: Also modifies menu display logic, focusing on multi-state menus and hotkey selection.
  • FinityFly/clitris#7: Refactors menu input handling and rendering, related to input processing changes in the menu.

Poem

A menu now dances with arrow key flair,
Settings quit swiftly, with logic laid bare.
Bold highlights guide you, instructions anew,
Enter selects what you wish to pursue.
With every small hop, the code grows more bright—
A rabbit’s delight in each menu rewrite!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-menu-nav

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@finityfly finityfly merged commit ccc6ee8 into main Jul 30, 2025
1 check was pending
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ccef65 and 32f5b79.

📒 Files selected for processing (2)
  • src/Menu.cpp (3 hunks)
  • src/Settings.cpp (3 hunks)
🔇 Additional comments (9)
src/Settings.cpp (2)

164-165: LGTM! Improved instruction clarity.

The updated instruction text with bracketed arrow symbols ([↑/↓], [←/→], [ENTER], [Q]) provides clearer visual guidance for users compared to the previous format.


353-353: LGTM! Consistent quit key handling.

The direct comparison implementation matches the insert mode handling on line 281, maintaining consistency in the quit key logic.

src/Menu.cpp (7)

112-112: LGTM! Proper initialization.

The selected_option variable is correctly initialized to 0, ensuring the first menu item is highlighted by default.


127-169: Well-structured menu rendering with highlighting.

The drawMenu lambda provides clean separation of rendering logic and properly applies bold formatting to the selected option. The instruction text is consistent with Settings.cpp using bracketed notation.


179-186: LGTM! Robust navigation logic.

The arrow key navigation correctly handles wraparound using modulo arithmetic, ensuring smooth cycling through menu options in both directions.


191-197: LGTM! Preserved hotkey functionality.

The hotkey selection logic is maintained alongside the new navigation, providing both interaction methods for user convenience.


200-204: Clean selection completion and resource cleanup.

The selection completion logic properly cleans up windows and returns, ensuring no memory leaks from the ncurses windows.


218-218: LGTM! Error recovery with menu redraw.

After displaying an error message, the menu is properly redrawn to restore the clean interface state.


188-189: Enter Key Selection Logic Verified

The handling of '\n'/KEY_ENTER is consistent with the per-keyhot logic:

  • options[selected_option].first == "q" correctly returns -1 for the quit option.
  • Numeric options map to selected_option + 1, matching the character-based branches.
  • Downstream consumers in main.cpp handle -1 to return to the previous menu.

No changes are needed.

int ch = getch();
if (insertMode) {
if (check_quit(ch)) {
if (ch == 113 || ch == 27) {
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify character code consistency.

The direct comparison ch == 113 || ch == 27 replaces the lambda function. Ensure these character codes are consistent throughout the codebase.


🏁 Script executed:

#!/bin/bash
# Description: Verify that character codes 113 (q) and 27 (ESC) are used consistently across the codebase

echo "Searching for quit key handling patterns..."
rg -A 2 -B 2 "113|27" --type cpp

echo -e "\nSearching for 'q' key handling..."
rg -A 2 -B 2 "'q'|\"q\"" --type cpp

echo -e "\nSearching for ESC key handling..."
rg -A 2 -B 2 "ESC|escape" --type cpp

Length of output: 6287


Unify quit and ESC key comparisons

The literal checks in Settings.cpp (113/27) don’t match the character‐literal style used elsewhere ('q', "q", 'Q' and 27). To improve readability and maintain consistency, replace magic numbers with character literals or shared constants.

Files to update:

  • src/Settings.cpp
    • Mapping entry: {"QUIT", {113, 27}}
    • Runtime check: if (ch == 113 || ch == 27)
  • src/UI.cpp (for ESC)
    • Consider using the same KEY_ESC constant instead of raw 27

Proposed diff in Settings.cpp:

--- a/src/Settings.cpp
+++ b/src/Settings.cpp
@@ –45,7 +45,7 @@
     {"PAUSE",   {112}},              // p key
-    {"QUIT",    {113, 27}},          // q key, esc
+    {"QUIT",    {'q', KEY_ESC}},     // 'q' key, ESC
     {"RESTART", {114, 92}}           // r key, '\'
 };
@@ -281,7 +281,7 @@
-            if (ch == 113 || ch == 27) {
+            if (ch == 'q' || ch == KEY_ESC) {
                 insertMode = false;
                 insertBuffer.clear();

Suggestion: Define in a common header:

constexpr int KEY_ESC = 27;

and replace all raw 27 checks with KEY_ESC for consistency.

🤖 Prompt for AI Agents
In src/Settings.cpp at line 281 and related mapping entries, replace the raw
numeric literals 113 and 27 with character literals 'q' and a defined constant
KEY_ESC respectively to unify quit and ESC key comparisons. Define constexpr int
KEY_ESC = 27 in a common header file and update all occurrences of 27 in both
src/Settings.cpp and src/UI.cpp to use KEY_ESC for consistency and improved
readability.

@finityfly finityfly deleted the feat-menu-nav branch July 31, 2025 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant