Skip to content

feat(terminal): opt-in wide East Asian Ambiguous character width - #10078

Open
innocarpe wants to merge 3 commits into
stablyai:mainfrom
innocarpe:fix/terminal-east-asian-ambiguous-width
Open

innocarpe wants to merge 3 commits into
stablyai:mainfrom
innocarpe:fix/terminal-east-asian-ambiguous-width

Conversation

@innocarpe

@innocarpe innocarpe commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Opt-in setting for East Asian Ambiguous character cell width (iTerm2-style escape hatch), requested in #9958.

On Windows CJK locales, characters like ① ■ ● ★ → render poorly in Orca because:

  1. Unicode 11 width tables report them as width 1 (modern CLI default)
  2. Cascadia Mono / Consolas either lack the glyphs or draw them too small for a single cell

This PR keeps the modern CLI-aligned default (narrow) and adds Wide mode that:

  • Treats East Asian Ambiguous (EAW=A) code points as double-width in OrcaUnicodeProvider
  • Inserts CJK UI fonts (Malgun Gothic, Microsoft YaHei, Yu Gothic, …) ahead of Consolas so full-em glyphs fill the two-cell slot

Changes

  • terminalEastAsianAmbiguousWidth: 'narrow' | 'wide' (default narrow)
  • Shared EAW ambiguous range table + resolveEastAsianAmbiguousCellWidth
  • Provider reads mode at measurement time (settings toggle without re-register)
  • Settings → Terminal → Typography Advanced: Ambiguous Character Width
  • buildFontFamily(..., { eastAsianAmbiguousWide }) CJK fallback insertion

Fixes #9958

Screenshots

  • Settings → Terminal → Advanced typography disclosure → Ambiguous Character Width (Narrow / Wide)
  • No default visual change (narrow remains default)

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/shared/east-asian-ambiguous-width.test.ts src/shared/terminal-unicode-provider.test.ts src/renderer/src/components/terminal-pane/layout-serialization.test.ts (40/40)
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/pane-manager/pane-lifecycle.test.ts (30/30)
  • Full pnpm lint / pnpm typecheck / pnpm test / pnpm build
  • Unit coverage for EAW classification, wide-mode wcwidth, and CJK font insertion order

AI Review Report

  • Default safety: narrow preserves modern CLI width tables; wide is opt-in only
  • Consistency: wcwidth and charProperties stay aligned when wide expands ambiguous cells
  • Font coupling: wide mode alone without CJK fonts would leave ① tiny; both paths wired together as the issue specified
  • Cross-platform: CJK fallback list covers Windows (Malgun/YaHei/Yu Gothic), macOS (Apple SD/PingFang/Hiragino), Linux (Noto Sans CJK); browsers skip missing fonts
  • Mobile: not re-wired in this PR — mobile still loads Unicode11 directly; follow-up if settings plumbing is desired there
  • Headless emulator: continues to use the shared provider (module mode defaults narrow; daemon measurement stays CLI-aligned)

Security Audit

  • No new IPC, path handling, or command execution
  • Setting is a local preference only; no network or secrets

Notes

  • Changing width mid-session affects newly written cells; existing buffer layout is not reflowed (same as other terminals). UI copy notes opening a new pane for a full reflow.
  • Known trade-off when Wide is on: TUIs that assume ambiguous width 1 can misalign — that is why this stays opt-in and off by default.

ELI5

Some CJK symbols looked too skinny or wrong in the terminal on Windows. There is an optional Wide mode for East Asian Ambiguous characters so shapes like stars and arrows get a full cell width when you want that.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

Adds a narrow-or-wide setting for East Asian ambiguous characters. Wide mode assigns width two to ambiguous characters with base width one and selects CJK font fallbacks. The setting is available in desktop typography controls and is passed through desktop terminal startup, headless emulators, and mobile WebView initialization. The default is narrow.

Severity of issue fixed: Low

Merge Risk: High · previous review bd9f9

