Skip to content

Support Vietnamese IME and synthetic Unicode text forwarding in terminal - #6682

Merged
AmethystLiang merged 2 commits into
mainfrom
bug-help-chinese-but-not-vietnamese
Jun 29, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
bug-help-chinese-but-not-vietnamese

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

This PR supports Vietnamese IME input methods (e.g., Telex, VNI, UniKey) and synthetic Unicode character injection in the terminal pane. It replaces the CJK-specific terminal-ime-punctuation-forwarder with a generalized terminal-ime-native-text-forwarder that handles both punctuation and short text replacements (using feature flags matched from the active keyboard input source). It also introduces fallback forwarding for synthetic Unicode inputs that lack standard physical key identity.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Detailed testing notes: New unit tests added in terminal-ime-native-text-forwarder.test.ts and updated in terminal-ime-input-source.test.ts cover Vietnamese input sources, CJK punctuation, and synthetic Unicode injection scenarios.

AI Review Report

  • Checked IME text forwarding robustness with multi-codepoint inputs and modifier chords.
  • Verified that keyboard event bypass only triggers under specific safe conditions (no active compositions, no modifier keys except Shift).
  • Confirmed cross-platform compatibility: The native text forwarder is strictly gated to macOS, meaning Windows and Linux terminal inputs remain unchanged and safe.

Security Audit

  • Input handling: Verified that IME character commits are securely routed directly to the terminal PTY with no local shell execution or command evaluation risks.
  • Commands/IPC: No custom command execution or insecure IPC boundaries are modified.

Notes

This workaround only targets macOS (navigator.userAgent.includes('Mac')) to address xterm's Kitty keyboard protocol swallowing native input events.

Previously, the terminal IME workaround only forwarded punctuation for
macOS CJK input methods. This generalizes the system into a native text
forwarder that also handles:

- Short text replacements for Vietnamese input methods (Telex, VNI).
- Synthesized Unicode inputs with unreliable physical key metadata.

This prevents xterm's kitty keyboard protocol from encoding and
canceling these keydowns before the native glyphs can be committed.
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Mac IME workaround in the terminal pane is replaced end-to-end. The terminal-ime-input-source module drops its CJK-boolean API and instead exports a MacNativeTextInputSourceFeatures type with forwardAsciiPunctuation and forwardShortTextReplacements flags, a getMacNativeTextInputSourceFeatures mapper, and a createMacNativeTextInputSourceTracker / getMacNativeTextInputSourceTracker singleton. A new terminal-ime-native-text-forwarder module is added, providing isImeNativeTextKeydownCandidate and installTerminalImeNativeTextForwarder, which arm a short-lived pending-forward state on qualifying keydowns and intercept the subsequent insertText input event to bypass xterm and send committed text directly to the PTY. The old terminal-ime-punctuation-forwarder module and its tests are deleted. use-terminal-pane-lifecycle is updated to install and dispose the new forwarder.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: Vietnamese IME and synthetic Unicode forwarding in the terminal.
Description check ✅ Passed The description follows the template and covers summary, screenshots, testing, AI review, security audit, and notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch bug-help-chinese-but-not-vietnamese

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

Comment @coderabbitai help to get the list of available commands.

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 39ded567-dd89-472c-a8ac-9ba07410309e

📥 Commits

Reviewing files that changed from the base of the PR and between 3c614b2 and 17b5977.

📒 Files selected for processing (7)
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-punctuation-forwarder.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-punctuation-forwarder.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
💤 Files with no reviewable changes (2)
  • src/renderer/src/components/terminal-pane/terminal-ime-punctuation-forwarder.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-punctuation-forwarder.test.ts

@AmethystLiang
AmethystLiang merged commit 01cf5e3 into main Jun 29, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#6682)

Previously, the terminal IME workaround only forwarded punctuation for
macOS CJK input methods. This generalizes the system into a native text
forwarder that also handles:

- Short text replacements for Vietnamese input methods (Telex, VNI).
- Synthesized Unicode inputs with unreliable physical key metadata.

This prevents xterm's kitty keyboard protocol from encoding and
canceling these keydowns before the native glyphs can be committed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant