fix: Send classic Duo Chat prompt on keydown to ignore IME Enter

What does this MR do and why?

Classic Duo Chat sent the prompt on the Enter keyup. The keydown that confirms an IME conversion (for example Japanese) fires before the keyup of the last composed character, which cleared the composition guard, so the confirming Enter sent an unfinished message.

This sends on keydown instead and skips composing key events (isComposing or keyCode 229), key repeats, and modified Enters, matching the fix already in Duo Agentic Chat. Slash-command and context-menu selection stay on keyup.

Changelog: fixed Closes #631610

Before / After

Before: With an IME (e.g. Japanese), the Enter that confirms a composition submitted the chat prompt mid-composition and sent an unfinished message — classic Duo Chat sent on keyup, by which point the composition guard was already cleared.

After: The prompt is sent on keydown, and Enter events that are composing (isComposing or keyCode 229), key repeats, or modified are ignored, so the IME-confirming Enter no longer submits. Slash-command and context-menu selection still act on keyup.

How to set up and validate locally

  1. Run the updated spec:
    yarn jest ee/spec/frontend/ai/tanuki_bot/components/duo_chat_view_spec.js
  2. Or in the UI with an IME enabled: compose a message in classic Duo Chat and press Enter to confirm the conversion — the message is not sent until you press Enter again to submit.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #631610

Edited by Jeston Singh

Merge request reports

Loading
Loading