-
Notifications
You must be signed in to change notification settings - Fork 62
fix: use B for back instead of Esc character
#1211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |||||||||||||||||||||
| import sys | ||||||||||||||||||||||
| import termios | ||||||||||||||||||||||
| import tty | ||||||||||||||||||||||
| import select | ||||||||||||||||||||||
| from datetime import datetime | ||||||||||||||||||||||
| from typing import Any | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic bug: Back action only recognizes uppercase 'B'
Suggested change
|
||||||||||||||||||||||
|
|
@@ -346,7 +345,7 @@ def build_lines(): | |||||||||||||||||||||
| else: | ||||||||||||||||||||||
| menu_lines.append(f" \033[90m {option}\033[0m") | ||||||||||||||||||||||
| # Hint line last | ||||||||||||||||||||||
| menu_lines.append("\033[90m[Enter] select • [↑↓] navigate • [Esc] back to new tab\033[0m") | ||||||||||||||||||||||
| menu_lines.append("\033[90m[Enter] select • [↑↓] navigate • [B] back to new tab\033[0m") | ||||||||||||||||||||||
| return menu_lines | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Initial render | ||||||||||||||||||||||
|
|
@@ -374,7 +373,7 @@ def build_lines(): | |||||||||||||||||||||
| self.input_mode = False | ||||||||||||||||||||||
| self._load_agent_runs() # Refresh the data | ||||||||||||||||||||||
| break | ||||||||||||||||||||||
| elif key == "\x1b": # Esc - back to new tab | ||||||||||||||||||||||
| elif key == "B": # Back to new tab | ||||||||||||||||||||||
| self.current_tab = 1 # 'new' tab index | ||||||||||||||||||||||
| self.input_mode = True | ||||||||||||||||||||||
| break | ||||||||||||||||||||||
|
|
@@ -476,18 +475,13 @@ def _get_char(self): | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Handle escape sequences (arrow keys) | ||||||||||||||||||||||
| if ch == "\x1b": # ESC | ||||||||||||||||||||||
| # Peek for additional bytes to distinguish bare ESC vs sequences | ||||||||||||||||||||||
| ready, _, _ = select.select([sys.stdin], [], [], 0.03) | ||||||||||||||||||||||
| if not ready: | ||||||||||||||||||||||
| return "\x1b" # bare Esc | ||||||||||||||||||||||
| # Read the rest of the escape sequence synchronously | ||||||||||||||||||||||
| ch2 = sys.stdin.read(1) | ||||||||||||||||||||||
| if ch2 == "[": | ||||||||||||||||||||||
| ready2, _, _ = select.select([sys.stdin], [], [], 0.03) | ||||||||||||||||||||||
| if not ready2: | ||||||||||||||||||||||
| return "\x1b[" | ||||||||||||||||||||||
| ch3 = sys.stdin.read(1) | ||||||||||||||||||||||
| return f"\x1b[{ch3}" | ||||||||||||||||||||||
| else: | ||||||||||||||||||||||
| # Return combined sequence (e.g., Alt+<key>) | ||||||||||||||||||||||
| return ch + ch2 | ||||||||||||||||||||||
| return ch | ||||||||||||||||||||||
| finally: | ||||||||||||||||||||||
|
|
@@ -539,7 +533,7 @@ def _handle_keypress(self, key: str): | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| def _handle_input_mode_keypress(self, key: str): | ||||||||||||||||||||||
| """Handle keypresses when in text input mode.""" | ||||||||||||||||||||||
| if key == "\x1b": # Esc key - exit input mode | ||||||||||||||||||||||
| if key == "B": # Back action in new tab | ||||||||||||||||||||||
| self.input_mode = False | ||||||||||||||||||||||
| elif key == "\r" or key == "\n": # Enter - create agent run | ||||||||||||||||||||||
| if self.prompt_input.strip(): # Only create if there's actual content | ||||||||||||||||||||||
|
|
@@ -703,9 +697,9 @@ def _clear_and_redraw(self): | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Show appropriate instructions based on context | ||||||||||||||||||||||
| if self.input_mode and self.current_tab == 1: # new tab input mode | ||||||||||||||||||||||
| print(f"\n{self._format_status_line('Type your prompt • [Enter] create • [Esc] cancel • [Tab] switch tabs • [Ctrl+C] quit')}") | ||||||||||||||||||||||
| print(f"\n{self._format_status_line('Type your prompt • [Enter] create • [B] cancel • [Tab] switch tabs • [Ctrl+C] quit')}") | ||||||||||||||||||||||
| elif self.input_mode: # other input modes | ||||||||||||||||||||||
| print(f"\n{self._format_status_line('Type your prompt • [Enter] create • [Esc] cancel • [Ctrl+C] quit')}") | ||||||||||||||||||||||
| print(f"\n{self._format_status_line('Type your prompt • [Enter] create • [B] cancel • [Ctrl+C] quit')}") | ||||||||||||||||||||||
| elif self.show_action_menu: | ||||||||||||||||||||||
| print(f"\n{self._format_status_line('[Enter] select • [↑↓] navigate • [C] close • [Q] quit')}") | ||||||||||||||||||||||
| elif self.current_tab == 0: # recents | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input handling regression: Removing
selectbreaks bare ESC handlingWithout
select, a lone ESC blocks onread(1). Keepselectto non-blockingly detect escape sequences.