Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(desktop): let clicks reach the full-screen live screen on Mac and Windows (#4311)

Aditya Umale597e70d7930d
diff --git a/src/components/LiveDesktop.test.ts b/src/components/LiveDesktop.test.ts
index 85497a83e9..8e776d5c5f 100644
--- a/src/components/LiveDesktop.test.ts
+++ b/src/components/LiveDesktop.test.ts
@@ -1,5 +1,6 @@
// @vitest-environment happy-dom
// The live desktop's own lifecycle, with the connection played by the test.
+import { readFileSync } from "node:fs";
import { createElement } from "react";
import { flushSync } from "react-dom";
import { createRoot, type Root } from "react-dom/client";
@@ -27,6 +28,8 @@ vi.mock("./DesktopCapabilities", async (importOriginal) => ({
}));
const { LiveDesktop } = await import("./LiveDesktop");
+const css = readFileSync("src/styles.css", "utf8");
+const noDragSelector = /\/\* Window drag regions\.[\s\S]*?\*\/\s*([^{]+)\{\s*-webkit-app-region: no-drag;/.exec(css)![1].trim();
let root: Root;
let props: Parameters<typeof LiveDesktop>[0];
const draw = (patch: Partial<typeof props> = {}) => {
@@ -125,4 +128,15 @@ describe("the live desktop", () => {
flushSync(() => button("Hand control back")!.click());
expect(props.onHandBack).toHaveBeenCalledTimes(1);
});
+
+ // On macOS and frameless Windows the sidebar, chat header and frame bar under the full-screen desktop are window
+ // drag regions, and Electron ignores z-index for them, so a press on the top of the live screen moved the window.
+ it("full screen opts the live screen out of the window drag regions beneath it", () => {
+ const desktop = () => document.querySelector<HTMLElement>("[data-live-desktop]")!;
+ expect(desktop().matches(noDragSelector), "in the side panel nothing changes").toBe(false);
+ draw({ expanded: true });
+ expect(desktop().matches(noDragSelector)).toBe(true);
+ draw({ expanded: false });
+ expect(desktop().matches(noDragSelector)).toBe(false);
+ });
});
diff --git a/src/styles.css b/src/styles.css
index 6ed924cb81..9fcfeb0829 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -3031,12 +3031,14 @@ button:disabled.bg-danger {
property inherits, so a select's or input's wrapper is cut out too: its
chevron or icon overlay would otherwise drag over the field. A modal's
full-window backdrop is cut out with its dialog, so a press on it over a
- header still closes the dialog instead of moving the window. */
+ header still closes the dialog instead of moving the window. The
+ full-screen live desktop covers the headers beneath it the same way. */
[data-window-drag] :has(> :is(select, input)),
[data-window-drag] :is(button, a[href], input, select, textarea, label, summary, [role="button"], [role="link"], [role="tab"], [role="switch"], [role="checkbox"], [role="radio"], [role="combobox"], [role="slider"], [role="separator"], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])),
:is([role="menu"], [role="listbox"], [role="dialog"], [role="alertdialog"], [role="tooltip"]),
.fixed:has(> :is([role="dialog"], [role="alertdialog"], [aria-modal="true"])),
-[data-browser-transport] {
+[data-browser-transport],
+[data-live-desktop][data-expanded] {
-webkit-app-region: no-drag;
}