Skip to content

🎨 Palette: Improve TUI accessibility and explicit keyboard hints#137

Open
haseeb-heaven wants to merge 1 commit into
mainfrom
palette/tui-accessibility-4943688031202912308
Open

🎨 Palette: Improve TUI accessibility and explicit keyboard hints#137
haseeb-heaven wants to merge 1 commit into
mainfrom
palette/tui-accessibility-4943688031202912308

Conversation

@haseeb-heaven

@haseeb-heaven haseeb-heaven commented Jun 16, 2026

Copy link
Copy Markdown
Owner

💡 What: Added inline choices for headless prompts, explicit shortcut hints in footers, and Ctrl-C handling in raw mode.
🎯 Why: Enhances terminal UX by preventing keyboard traps, improving clarity of available options, and making shortcuts explicit.
📸 Before/After: Before, no options were visible in headless prompts and Ctrl-C was ignored in raw mode. After, choices are inline and Ctrl-C properly exits.
♿ Accessibility: Ensures keyboard users are not trapped in menus and options are clearly discoverable without guesswork.


PR created automatically by Jules for task 4943688031202912308 started by @haseeb-heaven

Summary by CodeRabbit

  • Improvements

    • Terminal UI now displays explicit keyboard shortcut hints (Esc/Ctrl-C to cancel) in selector help text for better accessibility.
    • Option prompts now show available choices inline for clearer selection guidance.
    • Enhanced keyboard interrupt handling during interactive selection.
  • Bug Fixes

    • Ctrl-C now properly cancels interactive selections with clear user feedback.

💡 What: Added inline choices for headless prompts, explicit shortcut hints in footers, and Ctrl-C handling in raw mode.
🎯 Why: Enhances terminal UX by preventing keyboard traps, improving clarity of available options, and making shortcuts explicit.
📸 Before/After: Before, no options were visible in headless prompts and Ctrl-C was ignored in raw mode. After, choices are inline and Ctrl-C properly exits.
♿ Accessibility: Ensures keyboard users are not trapped in menus and options are clearly discoverable without guesswork.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

TerminalUI._read_key now raises KeyboardInterrupt when it reads \x03 (Ctrl-C) on non-Windows terminals. Footer and help strings in the selector, non-TTY option prompt, and boolean selector are updated to mention (Esc/Ctrl-C to cancel) and display allowed choices inline. A dev notes entry in .jules/palette.md records the rationale.

Changes

TUI Keyboard Accessibility

Layer / File(s) Summary
Ctrl-C interception and UX hint text
libs/terminal_ui.py
_read_key intercepts \x03 and raises KeyboardInterrupt('Selection cancelled by user.'). The selector default footer is extended with (Esc/Ctrl-C to cancel), the non-TTY _select_option prompt now includes [opt1|opt2|...] inline, and _select_boolean's non-TTY help text matches the new wording.
Dev palette entry
.jules/palette.md
Adds a dated entry describing the keyboard trap learnings and the three action items implemented in terminal_ui.py.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A key pressed in darkness, \x03 arrives,
The rabbit hops free — no trap deprives!
"Esc or Ctrl-C," the footer now sings,
Choices displayed inline — clarity rings.
No keyboard trap holds this bunny for long! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main changes: improving TUI accessibility with explicit keyboard hints (Ctrl-C/Esc) and inline option display.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch palette/tui-accessibility-4943688031202912308

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
libs/terminal_ui.py (1)

19-30: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add Ctrl-C handling in the Windows key-reader path for parity.

KeyboardInterrupt on \x03 was added only in the non-Windows branch, so cancellation behavior is inconsistent across platforms and the keyboard-trap fix is incomplete on Windows.

Suggested patch
         if os.name == 'nt':
             import msvcrt
             key = msvcrt.getwch()
