|
4 | 4 | import sys |
5 | 5 | import termios |
6 | 6 | import tty |
7 | | -import select |
8 | 7 | from datetime import datetime |
9 | 8 | from typing import Any |
10 | 9 |
|
@@ -346,7 +345,7 @@ def build_lines(): |
346 | 345 | else: |
347 | 346 | menu_lines.append(f" \033[90m {option}\033[0m") |
348 | 347 | # Hint line last |
349 | | - menu_lines.append("\033[90m[Enter] select • [↑↓] navigate • [Esc] back to new tab\033[0m") |
| 348 | + menu_lines.append("\033[90m[Enter] select • [↑↓] navigate • [B] back to new tab\033[0m") |
350 | 349 | return menu_lines |
351 | 350 |
|
352 | 351 | # Initial render |
@@ -374,7 +373,7 @@ def build_lines(): |
374 | 373 | self.input_mode = False |
375 | 374 | self._load_agent_runs() # Refresh the data |
376 | 375 | break |
377 | | - elif key == "\x1b": # Esc - back to new tab |
| 376 | + elif key == "B": # Back to new tab |
378 | 377 | self.current_tab = 1 # 'new' tab index |
379 | 378 | self.input_mode = True |
380 | 379 | break |
@@ -476,18 +475,13 @@ def _get_char(self): |
476 | 475 |
|
477 | 476 | # Handle escape sequences (arrow keys) |
478 | 477 | if ch == "\x1b": # ESC |
479 | | - # Peek for additional bytes to distinguish bare ESC vs sequences |
480 | | - ready, _, _ = select.select([sys.stdin], [], [], 0.03) |
481 | | - if not ready: |
482 | | - return "\x1b" # bare Esc |
| 478 | + # Read the rest of the escape sequence synchronously |
483 | 479 | ch2 = sys.stdin.read(1) |
484 | 480 | if ch2 == "[": |
485 | | - ready2, _, _ = select.select([sys.stdin], [], [], 0.03) |
486 | | - if not ready2: |
487 | | - return "\x1b[" |
488 | 481 | ch3 = sys.stdin.read(1) |
489 | 482 | return f"\x1b[{ch3}" |
490 | 483 | else: |
| 484 | + # Return combined sequence (e.g., Alt+<key>) |
491 | 485 | return ch + ch2 |
492 | 486 | return ch |
493 | 487 | finally: |
@@ -539,7 +533,7 @@ def _handle_keypress(self, key: str): |
539 | 533 |
|
540 | 534 | def _handle_input_mode_keypress(self, key: str): |
541 | 535 | """Handle keypresses when in text input mode.""" |
542 | | - if key == "\x1b": # Esc key - exit input mode |
| 536 | + if key == "B": # Back action in new tab |
543 | 537 | self.input_mode = False |
544 | 538 | elif key == "\r" or key == "\n": # Enter - create agent run |
545 | 539 | if self.prompt_input.strip(): # Only create if there's actual content |
@@ -703,9 +697,9 @@ def _clear_and_redraw(self): |
703 | 697 |
|
704 | 698 | # Show appropriate instructions based on context |
705 | 699 | if self.input_mode and self.current_tab == 1: # new tab input mode |
706 | | - print(f"\n{self._format_status_line('Type your prompt • [Enter] create • [Esc] cancel • [Tab] switch tabs • [Ctrl+C] quit')}") |
| 700 | + print(f"\n{self._format_status_line('Type your prompt • [Enter] create • [B] cancel • [Tab] switch tabs • [Ctrl+C] quit')}") |
707 | 701 | elif self.input_mode: # other input modes |
708 | | - print(f"\n{self._format_status_line('Type your prompt • [Enter] create • [Esc] cancel • [Ctrl+C] quit')}") |
| 702 | + print(f"\n{self._format_status_line('Type your prompt • [Enter] create • [B] cancel • [Ctrl+C] quit')}") |
709 | 703 | elif self.show_action_menu: |
710 | 704 | print(f"\n{self._format_status_line('[Enter] select • [↑↓] navigate • [C] close • [Q] quit')}") |
711 | 705 | elif self.current_tab == 0: # recents |
|
0 commit comments