AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(chat): pressing Enter to pick a Chinese, Japanese or Korean word no longer sends the message (#17134)
Hazem Adel0e0eccc56015
diff --git a/packages/web/src/app/routes/chat-with-ai/components/multi-question-form.tsx b/packages/web/src/app/routes/chat-with-ai/components/multi-question-form.tsxindex 6dc802d6b70..2f193ad55cb 100644--- a/packages/web/src/app/routes/chat-with-ai/components/multi-question-form.tsx+++ b/packages/web/src/app/routes/chat-with-ai/components/multi-question-form.tsx@@ -506,7 +506,11 @@ function ChoiceBody({firstOptionRef.current.focus();return;}- if (e.key === 'Enter' && (answer ?? '').trim()) {+ if (+ e.key === 'Enter' &&+ !e.nativeEvent.isComposing &&+ (answer ?? '').trim()+ ) {e.preventDefault();onPick((answer ?? '').trim());}diff --git a/packages/web/src/app/routes/chat-with-ai/components/onboarding-question-card.tsx b/packages/web/src/app/routes/chat-with-ai/components/onboarding-question-card.tsxindex 4899d5036e2..18229ae4c7f 100644--- a/packages/web/src/app/routes/chat-with-ai/components/onboarding-question-card.tsx+++ b/packages/web/src/app/routes/chat-with-ai/components/onboarding-question-card.tsx@@ -226,7 +226,7 @@ function OnboardingPill({setDismissed(true);return;}- if (e.key === 'Enter') {+ if (e.key === 'Enter' && !e.nativeEvent.isComposing) {e.preventDefault();if (open && activeIndex >= 0) {pick(suggestions[activeIndex]);diff --git a/packages/web/src/app/routes/chat-with-ai/index.tsx b/packages/web/src/app/routes/chat-with-ai/index.tsxindex 9c6e5560fe7..25ea883a05e 100644--- a/packages/web/src/app/routes/chat-with-ai/index.tsx+++ b/packages/web/src/app/routes/chat-with-ai/index.tsx@@ -278,7 +278,8 @@ export function ChatWithAIPage() {onChange={(e) => setRenameValue(e.target.value)}onBlur={() => void handleRename()}onKeyDown={(e) => {- if (e.key === 'Enter') void handleRename();+ if (e.key === 'Enter' && !e.nativeEvent.isComposing)+ void handleRename();if (e.key === 'Escape') {renameCancelledRef.current = true;setIsRenaming(false);diff --git a/packages/web/src/components/prompt-kit/prompt-input.tsx b/packages/web/src/components/prompt-kit/prompt-input.tsxindex abd615a41ed..1dfb44e9312 100644--- a/packages/web/src/components/prompt-kit/prompt-input.tsx+++ b/packages/web/src/components/prompt-kit/prompt-input.tsx@@ -154,7 +154,7 @@ function PromptInputTextarea({};const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {- if (e.key === 'Enter' && !e.shiftKey) {+ if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) {e.preventDefault();onSubmit?.();}diff --git a/packages/web/src/features/chat/chat-input/index.tsx b/packages/web/src/features/chat/chat-input/index.tsxindex 107fbda8bef..f1e72aa6c5e 100644--- a/packages/web/src/features/chat/chat-input/index.tsx+++ b/packages/web/src/features/chat/chat-input/index.tsx@@ -70,7 +70,7 @@ const ChatInput = React.forwardRef<HTMLTextAreaElement, ChatInputProps>(};const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {- if (e.key === 'Enter' && !e.shiftKey) {+ if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) {e.preventDefault();if (!disabled && (input || files.length > 0)) {handleSubmit(e as unknown as React.FormEvent);diff --git a/packages/web/test/components/prompt-kit/prompt-input-ime.test.tsx b/packages/web/test/components/prompt-kit/prompt-input-ime.test.tsxnew file mode 100644index 00000000000..4318f19ad04--- /dev/null+++ b/packages/web/test/components/prompt-kit/prompt-input-ime.test.tsx@@ -0,0 +1,45 @@+/**+ * @vitest-environment jsdom+ */+import { cleanup, fireEvent, render, screen } from '@testing-library/react';+import { afterEach, describe, expect, it, vi } from 'vitest';++import {+ PromptInput,+ PromptInputTextarea,+} from '@/components/prompt-kit/prompt-input';++afterEach(() => {+ cleanup();+});++describe('PromptInputTextarea Enter', () => {+ it('does not send while an IME is still composing', () => {+ const onSubmit = renderPrompt();++ fireEvent.keyDown(screen.getByRole('textbox'), {+ key: 'Enter',+ isComposing: true,+ });++ expect(onSubmit).not.toHaveBeenCalled();+ });++ it('sends on a plain Enter', () => {+ const onSubmit = renderPrompt();++ fireEvent.keyDown(screen.getByRole('textbox'), { key: 'Enter' });++ expect(onSubmit).toHaveBeenCalledTimes(1);+ });+});++function renderPrompt() {+ const onSubmit = vi.fn();+ render(+ <PromptInput value="nihao" onSubmit={onSubmit}>+ <PromptInputTextarea />+ </PromptInput>,+ );+ return onSubmit;+}