Skip to content

Commit 90db33c

Browse files
committed
Fix system app-lock availability handling
1 parent 6c49baf commit 90db33c

4 files changed

Lines changed: 28 additions & 5 deletions

File tree

components/settings/tabs/SettingsSystemTab.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ test("app lock system unlock enablement does not require current password in set
7777
assert.doesNotMatch(systemUnlockSection, /settings\.appLock\.currentPassword/);
7878
});
7979

80-
test("app lock system unlock toggle still allows disabling when system auth is unavailable", () => {
80+
test("app lock system unlock setting hides when unavailable unless already enabled", () => {
8181
const source = readFileSync(new URL("./SettingsSystemTab.tsx", import.meta.url), "utf8");
8282
const appLockSectionStart = source.indexOf('<SectionHeader title={t("settings.appLock.title")} />');
8383
const nextSectionStart = source.indexOf("<SectionHeader", appLockSectionStart + 1);
8484
const appLockSection = source.slice(appLockSectionStart, nextSectionStart);
8585

86-
assert.match(appLockSection, /disabled=\{isSavingAppLockSystemUnlock \|\| \(!appLockSettings\.systemUnlockEnabled && !appLockSystemUnlockStatus\.available\)\}/);
86+
assert.match(source, /appLockSystemUnlockStatus\?\.available \|\| appLockSettings\.systemUnlockEnabled/);
87+
assert.match(appLockSection, /disabled=\{isSavingAppLockSystemUnlock \|\| !appLockSystemUnlockStatus\.available\}/);
8788
});
8889

8990
test("app lock system unlock exposes auto prompt as a child option", () => {

components/settings/tabs/SettingsSystemTab.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,12 @@ const SettingsSystemTab: React.FC<SettingsSystemTabProps> = ({
178178
const [isSavingAppLock, setIsSavingAppLock] = useState(false);
179179
const [isSavingAppLockSystemUnlock, setIsSavingAppLockSystemUnlock] = useState(false);
180180
const hasAppLockPassword = Boolean(appLockSettings.passwordVerifier);
181-
const showAppLockSystemUnlock = Boolean(hasAppLockPassword && appLockSystemUnlockStatus?.supported && appLockSystemUnlockStatus.label);
181+
const showAppLockSystemUnlock = Boolean(
182+
hasAppLockPassword &&
183+
appLockSystemUnlockStatus?.supported &&
184+
appLockSystemUnlockStatus.label &&
185+
(appLockSystemUnlockStatus?.available || appLockSettings.systemUnlockEnabled)
186+
);
182187

183188
const [tempDirInfo, setTempDirInfo] = useState<TempDirInfo | null>(null);
184189
const [isLoading, setIsLoading] = useState(false);
@@ -486,6 +491,7 @@ const SettingsSystemTab: React.FC<SettingsSystemTabProps> = ({
486491
setIsSavingAppLockSystemUnlock(false);
487492
}
488493
}, [
494+
appLockSettings.systemUnlockEnabled,
489495
appLockSettings.systemUnlockAutoPromptEnabled,
490496
appLockSystemUnlockStatus?.label,
491497
mapAppLockChangeError,
@@ -769,7 +775,7 @@ const SettingsSystemTab: React.FC<SettingsSystemTabProps> = ({
769775
<div className="flex flex-col items-end gap-2">
770776
<Toggle
771777
checked={appLockSettings.systemUnlockEnabled}
772-
disabled={isSavingAppLockSystemUnlock || (!appLockSettings.systemUnlockEnabled && !appLockSystemUnlockStatus.available)}
778+
disabled={isSavingAppLockSystemUnlock || !appLockSystemUnlockStatus.available}
773779
ariaLabel={t("settings.appLock.systemUnlock.label").replace("{label}", appLockSystemUnlockStatus.label)}
774780
onChange={(enabled) => void handleAppLockSystemUnlockChange(enabled)}
775781
/>

electron/bridges/appLockSystemAuthBridge.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function resolveDefaultHelperPath() {
9696
if (process.resourcesPath) {
9797
return path.join(process.resourcesPath, "windowsHello", "NetcattyWindowsHello.exe");
9898
}
99-
return path.join(__dirname, "windowsHelloHelper", "build", "NetcattyWindowsHello.exe");
99+
return path.join(__dirname, "windowsHelloHelper", "build", process.arch, "NetcattyWindowsHello.exe");
100100
}
101101

102102
function createAppLockSystemAuthBridge({

electron/bridges/appLockSystemAuthBridge.test.cjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
createAppLockSystemAuthBridge,
66
normalizeSystemAuthStatus,
77
normalizeSystemAuthUnlockResult,
8+
resolveDefaultHelperPath,
89
} = require("./appLockSystemAuthBridge.cjs");
910

1011
test("normalizes unsupported status", () => {
@@ -85,6 +86,21 @@ test("Windows status and unlock call helper with HWND", async () => {
8586
assert.deepEqual(calls[1].args, ["verify", "--hwnd", "1234605616436508552", "--message", "Unlock Netcatty"]);
8687
});
8788

89+
test("Windows dev helper path follows the architecture-specific build output", () => {
90+
const originalPlatform = Object.getOwnPropertyDescriptor(process, "platform");
91+
const originalArch = Object.getOwnPropertyDescriptor(process, "arch");
92+
Object.defineProperty(process, "platform", { value: "win32" });
93+
Object.defineProperty(process, "arch", { value: "x64" });
94+
95+
try {
96+
const helperPath = resolveDefaultHelperPath();
97+
assert.match(helperPath, /windowsHelloHelper[\\/]build[\\/]x64[\\/]NetcattyWindowsHello\.exe$/);
98+
} finally {
99+
Object.defineProperty(process, "platform", originalPlatform);
100+
Object.defineProperty(process, "arch", originalArch);
101+
}
102+
});
103+
88104
test("Windows helper maps unavailable and cancelled states", async () => {
89105
const bridge = createAppLockSystemAuthBridge({
90106
platform: "win32",

0 commit comments

Comments
 (0)