Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 点击遮罩关闭伙伴设置抽屉
nana4663f20207ae
diff --git a/apps/desktop/src/renderer/__tests__/dialogScrimDismissal.test.ts b/apps/desktop/src/renderer/__tests__/dialogScrimDismissal.test.tsindex 162258c69e..134dfe81ec 100644--- a/apps/desktop/src/renderer/__tests__/dialogScrimDismissal.test.ts+++ b/apps/desktop/src/renderer/__tests__/dialogScrimDismissal.test.ts@@ -1,7 +1,8 @@/*** DESIGN.md §4 Dialog & Modal「Closing affordance」:模态弹窗点遮罩/窗口外部一律不关闭,* 只能用自身按钮或 Esc 关闭。Radix Dialog 默认点外部即关闭,所以每个 `Dialog.Content`- * 都必须无条件 `preventDefault` 外部指针事件。AlertDialog 本身不响应外部点击,不在此列。+ * 都必须无条件 `preventDefault` 外部指针事件;规范明确的侧边抽屉例外除外。+ * AlertDialog 本身不响应外部点击,不在此列。*/import { readFileSync, readdirSync } from 'node:fs';import { relative, resolve } from 'node:path';@@ -11,8 +12,12 @@ import { describe, expect, it } from 'vitest';const RENDERER_ROOT = resolve(__dirname, '..');-// 已登记例外:点遮罩先弹二次确认,而不是直接关闭(DESIGN.md「Cindy Make preflight exception」)。-const EXEMPT_FILES = new Set(['components/cindy-make/CindyMakePreflightDialog.tsx']);+const EXEMPT_FILES = new Set([+ // 点遮罩先弹二次确认(DESIGN.md「Cindy Make preflight exception」)。+ 'components/cindy-make/CindyMakePreflightDialog.tsx',+ // DESIGN.md §4 的侧边抽屉例外;真实点击和保存保护由 botSettingsDrawer.test.tsx 覆盖。+ 'features/bots/BotSettingsDrawer.tsx',+]);const OUTSIDE_HANDLERS = ['onPointerDownOutside', 'onInteractOutside'];@@ -114,7 +119,7 @@ function rendererLabel(path: string): string {}describe('dialog scrim dismissal', () => {- it('every Radix Dialog.Content ignores clicks outside the dialog', () => {+ it('every non-exempt Radix Dialog.Content ignores clicks outside the dialog', () => {const offenders = rendererComponentFiles(RENDERER_ROOT).filter((path) => !EXEMPT_FILES.has(rendererLabel(path))).flatMap((path) => unguardedDialogContents(rendererLabel(path), readFileSync(path, 'utf8')));diff --git a/apps/desktop/src/renderer/features/bots/BotSettingsDrawer.tsx b/apps/desktop/src/renderer/features/bots/BotSettingsDrawer.tsxindex af2fb9c510..5141a5088d 100644--- a/apps/desktop/src/renderer/features/bots/BotSettingsDrawer.tsx+++ b/apps/desktop/src/renderer/features/bots/BotSettingsDrawer.tsx@@ -137,7 +137,6 @@ export function BotSettingsDrawer() {{/* Keep portaled controls inside the overlay’s React tree so its scroll lock allows them. */}<Dialog.Overlay className="modal-scrim fixed inset-0 z-50"><Dialog.Content- onPointerDownOutside={(event) => event.preventDefault()}aria-describedby={undefined}// CJK IME: Escape during composition only cancels the candidate.onEscapeKeyDown={(event) => {diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botSettingsDrawer.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botSettingsDrawer.test.tsxindex b3c2b69463..a013fe3f06 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botSettingsDrawer.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/botSettingsDrawer.test.tsx@@ -95,6 +95,49 @@ afterEach(() => {});describe('BotSettingsDrawer', () => {+ // Unit regression for the reported inert scrim (DESIGN.md §4: side drawers dismiss outside).+ // Existing cases cover navigation, Escape and ×, but not pointer dismissal through the real+ // BotSettingsDrawer. A pointer on the scrim must close only when the save/draft guard permits;+ // pointers inside the drawer or its portal must leave it open.+ it('closes from the scrim only after the draft guard allows leaving', async () => {+ guard.mockResolvedValue(false);+ const router = createMemoryRouter([{ path: '*', element: <BotSettingsDrawer /> }], {+ initialEntries: ['/bots/bot-1?settings=1&settingsPage=memory&keep=1'],+ });+ render(<RouterProvider router={router} />);+ // Radix installs its document pointer listener on the next task.+ await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)); });+ const scrim = screen.getByRole('dialog').parentElement!;+ fireEvent.pointerDown(scrim, { pointerType: 'mouse', button: 0 });+ fireEvent.click(scrim);+ await waitFor(() => expect(guard).toHaveBeenCalledOnce());+ expect(screen.getByRole('dialog')).toBeTruthy();+ expect(router.state.location.search).toContain('settings=1');++ guard.mockResolvedValue(true);+ fireEvent.pointerDown(scrim, { pointerType: 'mouse', button: 0 });+ fireEvent.click(scrim);+ await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());+ expect(guard).toHaveBeenCalledTimes(2);+ expect(router.state.location.pathname).toBe('/bots/bot-1');+ expect(router.state.location.search).toBe('?keep=1');+ });++ it('keeps settings open when clicking inside the drawer or its portaled controls', async () => {+ render(<RouterProvider router={createMemoryRouter(+ [{ path: '*', element: <BotSettingsDrawer /> }],+ { initialEntries: ['/bots/bot-1?settings=1'] },+ )} />);+ await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)); });+ fireEvent.pointerDown(screen.getByTestId('simple-bot-settings'), { pointerType: 'mouse', button: 0 });+ fireEvent.click(screen.getByRole('button', { name: 'Choose model' }));+ const option = await screen.findByRole('button', { name: 'Model row' });+ fireEvent.pointerDown(option, { pointerType: 'mouse', button: 0 });+ fireEvent.click(option);+ expect(screen.getByTestId('simple-bot-settings')).toBeTruthy();+ expect(guard).not.toHaveBeenCalled();+ });+it('does not open editable settings for a copy demoted to another computer', async () => {cloud.demotedBotIds = ['bot-1'];const router = createMemoryRouter([{ path: '*', element: <BotSettingsDrawer /> }],