Skip to content

fix(tui): wrap composer to viewport with grapheme-aware cursor - #78

Merged
arcuru merged 2 commits into
arcuru:mainfrom
arcuru-bot:fix/tui-composer-wrap-reviewed
Sep 27, 2026
Merged

arcuru merged 2 commits into
arcuru:mainfrom
arcuru-bot:fix/tui-composer-wrap-reviewed

Conversation

@arcuru-bot

Copy link
Copy Markdown
Contributor

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+Enter inserts a line break without sending the draft (Shift+Enter still 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.

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.
@arcuru
arcuru merged commit 658ba4b into arcuru:main Sep 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants