Skip to content

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

fix(mac): stop the pending retry after Not now; isolate the dismissal test

AdityaUmaleb442c1288951
diff --git a/src/components/MacLocalControl.test.ts b/src/components/MacLocalControl.test.ts
index ab0bf8acad..c8536abe80 100644
--- a/src/components/MacLocalControl.test.ts
+++ b/src/components/MacLocalControl.test.ts
@@ -12,7 +12,7 @@ vi.mock("./DesktopCapabilities", () => ({
useDesktopCapabilities: () => ({ capabilities: { host: { platform: "darwin" }, localComputer: fixture.localComputer }, ready: true }),
}));
-const { MacLocalControl, hideMacLocalControlUntilRelaunch } = await import("./MacLocalControl");
+const { MacLocalControl } = await import("./MacLocalControl");
afterAll(() => vi.unstubAllGlobals());
describe("Mac local computer status", () => {
@@ -39,10 +39,13 @@ describe("Mac local computer status", () => {
expect(renderToStaticMarkup(createElement(MacLocalControl))).toBe("");
});
- it("hides the card after Not now until the app starts again", () => {
+ it("hides the card after Not now until the app starts again", async () => {
+ vi.resetModules();
+ const isolated = await import("./MacLocalControl");
fixture.localComputer = { available: false, message: "Accessibility required; grant access in System Settings" } as DesktopCapabilities["localComputer"];
+ expect(renderToStaticMarkup(createElement(isolated.MacLocalControl))).toContain("Allow control of this computer");
+ isolated.hideMacLocalControlUntilRelaunch();
+ expect(renderToStaticMarkup(createElement(isolated.MacLocalControl))).toBe("");
expect(renderToStaticMarkup(createElement(MacLocalControl))).toContain("Allow control of this computer");
- hideMacLocalControlUntilRelaunch();
- expect(renderToStaticMarkup(createElement(MacLocalControl))).toBe("");
});
});
diff --git a/src/components/MacLocalControl.tsx b/src/components/MacLocalControl.tsx
index 5b166c4d99..7c64678a45 100644
--- a/src/components/MacLocalControl.tsx
+++ b/src/components/MacLocalControl.tsx
@@ -6,7 +6,6 @@ import { MacCuaRecoveryActions } from "./MacCuaRecoveryActions";
import { NotNowButton } from "./NoticeCard";
import { t } from "@/lib/i18n";
-// "Not now" hides the card in every place it shows until the app starts again; nothing is saved.
let hiddenUntilRelaunch = false;
const hiddenListeners = new Set<() => void>();
const subscribeHidden = (listener: () => void) => { hiddenListeners.add(listener); return () => { hiddenListeners.delete(listener); }; };
@@ -51,7 +50,7 @@ export function MacLocalControl() {
};
useEffect(() => {
- if (!awaitingGrant) return;
+ if (!awaitingGrant || hidden) return;
let used = false;
const onFocus = () => {
if (used) return;
@@ -66,7 +65,7 @@ export function MacLocalControl() {
window.removeEventListener("focus", onFocus);
document.removeEventListener("visibilitychange", onFocus);
};
- }, [awaitingGrant]);
+ }, [awaitingGrant, hidden]);
if (capabilities.host.platform !== "darwin" || capabilities.localComputer.reasonCode === "remote-server") return null;
if (capabilities.localComputer.available || hidden) return null;