Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit c6c59c6

Browse files
committed
feat(cpu_dialog): add actual Windows CPU detection
1 parent 0a81e26 commit c6c59c6

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

apps/client/src/widgets/dialogs/incorrect_cpu_arch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import utils from "../../services/utils.js";
44
import { t } from "../../services/i18n.js";
55

66
const TPL = /*html*/`
7-
<div class="rosetta-warning-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;">
7+
<div class="cpu-arch-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;">
88
<div class="modal-dialog modal-lg" role="document">
99
<div class="modal-content">
1010
<div class="modal-header">

apps/server/src/routes/api/system_info.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { execSync } from "child_process";
2-
import { isMac } from "../../services/utils";
2+
import { isMac, isWindows } from "../../services/utils";
3+
import { arch, cpus } from "os";
34

45
function systemChecks() {
56
return {
6-
isCpuArchMismatch: isRunningUnderRosetta2()
7+
isCpuArchMismatch: isCpuArchMismatch()
78
}
89
}
910

@@ -13,8 +14,31 @@ function systemChecks() {
1314
* Uses the macOS sysctl.proc_translated to properly detect translation.
1415
* @returns true if running under Rosetta 2, false otherwise
1516
*/
16-
export const isRunningUnderRosetta2 = () => {
17-
return true;
17+
export const isCpuArchMismatch = () => {
18+
if (isMac) {
19+
try {
20+
// Use child_process to check sysctl.proc_translated
21+
// This is the proper way to detect Rosetta 2 translation
22+
const result = execSync("sysctl -n sysctl.proc_translated 2>/dev/null", {
23+
encoding: "utf8",
24+
timeout: 1000
25+
}).trim();
26+
27+
// 1 means the process is being translated by Rosetta 2
28+
// 0 means native execution
29+
// If the sysctl doesn't exist (on Intel Macs), this will return empty/error
30+
return result === "1";
31+
} catch (error) {
32+
// If sysctl fails or doesn't exist (Intel Macs), not running under Rosetta 2
33+
return false;
34+
}
35+
} else if (isWindows && arch() === "x64") {
36+
return cpus().some(cpu =>
37+
cpu.model.includes('Microsoft SQ') ||
38+
cpu.model.includes('Snapdragon'));
39+
} else {
40+
return false;
41+
}
1842
};
1943

2044
export default {

0 commit comments

Comments
 (0)