gemini-cli - ✅(Solved) Fix Thai SARA AM (U+0E33) width mismatch causing erratic line jumping and output duplication (spamming) in tmux [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25369Fetched 2026-04-15 06:45:20
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Participants
Timeline (top)
labeled ×3commented ×1cross-referenced ×1referenced ×1

Root Cause

Symptoms identified:

  1. Output Duplication (Streaming Spam): When the AI streams a response containing SARA AM, the terminal fails to refresh the current line correctly. Instead, it "spams" the same line multiple times vertically. (e.g., a single bullet point appearing 8-10 times, as shown in the attached example).
  2. Self-Jumping Input Line: During interactive typing, entering SARA AM causes the current input line to "jump" downward spontaneously, leaving large vertical gaps between the prompt and the previous output.
  3. Cursor Desync: The internal layout engine (Ink) loses track of the actual cursor position because it perceives SARA AM as part of a 1-column cluster, while tmux/terminal renders it as a 2-column sequence.

Fix Action

Fixed

PR fix notes

PR #25385: fix(cli): correct Thai/Lao SARA AM width mismatch causing rendering bugs

Description (problem / solution / changelog)

Summary

Fixes #25369

  • [email protected] uses Intl.Segmenter which merges Consonant + SARA AM (U+0E33/U+0EB3) into a single grapheme cluster and reports width 1. Terminals render the pair as 2 columns, causing cursor desync, output duplication, and erratic line jumping in tmux.
  • Adds width compensation in getCachedStringWidth that adds +1 for each SARA AM preceded by another character (where Intl.Segmenter under-counts)
  • Overrides Ink's internal width function via setStringWidthFunction so both the text-buffer and Ink rendering paths use the corrected width

Root Cause

[email protected]("กำ") → 1  (wrong, terminal renders 2 columns)
[email protected]("กำหนด") → 4  (wrong, terminal renders 5 columns)

Intl.Segmenter groups Consonant + SARA AM into one grapheme cluster. string-width then computes width using only the East Asian Width of the first code point (the consonant = 1), ignoring SARA AM which terminals render as an additional column.

Changes

FileChange
packages/cli/src/ui/utils/textUtils.tsAdd saraAmCompensation() helper, apply in getCachedStringWidth (both happy path and fallback)
packages/cli/src/interactiveCli.tsxCall setStringWidthFunction(getCachedStringWidth) to override Ink's width calculation
packages/cli/src/ui/utils/textUtils.test.ts6 new tests covering Thai, Lao, standalone, multi-cluster, and mixed text

Test plan

  • vitest run packages/cli/src/ui/utils/textUtils.test.ts — 82 tests pass
  • TypeScript compiles (no new errors in changed files)
  • Pre-commit hooks pass (prettier + eslint)
  • Manual verification with Thai text in tmux

Changed files

  • packages/cli/src/interactiveCli.tsx (modified, +7/-1)
  • packages/cli/src/ui/utils/textUtils.test.ts (modified, +31/-0)
  • packages/cli/src/ui/utils/textUtils.ts (modified, +30/-3)

Code Example

> /about
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                   │
About Gemini CLI│                                                                                                                                                   │
CLI Version                                        0.37.2Git Commit                                         545e956c3                                                                                      │
Model                                              gemini-3-flash-preview                                                                         │
Sandbox                                            no sandbox                                                                                     │
OS                                                 linux                                                                                          │
Auth Method                                        Signed in with GoogleTier                                               Gemini Code Assist in Google One AI Pro│                                                                     │
│                                                                                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
RAW_BUFFERClick to expand / collapse

What happened?

When using Gemini CLI inside a tmux environment, any Thai text containing the character SARA AM (U+0E33) triggers severe rendering bugs that make the CLI unusable.

Symptoms identified:

  1. Output Duplication (Streaming Spam): When the AI streams a response containing SARA AM, the terminal fails to refresh the current line correctly. Instead, it "spams" the same line multiple times vertically. (e.g., a single bullet point appearing 8-10 times, as shown in the attached example).
  2. Self-Jumping Input Line: During interactive typing, entering SARA AM causes the current input line to "jump" downward spontaneously, leaving large vertical gaps between the prompt and the previous output.
  3. Cursor Desync: The internal layout engine (Ink) loses track of the actual cursor position because it perceives SARA AM as part of a 1-column cluster, while tmux/terminal renders it as a 2-column sequence.

The Technical Root Cause:

  • Ink's behavior: Uses Intl.Segmenter which merges Consonant + SARA AM into a single grapheme cluster of width 1.
  • tmux/xterm.js behavior: Renders the same sequence across 2 columns (matching standard wcwidth logic).
  • The Mismatch: Since the terminal's physical cursor is 1 unit ahead of where Ink thinks it is, every frame refresh results in Ink sending "move cursor" or "clear line" commands to incorrect coordinates. This triggers tmux to scroll or wrap lines prematurely to protect the buffer, leading to the "spamming" effect.

What did you expect to happen?

The CLI should maintain a 1:1 coordinate sync with the terminal grid. Typing or streaming SARA AM should result in a single, stable line of text without triggering unintended line breaks or duplicated output.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

> /about
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                   │
│ About Gemini CLI                                                                                                                                  │
│                                                                                                                                                   │
│ CLI Version                                        0.37.2                                                                                         │
│ Git Commit                                         545e956c3                                                                                      │
│ Model                                              gemini-3-flash-preview                                                                         │
│ Sandbox                                            no sandbox                                                                                     │
│ OS                                                 linux                                                                                          │
│ Auth Method                                        Signed in with Google                                             │
│ Tier                                               Gemini Code Assist in Google One AI Pro                                                        │
│                                                                     │
│                                                                                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
</details>

Login information

Logged in via Google Account.

Anything else we need to know?

  • Platform: Linux (Debian) + tmux.
  • Consistency: This issue is exclusive to SARA AM (U+0E33). Other Thai combining marks (vowels/tones) work correctly because both Ink and terminals agree they have 0 width.
  • Replicability: The issue is highly replicable by simply asking the AI to "Response in Thai with words like 'กำลัง', 'ทำ', 'แนะนำ'".

Visual Evidence of the "Spam" bug:

มันทำอะไรได้บ้าง? (The God Mode) มันทำอะไรได้บ้าง? (The God Mode) มันทำอะไรได้บ้าง? (The God Mode) มันทำอะไรได้บ้าง? (The God Mode) ... (repeated multiple times for a single output line)

Proposed Fix: Update the string-width calculation within the Ink library to treat U+0E33 as having a visual width of 1, effectively making the Consonant + SARA AM cluster have a total width of 2, aligning it with the behavior of terminal grids.

extent analysis

TL;DR

Update the string-width calculation in the Ink library to treat U+0E33 (SARA AM) as having a visual width of 1, aligning with terminal grid behavior.

Guidance

  • Verify the issue is specific to the SARA AM character (U+0E33) and not other Thai combining marks, as they may have different width treatments.
  • Test the proposed fix by updating the Ink library's string-width calculation to treat the Consonant + SARA AM cluster as having a total width of 2.
  • To mitigate the issue temporarily, avoid using the SARA AM character in responses or inputs when using the Gemini CLI within a tmux environment.
  • Review the Intl.Segmenter behavior in the Ink library to ensure it correctly handles Unicode characters and their widths.

Example

No code snippet is provided as the fix involves updating the Ink library's internal string-width calculation, which is not explicitly shown in the issue.

Notes

The proposed fix assumes that updating the Ink library's string-width calculation will resolve the issue. However, this may require additional testing to ensure it does not introduce other rendering issues.

Recommendation

Apply the proposed fix by updating the Ink library to treat U+0E33 as having a visual width of 1, as this aligns with the behavior of terminal grids and should resolve the rendering bugs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING