Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-06-11 - TUI Keyboard Trap & Options Clarity

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 changelog date to match this PR timeline.

Line 1 uses 2024-06-11, but this PR was created on 2026-06-11; this will make the entry appear out of sequence in historical notes.

Suggested patch
-## 2024-06-11 - TUI Keyboard Trap & Options Clarity
+## 2026-06-11 - TUI Keyboard Trap & Options Clarity
📝 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-11 - TUI Keyboard Trap & Options Clarity
## 2026-06-11 - TUI Keyboard Trap & Options Clarity
🤖 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 changelog entry header in
.jules/palette.md by changing the date string "2024-06-11" to "2026-06-11" so
the entry matches this PR's creation date; edit the top header line that
currently reads "## 2024-06-11 - TUI Keyboard Trap & Options Clarity" to "##
2026-06-11 - TUI Keyboard Trap & Options Clarity".

**Learning:** TUI environments in raw mode can trap keyboard interrupts (Ctrl-C) if `\x03` is not explicitly handled, and default rich prompts mask available choices without strict matching.
**Action:** Explicitly map `\x03` to exit actions, add shortcut hints to footers, and format string prompts to display options clearly.
8 changes: 5 additions & 3 deletions libs/terminal_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _read_key(self):
return mapping.get(extended, extended)
if key == '\r':
return 'enter'
if key == '\x1b':
if key in ('\x1b', '\x03'):
return 'escape'
return key

Expand All @@ -43,6 +43,8 @@ def _read_key(self):
return mapping.get(next_chars, 'escape')
if key in ('\r', '\n'):
return 'enter'
if key == '\x03':
return 'escape'
return key
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
Expand All @@ -67,7 +69,7 @@ def _render_selector(self, title, options, selected_index, help_text, default):
style = 'bold green' if index == selected_index else ''
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.') + ' Esc/Ctrl-C to cancel.'
self.console.print(Panel.fit(footer, title='Interpreter TUI', border_style='green'))
self.console.print(f"[bold cyan]{title}[/bold cyan]")
self.console.print(table)
Expand All @@ -76,7 +78,7 @@ def _render_selector(self, title, options, selected_index, help_text, default):
def _select_option(self, title, options, default, help_text=None):
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()
if answer in options:
return answer
for option in options:
Expand Down
Loading