feat(tui): add width_method config option for ZWJ emoji handling#15392
Closed
Flare576 wants to merge 1 commit intoanomalyco:devfrom
Closed
feat(tui): add width_method config option for ZWJ emoji handling#15392Flare576 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.
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
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.
Problem
ZWJ emoji sequences (family emoji, profession emoji, pride flag, etc.) cause layout corruption in terminals that don't render them as joined glyphs — most notably tmux, but also many older terminals. Text after a ZWJ sequence shifts across the screen, wraps incorrectly, and input box spacing breaks.
This affects anyone running OpenCode inside tmux with a pane split, and is a long-standing source of reports (see #6210).
Solution
OpenTUI's Zig layer already has a fully implemented and tested
no_zwjwidth calculation mode that handles this correctly. This PR exposes it as a user-configurable option viaopencode.json.Depends on: anomalyco/opentui#751 — which wires
no_zwjthrough the TypeScript→FFI chain. No default is changed in OpenTUI; this PR just passes the user's preference through.Changes
packages/opencode/src/config/tui-schema.ts: Addwidth_methodtoTuiOptionsschema ("unicode" | "wcwidth" | "no_zwj", optional)packages/opencode/src/cli/cmd/tui/app.tsx: Passinput.config.width_methodto therender()call aswidthMethodUsage
Users experiencing layout corruption add one line to their
opencode.json:{ "tui": { "width_method": "no_zwj" } }Behavior
no_zwjbreaks ZWJ-joined emoji into their component glyphs (👩🚀 renders as 👩 + 🚀), which is visually imperfect but correctly laid out. Skin tone modifiers, regional indicator flags, combining accents, and CJK characters are completely unaffected.unicode(default)no_zwj(opt-in)wcwidthNo Breaking Changes
Default is still
"unicode". Users who don't setwidth_methodsee identical behavior to today.