Skip to content

fix(tui): handle wide Bengali graphemes - #46112

Closed
Blackman99 wants to merge 1 commit into
anomalyco:devfrom
Blackman99:bengali-width
Closed

Blackman99 wants to merge 1 commit into
anomalyco:devfrom
Blackman99:bengali-width

Conversation

@Blackman99

Copy link
Copy Markdown

Issue for this PR

Closes #46107

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Upgrades OpenTUI from 0.4.5 to 0.5.9 so terminals that use the unicode-wide profile measure complex Bengali graphemes correctly. The reported sample measured 12 cells before the upgrade and 18 cells after it, which prevents cumulative drift past the panel border.

The dependency and plugin peer versions were updated with the repository's upgrade-opentui script. A renderer regression test covers Bengali wrapping inside a border, a repeated render, terminal resize, and unchanged ASCII/CJK content.

How did you verify your code works?

  • The renderer test fails on origin/dev because the width method falls back to unicode, then passes with OpenTUI 0.5.9 and unicode-wide.
  • bun run test in packages/tui: 194 passed, 1 skipped.
  • bun typecheck in packages/tui, packages/plugin, and packages/opencode.
  • Pre-push bun turbo typecheck: 30/30 packages passed.
  • bun install --frozen-lockfile.
  • Prettier and oxlint on the new test: 0 warnings, 0 errors.

Screenshots / recordings

N/A — terminal-specific rendering is covered by exact wide and resized frame assertions.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@2u841r

2u841r commented Sep 4, 2026

Copy link
Copy Markdown

Independently verified this on Linux with ghostty 1.3.1, which also fills in the "Terminal: Unknown" field from #46107.

Isolated comparison of the two versions, same sample, 24 column bordered box.

0.4.5, requesting unicode-wide, silently resolves to unicode:

│বাংলা ভাষায় কথা বলি বাংলা       │

0.5.9, requesting unicode-wide:

│বাংলা ভাষায় কথা বলি    │
│বাংলা                  │

0.5.9 on the plain unicode profile still overflows, so this fixes the drift only when the wide profile is negotiated, rather than correcting widths unconditionally. That negotiation does happen here: the native lib carries ghosttyWideGraphemeWidths and term_from_xtversion, and ghostty answers the XTVERSION query.

Confirmed end to end as well: running the TUI from this branch in ghostty 1.3.1, the Bengali sample stays inside the panel and the border stays aligned. Word internal spacing from ghostty's two cell advance looks the same as it did on 0.4.5, so that part is not a regression.

Bump checks on a local branch off dev:

  • lock diff touches only the opentui packages plus bun-ffi-structs 0.2.4 to 0.3.1
  • packages/tui: 193 pass, 1 skip, 0 fail
  • bun turbo typecheck from root: 30/30 successful

One suggestion: consider dropping packages/tui/test/bengali-width.test.tsx. It renders a bare box and text with capabilities forced, so no opencode code is under test, and asserting renderer.widthMethod checks the dependency rather than this repo. Because it forces the profile, it would keep passing even if detection broke for every real terminal, which is the part the fix actually hinges on. The frame assertions are captured output with exact trailing space counts, so any future width table change breaks them without indicating whether the new output is correct.

Also, 0.5.10 is published now.

@2u841r

2u841r commented Sep 4, 2026

Copy link
Copy Markdown

Clarification on my numbers above: those were from a bump-only branch, without this PR's test file, which is why I saw 193 pass where you report 194. I have since run this branch directly: bengali-width.test.tsx passes on its own, and the full packages/tui suite is 194 pass, 1 skip, 0 fail. Your numbers reproduce exactly. My note about the test was about what it covers, not whether it works.

@2u841r

2u841r commented Sep 4, 2026

Copy link
Copy Markdown

I tested with Hindi also. same problem, same fix.

Mentioning @nexxeln because he is maybe from India.

@serezha93

serezha93 commented Sep 11, 2026 •

Copy link
Copy Markdown

Cross-linking another issue that may benefit from this OpenTUI upgrade: #36454.

OpenCode on OpenTUI 0.4.5 still emits the same shutdown warning:

Code highlighting failed, falling back to plain text: warn: TreeSitter client destroyed

Upstream tracked that teardown race in anomalyco/opentui#1319 and closed it as completed after renderer teardown ordering changed. The reproduction above is on macOS with OpenCode 1.18.30.

Would be useful to verify #36454 against this PR / current OpenTUI before merge. If the warning disappears, this PR may address both renderer issues; if not, that gives a clear remaining upstream gap.

No claim yet that the bump fixes #36454 — just flagging the likely overlap.

@2u841r

2u841r commented Oct 6, 2026

Copy link
Copy Markdown

hello @nexxeln, it's urgent

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@thdxr thdxr closed this Oct 10, 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.

Bengali graphemes can render outside TUI borders

4 participants