Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix: add settings shortcut to cursor permission warning

EtienneLescot7b79cd5a2291
diff --git a/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx b/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx
index b3183d7f7..89158eb72 100644
--- a/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx
+++ b/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx
@@ -19,9 +19,11 @@ const SOURCE = { id: "screen:0:0", name: "Screen 1", display_id: "1", thumbnail:
let api: Record<string, ReturnType<typeof vi.fn>>;
let emitSystemAudioUnavailable: (() => void) | undefined;
+let openAccessibilitySettings: ReturnType<typeof vi.fn>;
function stubElectronAPI(systemAudioEnabled = false) {
emitSystemAudioUnavailable = undefined;
+ openAccessibilitySettings = vi.fn(async () => undefined);
api = {
getRecordingPrefs: vi.fn(async () => ({
micEnabled: true,
@@ -52,6 +54,9 @@ function stubElectronAPI(systemAudioEnabled = false) {
hideCountdownOverlay: vi.fn(async () => true),
};
window.electronAPI = api as unknown as ElectronAPI;
+ Object.defineProperty(window.electronAPI, "permissions", {
+ value: { openSettings: openAccessibilitySettings },
+ });
}
async function settle(ms = 0) {
@@ -187,7 +192,21 @@ describe("useScreenRecorder native macOS start warnings", () => {
expect(api.requestNativeMacCursorAccess).toHaveBeenCalledOnce();
expect(api.startNativeMacRecording).toHaveBeenCalledOnce();
expect(view.result.current.recording).toBe(true);
- expect(toast.warning).toHaveBeenCalledWith("recording.cursorAccessibilityUnavailable");
+ expect(toast.warning).toHaveBeenCalledWith(
+ "recording.cursorAccessibilityUnavailable",
+ expect.objectContaining({
+ action: expect.objectContaining({ label: "permissions.actions.openSettings" }),
+ }),
+ );
+ const warningOptions = vi.mocked(toast.warning).mock.calls.at(-1)?.[1] as
+ | { action?: { onClick?: () => void } }
+ | undefined;
+
+ await act(async () => {
+ warningOptions?.action?.onClick?.();
+ });
+
+ expect(openAccessibilitySettings).toHaveBeenCalledWith("accessibility");
});
it("shows the Accessibility warning once across repeated recording attempts", async () => {
diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts
index 42e2feebc..3e036e46e 100644
--- a/src/hooks/useScreenRecorder.ts
+++ b/src/hooks/useScreenRecorder.ts
@@ -226,6 +226,7 @@ export async function finalizeWebcamAsset(
export function useScreenRecorder(): UseScreenRecorderReturn {
const t = useScopedT("editor");
+ const tLaunch = useScopedT("launch");
/**
* `t` through a ref, for the callbacks that must not be rebuilt when it
* changes identity.
@@ -1653,7 +1654,15 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
!cursorAccessibilityWarningShown.current
) {
cursorAccessibilityWarningShown.current = true;
- toast.warning(t("recording.cursorAccessibilityUnavailable"));
+ toast.warning(t("recording.cursorAccessibilityUnavailable"), {
+ duration: 10_000,
+ action: {
+ label: tLaunch("permissions.actions.openSettings"),
+ onClick: () => {
+ void window.electronAPI?.permissions.openSettings("accessibility");
+ },
+ },
+ });
}
}
} catch (error) {