Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): Open-with-AI menu non-modal so it can't trap the UI (#1620)

Andrew Mikofalvy18a4f4aed358
diff --git a/.changeset/fix-open-with-ai-modal-trap.md b/.changeset/fix-open-with-ai-modal-trap.md
new file mode 100644
index 000000000..6a33c0c6a
--- /dev/null
+++ b/.changeset/fix-open-with-ai-modal-trap.md
@@ -0,0 +1,9 @@
+---
+"@inkeep/open-knowledge": patch
+"@inkeep/open-knowledge-core": patch
+"@inkeep/open-knowledge-server": patch
+"@inkeep/open-knowledge-app": patch
+"@inkeep/open-knowledge-desktop": patch
+---
+
+Fix the editor toolbar's "Open with AI" menu freezing the rest of the app in the macOS desktop app. Once the menu became openable on the desktop host, its default modal behavior disabled pointer events on everything outside the menu while it was open. Because the menu lives in the macOS title-bar drag region — where the outside-click that normally dismisses a modal doesn't reliably reach the menu — the only way to close it was to pick an agent, and meanwhile the rest of the chrome (notably the bottom-left project switcher) couldn't be clicked. The menu is now non-modal: opening it no longer blocks the rest of the UI, and clicking anywhere outside dismisses it. Browsers (`ok ui`) are unaffected.
diff --git a/packages/app/src/components/handoff/OpenInAgentMenu.non-modal.dom.test.tsx b/packages/app/src/components/handoff/OpenInAgentMenu.non-modal.dom.test.tsx
new file mode 100644
index 000000000..3c3a4db3c
--- /dev/null
+++ b/packages/app/src/components/handoff/OpenInAgentMenu.non-modal.dom.test.tsx
@@ -0,0 +1,57 @@
+import { afterEach, describe, expect, mock, test } from 'bun:test';
+import { cleanup, render, screen, waitFor } from '@testing-library/react';
+import type { HandoffDispatchInput } from './useHandoffDispatch';
+
+type WindowGlobals = { NodeFilter?: typeof NodeFilter };
+type GlobalWithDomShims = typeof globalThis &
+ WindowGlobals & { window?: WindowGlobals; ResizeObserver?: unknown };
+const globalWithDomShims = globalThis as GlobalWithDomShims;
+if (
+ globalWithDomShims.NodeFilter === undefined &&
+ globalWithDomShims.window?.NodeFilter !== undefined
+) {
+ globalWithDomShims.NodeFilter = globalWithDomShims.window.NodeFilter;
+}
+if (globalWithDomShims.ResizeObserver === undefined) {
+ class NoopResizeObserver {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ }
+ globalWithDomShims.ResizeObserver = NoopResizeObserver;
+}
+
+mock.module('@/lib/config-context', () => ({
+ useConfigContext: () => ({ merged: null }),
+}));
+mock.module('./useInstalledAgents', () => ({
+ useInstalledAgents: () => ({ states: {}, refresh: () => {} }),
+}));
+mock.module('./useHandoffDispatch', () => ({
+ useHandoffDispatch: () => ({ dispatch: async () => {}, reinstallCoworkSkill: async () => {} }),
+}));
+
+const { OpenInAgentMenu } = await import('./OpenInAgentMenu');
+
+const FILE_INPUT: HandoffDispatchInput = {
+ docContext: null,
+ projectDir: '/tmp/project',
+ docPath: 'note.md',
+};
+
+describe('OpenInAgentMenu non-modal contract', () => {
+ afterEach(() => {
+ cleanup();
+ document.body.style.pointerEvents = '';
+ });
+
+ test('opening the menu does not disable outside pointer events (body stays interactive)', async () => {
+ render(<OpenInAgentMenu input={FILE_INPUT} open onOpenChange={() => {}} />);
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('open-in-agent-menu')).not.toBeNull();
+ });
+
+ expect(document.body.style.pointerEvents).not.toBe('none');
+ });
+});
diff --git a/packages/app/src/components/handoff/OpenInAgentMenu.tsx b/packages/app/src/components/handoff/OpenInAgentMenu.tsx
index 3b06500de..4d5c0e384 100644
--- a/packages/app/src/components/handoff/OpenInAgentMenu.tsx
+++ b/packages/app/src/components/handoff/OpenInAgentMenu.tsx
@@ -76,7 +76,7 @@ export function OpenInAgentMenu({ input, open, onOpenChange }: OpenInAgentMenuPr
};
return (
- <DropdownMenu open={menuOpen} onOpenChange={handleOpenChange}>
+ <DropdownMenu open={menuOpen} onOpenChange={handleOpenChange} modal={false}>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"