Skip to content

🎨 Palette: Add TUI Keyboard Traps and Prompt Choices#187

Open
haseeb-heaven wants to merge 1 commit into
mainfrom
palette/tui-keyboard-traps-prompt-choices-13538077490241913394
Open

🎨 Palette: Add TUI Keyboard Traps and Prompt Choices#187
haseeb-heaven wants to merge 1 commit into
mainfrom
palette/tui-keyboard-traps-prompt-choices-13538077490241913394

Conversation

@haseeb-heaven

@haseeb-heaven haseeb-heaven commented Jul 4, 2026

Copy link
Copy Markdown
Owner

🎨 Palette: Add TUI Keyboard Traps and Prompt Choices

💡 What: Added explicit prompt choices when running in non-TTY mode, added a Ctrl-C to cancel indicator in TUI selector panel, and fixed a keyboard trap where Ctrl-C would be read natively without triggering KeyboardInterrupt in raw mode.
🎯 Why: To ensure users are not locked in raw terminal mode when standard abort keys are used, and to show explicit valid options for configuration inputs.
📸 Before/After: Visual hints added for cancelability.
♿ Accessibility: Preventing keyboard traps is a critical a11y consideration; ensuring users have a visible exit path and the TUI handles standard interrupt sequences.


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

Summary by CodeRabbit

  • Bug Fixes
    • Ctrl-C now cancels terminal selections consistently instead of being treated as typed input.
    • Updated the selector footer to clearly show “Ctrl-C to cancel,” reducing confusion in keyboard navigation.
    • Improved non-interactive prompts to include the available options directly in the prompt text, making selections clearer.

💡 What: Added explicit prompt choices when running in non-TTY mode, added a `Ctrl-C to cancel` indicator in TUI selector panel, and fixed a keyboard trap where `Ctrl-C` would be read natively without triggering `KeyboardInterrupt` in raw mode.
🎯 Why: To ensure users are not locked in raw terminal mode when standard abort keys are used, and to show explicit valid options for configuration inputs.
📸 Before/After: Visual hints added for cancelability.
♿ Accessibility: Preventing keyboard traps is a critical a11y consideration; ensuring users have a visible exit path and the TUI handles standard interrupt sequences.
@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 trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds explicit Ctrl-C (\x03) handling to TerminalUI._read_key on Windows and POSIX paths, raising KeyboardInterrupt instead of returning the character. Updates selector footer text and non-TTY prompt to show available options. Documents the issue in .jules/palette.md.

Changes

Ctrl-C Cancellation Handling

Layer / File(s) Summary
Key interception on Ctrl-C
libs/terminal_ui.py
_read_key now raises KeyboardInterrupt('Selection cancelled by user.') when Ctrl-C (\x03) is detected, on both Windows (msvcrt.getwch) and POSIX raw-mode read paths.
Prompt messaging updates
libs/terminal_ui.py
_render_selector's default footer now mentions "Ctrl-C to cancel", and _select_option's non-TTY prompt now includes a pipe-delimited list of options in the prompt text.
Documentation note
.jules/palette.md
New entry documents the terminal raw-mode Ctrl-C trap and the corresponding messaging guidance change.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Related issues: None specified.

Related PRs: None specified.

Suggested labels: bug, enhancement, documentation

Suggested reviewers: haseeb-heaven

🐰 A Ctrl-C tap, no longer trapped in text,
escape hatches open, the cursor unvexed.
Footers now whisper the key you should press,
options laid bare in the prompt's pipe-dressed dress.
A palette note carved for the next weary soul. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main changes: TUI keyboard cancellation handling and prompt choice improvements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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-keyboard-traps-prompt-choices-13538077490241913394

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.

@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

🤖 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`:
- Line 74: The footer in the terminal selection helper currently drops the
Ctrl-C cancel hint whenever `help_text` is provided. Update the footer
construction in `libs/terminal_ui.py` so the cancel hint is always appended, and
make sure the callers like `_select_boolean` and `select_model` still show their
custom help text plus the Ctrl-C guidance. Keep the change centered around the
footer logic used by the selection prompt functions.
🪄 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: 396e7d43-71a3-4353-a8fa-7bfd18240cbe

📥 Commits

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

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

Comment thread libs/terminal_ui.py
table.add_row(marker, label, style=style)

footer = help_text or 'Use Up/Down arrows and Enter to select.'
footer = help_text or 'Use Up/Down arrows and Enter to select. Ctrl-C to cancel.'

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Ctrl-C hint is lost whenever callers pass an explicit help_text.

The new "Ctrl-C to cancel" text is only used as a fallback when help_text is falsy. But _select_boolean (line 118) and select_model (line 129) always pass their own explicit help_text strings that don't mention Ctrl-C, so those screens — a large fraction of all prompts shown by interactive_settings/launch — never surface the cancellation hint this PR is meant to add. Only select_mode/select_language (which pass no help_text) benefit from the new default.

Consider always appending the Ctrl-C hint regardless of whether a custom help_text was supplied.

💡 Proposed fix
-        footer = help_text or 'Use Up/Down arrows and Enter to select. Ctrl-C to cancel.'
+        base_footer = help_text or 'Use Up/Down arrows and Enter to select.'
+        footer = f'{base_footer} Ctrl-C to cancel.' if 'Ctrl-C' not in base_footer else base_footer
📝 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. Ctrl-C to cancel.'
base_footer = help_text or 'Use Up/Down arrows and Enter to select.'
footer = f'{base_footer} Ctrl-C to cancel.' if 'Ctrl-C' not in base_footer else base_footer
🤖 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 74, The footer in the terminal selection helper
currently drops the Ctrl-C cancel hint whenever `help_text` is provided. Update
the footer construction in `libs/terminal_ui.py` so the cancel hint is always
appended, and make sure the callers like `_select_boolean` and `select_model`
still show their custom help text plus the Ctrl-C guidance. Keep the change
centered around the footer logic used by the selection prompt functions.

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