Skip to content

Commit 014b60b

Browse files
authored
fix: use B for back instead of Esc character (#1211)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed
1 parent 90a79c4 commit 014b60b

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/codegen/cli/tui/app.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import sys
55
import termios
66
import tty
7-
import select
87
from datetime import datetime
98
from typing import Any
109

@@ -346,7 +345,7 @@ def build_lines():
346345
else:
347346
menu_lines.append(f" \033[90m {option}\033[0m")
348347
# 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")
350349
return menu_lines
351350

352351
# Initial render
@@ -374,7 +373,7 @@ def build_lines():
374373
self.input_mode = False
375374
self._load_agent_runs() # Refresh the data
376375
break
377-
elif key == "\x1b": # Esc - back to new tab
376+
elif key == "B": # Back to new tab
378377
self.current_tab = 1 # 'new' tab index
379378
self.input_mode = True
380379
break
@@ -476,18 +475,13 @@ def _get_char(self):
476475

477476
# Handle escape sequences (arrow keys)
478477
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
483479
ch2 = sys.stdin.read(1)
484480
if ch2 == "[":
485-
ready2, _, _ = select.select([sys.stdin], [], [], 0.03)
486-
if not ready2:
487-
return "\x1b["
488481
ch3 = sys.stdin.read(1)
489482
return f"\x1b[{ch3}"
490483
else:
484+
# Return combined sequence (e.g., Alt+<key>)
491485
return ch + ch2
492486
return ch
493487
finally:
@@ -539,7 +533,7 @@ def _handle_keypress(self, key: str):
539533

540534
def _handle_input_mode_keypress(self, key: str):
541535
"""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
543537
self.input_mode = False
544538
elif key == "\r" or key == "\n": # Enter - create agent run
545539
if self.prompt_input.strip(): # Only create if there's actual content
@@ -703,9 +697,9 @@ def _clear_and_redraw(self):
703697

704698
# Show appropriate instructions based on context
705699
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')}")
707701
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')}")
709703
elif self.show_action_menu:
710704
print(f"\n{self._format_status_line('[Enter] select • [↑↓] navigate • [C] close • [Q] quit')}")
711705
elif self.current_tab == 0: # recents

0 commit comments

Comments
 (0)