Skip to content

fix: prevent Enter from sending during IME composition on macOS#97

Merged
GCWing merged 2 commits intoGCWing:mainfrom
QZQ-go:fix/issue-70-macos-ime-enter
Mar 9, 2026
Merged

fix: prevent Enter from sending during IME composition on macOS#97
GCWing merged 2 commits intoGCWing:mainfrom
QZQ-go:fix/issue-70-macos-ime-enter

Conversation

@QZQ-go
Copy link
Contributor

@QZQ-go QZQ-go commented Mar 9, 2026

PR Title

fix: prevent Enter from sending during IME composition on macOS


Summary

  • Fixes issue Enter key sends message instead of dismissing IME candidate box #70 where pressing Enter while Chinese IME candidate box is visible could send the message prematurely on macOS.
  • Adds stronger IME composition detection in chat input send handling.
  • Adds a regression E2E scenario to verify Enter is ignored during composition and works after composition ends.

Problem

On macOS Chinese IME (system/Sogou/Tencent), Enter used for candidate confirmation could trigger message send before composition was truly finished.

Root Cause

Send logic depended mainly on KeyboardEvent.isComposing, which can be transient/insufficient around composition end timing in some IME flows.

Fix Details

  1. ChatInput.tsx

    • Track composition lifecycle via refs (isImeComposingRef).
    • Add short guard window after composition end (IME_ENTER_GUARD_MS = 120) to avoid accidental Enter send.
    • Block Enter send if composing or just finished composition.
  2. RichTextInput.tsx

    • Expose onCompositionStart / onCompositionEnd callbacks.
    • Use combined composition check (native isComposing || internal composing ref) in key handling.
  3. E2E

    • Add composition event helpers in chat input page object.
    • Add regression test in basic-chat.spec.ts:
      • Enter during composition should NOT send.
      • Enter after composition end should send.

Validation

  • ✅ Manual verification on macOS with Chinese IME: passed (report from local testing).
  • ⚠️ npm run type-check / npm run build in src/web-ui: currently fail due to existing repository-wide TS baseline issues unrelated to this PR.
  • ⚠️ tests/e2e npm run test:chat: blocked in local environment by tauri-driver/config startup issues.

Changed Files

  • src/web-ui/src/flow_chat/components/ChatInput.tsx
  • src/web-ui/src/flow_chat/components/RichTextInput.tsx
  • tests/e2e/page-objects/components/ChatInput.ts
  • tests/e2e/specs/chat/basic-chat.spec.ts

Related

@QZQ-go QZQ-go force-pushed the fix/issue-70-macos-ime-enter branch from d80e095 to 5a2e4e9 Compare March 9, 2026 08:44
@GCWing GCWing merged commit eabccdf into GCWing:main Mar 9, 2026
2 checks passed
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.

Enter key sends message instead of dismissing IME candidate box

2 participants