Skip to content

Commit e1e219a

Browse files
committed
feat(auto-update-manager): show a system prompt about mismatched arch on apple arm on application start
1 parent a9b2fa7 commit e1e219a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/compass/src/main/auto-update-manager.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,41 @@ class CompassAutoUpdateManager {
827827
this.setState(AutoUpdateManagerState.RestartDismissed);
828828
}
829829

830+
private static checkForMismatchedMacOSArch() {
831+
const mismatchedOnArm =
832+
isMismatchedArchDarwin() && getSystemArch() === 'arm64';
833+
834+
if (!mismatchedOnArm) {
835+
return;
836+
}
837+
838+
void dialog
839+
.showMessageBox({
840+
icon: COMPASS_ICON,
841+
message: 'Mismatched architecture detected',
842+
detail:
843+
'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. ' +
844+
'Would you like to download the version of Compass optimized for Apple Silicon processors now?',
845+
buttons: [
846+
'Download Compass for Apple Silicon (Recommended)',
847+
'Not now',
848+
],
849+
cancelId: 1,
850+
})
851+
.then(({ response }) => {
852+
if (response === 0) {
853+
const url = `https://compass.mongodb.com/api/v2/download/latest/compass/${this.autoUpdateOptions.channel}/darwin-arm64`;
854+
void dl.download(BrowserWindow.getAllWindows()[0], url);
855+
}
856+
});
857+
}
858+
830859
private static _init(
831860
compassApp: typeof CompassApplication,
832861
options: Partial<AutoUpdateManagerOptions> = {}
833862
): void {
834863
this.fetch = (url: string) => compassApp.httpClient.fetch(url);
864+
835865
compassApp.addExitHandler(() => {
836866
this.stop();
837867
return Promise.resolve();
@@ -867,6 +897,8 @@ class CompassAutoUpdateManager {
867897
...options,
868898
};
869899

900+
this.checkForMismatchedMacOSArch();
901+
870902
// TODO(COMPASS-7232): If auto-updates are not supported, then there is
871903
// still a menu item to check for updates and then if it finds an update but
872904
// auto-updates aren't supported it will still display a popup with an

0 commit comments

Comments
 (0)