Skip to content

fix: prevent Chinese IME Enter from triggering message send#226

Open
FarewellSagittarius wants to merge 13 commits intoop7418:mainfrom
FarewellSagittarius:main
Open

fix: prevent Chinese IME Enter from triggering message send#226
FarewellSagittarius wants to merge 13 commits intoop7418:mainfrom
FarewellSagittarius:main

Conversation

@FarewellSagittarius
Copy link

Summary

Fixes #225

When using macOS native Chinese IME and pressing Enter to confirm English text, the message is sent unexpectedly. This happens because compositionend fires before keydown(Enter) in the same event loop tick, so isComposing is already false when Enter is handled.

Fix: Defer the isComposing reset with setTimeout(0) so the Enter keydown in the same cycle is still suppressed.

- const handleCompositionEnd = useCallback(() => setIsComposing(false), []);
+ const handleCompositionEnd = useCallback(() => {
+   setTimeout(() => setIsComposing(false), 0);
+ }, []);

This is a standard pattern used by VS Code, Slack, etc. No impact on non-IME users.

Test plan

  • macOS native Chinese IME (Pinyin) → type English → Enter confirms without sending
  • Normal Enter (no IME) still sends message
  • Shift+Enter still inserts newline
  • TypeCheck + 238 unit tests pass

Farewell added 4 commits March 10, 2026 10:38
On macOS native Chinese IME, compositionend fires before keydown(Enter)
when confirming English text, causing isComposing to be false when Enter
is handled. Delay the compositionend state reset with setTimeout(0) so
the Enter keydown in the same event loop is still suppressed.
@vercel
Copy link

vercel bot commented Mar 13, 2026

Someone is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

Farewell added 9 commits March 13, 2026 15:51
Add Next.js instrumentation hook to trigger bridge auto-start on server
startup. Previously auto-start only worked in Electron (main process sent
POST to /api/bridge), so launchd/web deployments required manual start.
# Conflicts:
#	src/instrumentation.ts
On macOS native Chinese IME, compositionend fires before keydown(Enter)
when confirming English text, causing isComposing to be false when Enter
is handled. Delay the compositionend state reset with setTimeout(0) so
the Enter keydown in the same event loop is still suppressed.
Add Next.js instrumentation hook to trigger bridge auto-start on server
startup. Previously auto-start only worked in Electron (main process sent
POST to /api/bridge), so launchd/web deployments required manual start.
# Conflicts:
#	src/instrumentation.ts
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.

Bug: Chinese IME Enter key triggers message send during composition

1 participant