Skip to content

🎨 Palette: [UX improvement] Improve TUI interactive hints and controls#98

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

🎨 Palette: [UX improvement] Improve TUI interactive hints and controls#98
haseeb-heaven wants to merge 1 commit into
mainfrom
palette/tui-accessibility-hints-9262072439929030398

Conversation

@haseeb-heaven

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

Copy link
Copy Markdown
Owner

💡 What

  • Added Esc/Ctrl-C to cancel hints to the TUI interaction footer.
  • Surfaced explicitly available options when displaying plain-text prompts (by formatting [options]).
  • Caught the standard Ctrl-C byte (\x03) in raw keyboard input loops, raising a clean KeyboardInterrupt.

🎯 Why

  • Explicit shortcuts drastically improve discoverability for users who may not inherently know the exit commands for a TUI.
  • Preventing keyboard traps in raw-mode (where users press Ctrl-C and nothing happens) is a critical standard of CLI user experience.
  • When rich prompts fallback to text, hiding valid input options leads to frustrating trial-and-error. Explicitly rendering [opt1|opt2] solves this.

📸 Before/After

  • Before: Prompt asked "Mode" and users had to guess valid options if not displayed as a table.
  • After: Prompt asks "Mode [code|chat|script|command|vision]"
  • Before: No visual indication of how to cancel out of a selection loop.
  • After: (Esc/Ctrl-C to cancel) permanently rendered in the prompt panel.

♿ Accessibility

  • Prevents keyboard trapping by fully honoring system interrupt bytes.
  • Better cognitive accessibility by providing immediate shortcuts and visual hints, removing the need for user memorization.

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

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced terminal UI keyboard handling to support both Esc and Ctrl-C for cancellation, preventing keyboard traps
    • Updated selector prompts to explicitly display available choices and cancellation shortcuts for improved discoverability
  • Documentation
    • Added terminal UI raw-mode keyboard handling documentation

This commit improves discoverability and keyboard accessibility for the Terminal UI.
1. Adds explicit `Esc/Ctrl-C` shortcut hints in the TUI selector footer.
2. Formats options inside standard text prompts (`Prompt.ask`) to explicitly show available inputs.
3. Catch standard terminal interrupt byte (`\x03`) to ensure clean exits when in raw termios mode.
@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.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR improves terminal UI keyboard handling in the selector by accepting both Escape and Ctrl-C for cancellation, updates the help text and prompt to make shortcuts discoverable, and documents the keyboard trap prevention approach.

Changes

Terminal UI Keyboard Handling and Accessibility

Layer / File(s) Summary
Keyboard cancellation handling
libs/terminal_ui.py
The selector event loop now accepts both escape and Ctrl-C (\x03) to trigger cancellation via KeyboardInterrupt, broadening the user's exit options.
UI feedback improvements
libs/terminal_ui.py
Footer help text now explicitly states "Esc/Ctrl-C to cancel", and the option prompt message includes the list of available choices to improve discoverability.
Accessibility documentation
.jules/palette.md
New dated entry documents preventing TUI keyboard traps by mapping standard interrupt bytes and explicitly surfacing shortcut hints to users.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through keys so fine,
Both Escape and Ctrl-C align,
The prompt now shows each hidden choice,
With helpful hints to find its voice—
Raw mode traps? They flee in fright! 🐰✨

🚥 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 references UX improvements and TUI controls, which aligns with the actual changes (keyboard handling, cancellation hints, option visibility).
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-hints-9262072439929030398

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.

@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 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: 2

🤖 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 @.jules/palette.md:
- Line 1: Update the markdown header date from "## 2024-06-02 - TUI Keyboard
Traps and Discoverability" to "## 2026-06-02 - TUI Keyboard Traps and
Discoverability" in the .jules/palette.md file so the entry reflects the PR
creation date; locate the header line containing "TUI Keyboard Traps and
Discoverability" and correct the year only.

In `@libs/terminal_ui.py`:
- Line 80: The prompt construction in Prompt.ask currently uses an escaped
bracket ("\\[") which renders a literal backslash; update the Prompt.ask call
(where answer is assigned) to build the prompt string with a normal opening
bracket "[" (e.g., f"{title} [{'|'.join(options)}]") so the displayed prompt
shows "Mode [code|chat|script]" instead of "Mode \[code|chat|script]"; keep
default=default_choice and .strip() as-is.
🪄 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: 5713ecf0-cfcc-4e34-8495-8e20e4e986c1

📥 Commits

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

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

Comment thread .jules/palette.md
@@ -0,0 +1,3 @@
## 2024-06-02 - TUI Keyboard Traps and Discoverability

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

Correct the year in the date header.

The entry is dated 2024-06-02, but the PR was created on 2026-06-02. This appears to be a typo.

📅 Proposed fix
-## 2024-06-02 - TUI Keyboard Traps and Discoverability
+## 2026-06-02 - TUI Keyboard Traps and Discoverability
📝 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
## 2024-06-02 - TUI Keyboard Traps and Discoverability
## 2026-06-02 - TUI Keyboard Traps and Discoverability
🤖 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 @.jules/palette.md at line 1, Update the markdown header date from "##
2024-06-02 - TUI Keyboard Traps and Discoverability" to "## 2026-06-02 - TUI
Keyboard Traps and Discoverability" in the .jules/palette.md file so the entry
reflects the PR creation date; locate the header line containing "TUI Keyboard
Traps and Discoverability" and correct the year only.

Comment thread libs/terminal_ui.py
if not sys.stdin.isatty():
default_choice = default if default in options else options[0]
answer = Prompt.ask(f"{title}", default=default_choice).strip()
answer = Prompt.ask(f"{title} \\[{'|'.join(options)}]", default=default_choice).strip()

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

Fix the escaped bracket in the prompt format.

The \\[ will display as a literal backslash followed by a bracket (\[) instead of just a bracket ([). This results in incorrect prompt text like Mode \[code|chat|script] instead of Mode [code|chat|script].

🐛 Proposed fix
-            answer = Prompt.ask(f"{title} \\[{'|'.join(options)}]", default=default_choice).strip()
+            answer = Prompt.ask(f"{title} [{'|'.join(options)}]", default=default_choice).strip()
📝 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
answer = Prompt.ask(f"{title} \\[{'|'.join(options)}]", default=default_choice).strip()
answer = Prompt.ask(f"{title} [{'|'.join(options)}]", default=default_choice).strip()
🤖 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` at line 80, The prompt construction in Prompt.ask
currently uses an escaped bracket ("\\[") which renders a literal backslash;
update the Prompt.ask call (where answer is assigned) to build the prompt string
with a normal opening bracket "[" (e.g., f"{title} [{'|'.join(options)}]") so
the displayed prompt shows "Mode [code|chat|script]" instead of "Mode
\[code|chat|script]"; keep default=default_choice and .strip() as-is.

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