You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cli: export the terminal display-width measure #8863
#7572 fixed help alignment by measuring text in terminal cells instead of UTF-16 code units, which closed #7557. The measure itself stayed internal (visualLength in CliOutput.ts), so the second half of that issue is still open.
Anything a CLI draws next to the built-in output has to measure text by the same rules to line up with it: a custom CliOutput.Formatter, a boxed banner, a table, a prompt built on Prompt.Custom. Today the only options are copying the grapheme and East Asian Width logic into the application, or adding string-width. Either way the application's measure can disagree with the one the built-in help uses, so the two drift as either side changes.
What is the feature you are proposing to solve the problem?
Export the existing measure, for example as CliOutput.displayWidth:
It should strip ANSI styling as it does today, so styled and unstyled text measure the same. No new logic is needed, only the export and a doc comment.
What alternatives have you considered?
Reimplementing it per application: what we do today. It duplicates Unicode knowledge that already lives in Effect, and the two implementations can disagree.
string-width: an extra dependency that measures by its own tables, so it can still disagree with the built-in help.
A home in effect/String instead of effect/cli: also fine, since the measure is useful outside the CLI module.
I've been wanting to wait til v4 is release to see if porting boxes would make sense, but certainly a String.width functionality might benefit you here before then.
~ comment
Activity
lloydrichards commentedon Oct 7, 2026
Probably interesting for this issue, I've needed to solve this exact same issue for
effect-boxesand have a dependency-less implementation of this -> https://github.com/lloydrichards/effect-boxes/blob/main/packages/effect-boxes/src/internal/width.ts