Skip to content

feat(tui): add width_method config option for ZWJ emoji handling#15392

Closed
Flare576 wants to merge 1 commit intoanomalyco:devfrom
Flare576:feat/no-zwj-width-method
Closed

feat(tui): add width_method config option for ZWJ emoji handling#15392
Flare576 wants to merge 1 commit intoanomalyco:devfrom
Flare576:feat/no-zwj-width-method

Conversation

@Flare576
Copy link

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_zwj width calculation mode that handles this correctly. This PR exposes it as a user-configurable option via opencode.json.

Depends on: anomalyco/opentui#751 — which wires no_zwj through 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: Add width_method to TuiOptions schema ("unicode" | "wcwidth" | "no_zwj", optional)
  • packages/opencode/src/cli/cmd/tui/app.tsx: Pass input.config.width_method to the render() call as widthMethod

Usage

Users experiencing layout corruption add one line to their opencode.json:

{
  "tui": {
    "width_method": "no_zwj"
  }
}

Behavior

no_zwj breaks 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.

Mode Effect
unicode (default) ZWJ sequences as single glyph — correct on modern terminals, corrupts tmux
no_zwj (opt-in) ZWJ sequences split — safe everywhere, slightly less pretty
wcwidth Existing option, unchanged

No Breaking Changes

Default is still "unicode". Users who don't set width_method see identical behavior to today.

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.
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 27, 2026
@github-actions
Copy link
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actions
Copy link
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.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 27, 2026
@github-actions github-actions bot closed this Feb 27, 2026
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.

1 participant