Skip to content
32 changes: 32 additions & 0 deletions packages/compass/src/main/auto-update-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,11 +827,41 @@ class CompassAutoUpdateManager {
this.setState(AutoUpdateManagerState.RestartDismissed);
}

private static checkForMismatchedMacOSArch() {
const mismatchedOnArm =
isMismatchedArchDarwin() && getSystemArch() === 'arm64';

if (!mismatchedOnArm) {
return;
}

void dialog
.showMessageBox({
Comment on lines +871 to +872
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the performance issue is bad enough that it deserves a system prompt and not a toast or something similar, but I'm open to the feedback here

icon: COMPASS_ICON,
message: 'Mismatched architecture detected',
detail:
'You are currently using a build of Compass that is not optimized for Apple Silicon processors. This version might have significat performance issues when used. ' +
'Would you like to download the version of Compass optimized for Apple Silicon processors now?',
buttons: [
'Download Compass for Apple Silicon (Recommended)',
'Not now',
],
cancelId: 1,
})
.then(({ response }) => {
if (response === 0) {
const url = `https://compass.mongodb.com/api/v2/download/latest/compass/${this.autoUpdateOptions.channel}/darwin-arm64`;
void dl.download(BrowserWindow.getAllWindows()[0], url);
}
});
}

private static _init(
compassApp: typeof CompassApplication,
options: Partial<AutoUpdateManagerOptions> = {}
): void {
this.fetch = (url: string) => compassApp.httpClient.fetch(url);

compassApp.addExitHandler(() => {
this.stop();
return Promise.resolve();
Expand Down Expand Up @@ -867,6 +897,8 @@ class CompassAutoUpdateManager {
...options,
};

this.checkForMismatchedMacOSArch();

// TODO(COMPASS-7232): If auto-updates are not supported, then there is
// still a menu item to check for updates and then if it finds an update but
// auto-updates aren't supported it will still display a popup with an
Expand Down
Loading