Skip to content

Conversation

@sters
Copy link

@sters sters commented Jan 12, 2026

Problem

When using IME with Japanese in the terminal panel, implicitly confirming IME does not work properly.

Environment

  • MacOS 26.2
  • Wave Terminal 0.13.1 (202512170503)
  • Google Japanese IME 2.32.5990

Step to reproduce

  1. Input てすと
  2. Input Tab (or Space)
  3. IME changes the status to confirming (showing some candidates) and the text changes to テスト
  4. Input next chars like
  5. IME closes candidates for てすと
    • Expected: Confirm テスト and continue with next chars composition
    • Actual: テスト is lost, only next chars composition continues

Cause

I added some logs and check the behavior, the event triggering order seems complicated.

  • When explicitly confirming IME (Input Enter)
    • compositionend -> handleTermData
  • When implicitly confirming IME (Input Tab + Input next char)
    • compositionend -> compositionstart -> handleTermData

DEMO

Current This PR Reference (Chrome's textarea)
current.mp4
updated.mp4
reference.mp4

Note

I'm not familiar with other CJK languages and IME itself. There may be patterns I'm unaware of.

@CLAassistant
Copy link

CLAassistant commented Jan 12, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 12, 2026

Walkthrough

The change reworks IME input handling in TermWrap.handleTermData by replacing an early composition block with a time-windowed deduplication mechanism. A 50-millisecond dedup window now permits the first data after composition ends, even if a new composition has started, while blocking duplicate inputs from the same window (such as from Capslock or input method switches). An additional guard was added to explicitly prevent intermediate composition updates from being transmitted to the terminal handler.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: reworking IME handling to support implicit IME confirmation when composition order changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly explains the IME composition handling problem with Japanese input, including reproduction steps, root cause analysis, and the PR's solution.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/app/view/term/termwrap.ts (1)

625-652: IME dedup logic works for desktop but lacks mobile/iOS fallback for Hangul composition events.

The 50ms dedup window is appropriate for desktop CJK IMEs (Pinyin, Japanese), though timing varies across implementations. However, a critical gap exists: iOS and other mobile platforms do not emit composition events for Hangul/Korean input—instead, input arrives via beforeinput events. The current implementation will silently fail to handle Korean input on iOS.

To address this:

  1. Add beforeinput fallback handling for platforms where composition events don't fire. Detect IME input via inputType values (e.g., "insertCompositionText") and use that as a fallback to capture Korean input on mobile.

  2. Extract IMEDedupWindowMs as a class-level constant for visibility and future configurability.

  3. Test across platforms and IME implementations: Pinyin, Japanese (Mozc/Anthy), Hangul on desktop (Chrome, Firefox, Safari) and mobile (iOS Safari, Android Chrome).

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 31a8714 and 0a9036e.

📒 Files selected for processing (1)
  • frontend/app/view/term/termwrap.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: merge-gatekeeper
🔇 Additional comments (1)
frontend/app/view/term/termwrap.ts (1)

654-661: LGTM - Guard placement is correct.

Placing this guard after the dedup check ensures that:

  1. Confirmed text from a recent compositionend is allowed through (even if a new composition has started)
  2. Intermediate composition updates during active composition are blocked

The logic flow is sound.

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.

2 participants