Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
fix(console): keep mention badges aligned at the bottom of a long draft; no send on IME Enter
raullopez-sandbox1d27e917f59c
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsx b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsxindex 5bb62b17e..4fc820f30 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsx@@ -417,7 +417,7 @@ export const ChatComposer = observer(function ChatComposer({</div><PromptInputTextarearef={input}- className="relative min-h-0 px-1 py-1.5"+ className="relative block min-h-0 px-1 py-1.5"aria-label={`Message ${recipient}`}placeholder={disabled ?? `Message ${recipient}...`}value={draft}diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/ui/prompt-input.tsx b/console/apps/switch-console-desktop/src/renderer/features/chats/ui/prompt-input.tsxindex 440351a60..929196ebb 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/ui/prompt-input.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/ui/prompt-input.tsx@@ -73,7 +73,8 @@ export function PromptInputTextarea({onKeyDown?.(event);if (event.defaultPrevented) return;if (event.key !== 'Enter' || event.shiftKey) return;- if (composing || event.nativeEvent.isComposing) return;+ // keyCode 229: a key the IME is handling, which some IMEs send with isComposing false.+ if (composing || event.nativeEvent.isComposing || event.keyCode === 229) return;event.preventDefault();const form = event.currentTarget.form;const submit = form?.querySelector<HTMLButtonElement>('button[type="submit"]');diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/chat-composer-mentions.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/chat-composer-mentions.test.tsxnew file mode 100644index 000000000..769f1c01e--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/chat-composer-mentions.test.tsx@@ -0,0 +1,102 @@+/**+ * The composer's mention badges sit behind the textarea on a mirrored layer;+ * they only line up with the text if that layer scrolls exactly like the+ * textarea. And Enter that an IME is handling must never send.+ */+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, describe, expect, it, vi } from 'vitest';+// Geometry is the subject, so the real utility classes must be present.+import '@renderer/index.css';+import { ChatComposer } from '@renderer/features/chats/components/chat-composer';+import {+ ChatTimeline,+ type TimelineApi,+} from '@renderer/features/chats/stores/chat-timeline-store';+import { PromptInput, PromptInputTextarea } from '@renderer/features/chats/ui/prompt-input';++let container: HTMLDivElement | null = null;+let root: Root | null = null;++afterEach(async () => {+ if (root) await act(async () => root!.unmount());+ container?.remove();+ container = null;+ root = null;+});++async function render(node: React.ReactNode): Promise<HTMLTextAreaElement> {+ container = document.createElement('div');+ container.style.width = '600px';+ document.body.appendChild(container);+ root = createRoot(container);+ await act(async () => root!.render(node));+ return container.querySelector('textarea')!;+}++const agent = {+ id: 'a2',+ name: 'agent-two',+ displayName: null,+ iconUrl: null,+ provider: null,+ alias: null,+ ownerName: null,+ ownedByViewer: false,+};++describe('ChatComposer mention badges', () => {+ it('scroll in step with the text at the bottom of a long draft', async () => {+ const textarea = await render(+ <ChatComposer+ serverId="s"+ timeline={new ChatTimeline('room-geometry', {} as TimelineApi)}+ agents={[agent]}+ groupName="Ship review"+ activity={null}+ replyTo={null}+ onClearReply={() => {}}+ disabled={null}+ />+ );+ const draft = `${Array.from({ length: 30 }, (_, i) => `line ${i}`).join('\n')}\n@agent-two last`;+ await act(async () => {+ Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')!.set!.call(+ textarea,+ draft+ );+ textarea.dispatchEvent(new Event('input', { bubbles: true }));+ });+ const mark = container!.querySelector('mark')!;+ const backdrop = mark.parentElement!;+ expect(mark.textContent).toBe('@agent-two');+ expect(textarea.scrollHeight).toBeGreaterThan(textarea.clientHeight);+ expect(backdrop.clientHeight).toBe(textarea.clientHeight);+ expect(backdrop.scrollHeight).toBe(textarea.scrollHeight);+ await act(async () => {+ textarea.scrollTop = textarea.scrollHeight;+ textarea.dispatchEvent(new Event('scroll'));+ });+ expect(backdrop.scrollTop).toBe(textarea.scrollTop);+ });+});++describe('PromptInputTextarea', () => {+ it('does not submit on an Enter the IME is handling, even without isComposing', async () => {+ const onSubmit = vi.fn();+ const textarea = await render(+ <PromptInput onSubmit={onSubmit}>+ <PromptInputTextarea defaultValue="hi" />+ <button type="submit">Send</button>+ </PromptInput>+ );+ const enter = (keyCode: number) =>+ textarea.dispatchEvent(+ new KeyboardEvent('keydown', { key: 'Enter', keyCode, bubbles: true, cancelable: true })+ );+ await act(async () => enter(229));+ expect(onSubmit).not.toHaveBeenCalled();+ await act(async () => enter(13));+ expect(onSubmit).toHaveBeenCalledTimes(1);+ });+});