Skip to content

Fix chat composer IME Enter handling#1730

Merged
senamakel merged 2 commits into
tinyhumansai:mainfrom
aqilaziz:fix-chat-composer-ime-enter
May 15, 2026
Merged

Fix chat composer IME Enter handling#1730
senamakel merged 2 commits into
tinyhumansai:mainfrom
aqilaziz:fix-chat-composer-ime-enter

Conversation

@aqilaziz
Copy link
Copy Markdown
Contributor

@aqilaziz aqilaziz commented May 14, 2026

Summary

  • prevent Enter from sending while the chat textarea is in IME composition
  • cover React composition state, native isComposing, legacy keyCode 229, and normal Enter/Shift+Enter paths
  • add render coverage for the real Conversations textarea flow

Closes #1718

Validation

  • pnpm --filter openhuman-app exec vitest run --config test/vitest.config.ts src/pages/conversations/composerSendDecision.test.ts src/pages/__tests__/Conversations.render.test.tsx
  • pnpm typecheck
  • pnpm --filter openhuman-app exec prettier --check src/pages/__tests__/Conversations.render.test.tsx src/pages/Conversations.tsx src/pages/conversations/composerSendDecision.ts src/pages/conversations/composerSendDecision.test.ts
  • pnpm --filter openhuman-app exec eslint src/pages/Conversations.tsx src/pages/conversations/composerSendDecision.ts src/pages/conversations/composerSendDecision.test.ts src/pages/__tests__/Conversations.render.test.tsx --ext .ts,.tsx (passes with existing react-hooks/set-state-in-effect warnings in Conversations.tsx)
  • python -m diff_cover.diff_cover_tool app/coverage/lcov.normalized.info --compare-branch=origin/main --fail-under=80 --markdown-report app/coverage/diff-coverage.md (100% diff coverage)

Notes

  • Local pre-push pnpm rust:check is blocked in this shallow clone because app/src-tauri/vendor/tauri-cef/crates/tauri/Cargo.toml is absent. This PR only changes frontend TS/TSX files.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed message composer to properly handle text input method (IME) composition events. Pressing Enter while composing text with IME will no longer accidentally send incomplete messages; sending now works correctly once composition is complete.

Review Change Stack

@aqilaziz aqilaziz requested a review from a team May 14, 2026 11:48
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bcc4f166-25a6-421f-9667-117d3d60e8eb

📥 Commits

Reviewing files that changed from the base of the PR and between 1699378 and 8dd7931.

📒 Files selected for processing (4)
  • app/src/pages/Conversations.tsx
  • app/src/pages/__tests__/Conversations.render.test.tsx
  • app/src/pages/conversations/composerSendDecision.test.ts
  • app/src/pages/conversations/composerSendDecision.ts

📝 Walkthrough

Walkthrough

This PR prevents the chat composer from sending messages when text composition (IME) is active. It introduces IME-aware keydown decision helpers in composerSendDecision.ts and integrates them into the Conversations page textarea with composition event tracking to gate Enter-to-send behavior.

Changes

IME Composition Awareness for Composer

Layer / File(s) Summary
Composer keydown decision helpers and unit tests
app/src/pages/conversations/composerSendDecision.ts, app/src/pages/conversations/composerSendDecision.test.ts
Defines ComposerKeyDownEventLike interface, isComposerImeComposing detection function checking isComposing, keyCode === 229, and native-event mirrors, and shouldSendComposerKeyDown that gates Enter sends (requiring key === 'Enter', no shiftKey, and no IME composition). Unit tests cover Enter, Shift+Enter, and multiple IME detection paths.
Conversations integration with composition tracking and tests
app/src/pages/Conversations.tsx, app/src/pages/__tests__/Conversations.render.test.tsx
Imports shouldSendComposerKeyDown, creates compositionActiveRef to track textarea composition state, adds onCompositionStart/onCompositionEnd handlers to toggle composition state, and updates handleInputKeyDown to gate Enter sends via the new helper. Integration tests verify that Enter during active IME composition does not submit and that Enter after composition ends submits normally.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • tinyhumansai/openhuman#1239: Introduces the composer send-decision module; this PR extends it with IME-aware shouldSendComposerKeyDown logic that the Conversations page now uses.

Poem

🐰 In keyboards worldwide, a tale takes flight,
Where Enter key beholds IME's might,
Compose, compose—don't rush the send!
Until the composition meets its end,
Now messages flow just right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix chat composer IME Enter handling' directly and specifically describes the main change: addressing IME Enter key behavior in the composer, which is the core focus of all changes.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from issue #1718: prevents Enter from sending during IME composition across React/native/legacy detection methods, adds regression test coverage for IME and normal Enter paths, and maintains diff coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to IME Enter handling: helper functions for composition detection, textarea state tracking via compositionStart/End handlers, conditional send logic, and corresponding test coverage with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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]
coderabbitai Bot previously approved these changes May 14, 2026
# Conflicts:
#	app/src/pages/Conversations.tsx
#	app/src/pages/__tests__/Conversations.render.test.tsx
@senamakel senamakel merged commit b5f5b7e into tinyhumansai:main May 15, 2026
19 of 20 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.

Chat composer sends while IME composition is active

2 participants