Address HUD protection review feedback

This commit is contained in:
young
2026-09-03 11:51:48 +10:00
parent ae36ac8a88
commit 7899d8fce0
7 changed files with 77 additions and 33 deletions
+3 -2
View File
@@ -19,6 +19,7 @@ import { useScopedT } from "../../contexts/I18nContext";
import { useMicrophoneDevices } from "../../hooks/useMicrophoneDevices";
import { useScreenRecorder } from "../../hooks/useScreenRecorder";
import { useVideoDevices } from "../../hooks/useVideoDevices";
import { supportsHudCaptureProtection } from "../../lib/hudCaptureProtection";
import { Button } from "../ui/button";
import { HudInteractionContext } from "./contexts/HudInteractionContext";
import { canToggleFloatingWebcamPreview } from "./floatingWebcamPreview";
@@ -115,7 +116,7 @@ function LaunchWindowContent() {
toggleHudCaptureProtection,
} = useLaunchWindowSystemState(preparePermissions);
const supportsHudCaptureProtection = true;
const hudCaptureProtectionSupported = supportsHudCaptureProtection(platform ?? "");
useEffect(() => {
if (!selectedDeviceId) {
@@ -372,7 +373,7 @@ function LaunchWindowContent() {
</div>
<MorePopover
supportsHudCaptureProtection={supportsHudCaptureProtection}
supportsHudCaptureProtection={hudCaptureProtectionSupported}
hideHudFromCapture={hideHudFromCapture}
onToggleHudCaptureProtection={() => {
void toggleHudCaptureProtection();
+33
View File
@@ -0,0 +1,33 @@
import { describe, expect, it } from "vitest";
import {
getHudCaptureExcludedProcessIds,
supportsHudCaptureProtection,
} from "./hudCaptureProtection";
describe("supportsHudCaptureProtection", () => {
it.each([
["win32", true],
["darwin", true],
["linux", false],
["freebsd", false],
])("reports support for %s as %s", (platform, expected) => {
expect(supportsHudCaptureProtection(platform)).toBe(expected);
});
});
describe("getHudCaptureExcludedProcessIds", () => {
it("passes the current process to macOS capture when protection is enabled", () => {
expect(getHudCaptureExcludedProcessIds("darwin", true, 4512)).toEqual([4512]);
});
it.each([
["darwin", false, 4512],
["win32", true, 4512],
["linux", true, 4512],
["darwin", true, 0],
["darwin", true, Number.NaN],
])("returns no native exclusions for %s, enabled=%s, pid=%s", (platform, enabled, pid) => {
expect(getHudCaptureExcludedProcessIds(platform, enabled, pid as number)).toEqual([]);
});
});
+15
View File
@@ -0,0 +1,15 @@
export function supportsHudCaptureProtection(platform: string): boolean {
return platform === "darwin" || platform === "win32";
}
export function getHudCaptureExcludedProcessIds(
platform: string,
enabled: boolean,
processId: number,
): number[] {
if (platform !== "darwin" || !enabled || !Number.isSafeInteger(processId) || processId <= 0) {
return [];
}
return [processId];
}