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(switchdash): opt dialogs out of the window drag region (CHOO-1953)
Louis Amaudruze13245ee7f83
diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/modal/modal-renderer.tsx b/dash/apps/switchdash-desktop/src/renderer/lib/modal/modal-renderer.tsxindex e5c58de36..891f1e887 100644--- a/dash/apps/switchdash-desktop/src/renderer/lib/modal/modal-renderer.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/lib/modal/modal-renderer.tsx@@ -109,7 +109,10 @@ export const ModalRenderer = observer(function ModalRenderer() {}}}className={cn(- 'fixed left-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 flex-col overflow-hidden rounded-xl bg-background-quaternary text-sm ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',+ // `no-drag`: the popup portals to `document.body`, so a view's+ // `-webkit-app-region: drag` rect stays live underneath it and would+ // otherwise swallow pointer-down. See the DialogOverlay docblock.+ 'fixed left-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 flex-col overflow-hidden rounded-xl bg-background-quaternary text-sm ring-1 ring-foreground/10 duration-100 outline-none [-webkit-app-region:no-drag] data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',POSITION_CLASSES[displayEntry?.position ?? 'center'],SIZE_CLASSES[displayEntry?.size ?? 'md'])}diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/ui/dialog.tsx b/dash/apps/switchdash-desktop/src/renderer/lib/ui/dialog.tsxindex 756e461cd..fe3be134d 100644--- a/dash/apps/switchdash-desktop/src/renderer/lib/ui/dialog.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/lib/ui/dialog.tsx@@ -20,12 +20,22 @@ function DialogClose({ ...props }: DialogPrimitive.Close.Props) {return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;}+/**+ * Draggable regions are geometric rectangles Chromium computes from layout, not+ * something a DOM subtree inherits. Dialogs portal to `document.body`, so a view+ * that declares `-webkit-app-region: drag` (the home panel, `page-header`,+ * `page-layout`, `Titlebar`, `sidebar-space`) keeps its rect live *underneath* an+ * open dialog: without an explicit opt-out, pointer-down over the dialog is taken+ * by the window-drag handler, so text cannot be selected and clicks land as drags.+ * The backdrop opts the whole viewport out for as long as a dialog is open, which+ * also keeps outside-click dismissal working over those views.+ */function DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props) {return (<DialogPrimitive.Backdropdata-slot="dialog-overlay"className={cn(- 'fixed inset-0 isolate z-50 bg-black/30 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',+ 'fixed inset-0 isolate z-50 bg-black/30 duration-100 [-webkit-app-region:no-drag] data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',className)}{...props}@@ -50,7 +60,10 @@ function DialogContent({}}}className={cn(- 'fixed top-1/2 left-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl bg-background text-sm ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 sm:max-w-lg',+ // `no-drag` is repeated here rather than left to the backdrop so the+ // popup carries the opt-out itself, even if it is ever rendered+ // without one. See the DialogOverlay docblock.+ 'fixed top-1/2 left-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl bg-background text-sm ring-1 ring-foreground/10 duration-100 outline-none [-webkit-app-region:no-drag] data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 sm:max-w-lg',className)}{...props}diff --git a/dash/apps/switchdash-desktop/src/renderer/tests/browser/modal-drag-region.test.tsx b/dash/apps/switchdash-desktop/src/renderer/tests/browser/modal-drag-region.test.tsxnew file mode 100644index 000000000..f7554bc4d--- /dev/null+++ b/dash/apps/switchdash-desktop/src/renderer/tests/browser/modal-drag-region.test.tsx@@ -0,0 +1,84 @@+import { act, type ReactNode } from 'react';+import { createRoot } from 'react-dom/client';+import { afterEach, describe, expect, it } from 'vitest';+import { ModalRenderer } from '@renderer/lib/modal/modal-renderer';+import { modalStore } from '@renderer/lib/modal/modal-store';+import { Dialog, DialogContent } from '@renderer/lib/ui/dialog';++/**+ * Draggable regions are geometric rectangles Chromium derives from layout, not+ * an inherited DOM property. Dialogs portal to `document.body`, so the drag rect+ * a view declares (the home panel since CHOO-1430, plus `page-header`,+ * `page-layout`, `Titlebar` and `sidebar-space`) stays live underneath an open+ * dialog and takes its pointer-down events: the window moves and form text+ * cannot be selected (CHOO-1953).+ *+ * Only Electron acts on a drag region, so — as in `home-drag-region.test.tsx` —+ * these assertions are on the markup rather than on behaviour. They exist to+ * catch a restyle or refactor silently dropping the opt-out again.+ */++const NO_DRAG = '[-webkit-app-region:no-drag]';++let container: HTMLDivElement | null = null;++async function render(node: ReactNode): Promise<void> {+ container = document.createElement('div');+ document.body.appendChild(container);+ const root = createRoot(container);+ await act(async () => root.render(node));+}++// `unsavedChangesModal` stands in for any registry modal: the assertions are on+// the chrome ModalRenderer wraps around the content, not on the content itself,+// and this one renders from its props alone — no query client or store to stub.+async function renderRegistryModal(): Promise<void> {+ modalStore.setModal('unsavedChangesModal', {+ fileName: 'test.txt',+ onSuccess: () => {},+ onClose: () => {},+ });+ await render(<ModalRenderer />);+}++afterEach(() => {+ modalStore.closeModal();+ container?.remove();+ container = null;+});++describe('modal drag region', () => {+ it('opts the registry modal popup out of the drag region', async () => {+ await renderRegistryModal();++ // The popup portals out of `container`, so query the document.+ const popup = document.querySelector('[data-slot="dialog-content"]');++ expect(popup).not.toBeNull();+ expect(popup?.className).toContain(NO_DRAG);+ });++ it('opts the backdrop out so outside clicks dismiss rather than drag', async () => {+ await renderRegistryModal();++ const overlay = document.querySelector('[data-slot="dialog-overlay"]');++ expect(overlay).not.toBeNull();+ expect(overlay?.className).toContain(NO_DRAG);+ });++ it('opts the standalone DialogContent out too', async () => {+ await render(+ <Dialog open>+ <DialogContent>+ <p>Test</p>+ </DialogContent>+ </Dialog>+ );++ const popup = document.querySelector('[data-slot="dialog-content"]');++ expect(popup).not.toBeNull();+ expect(popup?.className).toContain(NO_DRAG);+ });+});