From 3c11e59f7642dae6c8ff4639aa0761f2b6a5f884 Mon Sep 17 00:00:00 2001 From: waleed Date: Mon, 6 Jul 2026 20:10:02 -0700 Subject: [PATCH 1/3] fix(user-input): stop @mention/skill menu from reopening after dismiss - Fixes a bug where the @mention (and /skill) autocomplete menu couldn't be dismissed: clicking away or pressing Escape closed it, but the very next click/selection change reopened it because the caret was still inside the unfinished @token - Adds a one-shot "dismissed" marker per token, set only on a real outside-click/Escape dismiss, cleared the instant the user types again - Shared fix in use-prompt-editor.ts covers every consumer: home chat input, scheduled-task modal, task-details modal --- .../prompt-editor/use-prompt-editor.test.tsx | 226 ++++++++++++++++++ .../prompt-editor/use-prompt-editor.ts | 48 ++++ 2 files changed, 274 insertions(+) create mode 100644 apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/use-prompt-editor.test.tsx diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/use-prompt-editor.test.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/use-prompt-editor.test.tsx new file mode 100644 index 00000000000..dbb0f8a7682 --- /dev/null +++ b/apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/use-prompt-editor.test.tsx @@ -0,0 +1,226 @@ +/** + * @vitest-environment jsdom + */ +import { act, type ReactNode } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' + +vi.mock('@/hooks/queries/skills', () => ({ useSkills: () => ({ data: [] }) })) +vi.mock('@/hooks/queries/workflows', () => ({ useWorkflows: () => ({ data: [] }) })) +vi.mock('@/hooks/queries/tables', () => ({ useTablesList: () => ({ data: [] }) })) +vi.mock('@/hooks/queries/workspace-files', () => ({ useWorkspaceFiles: () => ({ data: [] }) })) +vi.mock('@/hooks/queries/kb/knowledge', () => ({ useKnowledgeBasesQuery: () => ({ data: [] }) })) +vi.mock('@/hooks/queries/folders', () => ({ useFolders: () => ({ data: [] }) })) +vi.mock('@/hooks/queries/workspace-file-folders', () => ({ + useWorkspaceFileFolders: () => ({ data: [] }), +})) +vi.mock('@/hooks/queries/mothership-chats', () => ({ useMothershipChats: () => ({ data: [] }) })) +vi.mock('@/hooks/queries/schedules', () => ({ useWorkspaceSchedules: () => ({ data: [] }) })) +vi.mock('@/hooks/queries/logs', () => ({ useLogsList: () => ({ data: undefined }) })) +vi.mock('@/blocks/integration-matcher', () => ({ + getIntegrationMatcher: () => ({ regex: null, byName: new Map() }), + listIntegrations: () => [], +})) + +import type { PlusMenuHandle } from '@/app/workspace/[workspaceId]/home/components/user-input/components/constants' +import { + type UsePromptEditorProps, + usePromptEditor, +} from '@/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/use-prompt-editor' + +/** + * Mounts `usePromptEditor` in a real React 19 root under jsdom (no + * `@testing-library/react` in this repo — see `hooks/queries/unsubscribe.test.tsx` + * for the established pattern) and wires a real `