🎨 Palette: Improve TUI accessibility and explicit keyboard hints#137
🎨 Palette: Improve TUI accessibility and explicit keyboard hints#137haseeb-heaven wants to merge 1 commit into
Conversation
💡 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.
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthrough
ChangesTUI Keyboard Accessibility
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winAdd Ctrl-C handling in the Windows key-reader path for parity.
KeyboardInterrupton\x03was 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
📒 Files selected for processing (2)
.jules/palette.mdlibs/terminal_ui.py
| 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')) |
There was a problem hiding this comment.
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.
| 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.
💡 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
Bug Fixes