waveterm icon indicating copy to clipboard operation
waveterm copied to clipboard

change IME composing handling order to support implicitly confirming IME

Open sters opened this issue 1 month ago • 2 comments

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)

Note

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

sters avatar Jan 12 '26 13:01 sters

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jan 12 '26 13:01 CLAassistant

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.

coderabbitai[bot] avatar Jan 12 '26 13:01 coderabbitai[bot]

thanks for submitting this and thanks for the videos. I'm not a native IME user, so it can be hard to track down and fix bugs like these. I'll try to get this reviewed and hopefully merged for the next release.

sawka avatar Jan 22 '26 02:01 sawka