Skip to content

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

fix(mac): don't open Screen Recording settings after Not now

AdityaUmaled11911cde257
diff --git a/src/components/MacLocalControl.test.ts b/src/components/MacLocalControl.test.ts
index c8536abe80..fa78d60635 100644
--- a/src/components/MacLocalControl.test.ts
+++ b/src/components/MacLocalControl.test.ts
@@ -48,4 +48,18 @@ describe("Mac local computer status", () => {
expect(renderToStaticMarkup(createElement(isolated.MacLocalControl))).toBe("");
expect(renderToStaticMarkup(createElement(MacLocalControl))).toContain("Allow control of this computer");
});
+
+ it("does not open Screen Recording settings after Not now during the Accessibility step", async () => {
+ vi.resetModules();
+ const isolated = await import("./MacLocalControl");
+ const open = vi.fn(async (pane: string) => { if (pane === "accessibility") isolated.hideMacLocalControlUntilRelaunch(); });
+ await isolated.openMacControlSettings(open);
+ expect(open.mock.calls).toEqual([["accessibility"]]);
+
+ vi.resetModules();
+ const fresh = await import("./MacLocalControl");
+ const openAll = vi.fn(async () => {});
+ await fresh.openMacControlSettings(openAll);
+ expect(openAll.mock.calls).toEqual([["accessibility"], ["screen"]]);
+ });
});
diff --git a/src/components/MacLocalControl.tsx b/src/components/MacLocalControl.tsx
index b9857ea83b..d3716d4647 100644
--- a/src/components/MacLocalControl.tsx
+++ b/src/components/MacLocalControl.tsx
@@ -16,6 +16,15 @@ export function hideMacLocalControlUntilRelaunch() {
for (const listener of hiddenListeners) listener();
}
+/** Opens Accessibility, then Screen Recording settings; stops if the card was dismissed in between. */
+export async function openMacControlSettings(
+ open: (pane: "accessibility" | "screen") => Promise<void> | undefined = (pane) => window.ogb?.permOpenSettings?.(pane),
+) {
+ await open("accessibility");
+ if (hiddenUntilRelaunch) return;
+ await open("screen");
+}
+
export function MacLocalControl() {
const { capabilities } = useDesktopCapabilities();
const hidden = useSyncExternalStore(subscribeHidden, readHidden, readHidden);
@@ -41,8 +50,7 @@ export function MacLocalControl() {
setError(null);
setAwaitingGrant(true);
try {
- await window.ogb?.permOpenSettings?.("accessibility");
- await window.ogb?.permOpenSettings?.("screen");
+ await openMacControlSettings();
} catch (reason) {
setAwaitingGrant(false);
setError(reason instanceof Error ? reason.message : String(reason));