fix(ui): wrap agent note text by terminal cells - #567
Merged
Conversation
Contributor
|
PR author is not in the allowed authors list. |
Contributor
Author
|
Thanks for the quick merge! |
1 task
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.
Summary
Plain-text agent notes (inline cards, hover popovers, static pager
inline-note lines) wrap their text with
wrapText, which measures withString#lengthand splits withString#slice— UTF-16 code units. Therenderers then clamp each line by terminal cells (
fitText/padText),so for CJK text (1 code unit = 2 cells) the wrapped lines come out up to
2× the box width and the clamp truncates them, silently dropping text.
Code-unit splitting can also cut an emoji's surrogate pair in half
(renders as U+FFFD).
measureTextWidthand track the current line'scell width alongside the string, so line-fit checks compare cells to
cells
sliceTextByWidth, which walksgrapheme clusters — wide characters and emoji are never split
on one line for the renderer's
fitTextto clamp instead of droppingit, and decide "line is empty" by string length so zero-width
characters can't produce over-wide lines
degenerate width 1, surrogate-pair and ZWJ emoji
Closes #566
Repro
With a 40-cell box and a 62-char / 124-cell Japanese summary:
English output is unchanged — wrapping of ASCII input is byte-identical
before and after.
Testing
All run in a clean Linux container (oven/bun + git), matching CI's
ubuntu-latest environment:
bun run typecheckbun run lintbun run format:checkbun test src— 1,140 tests, 0 failbun run test:tty-smoke— 9 pass, identical to a baseline run withoutthis change (the harness needs util-linux
script, which macOS lacks)