fix(tui): wrap composer to viewport with grapheme-aware cursor - #78
Merged
Merged
Conversation
Shift+Enter cannot be delivered by a terminal that has not negotiated the keyboard-enhancement protocol: the legacy encoding sends a bare CR, so the break was indistinguishable from send and unreachable in practice — the same constraint that rules out a Ctrl+M binding. Accept Alt+Enter (ESC CR, which does carry a modifier) and keep Shift+Enter for terminals that report it. Add frame-level tests that render the chat view into a test backend and pin the composer's growth cap, its scroll offset, and the cursor's terminal coordinates for wide graphemes; the previous byte-indexed math placed the cursor 200 columns off-screen for a long draft, which these now catch. Correct the input-box docs: the break is Alt+Enter, and a tall draft squeezes the transcript rather than keeping a message row visible.
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.
Why
Long drafts ran off the side of the chat composer, and its cursor used a UTF-8 byte offset as a terminal column. That put the cursor in the wrong place for Unicode text.
What changed
The composer now wraps to the terminal width, grows up to the available space, and scrolls to keep the cursor in view. Its layout counts grapheme display cells; editing also moves and deletes whole graphemes.
Alt+Enterinserts a line break without sending the draft (Shift+Enterstill works in terminals that report it). The TUI guide documents the behavior.Unit and rendered-frame tests cover wrapping, resizing, long drafts, Unicode cursor placement, and multiline editing. I also tested multiline input, terminal resizing, and Unicode interactively in the TUI.