Skip to content

Build your personal knowledge base with Trilium Notes

feat(cpu_dialog): add actual Windows CPU detection

Elian Doranc6c59c63bb18
diff --git a/apps/client/src/widgets/dialogs/incorrect_cpu_arch.ts b/apps/client/src/widgets/dialogs/incorrect_cpu_arch.ts
index 8cefce5333..c45d8bb291 100644
--- a/apps/client/src/widgets/dialogs/incorrect_cpu_arch.ts
+++ b/apps/client/src/widgets/dialogs/incorrect_cpu_arch.ts
@@ -4,7 +4,7 @@ import utils from "../../services/utils.js";
import { t } from "../../services/i18n.js";
const TPL = /*html*/`
-<div class="rosetta-warning-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;">
+<div class="cpu-arch-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
diff --git a/apps/server/src/routes/api/system_info.ts b/apps/server/src/routes/api/system_info.ts
index b2fa4d5c8b..b40c01d243 100644
--- a/apps/server/src/routes/api/system_info.ts
+++ b/apps/server/src/routes/api/system_info.ts
@@ -1,9 +1,10 @@
import { execSync } from "child_process";
-import { isMac } from "../../services/utils";
+import { isMac, isWindows } from "../../services/utils";
+import { arch, cpus } from "os";
function systemChecks() {
return {
- isCpuArchMismatch: isRunningUnderRosetta2()
+ isCpuArchMismatch: isCpuArchMismatch()
}
}
@@ -13,8 +14,31 @@ function systemChecks() {
* Uses the macOS sysctl.proc_translated to properly detect translation.
* @returns true if running under Rosetta 2, false otherwise
*/
-export const isRunningUnderRosetta2 = () => {
- return true;
+export const isCpuArchMismatch = () => {
+ if (isMac) {
+ try {
+ // Use child_process to check sysctl.proc_translated
+ // This is the proper way to detect Rosetta 2 translation
+ const result = execSync("sysctl -n sysctl.proc_translated 2>/dev/null", {
+ encoding: "utf8",
+ timeout: 1000
+ }).trim();
+
+ // 1 means the process is being translated by Rosetta 2
+ // 0 means native execution
+ // If the sysctl doesn't exist (on Intel Macs), this will return empty/error
+ return result === "1";
+ } catch (error) {
+ // If sysctl fails or doesn't exist (Intel Macs), not running under Rosetta 2
+ return false;
+ }
+ } else if (isWindows && arch() === "x64") {
+ return cpus().some(cpu =>
+ cpu.model.includes('Microsoft SQ') ||
+ cpu.model.includes('Snapdragon'));
+ } else {
+ return false;
+ }
};
export default {