+            if key == '\x03':
+                raise KeyboardInterrupt('Selection cancelled by user.')
             if key in ('\x00', '\xe0'):
                 extended = msvcrt.getwch()
                 mapping = {'H': 'up', 'P': 'down', 'K': 'left', 'M': 'right'}
                 return mapping.get(extended, extended)

Also applies to: 46-47

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/terminal_ui.py` around lines 19 - 30, The Windows key-reader path in the
if os.name == 'nt' block using msvcrt.getwch() does not handle Ctrl-C (the
'\x03' key) to raise KeyboardInterrupt, while the non-Windows branch apparently
has this handling. Add a check in the Windows branch after retrieving the key
from msvcrt.getwch() to detect when key equals '\x03' and raise
KeyboardInterrupt to ensure consistent cancellation behavior across both Windows
and non-Windows platforms.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libs/terminal_ui.py`:
- Around line 72-73: The current footer logic in the assignment on line 72 uses
the `or` operator which means if custom help_text is provided, the "(Esc/Ctrl-C
to cancel)" guidance is completely dropped. To ensure the cancel hint is always
present for accessibility, modify the footer assignment to always include the
cancel hint guidance by appending it to the help text (whether custom or
default) rather than choosing one or the other with the `or` operator. This
ensures the Panel.fit call on line 73 always displays the cancel guidance
regardless of whether custom help text is provided.

---

Outside diff comments:
In `@libs/terminal_ui.py`:
- Around line 19-30: The Windows key-reader path in the if os.name == 'nt' block
using msvcrt.getwch() does not handle Ctrl-C (the '\x03' key) to raise
KeyboardInterrupt, while the non-Windows branch apparently has this handling.
Add a check in the Windows branch after retrieving the key from msvcrt.getwch()
to detect when key equals '\x03' and raise KeyboardInterrupt to ensure
consistent cancellation behavior across both Windows and non-Windows platforms.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8fcc6c67-535c-4609-a822-0efdd99e3d25

📥 Commits

Reviewing files that changed from the base of the PR and between 2a47494 and be697b7.

📒 Files selected for processing (2)
  • .jules/palette.md
  • libs/terminal_ui.py

Comment thread libs/terminal_ui.py
Comment on lines +72 to 73
footer = help_text or 'Use Up/Down arrows and Enter to select. (Esc/Ctrl-C to cancel)'
self.console.print(Panel.fit(footer, title='Interpreter TUI', border_style='green'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Ensure cancel hint is always present even when custom help text is passed.

footer = help_text or ... means custom help strings can silently drop the new (Esc/Ctrl-C to cancel) guidance (e.g., model selector help text), which weakens the accessibility objective.

Suggested patch
-        footer = help_text or 'Use Up/Down arrows and Enter to select. (Esc/Ctrl-C to cancel)'
+        footer = help_text or 'Use Up/Down arrows and Enter to select.'
+        if '(Esc/Ctrl-C to cancel)' not in footer:
+            footer = f'{footer} (Esc/Ctrl-C to cancel)'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
footer = help_text or 'Use Up/Down arrows and Enter to select. (Esc/Ctrl-C to cancel)'
self.console.print(Panel.fit(footer, title='Interpreter TUI', border_style='green'))
footer = help_text or 'Use Up/Down arrows and Enter to select.'
if '(Esc/Ctrl-C to cancel)' not in footer:
footer = f'{footer} (Esc/Ctrl-C to cancel)'
self.console.print(Panel.fit(footer, title='Interpreter TUI', border_style='green'))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/terminal_ui.py` around lines 72 - 73, The current footer logic in the
assignment on line 72 uses the `or` operator which means if custom help_text is
provided, the "(Esc/Ctrl-C to cancel)" guidance is completely dropped. To ensure
the cancel hint is always present for accessibility, modify the footer
assignment to always include the cancel hint guidance by appending it to the
help text (whether custom or default) rather than choosing one or the other with
the `or` operator. This ensures the Panel.fit call on line 73 always displays
the cancel guidance regardless of whether custom help text is provided.

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