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): an IME's Enter in New room neither adds a participant nor creates the room
raullopez-sandbox298528cf3631
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsxindex 5d51a1e6a..c2a60bb0a 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/CreateRoomModal.tsx@@ -30,6 +30,7 @@ import { MessagingAppSelector, SWITCH_CONSOLE } from './messaging-app-selector';import { ParticipantPicker } from './participant-picker';import type { Participant } from './participant-search';import { CreateRequestIds, canCreate, roomCreateRequest } from './room-create-request';+import { RoomNameInput } from './room-name-input';import { switchServersStore } from './switch-servers-store';type CreateRoomModalArgs = {@@ -220,19 +221,15 @@ export const CreateRoomModal = observer(function CreateRoomModal({</p>)}- <input- autoFocus- aria-label="Room name"- placeholder="Room name"+ <RoomNameInputvalue={name}- onChange={(e) => {- setName(e.target.value);+ onChange={(next) => {+ setName(next);setError(null);}}- onKeyDown={(e) => {- if (e.key === 'Enter' && canSubmit) void handleSubmit();+ onSubmit={() => {+ if (canSubmit) void handleSubmit();}}- className="w-full border-b border-border bg-transparent pb-2 text-xl font-semibold text-foreground outline-none placeholder:font-normal placeholder:text-foreground-passive focus:border-foreground-muted"/>{/* What the name becomes, where it becomes it: a bridged room is achannel of the same name in its app. */}diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-picker.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-picker.tsxindex cdb9282a9..34680f1da 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-picker.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/participant-picker.tsx@@ -137,6 +137,8 @@ export function ParticipantPicker({onFocus={() => setOpen(true)}onBlur={() => setOpen(false)}onKeyDown={(event) => {+ // keyCode 229: a key the IME is handling, which some IMEs send with isComposing false.+ if (event.nativeEvent.isComposing || event.keyCode === 229) return;const action = pickerKey(event.key, {query,open,diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-name-input.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-name-input.tsxnew file mode 100644index 000000000..da38d1f5e--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/room-name-input.tsx@@ -0,0 +1,26 @@+/** The new room's name, large as its title; Enter submits, except an Enter the IME is handling. */+export function RoomNameInput({+ value,+ onChange,+ onSubmit,+}: {+ value: string;+ onChange: (value: string) => void;+ onSubmit: () => void;+}) {+ return (+ <input+ autoFocus+ aria-label="Room name"+ placeholder="Room name"+ value={value}+ onChange={(e) => onChange(e.target.value)}+ onKeyDown={(e) => {+ // keyCode 229: a key the IME is handling, which some IMEs send with isComposing false.+ if (e.nativeEvent.isComposing || e.keyCode === 229) return;+ if (e.key === 'Enter') onSubmit();+ }}+ className="w-full border-b border-border bg-transparent pb-2 text-xl font-semibold text-foreground outline-none placeholder:font-normal placeholder:text-foreground-passive focus:border-foreground-muted"+ />+ );+}diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/new-room-ime.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/new-room-ime.test.tsxnew file mode 100644index 000000000..31dfd1e39--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/new-room-ime.test.tsx@@ -0,0 +1,78 @@+/**+ * In the New room dialog, an Enter the IME is handling confirms the+ * composition and nothing else: it neither adds a participant nor creates+ * the room. A plain Enter still does both.+ */+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { ParticipantPicker } from '@renderer/features/switch-servers/participant-picker';+import type { Participant } from '@renderer/features/switch-servers/participant-search';+import { RoomNameInput } from '@renderer/features/switch-servers/room-name-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<HTMLInputElement> {+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+ await act(async () =>+ root!.render(<QueryClientProvider client={new QueryClient()}>{node}</QueryClientProvider>)+ );+ return container.querySelector('input')!;+}++const enter = (input: HTMLInputElement, init: KeyboardEventInit) =>+ input.dispatchEvent(+ new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true, ...init })+ );++const helper: Participant = {+ kind: 'agent',+ id: 'a1',+ name: 'helper',+ iconUrl: null,+ detail: 'Agent · Claude Code',+};++describe('New room IME', () => {+ it('adds no participant on a composition Enter, and adds one on a plain Enter', async () => {+ const onChange = vi.fn();+ const input = await render(+ <ParticipantPicker+ candidates={[helper]}+ picked={[]}+ onChange={onChange}+ serverId={null}+ loading={false}+ />+ );+ await act(async () => input.focus());+ await act(async () => enter(input, { isComposing: true, keyCode: 13 }));+ await act(async () => enter(input, { keyCode: 229 }));+ expect(onChange).not.toHaveBeenCalled();+ await act(async () => enter(input, { keyCode: 13 }));+ expect(onChange).toHaveBeenCalledWith([helper]);+ });++ it('does not create the room on a composition Enter in the name, and does on a plain one', async () => {+ const onSubmit = vi.fn();+ const input = await render(+ <RoomNameInput value="会議" onChange={() => {}} onSubmit={onSubmit} />+ );+ await act(async () => enter(input, { isComposing: true, keyCode: 13 }));+ await act(async () => enter(input, { keyCode: 229 }));+ expect(onSubmit).not.toHaveBeenCalled();+ await act(async () => enter(input, { keyCode: 13 }));+ expect(onSubmit).toHaveBeenCalledTimes(1);+ });+});