fix(tui): preserve typed character when auto-focusing input#698
Open
cbagwell wants to merge 2 commits intoOpenHands:mainfrom
Open
fix(tui): preserve typed character when auto-focusing input#698cbagwell wants to merge 2 commits intoOpenHands:mainfrom
cbagwell wants to merge 2 commits intoOpenHands:mainfrom
Conversation
When user types a printable character while focus is elsewhere than prompt input box, the auto-focus logic now captures and inserts the character into the prompt input field, instead of losing it.
Collaborator
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 Acceptable - Solves a real UX problem with simple logic, but missing tests and evidence.
This fix correctly preserves typed characters during auto-focus. However, it needs test coverage to prevent future regressions.
| # Store the character before changing focus so it can be inserted | ||
| char = event.character | ||
| self.input_field.focus_input() | ||
| if char: |
Collaborator
There was a problem hiding this comment.
🟡 Suggestion: The if char: check is redundant. Since event.is_printable is already True (line 560), event.character is guaranteed to have a value.
Suggested change
| if char: | |
| self.input_field.active_input_widget.insert(char) |
Contributor
Author
There was a problem hiding this comment.
The if char: guard was added because of pyright and is required for type safety since event.character can technically be None per the Textual type stubs, even when event.is_printable is True.
Co-authored-by: openhands <openhands@all-hands.dev>
25962b5 to
20e65eb
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When user types a printable character while focus is elsewhere than prompt input box, the auto-focus logic now captures and inserts the character into the prompt input field, instead of losing it.