The default narrow mode can mis-measure text with combining marks, and the new settings preview can fail to render. Wide mode makes Powerline/Nerd Font icons double-width and can leave daemon snapshots using different widths from the renderer. The setting also never reaches mobile terminals. Fix these before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description clearly explains the purpose, implementation, linked issue, targeted tests, and known limitations. It does not provide actual before-and-after visual attachments for this UI change, an… Add before-and-after visual attachments, or write N/A with a reason if no visual proof applies. Complete the required template sections and checklist, document manual testing platforms, and report full validation results or CI coverage.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title is concise, specific, and accurately describes the primary change: an opt-in wide East Asian Ambiguous character width mode.
Linked Issues check Passed The PR meets the coding requirements in [#9958]. It adds the narrow default and opt-in wide mode, applies the mode in wcwidth and charProperties, and adds coverage for classification and provi…
Out of Scope Changes check Passed The changed files support [#9958]. They implement the setting, width resolution, renderer/headless/mobile activation, coupled CJK font fallback, settings UI, and automated tests. The summaries show no…
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Full details: Linked Issues check

Explanation

The PR meets the coding requirements in [#9958]. It adds the narrow default and opt-in wide mode, applies the mode in wcwidth and charProperties, and adds coverage for classification and provider behavior. Renderer activation occurs before terminal use in pane-lifecycle.ts. Headless activation accepts the mode before loading Unicode11Addon. Mobile initialization sets the mode before replay writes and selects the matching font family. Wide mode inserts CJK fallback fonts before Consolas. The PR also adds headless width, font-order, and layout-related tests.

Full details: Out of Scope Changes check

Explanation

The changed files support [#9958]. They implement the setting, width resolution, renderer/headless/mobile activation, coupled CJK font fallback, settings UI, and automated tests. The summaries show no unrelated feature, security, IPC, or command-execution changes.

Full details: Description check

Explanation

The description clearly explains the purpose, implementation, linked issue, targeted tests, and known limitations. It does not provide actual before-and-after visual attachments for this UI change, and it omits several required template sections and checklist confirmations.

Resolution

Add before-and-after visual attachments, or write N/A with a reason if no visual proof applies. Complete the required template sections and checklist, document manual testing platforms, and report full validation results or CI coverage.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/shared/terminal-unicode-provider.test.ts (1)

54-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise wide-mode charProperties as well.

The test only checks wcwidth; the newly added packed-property path is what buffer writes consume. Assert that an ambiguous code point has width bits 2 after switching to wide mode.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0015135e-dae9-4f27-b7f2-fb02d679f6ae

📥 Commits

Reviewing files that changed from the base of the PR and between 8448557 and b280441.

📒 Files selected for processing (15)
  • src/renderer/src/components/settings/TerminalAdvancedTypographyControls.tsx
  • src/renderer/src/components/settings/TerminalSettingsPreview.tsx
  • src/renderer/src/components/settings/setting-labels.ts
  • src/renderer/src/components/settings/terminal-typography-search.ts
  • src/renderer/src/components/terminal-pane/layout-serialization.test.ts
  • src/renderer/src/components/terminal-pane/layout-serialization.ts
  • src/renderer/src/components/terminal-pane/terminal-appearance.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • src/shared/constants.ts
  • src/shared/east-asian-ambiguous-width.test.ts
  • src/shared/east-asian-ambiguous-width.ts
  • src/shared/terminal-unicode-provider.test.ts
  • src/shared/terminal-unicode-provider.ts
  • src/shared/types.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b4ee663-013c-4bc9-a708-edad9d9fb749

📥 Commits

Reviewing files that changed from the base of the PR and between b280441 and f73f7df.

📒 Files selected for processing (1)
  • src/renderer/src/components/settings/TerminalSettingsPreview.tsx

@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026
@innocarpe
innocarpe force-pushed the fix/terminal-east-asian-ambiguous-width branch from f73f7df to bae2e4e Compare July 28, 2026 13:11
@DoDAON

DoDAON commented Jul 30, 2026

Copy link
Copy Markdown

Hi @innocarpe, thanks for picking this up and for the quick PR.

Just checking in on progress — it's been a few days since the last commit, and CodeRabbit's linked-issues check is still flagging that the headless emulator (src/main/daemon/headless-emulator.ts) and mobile (mobile/src/terminal/terminal-webview-html.ts) activation sites from the original issue aren't wired up yet, on top of the docstring coverage warning.

Those two paths matter for the SSH and mobile use cases specifically, so I'd like to see all three activation sites covered before merge. Are you still actively working on this, or would it help to have someone else pick up the remaining wiring? Happy to help if you're stuck on anything.

@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (bae2e4e42)

@DoDAON Thanks for the check-in — still on this, and the remaining two activation sites are now wired.

Headless (headless-emulator.ts)

  • Sets East Asian Ambiguous mode before activateOrcaTerminalUnicodeProvider
  • Runtime passes store.getSettings().terminalEastAsianAmbiguousWidth when creating PTY mirrors
  • Main process also syncs the process-wide mode on settings load/change so live headless buffers stay aligned with the renderer (SSH fidelity)

Mobile (terminal-webview-html.ts + engine)

  • Bundles Orca unicode into the WebView engine (window.OrcaTerminalUnicode)
  • After Unicode11, activates the Orca provider (this path previously stopped at Unicode11 and bypassed Orca entirely)
  • init accepts eastAsianAmbiguousWidth; wide mode also inserts CJK UI fonts ahead of Consolas (same coupling as desktop)

Tests

  • Headless: wide vs narrow ① cell advance
  • Mobile: activate order (open → Unicode11 → Orca → replay); Chrome 74 parse floor still green

Happy to adjust if you want mobile to pull the host setting via settings.get at session open as a follow-up (prop/init path is ready).

@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (26f03fc82)

Follow-up: 1cb8121 + font-extract test fix are on the branch (earlier sync comment referenced a pre-push tip).

@DoDAON — remaining activation sites are wired as described above. Full headless/mobile coverage for #9958 is in this PR tip.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR is safe to merge with minimal risk

Summary

This PR adds opt-in wide East Asian Ambiguous character width for Windows CJK locales where glyphs like ① ■ ★ → render too small. The implementation is clean and well-tested.

Major changes:

  • New terminalEastAsianAmbiguousWidth setting ('narrow' | 'wide', default 'narrow') keeps modern CLI alignment by default
  • Shared EAW range table with binary-search classification drives both wcwidth and charProperties so cell width stays consistent
  • CJK font fallback insertion in wide mode places full-em fonts (Malgun Gothic, YaHei, Yu Gothic, PingFang, Hiragino, Noto) ahead of Consolas
  • Cross-platform coverage: desktop renderer, headless emulator, and mobile WebView all read the mode and apply width expansion together with font changes

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Settings: terminalEastAsianAmbiguousWidth] -->|narrow/wide| B[setTerminalEastAsianAmbiguousWidthMode]
    B --> C[Process-global mode variable]
    
    A -->|eastAsianAmbiguousWide option| D[buildFontFamily]
    D -->|wide=true| E[Insert CJK fonts before Consolas]
    D -->|wide=false| F[Standard monospace fallback chain]
    
    C --> G[OrcaUnicodeProvider.wcwidth]
    C --> H[OrcaUnicodeProvider.charProperties]
    
    G -->|baseWidth=1 & mode=wide & isEastAsianAmbiguous| I[Return width 2]
    G -->|otherwise| J[Return baseWidth]
    
    H -->|mode=wide| K[Align charProperties width field with wcwidth]
    
    I --> L[Terminal cells allocated as double-width]
    E --> L
    
    style A fill:#e1f5ff
    style C fill:#fff3cd
    style L fill:#d4edda
Loading

Reviews (3) · Last reviewed commit: "feat(terminal): wire EAW wide mode throu..." · Reviewed by Greptile

@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (46640c27f)

Merge + review follow-up (46640c27f)

  • Rebased/merged onto latest main — conflict was only mobile imports; kept both TERMINAL_EAW_JS and TERMINAL_WHEEL_SCROLL_JS.
  • Greptile P2: dropped BMP PUA U+E000–U+F8FF from the EAW ambiguous table so Nerd Font / Powerline / OMP icons stay single-cell in wide mode (with regression tests).
  • Greptile note: setTerminalEastAsianAmbiguousWidthMode now runs once before the appearance pane loop (not per pane).
  • Extracted HeadlessEmulatorOptions to stay under max-lines after the main merge.

Evidence: east-asian-ambiguous-width.test.ts PUA cases + existing width suites.

innocarpe added a commit to innocarpe/orca that referenced this pull request Jul 30, 2026
Resolve conflict with upstream wheel-scroll inject (keep both EAW + wheel).

Review (Greptile stablyai#10078):
- Remove BMP PUA U+E000–U+F8FF from ambiguous ranges so Powerline/OMP
  icons stay single-cell in wide mode.
- Set process-wide EAW mode once before the appearance pane loop.
- Extract HeadlessEmulatorOptions to stay under max-lines.

Evidence: east-asian-ambiguous-width PUA tests + width suites.
@innocarpe
innocarpe force-pushed the fix/terminal-east-asian-ambiguous-width branch from 46640c2 to bd9f9d2 Compare October 29, 2026 09:34
@greptile-apps

greptile-apps Bot commented Oct 29, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P2 setTerminalEastAsianAmbiguousWidthMode called once per pane inside the loop src/renderer/src/components/terminal-pane/terminal-appearance.ts:183 ▶

    setTerminalEastAsianAmbiguousWidthMode is placed inside the for (const pane of ...) loop and sets the same process-global value on every iteration. More importantly, if manager.getPanes() returns an empty array (no open panes when the user changes the setting), the global mode is never updated by this call. A new pane opened afterward will read the correct value from the store in openTerminal, so there is no immediate regression - but the redundant per-pane call makes this code misleading about the intended call site. Moving the call (and the eastAsianAmbiguousWide local) to just before the loop clarifies intent and removes the dead execution case.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c4a332e-6c82-42ca-b5c0-8f7744af62e3
Commits

Reviewing files that changed from the base of the PR and between 46640c2 and bd9f9d2.

Files selected for processing: 25
  • mobile/scripts/build-terminal-webview-engine.mjs
  • mobile/src/terminal/document/host-message-router.ts
  • mobile/src/terminal/document/terminal-init.ts
  • mobile/src/terminal/document/text-scaling.ts
  • mobile/src/terminal/terminal-webview-contract.ts
  • mobile/src/terminal/terminal-webview-messages.ts
  • mobile/src/terminal/use-terminal-webview-controller.ts
  • src/main/daemon/headless-emulator-unicode-width.test.ts
  • src/main/daemon/headless-emulator.ts
  • src/main/runtime/terminal/output/headless-terminal-state.ts
  • src/main/startup/main-process-ready-foundation.ts
  • src/renderer/src/components/settings/TerminalAdvancedTypographyControls.tsx
  • src/renderer/src/components/settings/TerminalSettingsPreview.tsx
  • src/renderer/src/components/settings/setting-labels.ts
  • src/renderer/src/components/settings/terminal-typography-search.ts
  • src/renderer/src/components/terminal-pane/terminal-appearance.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-manager-options.ts
  • src/renderer/src/lib/monospace-font-family.test.ts
  • src/renderer/src/lib/monospace-font-family.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • src/shared/default-global-settings.ts
  • src/shared/east-asian-ambiguous-width.test.ts
  • src/shared/east-asian-ambiguous-width.ts
  • src/shared/global-settings-types.ts
  • src/shared/terminal-unicode-provider.ts
Files skipped from review as they are similar to previous changes: 1
  • src/renderer/src/components/settings/setting-labels.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

// Persistent font-size preset; transient CSS pinch zoom is committed into it on release.
textScale?: number
/** Desktop Settings twin for East Asian Ambiguous width (#9958); default narrow. */
eastAsianAmbiguousWidth?: 'narrow' | 'wide'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Data Integrity & Integration · Heavy lift

Supported by static analysis

Script executed:

rg -n -C 4 -g '*.{ts,tsx}' \
  'eastAsianAmbiguousWidth|terminalEastAsianAmbiguousWidth|<TerminalWebView\b' mobile/src

Repository: stablyai/orca

Length of output: 7751


Script executed:

set -o pipefail
printf '%s\n' '--- setting references ---'
rg -n -F --glob '*.{ts,tsx}' -- 'terminalEastAsianAmbiguousWidth' src mobile || test "$?" -eq 1
printf '%s\n' '--- TerminalPaneView ---'
nl -ba mobile/src/session/TerminalPaneView.tsx | sed -n '1,180p'
printf '%s\n' '--- TerminalPaneView references and owner ---'
rg -n -F --glob '*.{ts,tsx}' -e 'TerminalPaneView' -e 'terminalTheme' mobile/src/session mobile/src | sed -n '1,220p'
printf '%s\n' '--- controller and contract relevant blocks ---'
nl -ba mobile/src/terminal/use-terminal-webview-controller.ts | sed -n '1,75p;235,315p'
nl -ba mobile/src/terminal/terminal-webview-contract.ts | sed -n '70,115p'

Repository: stablyai/orca

Length of output: 29428


Script executed:

printf '%s\n' '--- MobileSessionActiveContent terminal owner ---'
nl -ba mobile/src/session/MobileSessionActiveContent.tsx | sed -n '200,275p'
printf '%s\n' '--- TerminalWebView implementation ---'
rg -n -F --glob '*.{ts,tsx}' -e 'export.*TerminalWebView' -e 'function TerminalWebView' -e 'useTerminalWebViewController' mobile/src/terminal mobile/src/session
nl -ba mobile/src/terminal/TerminalWebView.tsx | sed -n '1,220p'
printf '%s\n' '--- mobile settings/context references ---'
rg -n -F --glob '*.{ts,tsx}' -e 'useAppStore' -e 'settings?.' -e 'getSettings' -e 'Settings' mobile/src/session mobile/src/terminal mobile/src | sed -n '1,260p'

Repository: stablyai/orca

Length of output: 42615


Connect the host setting to the mobile terminal.

MobileSessionActiveContent passes no width setting to TerminalPaneView, and TerminalPaneView omits eastAsianAmbiguousWidth when it renders TerminalWebView. The controller then defaults to 'narrow'. Pass the host’s terminalEastAsianAmbiguousWidth value through the session caller as eastAsianAmbiguousWidth.

postMessage,
promises,
sendToDocument,
eastAsianAmbiguousWidth,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

rg -n 'eastAsianAmbiguousWidth|setEastAsianAmbiguousWidthMode' mobile/src mobile/scripts
sed -n '240,310p' mobile/src/terminal/use-terminal-webview-controller.ts

Repository: stablyai/orca

Length of output: 3358


Script executed:

set -o pipefail
printf '%s\n' '--- controller symbols and effects ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'useTerminalWebViewController' -e 'eastAsianAmbiguousWidth' -e 'setEastAsianAmbiguousWidthMode' -e 'postMessage({ type: .init' -e 'type: .init' mobile/src mobile/scripts
printf '%s\n' '--- controller file ---'
nl -ba mobile/src/terminal/use-terminal-webview-controller.ts | sed -n '1,360p'
printf '%s\n' '--- host router ---'
nl -ba mobile/src/terminal/document/host-message-router.ts | sed -n '1,150p'
printf '%s\n' '--- terminal init ---'
nl -ba mobile/src/terminal/document/terminal-init.ts | sed -n '1,180p'
printf '%s\n' '--- TerminalPaneView candidates ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'TerminalPaneView' -e 'useTerminalWebViewController(' mobile/src

Repository: stablyai/orca

Length of output: 33098


Script executed:

set -o pipefail
printf '%s\n' '--- relevant references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'useTerminalWebViewController' -e 'eastAsianAmbiguousWidth' -e 'setEastAsianAmbiguousWidthMode' mobile/src mobile/scripts
printf '%s\n' '--- controller lifecycle ---'
nl -ba mobile/src/terminal/use-terminal-webview-controller.ts | sed -n '1,360p'
printf '%s\n' '--- document handlers ---'
nl -ba mobile/src/terminal/document/host-message-router.ts | sed -n '1,150p'
nl -ba mobile/src/terminal/document/terminal-init.ts | sed -n '1,180p'
printf '%s\n' '--- caller candidates ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'TerminalPaneView' -e 'useTerminalWebViewController(' mobile/src

Repository: stablyai/orca

Length of output: 33066


Script executed:

set -o pipefail
printf '%s\n' '--- native WebView wrapper ---'
nl -ba mobile/src/terminal/TerminalWebView.tsx | sed -n '1,180p'
printf '%s\n' '--- web WebView wrapper ---'
nl -ba mobile/src/terminal/TerminalWebView.web.tsx | sed -n '1,180p'
printf '%s\n' '--- TerminalPaneView ---'
nl -ba mobile/src/session/TerminalPaneView.tsx | sed -n '1,180p'
printf '%s\n' '--- MobileSessionActiveContent caller ---'
nl -ba mobile/src/session/MobileSessionActiveContent.tsx | sed -n '215,275p'
printf '%s\n' '--- WebView contract ---'
nl -ba mobile/src/terminal/terminal-webview-contract.ts | sed -n '60,115p'

Repository: stablyai/orca

Length of output: 22317


Script executed:

set -o pipefail
printf '%s\n' '--- terminal ref and init call sites ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'setTerminalWebViewRef' -e '.init({' -e 'handle.init' -e 'terminalWebViewRefs' -e 'TerminalWebViewHandle' mobile/src/session mobile/src/terminal
printf '%s\n' '--- ref owner and nearby lifecycle ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'function setTerminalWebViewRef' -e 'const setTerminalWebViewRef' -e 'onRef=' mobile/src/session

Repository: stablyai/orca

Length of output: 7156


Script executed:

set -o pipefail
printf '%s\n' '--- terminal WebView ref owner ---'
nl -ba mobile/src/session/use-mobile-session-terminal-webview.ts | sed -n '1,155p'
printf '%s\n' '--- terminal subscription init blocks ---'
nl -ba mobile/src/session/use-mobile-session-terminal-subscription.ts | sed -n '170,310p'

Repository: stablyai/orca

Length of output: 13229


Apply width-mode changes to a live terminal.

When a caller changes eastAsianAmbiguousWidth after initialization, useTerminalWebViewController rebuilds the handle but does not send a width-mode update. The wrappers do not reinitialize the document when the handle changes. The document handles this value only during init, where it sets the Unicode mode and font family. Later output can therefore use the old mode and font until another initialization occurs.

Add a live document command that updates the Unicode mode and scope.term.options.fontFamily. Existing buffer content need not reflow.

TerminalPaneView currently does not accept or pass eastAsianAmbiguousWidth, so this path is not reachable from the current mobile session and is a minor issue until a non-default value is wired.

)
setDefaultWslDistroOverride(store.getSettings().terminalWindowsWslDistro ?? null)
// Why: headless emulators measure widths in this process; keep EAW mode aligned with Settings (#9958).
setTerminalEastAsianAmbiguousWidthMode(store.getSettings().terminalEastAsianAmbiguousWidth)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Data Integrity & Integration · Heavy lift

Supported by static analysis

Script executed:

rg -n -C 3 'setTerminalEastAsianAmbiguousWidthMode\s*\(|new HeadlessEmulator\s*\(|createSessionOutputPipeline\s*\(' src/main src/shared

Repository: stablyai/orca

Length of output: 41615


Script executed:

set -o pipefail
printf '%s\n' '--- session-output-plane references ---'
rg -n -C 8 -F -- 'new HeadlessEmulator' src/main/daemon/session-output-plane.ts src/main/daemon/session-output-pipeline.ts src/main/daemon/terminal-checkpoint-serializer.ts src/main/runtime/terminal/output/terminal-buffer-operations.ts src/main/runtime/terminal/output/headless-terminal-state.ts
printf '%s\n' '--- mode and option declarations ---'
rg -n -C 12 -F -- 'eastAsianAmbiguousWidth' src/main/daemon/headless-emulator.ts src/main/daemon/session-output-plane.ts src/main/daemon/session-output-pipeline.ts src/main/daemon/terminal-checkpoint-serializer.ts src/main/runtime/terminal/output/terminal-buffer-operations.ts src/main/runtime/terminal/output/headless-terminal-state.ts src/shared/terminal-unicode-provider.ts
printf '%s\n' '--- relevant complete blocks ---'
sed -n '1,180p' src/main/daemon/session-output-plane.ts
sed -n '150,220p' src/main/daemon/terminal-checkpoint-serializer.ts
sed -n '1,110p' src/main/runtime/terminal/output/headless-terminal-state.ts
sed -n '1,180p' src/main/daemon/headless-emulator.ts

Repository: stablyai/orca

Length of output: 40384


Script executed:

set -o pipefail
printf '%s\n' '--- SessionOutputPlane callers and daemon process entrypoints ---'
rg -n -C 8 -F -- 'new SessionOutputPlane' src/main src/shared
rg -n -C 8 -e 'daemon.*fork|fork.*daemon|spawn.*daemon|daemon.*spawn|SessionOutputPlane|session-output-pipeline' src/main/daemon src/main/startup src/main/runtime
printf '%s\n' '--- all width-mode setter and settings propagation references ---'
rg -n -C 8 -e 'setTerminalEastAsianAmbiguousWidthMode|getTerminalEastAsianAmbiguousWidthMode|terminalEastAsianAmbiguousWidth' src/main src/shared src/renderer mobile
printf '%s\n' '--- daemon entrypoint candidates ---'
rg -n -l -e 'process\\.send|process\\.on\\(|MessagePort|parentPort|daemon' src/main/daemon src/main | head -80

Repository: stablyai/orca

Length of output: 45663


Script executed:

set -o pipefail
printf '%s\n' '--- daemon source files ---'
rg --files src/main/daemon | sort
printf '%s\n' '--- server construction and daemon startup calls ---'
rg -n -C 6 -F -- 'new DaemonServer' src/main/daemon src/main
rg -n -C 6 -F -- 'startDaemon' src/main/daemon src/main
printf '%s\n' '--- process-boundary calls ---'
rg -n -C 5 -e 'process[.]send|process[.]on[[:space:]]*[(]|fork[[:space:]]*[(]|spawn[[:space:]]*[(]|execFile[[:space:]]*[(]' src/main/daemon src/main/startup
printf '%s\n' '--- daemon server and spawner declarations ---'
sed -n '1,220p' src/main/daemon/daemon-server.ts
sed -n '1,240p' src/main/daemon/daemon-spawner.ts

Repository: stablyai/orca

Length of output: 45666


Script executed:

set -o pipefail
printf '%s\n' '--- daemon width references ---'
rg -n -C 5 -F -e 'terminalEastAsianAmbiguousWidth' -e 'setTerminalEastAsianAmbiguousWidthMode' src/main/daemon src/main/startup src/shared
printf '%s\n' '--- daemon entrypoint ---'
sed -n '1,260p' src/main/daemon/daemon-entry.ts
printf '%s\n' '--- daemon main ---'
sed -n '1,260p' src/main/daemon/daemon-main.ts
printf '%s\n' '--- child launch references ---'
rg -n -C 8 -F -e 'daemon-entry' -e 'daemon-main' -e 'launchDaemon' src/main/daemon/daemon-launched-child.ts src/main/daemon/daemon-launched-child-spawn.ts src/main/daemon/daemon-launch-paths.ts src/main/daemon/daemon-out-of-process-launcher.ts

Repository: stablyai/orca

Length of output: 36914


Synchronize terminalEastAsianAmbiguousWidth with the daemon.

The setting setter runs in the main process only. The daemon is launched through its own daemon-entry process, whose startup arguments and startDaemon options contain no width mode or settings synchronization.

SessionOutputPlane and replayTerminalSnapshot construct HeadlessEmulator without eastAsianAmbiguousWidth. Their daemon-local provider therefore starts in its default narrow mode. In wide mode, seeded history and live writes can use different cell widths from the renderer, which can misplace subsequent characters in snapshots.

Pass the mode to the daemon before emulator construction and history replay, then synchronize it when the setting changes.

// Why: bake ambiguous widths with Orca's provider before the sample write
// so wide mode is not stuck on xterm's default narrow tables (#9958).
setTerminalEastAsianAmbiguousWidthMode(settings.terminalEastAsianAmbiguousWidth)
activateOrcaTerminalUnicodeProvider(terminal)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Stability & Availability · Quick win

Supported by static analysis

Script executed:

set -eu
printf '%s\n' '--- changed preview and related calls ---'
rg -n -F -- 'activateOrcaTerminalUnicodeProvider' src/renderer/src/components/settings/TerminalSettingsPreview.tsx src/shared src/renderer/src/components/terminal-pane || test "$?" -eq 1
sed -n '110,190p' src/renderer/src/components/settings/TerminalSettingsPreview.tsx
printf '%s\n' '--- provider implementation ---'
sed -n '1,240p' src/shared/terminal-unicode-provider.ts
printf '%s\n' '--- live terminal setup references ---'
rg -n -F -- 'Unicode11Addon' src/renderer src/shared src/headless src/mobile app 2>/dev/null || true
printf '%s\n' '--- manifest and lock entries ---'
rg -n -F -- '@xterm/xterm' package.json pnpm-lock.yaml package-lock.json yarn.lock 2>/dev/null || true
printf '%s\n' '--- relevant tests ---'
rg -n -F -- 'TerminalSettingsPreview' src/renderer/src --glob '*test*' --glob '*spec*' || test "$?" -eq 1
printf '%s\n' '--- comparison hunk ---'
git diff --no-ext-diff --unified=40 401468bac7c5d1363c18c359ca3ce577e1c30443 bd9f9d28bf796e4e222992d7a1f750b7262cd2f9 -- src/renderer/src/components/settings/TerminalSettingsPreview.tsx src/shared/terminal-unicode-provider.ts

Repository: stablyai/orca

Length of output: 20140


Web query:

@xterm/xterm 6.1.0-beta.304 Unicode service set versiոն 11 unregistered Unicode11Addon

Result:

<source_evidence>
<source kind="search">
<title>@xterm/addon-unicode11 - npm</title>
<location>https://www.npmjs.com/package/%40xterm/addon-unicode11?activeTab=versions</location>
<excerpt>citeturn1search0 [wordlim: 200] Crawled: 2 days ago;     npm install --save @xterm/addon-unicode11 ... 0.10.0-beta.304  | 1  | 14 days ago

# @xterm/addon-unicode11

Image: This package contains built-in TypeScript declarations

0.9.0 • Public • Published 10 months ago

## @xterm/addon-unicode11

An addon providing Unicode version 11 rules for xterm.js.

### Install
    
    npm install --save @xterm/addon-unicode11

### Usage
    
    import { Terminal } from &#39;@xterm/xterm&#39;;
    import { Unicode11Addon } from &#39;@xterm/addon-unicode11&#39;;
    
    const terminal = new Terminal();
    const unicode11Addon = new Unicode11Addon();
    terminal.loadAddon(unicode11Addon);
    
    // activate the new version
    terminal.unicode.activeVersion = &#39;11&#39;;

## Versions

### Current Tags

Version  | Downloads (Last 7 Days)  | Tag
--- | --- | ---
0.9.0  | 641,080  | latest
0.10.0-beta.310  | 3,725  | beta

### Version History

Version  | Downloads (Last 7 Days)  | Published
--- | --- | ---
0.10.0-beta.310  | 3,725  | 14 days ago
0.10.0-beta.309  | 208  | 14 days ago
0.10.0-beta.308  | 1  | 14 days ago
0.10.0-beta.307  | 1  | 14 days ago
0.10.0-beta.306  | 1  | 14 days ago
0.10.0-beta.305  | 1  | 14 days ago
0.10.0-beta.304  | 1  | 14 days ago
0.10.0-beta.303  | 2  | 14 days ago
0.10.0-beta.302  | 1  | 14 days ago
0.10.0-beta.301  | 107,202  | 2 months ago
0.10.0-beta.300  | 15,536  | 2 months ago
0.10.0-beta.299  | 1,417  | 3 months ago
0.10.0-beta.298  | 7  | 3 months ago
0.10.0-beta.297  | 0  | 3 months ago
0.10.0-beta.296  | 0  | 3 months ago
0.10.0-beta.295  | 0  | 3 months ago
0.10.0-beta.294  | 0  | 3 months ago
0.10.0-beta.293  | 0  | 3 months ago
0.10.0-beta.292  | 1,224  | 3 months ago
0.10.0-beta.291  | 14,264  | 3 months ago
0.10.0-beta.290  | 180  | 3 months ago
0.10.0-beta.289  | 808  | 3 months ago
0.10.0-beta.288  | 5,927  | 4 months ago
0.10.0-beta.287  | 6,019  | 4 months ago

## Package Sidebar

### Install

`npm i @xterm/addon-unicode11`

### Repository

github.com/xtermjs/xterm.js/tree/master

### Homepage

github.com/xtermjs/xterm.js/tree/master#readme

### Weekly Downloads

871,359

### Version

0.9.0

### License

MIT

### Last publish

14 days ago</excerpt>
</source>
<source kind="search">
<title>@xterm/xterm - npm</title>
<location>https://www.npmjs.com/package/%40xterm/xterm?activeTab=versions</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 2 days ago; The recommended way to load xterm.js is via the ES6 module syntax: ...     npm i -S @xterm/addon-web-links ... 6.1.0-beta.304  | 112,491  | 2 months ago
### Importing

The recommended way to load xterm.js is via the ES6 module syntax:
    
    import { Terminal } from &#39;@xterm/xterm&#39;;

### Addons

⚠️ This section describes the new addon format introduced in v3.14.0, see here for the instructions on the old format

Addons are separate modules that extend the `Terminal` by building on the xterm.js API. To use an addon, you first need to install it in your project:
    
    npm i -S @xterm/addon-web-links

Then import the addon, instantiate it and call `Terminal.loadAddon`:
    
    import { Terminal } from &#39;@xterm/xterm&#39;;
    import { WebLinksAddon } from &#39;@xterm/addon-web-links&#39;;
    
    const terminal = new Terminal();
    // Load WebLinksAddon on terminal, this is all that&#39;s needed to get web links
    // working in the terminal.
    terminal.loadAddon(new WebLinksAddon());

The xterm.js team maintains the following addons, but anyone can build them:

  * `@xterm/addon-attach`: Attaches to a server running a process via a websocket
  * `@xterm/addon-clipboard`: Access the browser&#39;s clipboard
  * `@xterm/addon-fit`: Fits the terminal to the containing element
  * `@xterm/addon-image`: Adds image support
  * `@xterm/addon-search`: Adds search functionality
  * `@xterm/addon-serialize`: Serializes the terminal&#39;s buffer to a VT sequences or HTML
  * `@xterm/addon-unicode11`: Updates character widths to their unicode11 values
  * `@xterm/addon-web-links`: Adds web link detection and interaction
  * `@xterm/addon-webgl`: Renders xterm.js using a `canvas` element&#39;s webgl2 context


## Versions

### Current Tags

Version  | Downloads (Last 7 Days)  | Tag
--- | --- | ---
6.0.0  | 2,451,350  | latest
6.1.0-beta.315  | 14,836  | beta


### Version History

Version  | Downloads (Last 7 Days)  | Published
--- | --- | ---
6.1.0-beta.315  | 14,836  | 14 days ago
6.1.0-beta.314  | 218  | 14 days ago
6.1.0-beta.313  | 3  | 14 days ago
6.1.0-beta.312  | 1  | 14 days ago
6.1.0-beta.311  | 1  | 14 days ago
6.1.0-beta.310  | 1  | 14 days ago
6.1.0-beta.309  | 1  | 14 days ago
6.1.0-beta.308  | 0  | 14 days ago
6.1.0-beta.307  | 0  | 14 days ago
6.1.0-beta.306  | 0  | 14 days ago
6.1.0-beta.305  | 2  | 14 days ago
6.1.0-beta.304  | 112,491  | 2 months ago
6.1.0-beta.303  | 21,008  | 2 months ago
6.1.0-beta.302  | 2,001  | 3 months ago
6.1.0-beta.301  | 1  | 3 months ago
6.1.0-beta.300  | 6  | 3 months ago
6.1.0-beta.299  | 0  | 3 months ago
6.1.0-beta.298  | 0  | 3 months ago
6.1.0-beta.297  | 1  | 3 months ago
6.1.0-beta.296  | 16  | 3 months ago
6.1.0-beta.295  | 0  | 3 months ago
6.1.0-beta.294  | 6  | 3 months ago
6.1.0-beta.293  | 0  | 3 months ago
6.1.0-beta.292  | 24,454  | 3 months ago
6.1.0-beta.291  | 17,824  | 3 months ago
6.1.0-beta.290  | 1,948  | 3 months ago
6.1.0-beta.289  | 796  | 3 months ago
6.1.0-beta.288  | 1,459  | 4 months ago
6.1.0-beta.287  | 35,893  | 4 months ago
6.1.0-beta.286  | 0  | 4 months ago
6.1.0-beta.285  | 7,538  | 5 months ago
6.1.0-beta.284  | 0  | 5 months ago
6.1.0-beta.283  | 0  | 5 months ago
6.1.0-beta.282  | 2  | 5 months ago
6.1.0-beta.281  | 0  | 5 months ago
6.1.0-beta.280  | 0  | 5 months ago
6.1.0-beta.279  | 0  | 5 months ago
6.1.0-beta.278  | 0  | 5 months ago
6.1.0-beta.277  | 0  | 5 months ago
6.1.0-beta.276  | 3  | 5 months ago
6.1.0-beta.275  | 0  | 5 months ago
6.1.0-beta.274  | 0  | 5 months ago
6.1.0-beta.273  | 0  | 5 months ago
6.1.0-beta.272  | 0  | 5 months ago
6.1.0-beta.271  | 0  | 5 months ago
6.1.0-beta.270  | 0  | 5 months ago
6.1.0-beta.269  | 0  | 5 months ago
6.1.0-beta.268  | 0  | 5 months ago
6.1.0-beta.267  | 0  | 5 months ago
6.1.0-beta.266  | 0  | 5 months ago
6.1.0-beta.265  | 0  | 5 months ago
6.1.0-beta.264  | 0  | 5 months ago
6.1.0-beta.263  | 0  | 5 months ago
6.1.0-beta.262  | 0  | 5 months ago
6.1.0-beta.261  | 0  | 5 months ago
6.1.0-beta.260  | 0  | 5 months ago
6.1.0-beta.259  | 0  | 5 months ago
6.1.0-beta.258  | 0  | 5 months ago
6.1.0-beta.257  | 7  | 5 months ago
6.1.0-beta.256  | 475  | 5 months ago
6.1.0-beta.255  | 1  | 5 months ago
6.1.0-beta.254  | 0  | 5 months ago
6.1.0-beta.253  | 0  | 5 months ago
6.1.0-beta.94  | 0  | 10 months ago
6.1.0-beta.93  | 0  | 10 months ago
6.1.0-beta.92  | 0  | 10 months ago
6.1.0-beta.91  | 1,269  | 10 months ago
6.1.0-beta.90  | 0  | 10 months ago
6.1.0-beta.89  | 5  | 10 months ago
6.1.0-beta.88  | 0  | 10 months ago
6.1.0-beta.87  | 0  | 10 months ago
6.1.0-beta.86  | 0  | 10 months ago
6.1.0-beta.85  | 0  | 10 months ago
6.1.0-beta.84  | 0  | 10 months ago
6.1.0-beta.83  | 0  | 10 months ago
6.1.0-beta.82  | 0  | 10 months ago
6.1.0-beta.81  | 0  | 10 months ago
6.1.0-beta.80  | 0  | 10 months ago
6.1.0-beta.79  | 0  | 10 months ago
6.1.0-beta.78  | 0  | 10 months ago
6.1.0-beta.77  | 9  | 10 months ago
6.1.0-beta.76  | 0  | 10 months ago
6.1.0-beta.75  | 0  | 10 months ago
6.1.0-beta.74  | 0  | 10 months ago
6.1.0-beta.73  | 0  | 10 months ago
6.1.0-beta.72  | 2  | 10 months ago
6.1.0-beta.71  | 0  | 10 months ago
6.1.0-beta.70  | 0  | 10 months ago
6.1.0-beta.69  | 0  | 10 months ago
6.1.0-beta.68  | 0  | 10 months ago
6.1.0-beta.67  | 0  | 10 months ago
6.1.0-beta.66  | 0  | 10 months ago
6.1.0-beta.65  | 0  | 10 months ago
6.1.0-beta.64  | 0  | 10 months ago
6.1.0-beta.63  | 0  | 10 months ago
6.1.0-beta.62  | 0  | 10 months ago
6.1.0-beta.61  | 0  | 10 months ago
6.1.0-beta.60  | 1  | 10 months ago
6.1.0-beta.59  | 0  | 10 months ago
6.1.0-beta.58  | 0  | 10 months ago
6.1.0-beta.57  | 0  | 10 months ago
6.1.0-beta.56  | 9  | 10 months ago
6.1.0-beta.55  | 0  | 10 months ago
6.1.0-beta.54  | 0  | 10 months ago
6.1.0-beta.53  | 0  | 10 months ago
6.1.0-beta.52  | 0  | 10 months ago
6.1.0-beta.51  | 0  | 10 months ago
6.1.0-beta.50  | 0  | 10 months ago
6.1.0-beta.49  | 0  | 10 months ago
6.1.0-beta.48  | 0  | 10 months ago
6.1.0-beta.47  | 0  | 10 months ago
6.1.0-beta.46  | 0  | 10 months ago
6.1.0-beta.45  | 0  | 10 months ago
6.1.0-beta.44  | 0  | 10 months ago
6.1.0-beta.43  | 0  | 10 months ago
6.1.0-beta.42  | 0  | 10 months ago
6.1.0-beta.41  | 0  | 10 months ago
6.1.0-beta.40  | 1  | 10 months ago
6.1.0-beta.39  | 1  | 10 months ago
6.1.0-beta.38  | 1  | 10 months ago
6.1.0-beta.37  | 1  | 10 months ago
6.1.0-beta.36  | 1  | 10 months ago
6.1.0-beta.35  | 1  | 10 months ago
6.1.0-beta.12  | 1  | 10 months ago
6.1.0-beta.11  | 1  | 10 months ago
6.1.0-beta.10  | 1  | 10 months ago
6.1.0-beta.9  | 1  | 10 months ago
6.1.0-beta.8  | 1  | 10 months ago
6.1.0-beta.7  | 1  | 10 months ago
6.1.0-beta.6  | 1  | 10 months ago
6.1.0-beta.5  | 2  | 10 months ago
6.1.0-beta.4  | 1  | 10 months ago
6.1.0-beta.3  | 1  | 10 months ago
6.1.0-beta.2  | 1  | 10 months ago
6.1.0-beta.1  | 3  | 10 months ago
6.0.0  | 2,451,350  | 10 months ago
5.6.0-beta.143  | 604  | 10 months ago
5.6.0-beta.142  | 0  | 10 months ago
5.6.0-beta.141  | 1  | 10 months ago
5.6.0-beta.140  | 15  | a year ago
5.6.0-beta.139  | 0  | a year ago
5.6.0-beta.138  | 0  | a year ago
5.6.0-beta.137  | 34  | a year ago
5.6.0-beta.136  | 365  | a year ago
5.6.0-beta.135  | 33  | a year ago
5.6.0-beta.134  | 1  | a year ago
5.6.0-beta.133  | 0  | a year ago
5.6.0-beta.132  | 0  | a year ago
5.6.0-beta.131  | 32  | a year ago
5.6.0-beta.130  | 0  | a year ago
5.6.0-beta.129  | 14  | a year ago
5.6.0-beta.128  | 0  | a year ago
5.6.0-beta.127  | 12  | a year ago
5.6.0-beta.126  | 2  | a year ago
5.6.0-beta.125  | 0  | a year ago
5.6.0-beta.124  | 0  | a year ago
5.6.0-beta.123  | 0  | a year ago
5.6.0-beta.122  | 0  | a year ago
5.6.0-beta.121  | 0  | a year ago
5.6.0-beta.120  | 0  | a year ago
5.6.0-beta.119  | 339  | a year ago
</excerpt>
</source>
<source kind="search">
<title>xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则 - AtomGit | GitCode博客</title>
<location>https://blog.gitcode.com/e338a9e8661ecc8f2cc4c37393855ba8.html</location>
<excerpt>citeturn0search1 [wordlim: 200] Published: 4 weeks ago; Crawled: 3 weeks ago; xterm.js 在浏览器中渲染终端文本时,必须精确知道每个字符在等宽栅格中占据的单元格宽度(0、1 或 2 列)。 ... 为此,xterm.js 将&quot;Unicode 版本&quot;抽象为一套可注册、可切换的规则提供者(`IUnicodeVersionProvider`),默认内置 UnicodeV6(版本号 `&#39;6&#39;`),而 @xterm/addon-unicode11 则以官方 Addon 的形式提供 Unicode 11 版本的实现,覆盖从 xterm.js 5.0 开始引入的 `Terminal.unicode` API。
## 基本使用

在创建 `Terminal` 实例后,实例化 `Unicode11Addon` 并通过 `loadAddon` 加载,随后将 `terminal.unicode.activeVersion` 设置为 `&#39;11&#39;` 即可生效(原文档完整示例,可直接运行):
    
    `import { Terminal } from &#39;@xterm/xterm&#39;;
    import { Unicode11Addon } from &#39;@xterm/addon-unicode11&#39;;
    
    const terminal = new Terminal();
    const unicode11Addon = new Unicode11Addon();
    terminal.loadAddon(unicode11Addon);
    
    // activate the new version
    terminal.unicode.activeVersion = &#39;11&#39;;
    `

关键点说明:

  * `loadAddon(unicode11Addon)` 会调用 Addon 的 `activate(terminal)` 方法,由 Addon 内部将 `UnicodeV11` 规则注册到 `terminal.unicode`(详见下文&quot;注册与激活机制&quot;);
  * `activeVersion` 必须在 Addon 加载之后设置。若设置尚未注册的版本,会抛出 `unknown Unicode version &quot;...&quot;` 错误(见 UnicodeService.ts);
  * 如果当前尚未激活任何版本,`register` 会自动把新注册的版本设为激活版本(UnicodeService.ts)。
</excerpt>
</source>
<source kind="search">
<title>@xterm/headless - npm</title>
<location>https://www.npmjs.com/package/%40xterm/headless?activeTab=versions</location>
<excerpt>citeturn0search2 [wordlim: 200] Crawled: 6 days ago; 6.1.0-beta.304  | 156  | 10 days ago

## Versions

### Current Tags

Version  | Downloads (Last 7 Days)  | Tag
--- | --- | ---
6.0.0  | 1,149,013  | latest
6.1.0-beta.313  | 840  | beta

### Version History

Version  | Downloads (Last 7 Days)  | Published
--- | --- | ---
6.1.0-beta.313  | 840  | 9 days ago
6.1.0-beta.312  | 283  | 10 days ago
6.1.0-beta.311  | 132  | 10 days ago
6.1.0-beta.310  | 129  | 10 days ago
6.1.0-beta.309  | 122  | 10 days ago
6.1.0-beta.308  | 125  | 10 days ago
6.1.0-beta.307  | 142  | 10 days ago
6.1.0-beta.306  | 131  | 10 days ago
6.1.0-beta.305  | 138  | 10 days ago
6.1.0-beta.304  | 156  | 10 days ago
6.1.0-beta.303  | 59,525  | 2 months ago
6.1.0-beta.302  | 36,378  | 2 months ago
6.1.0-beta.301  | 895  | 2 months ago
6.1.0-beta.300  | 9  | 2 months ago
6.1.0-beta.299  | 3  | 2 months ago
6.1.0-beta.298  | 2  | 2 months ago
6.1.0-beta.297  | 3  | 2 months ago
</excerpt>
</source>
<source kind="search">
<title>Visual Studio Code : .../node/ptyService.ts | Fossies</title>
<location>https://fossies.org/linux/vscode/src/vs/platform/terminal/node/ptyService.ts</location>
<excerpt>citeturn0search3 [wordlim: 200] Crawled: 6 days ago;      1118     async setUnicodeVersion(version: &#39;6&#39; | &#39;11&#39;): Promise&lt;void&gt; { ...      1141             SerializeAddon = (await import(&#39;@xterm/addon-serialize&#39;)).
</excerpt>
</source>
<omitted_sources count="33">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://www.npmjs.com/package/%40xterm/addon-unicode11?activeTab=versions&utm_source=openai
- 2: https://www.npmjs.com/package/%40xterm/addon-unicode11?activeTab=versions&utm_source=openai

Web query:

site:github.com/xtermjs/xterm.js/blob/6.1.0-beta.304 UnicodeService.ts activeVersion unknown Unicode version

Result:

<source_evidence>
<source kind="search">
<title>xterm.js/src/common/CoreTerminal.ts at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/src/common/CoreTerminal.ts</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 4 weeks ago; # CoreTerminal.ts ... * Copyright (c) 2014-2020 The xterm.js authors. ... * Copyright (c) 2011 Fabrice Bellard ... this.unicodeService.register(new UnicodeV6());

# CoreTerminal.ts

# CoreTerminal.ts

Copy path

Top

## File metadata and controls

  * Code

  * Blame

307 lines (270 loc) · 13.6 KB

/**

* Copyright (c) 2014-2020 The xterm.js authors. All rights reserved.

* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)

* @license MIT

*

* Originally forked from (with the author&#39;s permission):

* Fabrice Bellard&#39;s javascript vt100 for jslinux:

* http://bellard.org/jslinux/

* Copyright (c) 2011 Fabrice Bellard

* The original design remains. The terminal itself

* has been extended to include xterm CSI codes, among

* other features.

*

* Terminal Emulation References:

* http://vt100.net/

* http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt

* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html

* http://invisible-island.net/vttest/

* http://www.inwap.com/pdp10/ansicode.txt

* http://linux.die.net/man/4/console_codes

* http://linux.die.net/man/7/urxvt

*/

import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, IMouseStateService, IUnicodeService, LogLevelEnum, IOscLinkService } from &#39;./services/Services&#39;;

import { InstantiationService } from &#39;./services/InstantiationService&#39;;

import { LogService } from &#39;./services/LogService&#39;;

import { BufferService, BufferServiceConstants } from &#39;./services/BufferService&#39;;

import { OptionsService } from &#39;./services/OptionsService&#39;;

import { IDisposable, IScrollEvent, ITerminalOptions, IParams } from &#39;./Types&#39;;

import { IAttributeData, IBufferSet } from &#39;./buffer/Types&#39;;

import { CoreService } from &#39;./services/CoreService&#39;;

import { MouseStateService } from &#39;./services/MouseStateService&#39;;

import { UnicodeV6 } from &#39;./input/UnicodeV6&#39;;

import { UnicodeService } from &#39;./services/UnicodeService&#39;;

import { CharsetService } from &#39;./services/CharsetService&#39;;

import { updateWindowsModeWrappedState } from &#39;./WindowsMode&#39;;

import { IFunctionIdentifier } from &#39;./parser/Types&#39;;

import { InputHandler } from &#39;./InputHandler&#39;;

import { WriteBuffer } from &#39;./input/WriteBuffer&#39;;

import { OscLinkService } from &#39;./services/OscLinkService&#39;;

import { Emitter, EventUtils, type IEvent } from &#39;./Event&#39;;

import { Disposable, MutableDisposable, toDisposable } from &#39;./Lifecycle&#39;;

// Only trigger this warning a single time per session

let hasWriteSyncWarnHappened = false;

export interface ICoreTerminal {

mouseStateService: IMouseStateService;

coreService: ICoreService;

optionsService: IOptionsService;

unicodeService: IUnicodeService;

buffers: IBufferSet;

options: Required&lt;ITerminalOptions&gt;;

registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) =&gt; boolean | Promise&lt;boolean&gt;): IDisposable;

registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) =&gt; boolean | Promise&lt;boolean&gt;): IDisposable;

registerEscHandler(id: IFunctionIdentifier, callback: () =&gt; boolean | Promise&lt;boolean&gt;): IDisposable;

registerOscHandler(ident: number, callback: (data: string) =&gt; boolean | Promise&lt;boolean&gt;): IDisposable;

registerApcHandler(id: IFunctionIdentifier, callback: (data: string) =&gt; boolean | Promise&lt;boolean&gt;): IDisposable;

}

export abstract class CoreTerminal extends Disposable implements ICoreTerminal {

protected readonly _instantiationService: IInstantiationService;

protected readonly _bufferService: IBufferService;

protected readonly _logService: ILogService;

protected readonly _charsetService: ICharsetService;

protected readonly _oscLinkService: IOscLinkService;

public readonly mouseStateService: IMouseStateService;

public readonly coreService: ICoreService;

public readonly unicodeService: IUnicodeService;

public readonly optionsService: IOptionsService;

protected _inputHandler: InputHandler;

private _writeBuffer: WriteBuffer;

private _windowsWrappingHeuristics = this._register(new MutableDisposable());

private readonly _onBinary = this._register(new Emitter&lt;string&gt;());

public readonly onBinary = this._onBinary.event;

private readonly _onData = this._register(new Emitter&lt;string&gt;());

public readonly onData = this._onData.event;

protected _onLineFeed = this._register(new Emitter&lt;void&gt;());

public readonly onLineFeed = this._onLineFeed.event;

protected readonly _onRender = this._register(new Emitter&lt;{ start: number, end: number }&gt;());

public readonly onRender = this._onRender.event;

private readonly _onResize = this._register(new Emitter&lt;{ cols: number, rows: number }&gt;());


this.optionsService.options[key] = options[key];

}

}

constructor(

options: Partial&lt;ITerminalOptions&gt;

) {

super();

// Setup and initialize services

this._instantiationService = new InstantiationService();

this.optionsService = this._register(new OptionsService(options));

this._instantiationService.setService(IOptionsService, this.optionsService);

this._logService = this._register(this._instantiationService.createInstance(LogService));

this._instantiationService.setService(ILogService, this._logService);

this._bufferService = this._register(this._instantiationService.createInstance(BufferService));

this._instantiationService.setService(IBufferService, this._bufferService);

this.coreService = this._register(this._instantiationService.createInstance(CoreService));

this._instantiationService.setService(ICoreService, this.coreService);

this.mouseStateService = this._register(this._instantiationService.createInstance(MouseStateService));

this._instantiationService.setService(IMouseStateService, this.mouseStateService);

this.unicodeService = this._register(this._instantiationService.createInstance(UnicodeService));

this.unicodeService.register(new UnicodeV6());

this._instantiationService.setService(IUnicodeService, this.unicodeService);

this._charsetService = this._instantiationService.createInstance(CharsetService);

this._instantiationService.setService(ICharsetService, this._charsetService);

</excerpt>
</source>
<source kind="search">
<title>xterm.js/src/common/CoreTerminal.ts at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/src/common/CoreTerminal.ts</location>
<excerpt>citeturn2search0 [wordlim: 200] Crawled: 4 weeks ago; * Copyright (c) 2014-2020 The xterm.js authors. ... import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, IMouseStateService, IUnicodeService, LogLevelEnum, IOscLinkService } from &#39;./services/Services&#39;;

# CoreTerminal.ts

# CoreTerminal.ts

Copy path

Top

## File metadata and controls

  * Code

  * Blame

307 lines (270 loc) · 13.6 KB

/**

* Copyright (c) 2014-2020 The xterm.js authors. All rights reserved.

* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)

* @license MIT

*

* Originally forked from (with the author&#39;s permission):

* Fabrice Bellard&#39;s javascript vt100 for jslinux:

* http://bellard.org/jslinux/

* Copyright (c) 2011 Fabrice Bellard

* The original design remains. The terminal itself

* has been extended to include xterm CSI codes, among

* other features.

*

* Terminal Emulation References:

* http://vt100.net/

* http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt

* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html

* http://invisible-island.net/vttest/

* http://www.inwap.com/pdp10/ansicode.txt

* http://linux.die.net/man/4/console_codes

* http://linux.die.net/man/7/urxvt

*/

import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, IMouseStateService, IUnicodeService, LogLevelEnum, IOscLinkService } from &#39;./services/Services&#39;;

import { InstantiationService } from &#39;./services/InstantiationService&#39;;

import { LogService } from &#39;./services/LogService&#39;;

import { BufferService, BufferServiceConstants } from &#39;./services/BufferService&#39;;

import { OptionsService } from &#39;./services/OptionsService&#39;;

import { IDisposable, IScrollEvent, ITerminalOptions, IParams } from &#39;./Types&#39;;

import { IAttributeData, IBufferSet } from &#39;./buffer/Types&#39;;

import { CoreService } from &#39;./services/CoreService&#39;;

import { MouseStateService } from &#39;./services/MouseStateService&#39;;

import { UnicodeV6 } from &#39;./input/UnicodeV6&#39;;

import { UnicodeService } from &#39;./services/UnicodeService&#39;;

import { CharsetService } from &#39;./services/CharsetService&#39;;

import { updateWindowsModeWrappedState } from &#39;./WindowsMode&#39;;

import { IFunctionIdentifier } from &#39;./parser/Types&#39;;

import { InputHandler } from &#39;./InputHandler&#39;;

</excerpt>
</source>
<source kind="search">
<title>@xterm/xterm - npm</title>
<location>https://www.npmjs.com/package/%40xterm/xterm?activeTab=versions</location>
<excerpt>citeturn2search1 [wordlim: 200] Crawled: 2 days ago; The recommended way to load xterm.js is via the ES6 module syntax: ... 6.1.0-beta.304  | 112,491  | 2 months ago

## Versions

### Current Tags

Version  | Downloads (Last 7 Days)  | Tag
--- | --- | ---
6.0.0  | 2,451,350  | latest
6.1.0-beta.315  | 14,836  | beta


### Version History

Version  | Downloads (Last 7 Days)  | Published
--- | --- | ---
6.1.0-beta.315  | 14,836  | 14 days ago
6.1.0-beta.314  | 218  | 14 days ago
6.1.0-beta.313  | 3  | 14 days ago
6.1.0-beta.312  | 1  | 14 days ago
6.1.0-beta.311  | 1  | 14 days ago
6.1.0-beta.310  | 1  | 14 days ago
6.1.0-beta.309  | 1  | 14 days ago
6.1.0-beta.308  | 0  | 14 days ago
6.1.0-beta.307  | 0  | 14 days ago
6.1.0-beta.306  | 0  | 14 days ago
6.1.0-beta.305  | 2  | 14 days ago
6.1.0-beta.304  | 112,491  | 2 months ago
6.1.0-beta.303  | 21,008  | 2 months ago
6.1.0-beta.302  | 2,001  | 3 months ago
6.1.0-beta.301  | 1  | 3 months ago
6.1.0-beta.300  | 6  | 3 months ago
</excerpt>
</source>
<source kind="search">
<title>xterm.js/addons/addon-unicode-graphemes/README.md at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/addons/addon-unicode-graphemes/README.md</location>
<excerpt>citeturn0search1 [wordlim: 200] Crawled: 2 months ago; An addon providing enhanced Unicode support (include grapheme clustering) for xterm.js.

The file `src/UnicodeProperties.ts` is generated and depends on the Unicode version.

# README.md

Copy path

Top


## @xterm/addon-unicode-graphemes

⚠️ This addon is currently experimental and may introduce unexpected and non-standard behavior

An addon providing enhanced Unicode support (include grapheme clustering) for xterm.js.

The file `src/UnicodeProperties.ts` is generated and depends on the Unicode version. See the unicode-properties project for credits and re-generation instructions.

### Install

This addon is not yet published to npm

### Usage
    
    import { Terminal } from &#39;@xterm/xterm&#39;;
    import { UnicodeGraphemesAddon } from &#39;@xterm/addon-unicode-graphemes&#39;;
    
    const terminal = new Terminal();
    const unicodeGraphemesAddon = new UnicodeGraphemesAddon();
    terminal.loadAddon(unicodeGraphemesAddon);</excerpt>
</source>
<source kind="search">
<title>Unchanged links repeatedly fire leave and hover during unrelated row updates · Issue #6213 · xtermjs/xterm.js · GitHub</title>
<location>GitHub issue 6213 in xtermjs/xterm.js (link omitted to avoid creating a cross-reference)</location>
<excerpt>citeturn0search2 [wordlim: 200] Published: 2 weeks ago; Crawled: 2 days ago;     &lt;script src=&quot;https://cdn.jsdelivr.net/npm/@xterm/[email protected]/lib/xterm.js&quot;&gt;&lt;/script&gt;

# Unchanged links repeatedly fire leave and hover during unrelated row updates #6213

Open

Unchanged links repeatedly fire leave and hover during unrelated row updates#6213

## Description

redblackbst

opened on Oct 11, 2026

Issue body actions

First noticed while using Codex CLI with animations enabled inside tmux in VS Code’s integrated terminal, both locally and over Remote SSH.

Updating unrelated terminal rows repeatedly fires `leave` and `hover` for an unchanged hovered link. This cancels a delayed tooltip before it can appear.

## Details

  * Browser: Microsoft Edge 155.0.4283.45 (headless validation)
  * VS Code: 1.141.0 (Electron `43.7.7`, Chromium `150.0.7871.250`)
  * OS: Arch Linux x86_64, kernel `7.2.9-arch1-1`
  * xterm.js: 6.1.0-beta.304
  * Terminal: 80 columns, 14 rows; fixed-provider and native OSC 8 links

### Steps to reproduce

  1. Save the HTML below as `xterm-repro.html`.
  2. Serve its directory with `python3 -m http.server 8000 --bind 127.0.0.1` and open `http://127.0.0.1:8000/xterm-repro.html`.
</excerpt>
</source>
<omitted_sources count="19">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://github.com/xtermjs/xterm.js/blob/master/src/common/CoreTerminal.ts?utm_source=openai
- 2: https://www.npmjs.com/package/%40xterm/xterm?activeTab=versions&utm_source=openai

Script executed:

set -eu
url='https://raw.githubusercontent.com/xtermjs/xterm.js/6.1.0-beta.304/src/common/services/UnicodeService.ts'
curl -fsSL "$url" | nl -ba | sed -n '1,180p']

Repository: stablyai/orca

Length of output: 262


Script executed:

set -eu
url='https://registry.npmjs.org/@xterm/xterm/-/xterm-6.1.0-beta.304.tgz'
members=$(curl -fsSL "$url" | tar -tzf - | grep -E '(^|/)(UnicodeService|unicodeService)[^/]*\.(js|mjs|cjs|ts)$' || true)
printf '%s\n' "$members"
for member in $members; do
  printf '%s\n' "--- $member ---"
  curl -fsSL "$url" | tar -xOzf - "$member" | nl -ba | grep -C 8 -E 'activeVersion|unknown Unicode|register'
done

Repository: stablyai/orca

Length of output: 1309


Load Unicode11Addon before activating the preview provider.

The preview does not register Unicode version 11. activateOrcaTerminalUnicodeProvider(terminal) then selects that version, and xterm throws unknown Unicode version "11" before the preview can render. Load Unicode11Addon before this call, as the live terminal path does.

[0x2776, 0x277f],
[0x2b56, 0x2b59],
[0x3248, 0x324f],
[0xe000, 0xf8ff],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

Exclude BMP private-use characters from wide mode.

When wide mode is enabled, this range makes single-cell private-use icons such as Powerline glyphs occupy two cells. Shell prompts and TUI decorations can then lose alignment. Remove this range from AMBIGUOUS_RANGES and test a private-use icon in both modes. The PR objective explicitly requires these icons to stay single-cell, even though Unicode classifies the range as Ambiguous. (unicode.org)

Comment on lines +87 to +88
if (desiredWidth !== extractWidth(base)) {
return createProperties(extractCharKind(base), desiredWidth, (base & 1) === 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

Supported by static analysis

Script executed:

set -eu
printf '%s\n' '--- changed file at head ---'
git diff --no-ext-diff --unified=80 401468bac7c5d1363c18c359ca3ce577e1c30443 bd9f9d28bf796e4e222992d7a1f750b7262cd2f9 -- src/shared/terminal-unicode-provider.ts
printf '%s\n' '--- package declarations and lock references ---'
rg -n -F --glob 'package.json' --glob 'pnpm-lock.yaml' -e '@xterm/xterm' -e '@xterm/addon-unicode11' .
printf '%s\n' '--- repository Unicode implementation references ---'
rg -n -F --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' -e 'charProperties' -e 'UnicodeV11' -e 'getStringCellWidth' -e 'wcwidth' src config package.json pnpm-lock.yaml || test "$?" -eq 1
printf '%s\n' '--- provider tests ---'
rg -n -F --glob '*test*' -e 'terminal-unicode-provider' -e 'combining' -e 'e\u0301' -e 'wide' src/shared src/renderer/src || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 45659


Web query:

@xterm/xterm 6.1.0-beta.304 UnicodeV11 charProperties combining mark inherited width

Result:

<source_evidence>
<source kind="search">
<title>IUnicodeVersionProvider</title>
<location>https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 6 months ago; Defined in xterm.d.ts:1875 ... ▸ charProperties(`codepoint`: number, `preceding`: number): number ... Unicode version dependent wcwidth implementation.
# Interface: IUnicodeVersionProvider

(EXPERIMENTAL) Unicode version provider. Used to register custom Unicode versions with `Terminal.unicode.register`.

## Hierarchy

  * IUnicodeVersionProvider

## Index

### Properties

  * version

### Methods

  * charProperties
  * wcwidth

## Properties

### `Readonly` version

• version: string

Defined in xterm.d.ts:1875

String indicating the Unicode version provided.

## Methods

### charProperties

▸ charProperties(`codepoint`: number, `preceding`: number): number

Defined in xterm.d.ts:1881

Parameters:

Name  | Type
--- | ---
`codepoint`  | number
`preceding`  | number

Returns: number


### wcwidth

▸ wcwidth(`codepoint`: number): *0  | 1  | 2*

Defined in xterm.d.ts:1880

Unicode version dependent wcwidth implementation.

Parameters:

Name  | Type
--- | ---
`codepoint`  | number
Returns: *0  | 1  | 2*</excerpt>
</source>
<source kind="search">
<title>IUnicodeVersionProvider</title>
<location>https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/</location>
<excerpt>citeturn1search0 [wordlim: 200] Crawled: 6 months ago;   * charProperties ... Defined in xterm.d.ts:1881
# Interface: IUnicodeVersionProvider

(EXPERIMENTAL) Unicode version provider. Used to register custom Unicode versions with `Terminal.unicode.register`.

## Hierarchy

  * IUnicodeVersionProvider

## Index

### Properties

  * version

### Methods

  * charProperties
  * wcwidth

## Properties

### `Readonly` version

• version: string

Defined in xterm.d.ts:1875

String indicating the Unicode version provided.

## Methods

### charProperties

▸ charProperties(`codepoint`: number, `preceding`: number): number

Defined in xterm.d.ts:1881

Parameters:

Name  | Type
--- | ---
`codepoint`  | number
`preceding`  | number

Returns: number


### wcwidth

▸ wcwidth(`codepoint`: number): *0  | 1  | 2*

Defined in xterm.d.ts:1880

Unicode version dependent wcwidth implementation.

Parameters:

Name  | Type
--- | ---
`codepoint`  | number
Returns: *0  | 1  | 2*</excerpt>
</source>
<source kind="search">
<title>xterm.js/addons/addon-unicode11/README.md at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/addons/addon-unicode11/README.md</location>
<excerpt>citeturn1search1 [wordlim: 200] Crawled: 2 months ago; An addon providing Unicode version 11 rules for xterm.js.

# README.md

Copy path


# README.md

Copy path

Top


## @xterm/addon-unicode11

An addon providing Unicode version 11 rules for xterm.js.

### Install
    
    npm install --save @xterm/addon-unicode11

### Usage
    
    import { Terminal } from &#39;@xterm/xterm&#39;;
    import { Unicode11Addon } from &#39;@xterm/addon-unicode11&#39;;
    
    const terminal = new Terminal();
    const unicode11Addon = new Unicode11Addon();
    terminal.loadAddon(unicode11Addon);
    
    // activate the new version
    terminal.unicode.activeVersion = &#39;11&#39;;
</excerpt>
</source>
<source kind="search">
<title>xterm.js/typings/xterm.d.ts at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts</location>
<excerpt>citeturn0search1 [wordlim: 200] Crawled: yesterday; * This contains the type declarations for the xterm.js library. ... * src/, that&#39;s because this file declares the *public* API which is intended ... * A string containing all characters that are considered word separated by ... * [0]: https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md ... * Resize the text area to given height and width in characters. ... /** Ps=11 Report xterm window state.

*/

export class Terminal implements IDisposable {

/**

* The element containing the terminal.

*/

readonly element: HTMLElement | undefined;

/**

* The screen element containing the terminal&#39;s canvas rendering layers and

* decorations, excluding the viewport and the scrollbar.

*/

readonly screenElement: HTMLElement | undefined;

/**

* The textarea that accepts input for the terminal.

*/

readonly textarea: HTMLTextAreaElement | undefined;

/**

* The number of rows in the terminal&#39;s viewport. Use

* `ITerminalOptions.rows` to set this in the constructor and

* `Terminal.resize` for when the terminal exists.

*/

readonly rows: number;

/**

* The number of columns in the terminal&#39;s viewport. Use

* `ITerminalOptions.cols` to set this in the constructor and

* `Terminal.resize` for when the terminal exists.

*/

readonly cols: number;

/**

* Access to the terminal&#39;s normal and alt buffer.

*/

readonly buffer: IBufferNamespace;

/**

* Get all markers registered against the buffer. If the alt buffer is

* active this will always return [].

*/

readonly markers: ReadonlyArray&lt;IMarker&gt;;

/**

* Get the parser interface to register custom escape sequence handlers.

*/

readonly parser: IParser;

/**

* (EXPERIMENTAL) Get the Unicode handling interface to register and switch

* Unicode version.

*/

readonly unicode: IUnicodeHandling;

/**

* Gets the terminal modes as set by SM/DECSET.

*/

readonly modes: IModes;

/**

* The dimensions of the terminal. This will be undefined before

* {@link open} is called.

*/

readonly dimensions: IRenderDimensions | undefined;

/**

* Gets or sets the terminal options. This supports setting multiple

* options.

*

* @example Get a single option

* ```ts

* console.log(terminal.options.fontSize);

* ```

*

* @example Set a single option:

* ```ts

* terminal.options.fontSize = 12;
</excerpt>
</source>
<source kind="search">
<title>@xterm/xterm - npm</title>
<location>https://www.npmjs.com/package/%40xterm/xterm?activeTab=versions</location>
<excerpt>citeturn0search2 [wordlim: 200] Crawled: 2 days ago; Version  | Downloads (Last 7 Days)  | Tag

## Versions

### Current Tags

Version  | Downloads (Last 7 Days)  | Tag
--- | --- | ---
6.0.0  | 2,451,350  | latest
6.1.0-beta.315  | 14,836  | beta


### Version History

Version  | Downloads (Last 7 Days)  | Published
--- | --- | ---
6.1.0-beta.315  | 14,836  | 14 days ago
6.1.0-beta.314  | 218  | 14 days ago
6.1.0-beta.313  | 3  | 14 days ago
6.1.0-beta.312  | 1  | 14 days ago
6.1.0-beta.311  | 1  | 14 days ago
6.1.0-beta.310  | 1  | 14 days ago
6.1.0-beta.309  | 1  | 14 days ago
6.1.0-beta.308  | 0  | 14 days ago
6.1.0-beta.307  | 0  | 14 days ago
6.1.0-beta.306  | 0  | 14 days ago
6.1.0-beta.305  | 2  | 14 days ago
6.1.0-beta.304  | 112,491  | 2 months ago
6.1.0-beta.303  | 21,008  | 2 months ago
6.1.0-beta.302  | 2,001  | 3 months ago
6.1.0-beta.301  | 1  | 3 months ago
6.1.0-beta.300  | 6  | 3 months ago
</excerpt>
</source>
<omitted_sources count="33">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/?utm_source=openai
- 2: https://github.com/xtermjs/xterm.js/blob/master/addons/addon-unicode11/README.md?utm_source=openai

Script executed:

set -eu
printf '%s\n' '--- provider with line numbers ---'
nl -ba src/shared/terminal-unicode-provider.ts | sed -n '1,130p'
printf '%s\n' '--- relevant package and lock excerpts ---'
nl -ba package.json | sed -n '288,308p'
nl -ba pnpm-lock.yaml | sed -n '400,432p'
printf '%s\n' '--- focused Unicode/provider tests ---'
find src/shared -maxdepth 1 -type f \\( -name '*unicode*test*' -o -name '*ambiguous*test*' \\) -print
rg -n -F --glob 'src/shared/*test*' -e 'charProperties' -e 'combining' -e 'e\\u0301' -e 'ZWJ' -e 'wcwidth' -e 'ambiguous' src/shared || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 8373


Web query:

raw xtermjs xterm.js 6.1.0-beta.304 addons/addon-unicode11/src/UnicodeV11.ts charProperties preceding combining mark

Result:

<source_evidence>
<source kind="search">
<title>IUnicodeVersionProvider</title>
<location>https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/</location>
<excerpt>citeturn0search2 [wordlim: 200] Crawled: 6 months ago;   * charProperties ... Defined in xterm.d.ts:1875
# Interface: IUnicodeVersionProvider

(EXPERIMENTAL) Unicode version provider. Used to register custom Unicode versions with `Terminal.unicode.register`.

## Hierarchy

  * IUnicodeVersionProvider

## Index

### Properties

  * version

### Methods

  * charProperties
  * wcwidth

## Properties

### `Readonly` version

• version: string

Defined in xterm.d.ts:1875

String indicating the Unicode version provided.

## Methods

### charProperties

▸ charProperties(`codepoint`: number, `preceding`: number): number

Defined in xterm.d.ts:1881

Parameters:

Name  | Type
--- | ---
`codepoint`  | number
`preceding`  | number

Returns: number


### wcwidth

▸ wcwidth(`codepoint`: number): *0  | 1  | 2*

Defined in xterm.d.ts:1880

Unicode version dependent wcwidth implementation.

Parameters:

Name  | Type
--- | ---
`codepoint`  | number
Returns: *0  | 1  | 2*</excerpt>
</source>
<source kind="search">
<title>xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则 - AtomGit | GitCode博客</title>
<location>https://blog.gitcode.com/e338a9e8661ecc8f2cc4c37393855ba8.html</location>
<excerpt>citeturn0search5 [wordlim: 200] Published: 4 weeks ago; Crawled: 3 weeks ago; 真正的 Unicode 11 规则逻辑全部集中在 UnicodeV11 中,它实现了 `IUnicodeVersionProvider`(接口见 typings/xterm.d.ts),即必须提供 `version`、`wcwidth(codepoint)` 与 `charProperties(codepoint, preceding)` 三个成员。
# xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则

原创2026-09-30 15:57:17 777 阅读

文章标签:前端UI组件

# xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则

本指南围绕 xterm.js 官方 Unicode 版本扩展 addons/addon-unicode11 展开,讲解如何安装、加载并激活 Unicode 11 字符宽度规则,并结合仓库源码剖析其 `wcwidth` 实现、查找表结构与注册机制。读完本文,你将掌握在 xterm.js 应用中切换 Unicode 版本以正确处理 emoji 等宽字符的完整方案,并能读懂该 Addon 与 `UnicodeService` 之间的底层协作关系。

## 为什么 xterm.js 需要&quot;Unicode 版本规则&quot;

xterm.js 在浏览器中渲染终端文本时,必须精确知道每个字符在等宽栅格中占据的单元格宽度(0、1 或 2 列)。这个宽度判断直接决定光标移动、行包裹、删除与选中高亮是否正确。Unicode 标准从 6.0 到 11.0 之间,大量字符的 East Asian Width(东亚宽度)和组合字符(combining character)属性发生了变化——最典型的就是 emoji 从&quot;单列&quot;演进为&quot;双列&quot;。

为此,xterm.js 将&quot;Unicode 版本&quot;抽象为一套可注册、可切换的规则提供者(`IUnicodeVersionProvider`),默认内置 UnicodeV6(版本号 `&#39;6&#39;`),而 @xterm/addon-unicode11 则以官方 Addon 的形式提供 Unicode 11 版本的实现,覆盖从 xterm.js 5.0 开始引入的 `Terminal.unicode` API。

## 安装

该 Addon 作为独立 npm 包发布(当前仓库内版本为 0.9.0,见 package.json),通过 npm 安装:
    
    `npm install --save @xterm/addon-unicode11
    `

它属于运行时(runtime)依赖,依赖宿主包 `@xterm/xterm` 提供的 `Terminal` 与 `ITerminalAddon` 类型。仓库内的 demo/client/tsconfig.json 展示了如何在 demo 项目中通过路径映射将 `@xterm/addon-unicode11` 指向本仓库源码目录进行联调:
    
    `&quot;@xterm/addon-unicode11&quot;: [
      &quot;../../addons/addon-unicode11&quot;
    ]
    `

  2. ASCII 可打印字符(32–126):宽度为 1;
  3. BMP 区(码点 &lt; 65536,即 `0xFFFF` 以内):直接查懒加载的 `Uint8Array` 查找表 `table`;
  4. BMP 之外(增补平面):先用二分查找 `bisearch` 匹配 `HIGH_COMBINING`(宽度 0),再匹配 `HIGH_WIDE`(宽度 2),否则为 1。

`bisearch`(UnicodeV11.ts)是对已排序的&quot;起始码点/结束码点&quot;区间数组做标准二分查找,复杂度为 O(log n),不会遍历整张表。

### 三张静态区间表 + 一张查找表

文件顶部定义了四组数据(UnicodeV11.ts):

  * `BMP_COMBINING`:BMP 内的组合字符区间,例如 `[0x0300, 0x036F]`(拉丁文附加符号)、`[0x1160, 0x11FF]`(谚文韵母)、`[0x20D0, 0x20F0]`(组合用符号);
  * `HIGH_COMBINING`:增补平面上的组合字符区间,例如 `[0x1D167, 0x1D169]`(音乐符号)、`[0xE0100, 0xE01EF]`(变体选择符补充区)、`[0x13430, 0x13438]`(埃及象形文字格式化控制符);
  * `BMP_WIDE`:BMP 内的宽字符区间,覆盖全部 CJK 统一表意文字 `[0x4E00, 0xA48C]`、谚文音节 `[0xAC00, 0xD7A3]` 等;
  * `HIGH_WIDE`:增补平面上的宽字符区间,重点是 emoji:`[0x1F300, 0x1F320]`、`[0x1F337, 0x1F37C]`、`[0x1F680, 0x1F6C5]`、`[0x1F90D, 0x1F971]`,以及 CJK 扩展 B/C/D `[0x20000, 0x2FFFD]`、`[0x30000, 0x3FFFD]`。

`BMP_COMBINING` 与 `BMP_WIDE` 会在首次加载 Addon 时被&quot;编译&quot;进一个 65536 项的 `Uint8Array` 查找表(UnicodeV11.ts):先整体填充 1,控制字符区间填 0,再按 `BMP_COMBINING` 填 0、按 `BMP_WIDE` 填 2。查找表在模块级缓存(`let table: Uint8Array`),因此多个终端实例共享同一份表,只初始化一次。

### `charProperties`:组合字符如何&quot;并入&quot;前一个字符

为了在等宽网格中正确呈现组合字符,`UnicodeV11` 还实现了 `charProperties`(UnicodeV11.ts):当当前码点宽度为 0 且存在前一个字符时,标记&quot;需要并入&quot;(`shouldJoin`),并将宽度继承为前一个字符的宽度;若前一个字符本身宽度为 0,则不并入。最终通过 `UnicodeService.createPropertyValue` 打包成包含宽度与并入标志的属性值,供行渲染与光标推进使用。

</excerpt>
</source>
<source kind="search">
<title>IUnicodeVersionProvider</title>
<location>https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/</location>
<excerpt>citeturn2search0 [wordlim: 200] Crawled: 6 months ago; Defined in xterm.d.ts:1875 ... ▸ charProperties(`codepoint`: number, `preceding`: number): number
# Interface: IUnicodeVersionProvider

(EXPERIMENTAL) Unicode version provider. Used to register custom Unicode versions with `Terminal.unicode.register`.

## Hierarchy

  * IUnicodeVersionProvider

## Index

### Properties

  * version

### Methods

  * charProperties
  * wcwidth

## Properties

### `Readonly` version

• version: string

Defined in xterm.d.ts:1875

String indicating the Unicode version provided.

## Methods

### charProperties

▸ charProperties(`codepoint`: number, `preceding`: number): number

Defined in xterm.d.ts:1881

Parameters:

Name  | Type
--- | ---
`codepoint`  | number
`preceding`  | number

Returns: number


### wcwidth

▸ wcwidth(`codepoint`: number): *0  | 1  | 2*

Defined in xterm.d.ts:1880

Unicode version dependent wcwidth implementation.

Parameters:

Name  | Type
--- | ---
`codepoint`  | number
Returns: *0  | 1  | 2*</excerpt>
</source>
<source kind="search">
<title>xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则 - AtomGit | GitCode博客</title>
<location>https://blog.gitcode.com/e338a9e8661ecc8f2cc4c37393855ba8.html</location>
<excerpt>citeturn2search6 [wordlim: 200] Published: 4 weeks ago; Crawled: 3 weeks ago; 真正的 Unicode 11 规则逻辑全部集中在 UnicodeV11 中,它实现了 `IUnicodeVersionProvider`(接口见 typings/xterm.d.ts),即必须提供 `version`、`wcwidth(codepoint)` 与 `charProperties(codepoint, preceding)` 三个成员。
# xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则

原创2026-09-30 15:57:17 777 阅读

文章标签:前端UI组件

# xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则

本指南围绕 xterm.js 官方 Unicode 版本扩展 addons/addon-unicode11 展开,讲解如何安装、加载并激活 Unicode 11 字符宽度规则,并结合仓库源码剖析其 `wcwidth` 实现、查找表结构与注册机制。读完本文,你将掌握在 xterm.js 应用中切换 Unicode 版本以正确处理 emoji 等宽字符的完整方案,并能读懂该 Addon 与 `UnicodeService` 之间的底层协作关系。

## 为什么 xterm.js 需要&quot;Unicode 版本规则&quot;

xterm.js 在浏览器中渲染终端文本时,必须精确知道每个字符在等宽栅格中占据的单元格宽度(0、1 或 2 列)。这个宽度判断直接决定光标移动、行包裹、删除与选中高亮是否正确。Unicode 标准从 6.0 到 11.0 之间,大量字符的 East Asian Width(东亚宽度)和组合字符(combining character)属性发生了变化——最典型的就是 emoji 从&quot;单列&quot;演进为&quot;双列&quot;。

为此,xterm.js 将&quot;Unicode 版本&quot;抽象为一套可注册、可切换的规则提供者(`IUnicodeVersionProvider`),默认内置 UnicodeV6(版本号 `&#39;6&#39;`),而 @xterm/addon-unicode11 则以官方 Addon 的形式提供 Unicode 11 版本的实现,覆盖从 xterm.js 5.0 开始引入的 `Terminal.unicode` API。

## 安装

该 Addon 作为独立 npm 包发布(当前仓库内版本为 0.9.0,见 package.json),通过 npm 安装:
    
    `npm install --save @xterm/addon-unicode11
    `

它属于运行时(runtime)依赖,依赖宿主包 `@xterm/xterm` 提供的 `Terminal` 与 `ITerminalAddon` 类型。仓库内的 demo/client/tsconfig.json 展示了如何在 demo 项目中通过路径映射将 `@xterm/addon-unicode11` 指向本仓库源码目录进行联调:
    
    `&quot;@xterm/addon-unicode11&quot;: [
      &quot;../../addons/addon-unicode11&quot;
    ]
    `

      public activate(terminal: Terminal): void {
        terminal.unicode.register(new UnicodeV11());
      }
      public dispose(): void { }
    }
    `

真正的 Unicode 11 规则逻辑全部集中在 UnicodeV11 中,它实现了 `IUnicodeVersionProvider`(接口见 typings/xterm.d.ts),即必须提供 `version`、`wcwidth(codepoint)` 与 `charProperties(codepoint, preceding)` 三个成员。

### `wcwidth`:三种宽度的判定流程

`UnicodeV11.wcwidth` 是核心方法,输入一个 Unicode 码点,输出 0(组合字符/控制字符)、1(单列)或 2(双列):
    
    `public wcwidth(num: number): UnicodeCharWidth {
      if (num &lt; 32) return 0;
      if (num &lt; 127) return 1;
      if (num &lt; 65536) return table[num] as UnicodeCharWidth;
      if (bisearch(num, HIGH_COMBINING)) return 0;
      if (bisearch(num, HIGH_WIDE)) return 2;
      return 1;
    }
    `

其判定层次为:

  1. ASCII 控制字符(0–31):宽度为 0;
  * `BMP_WIDE`:BMP 内的宽字符区间,覆盖全部 CJK 统一表意文字 `[0x4E00, 0xA48C]`、谚文音节 `[0xAC00, 0xD7A3]` 等;
  * `HIGH_WIDE`:增补平面上的宽字符区间,重点是 emoji:`[0x1F300, 0x1F320]`、`[0x1F337, 0x1F37C]`、`[0x1F680, 0x1F6C5]`、`[0x1F90D, 0x1F971]`,以及 CJK 扩展 B/C/D `[0x20000, 0x2FFFD]`、`[0x30000, 0x3FFFD]`。

`BMP_COMBINING` 与 `BMP_WIDE` 会在首次加载 Addon 时被&quot;编译&quot;进一个 65536 项的 `Uint8Array` 查找表(UnicodeV11.ts):先整体填充 1,控制字符区间填 0,再按 `BMP_COMBINING` 填 0、按 `BMP_WIDE` 填 2。查找表在模块级缓存(`let table: Uint8Array`),因此多个终端实例共享同一份表,只初始化一次。

### `charProperties`:组合字符如何&quot;并入&quot;前一个字符

为了在等宽网格中正确呈现组合字符,`UnicodeV11` 还实现了 `charProperties`(UnicodeV11.ts):当当前码点宽度为 0 且存在前一个字符时,标记&quot;需要并入&quot;(`shouldJoin`),并将宽度继承为前一个字符的宽度;若前一个字符本身宽度为 0,则不并入。最终通过 `UnicodeService.createPropertyValue` 打包成包含宽度与并入标志的属性值,供行渲染与光标推进使用。


## 底层机制:`UnicodeService` 与 `getStringCellWidth`

`activeVersion` 的赋值最终进入核心层的 UnicodeService:设置前校验版本是否已注册,然后更新 `_activeProvider` 并触发 `onChange` 事件。此后所有宽度计算都路由到当前激活的 provider:
    
    `public set activeVersion(version: string) {
      if (!this._providers[version]) {
        throw new Error(`unknown Unicode version &quot;${version}&quot;`);
      }
      this._active = version;
      this._activeProvider = this._providers[version];
      this._onChange.fire(version);
    }
    `

UnicodeService 还提供 `getStringCellWidth(s)`(UnicodeService.ts),它对整段字符串逐字符计算总宽度:正确处理 UTF-16 代理对(surrogate pair)合并为增补平面码点、组合字符并入前驱宽度、以及将&quot;并入差值&quot;从总宽度中扣除。这是终端行缓冲、光标定位与文本测量都依赖的核心口径——`Unicode11Addon` 测试也正是通过 `window.term._core.unicodeService.getStringCellWidth(&#39;🤣&#39;.repeat(10))` 来断言宽度结果的。

## 在 demo 应用中的真实接入方式

仓库自带的 demo 客户端 demo/client/client.ts 提供了可交互的验证入口:它在 Addon 集合中注册了 `unicode11`(构造器指向 `Unicode11Addon`,见 demo/client/client.ts),并在界面上勾选该 Addon 时执行:
    
    `if (name === &#39;unicode11&#39; &amp;&amp; checkbox.checked) {
      term.unicode.activeVersion = &#39;11&#39;;
    }
    `

而取消勾选时则回退到默认版本(demo/client/client.ts):
    
    `} else if (name === &#39;unicode11&#39; || name === &#39;unicodeGraphemes&#39;) {
      term.unicode.activeVersion = &#39;6&#39;;
    }
    `

你可以运行 demo(仓库脚本 `npm start` 会启动 demo/start.js)来直观对比同一串 emoji 在 `&#39;6&#39;` 与 `&#39;11&#39;` 两种规则下的渲染宽度差异。

## 注意事项与延伸阅读

  * 接口为实验性:`IUnicodeVersionProvider` 与 `IUnicodeHandling` 在 typings/xterm.d.ts 中均标注为 `(EXPERIMENTAL)`,后续版本可能存在 API 调整;
  * 与 grapheme 插件的关系:若需要按字素簇(grapheme cluster,如带肤色修饰符的 emoji)进一步合并字符,可配合 addon-unicode-graphemes 使用(其激活版本号为 `&#39;15-graphemes&#39;`,demo 中的切换逻辑见 demo/client/client.ts);
  * 字体依赖:Unicode 11 宽度规则只解决&quot;网格占用列数&quot;问题,实际渲染效果仍取决于终端所用字体是否包含对应字形(emoji 需要 emoji 字体支持);
  * 版本含义:`version = &#39;11&#39;` 对应 Unicode 11.0 标准的 East Asian Width 与组合字符属性表(源自 Unicode 官方 UCD 数据,仓库内以区间常量形式固化在 UnicodeV11.ts)。

总之,`@xterm/addon-unicode11` 是让 xterm.js 应用跟上现代 Unicode 宽度语义的最直接手段:安装、加载、切换 `activeVersion` 三步即可生效,而其背后的区间表、查找表与代理对处理逻辑,也为理解终端文本测宽机制提供了完整的可读源码范例。</excerpt>
</source>
<source kind="search">
<title>xterm.js/addons/addon-unicode-graphemes/README.md at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/addons/addon-unicode-graphemes/README.md</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 2 months ago; An addon providing enhanced Unicode support (include grapheme clustering) for xterm.js.

The file `src/UnicodeProperties.ts` is generated and depends on the Unicode version.

# README.md

Copy path

Top


## @xterm/addon-unicode-graphemes

⚠️ This addon is currently experimental and may introduce unexpected and non-standard behavior

An addon providing enhanced Unicode support (include grapheme clustering) for xterm.js.

The file `src/UnicodeProperties.ts` is generated and depends on the Unicode version. See the unicode-properties project for credits and re-generation instructions.

### Install

This addon is not yet published to npm

### Usage
    
    import { Terminal } from &#39;@xterm/xterm&#39;;
    import { UnicodeGraphemesAddon } from &#39;@xterm/addon-unicode-graphemes&#39;;
    
    const terminal = new Terminal();
    const unicodeGraphemesAddon = new UnicodeGraphemesAddon();
    terminal.loadAddon(unicodeGraphemesAddon);</excerpt>
</source>
<omitted_sources count="22">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://blog.gitcode.com/e338a9e8661ecc8f2cc4c37393855ba8.html?utm_source=openai
- 2: https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/?utm_source=openai

Script executed:

set -eu
url='https://raw.githubusercontent.com/xtermjs/xterm.js/6.1.0-beta.304/addons/addon-unicode11/src/UnicodeV11.ts'
tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT
curl -fsSL "$url" -o "$tmp"
printf '%s\n' "--- $url ---"
rg -n -C 12 -F -e 'charProperties' -e 'preceding' -e 'shouldJoin' "$tmp"

Repository: stablyai/orca

Length of output: 202


Script executed:

set -eu
base='https://unpkg.com/@xterm/[email protected]'
for path in lib/UnicodeV11.js lib/addon-unicode11.js; do
  url="$base/$path"
  printf '%s\n' "--- $url ---"
  if curl -fsSL "$url" | rg -n -C 14 -F -e 'charProperties' -e 'preceding' -e 'shouldJoin'; then
    exit 0
  fi
done
exit 1

Repository: stablyai/orca

Length of output: 11564


Preserve the inherited width of combining marks.

For e\u0301, Unicode11 returns the combining mark with the preceding cell width and the join flag. This branch changes that width to zero whenever the raw width differs, including in narrow mode. getStringCellWidth('e\u0301X') can then subtract the preceding width twice and misplace X.

Rewrite packed properties only for the intended base-width-one to wide expansion.

Suggested fix
--- "a/src/shared/terminal-unicode-provider.ts"
+++ "b/src/shared/terminal-unicode-provider.ts"
@@ -84,9 +84,9 @@
       )
       // Why: charProperties packs width into the property word; keep it aligned
       // with wcwidth when wide-mode expands East Asian Ambiguous cells.
-      if (desiredWidth !== extractWidth(base)) {
+      if (desiredWidth === 2 && extractWidth(base) === 1) {
         return createProperties(extractCharKind(base), desiredWidth, (base & 1) === 1)
       }
       return base
     }
   }

Add a regression test for e\u0301X in both width modes.

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (desiredWidth !== extractWidth(base)) {
return createProperties(extractCharKind(base), desiredWidth, (base & 1) === 1)
if (desiredWidth === 2 && extractWidth(base) === 1) {
return createProperties(extractCharKind(base), desiredWidth, (base & 1) === 1)

@innocarpe
innocarpe force-pushed the fix/terminal-east-asian-ambiguous-width branch from bd9f9d2 to fdeabc0 Compare November 2, 2026 11:56
Add terminalEastAsianAmbiguousWidth (narrow|wide, default narrow) so CJK
locales can match conhost double-width ambiguous glyphs (① ■ ★ →) without
changing the modern CLI-aligned default. Wide mode also inserts CJK UI
fonts ahead of Consolas so full-size glyphs fill the two-cell slot.

Closes stablyai#9958
buildFontFamily only adjusts the CJK fallback stack; activate Orca's
unicode provider (and wide ambiguous mode) before writing the sample
buffer so the preview measures like live panes.
DoDAON / stablyai#9958 asked for all three activation sites. Desktop already set
mode + OrcaUnicodeProvider; this pass completes the twins:

- Headless: honor eastAsianAmbiguousWidth (runtime store + settings sync)
- Mobile: bundle Orca unicode into the WebView engine and activate after
  Unicode11 (was bypassing Orca entirely); CJK font stack when wide
- Provider as plain object so the Chrome 74 engine floor parses cleanly

Evidence: headless-emulator-unicode-width + mobile engine/html tests
@innocarpe
innocarpe force-pushed the fix/terminal-east-asian-ambiguous-width branch from fdeabc0 to 962ea46 Compare November 3, 2026 02:55
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (962ea467f7)

Rebased onto current upstream/main. The startup import conflict keeps the moved applyAppIcon path and this PR's setTerminalEastAsianAmbiguousWidthMode call, so wide East Asian Ambiguous width still applies at launch.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Opt-in "treat East Asian Ambiguous characters as double-width" for the terminal

4 participants