Skip to content

fix(desktop): ignore IME composition enter - #38001

Closed
tgfjt wants to merge 1 commit into
NousResearch:mainfrom
tgfjt:fix/desktop-ime-enter-submit
Closed

fix(desktop): ignore IME composition enter#38001
tgfjt wants to merge 1 commit into
NousResearch:mainfrom
tgfjt:fix/desktop-ime-enter-submit

Conversation

@tgfjt

@tgfjt tgfjt commented Jun 3, 2026

Copy link
Copy Markdown

What does this PR do?

This fixes Hermes Desktop submitting a chat message when users press Enter to confirm Japanese/Chinese/Korean IME conversion.

The desktop composer currently handles every non-Shift Enter keydown as submit. During IME composition, the conversion-confirmation Enter also reaches the composer as a keydown event, so confirming text can accidentally send the unfinished message.

This PR adds a small IME composition guard before the submit shortcut runs. It checks both nativeEvent.isComposing and the browser IME processing key code 229, which covers the common macOS/Electron path where composition Enter may not be represented as a normal Enter event. Normal Enter submission remains unchanged.

Related Issue

Fixes #37483

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • apps/desktop/src/app/chat/composer/index.tsx
    • Skip composer keydown shortcuts while an IME composition event is active, preventing conversion-confirmation Enter from submitting the message.
  • apps/desktop/src/app/chat/composer/ime.ts
    • Add isImeCompositionKeyEvent() helper for nativeEvent.isComposing and IME processing keyCode === 229.
  • apps/desktop/src/app/chat/composer/ime.test.ts
    • Add regression tests for IME composition Enter, macOS/Electron keyCode === 229, and normal Enter behavior.

How to Test

  1. In Hermes Desktop on macOS, focus the chat composer and enable a Japanese IME.
  2. Type text that requires conversion, then press Enter to confirm the conversion.
    • Expected: the converted text stays in the composer and is not submitted.
  3. Press Enter again after composition has ended.
    • Expected: the message submits normally.

Automated checks run locally:

npm run test:ui -- src/app/chat/composer
npm run type-check
npx eslint src/app/chat/composer/ime.ts src/app/chat/composer/ime.test.ts src/app/chat/composer/index.tsx
npm run build

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.2 / Hermes Desktop Electron app

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

> hermes@0.15.1 test:ui
> vitest run --environment jsdom src/app/chat/composer

✓ src/app/chat/composer/ime.test.ts (3 tests)
✓ src/app/chat/composer/rich-editor.test.ts (1 test)

Test Files  2 passed (2)
Tests       4 passed (4)
> hermes@0.15.1 type-check
> tsc -b
npx eslint src/app/chat/composer/ime.ts src/app/chat/composer/ime.test.ts src/app/chat/composer/index.tsx
# passed
npm run build
# built successfully

@tgfjt

tgfjt commented Jun 3, 2026

Copy link
Copy Markdown
Author

dup #37483

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]: Desktop app: Enter key sends message during IME composition (Japanese, Chinese, Korean, etc.)

1 participant