feat(tui): add width_method config option for ZWJ emoji handling#25942
Open
Flare576 wants to merge 1 commit intoanomalyco:devfrom
Open
feat(tui): add width_method config option for ZWJ emoji handling#25942Flare576 wants to merge 1 commit intoanomalyco:devfrom
Flare576 wants to merge 1 commit intoanomalyco:devfrom
Conversation
Some terminals (tmux, older terminals) do not render ZWJ emoji sequences
as joined glyphs, causing layout corruption when the width measurement
assumes joining. OpenTUI's Zig layer has a 'no_zwj' mode that handles
this correctly, but it was previously unreachable from the JavaScript API.
This depends on anomalyco/opentui#<PR> which exposes 'no_zwj' in the
WidthMethod type and wires it through the FFI boundary.
Add a 'width_method' option to the TUI config schema that passes through
to OpenTUI's render() call. Users experiencing layout corruption from ZWJ
emoji can opt in via their opencode.json:
{ "tui": { "width_method": "no_zwj" } }
No default is changed — existing behavior is fully preserved.
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.
Issue for this PR
Closes #6210
Type of change
What does this PR do?
ZWJ emoji sequences (👩🚀 👨👩👧 🏳️🌈) corrupt terminal layout when the terminal doesn't render them as joined glyphs. tmux is the big one — text after a ZWJ sequence shifts across the screen, wraps wrong, and input box spacing breaks.
OpenTUI's Zig layer already has a
no_zwjwidth mode that handles this correctly. It was already implemented, already tested. It just wasn't reachable from TypeScript. anomalyco/opentui#751 wires that up. This PR is the OpenCode side: a single config option that passes the user's preference through to therender()call.Two files changed:
tui-schema.ts: addswidth_methodtoTuiOptions("unicode" | "wcwidth" | "no_zwj", optional)app.tsx: passes_config.width_methodtorendererConfig()Users add one line to their
opencode.json:{ "tui": { "width_method": "no_zwj" } }No default changes. Anyone not setting this gets identical behavior to today.
Note: depends on anomalyco/opentui#751. That PR's review feedback has been addressed and it's waiting on merge. Happy to wait, or if you want to merge this speculatively while that lands, the worst case is a no-op until opentui is bumped.
How did you verify your code works?
Ran OpenCode in a tmux split with the
no_zwjconfig set. Family emoji and profession emoji that previously shifted subsequent text now render as split glyphs (👩 + 🚀 instead of 👩🚀) — visually imperfect, but correctly laid out. Terminals that do render ZWJ correctly can leave this unset and see no change.Screenshots / recordings
No UI change visible without a terminal that exhibits the corruption. The fix is the absence of the corruption.
Checklist