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 @@
## 2025-01-01 - Terminal UI Accessibility
**Learning:** When falling back to headless or text inputs from TUI, explicit prompt choices help users, and avoiding keyboard traps (by explicitly handling Ctrl-C /  in raw TTY mode) prevents user frustration.
**Action:** Explicitly bind interrupt bytes like  to exit actions in raw terminal interfaces and surface keyboard shortcuts clearly in instructions.
7 changes: 5 additions & 2 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 @@ -68,6 +70,7 @@ def _render_selector(self, title, options, selected_index, help_text, default):
table.add_row(marker, label, style=style)

footer = help_text or 'Use Up/Down arrows and Enter to select.'
footer += ' (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 +79,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