Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

apps: Prefer Intel macOS download when amd64 architecture is detected

Vijay Hiremath58d43d160888
diff --git a/templates/corporate/apps.html b/templates/corporate/apps.html
index 397d06e6e3c..14fba67e68a 100644
--- a/templates/corporate/apps.html
+++ b/templates/corporate/apps.html
@@ -22,7 +22,10 @@
<a class="button download-from-apple-app-store" hidden href=""><img src="{{ static('images/store-badges/app-store-badge.svg') }}" alt=""/></a>
<span id="download-from-microsoft-store" hidden>or <a href="https://apps.microsoft.com/store/detail/XP8HN41S4PLGZ3">download from the Microsoft Store</a></span>
<span id="download-android-apk" hidden>or manually download APK for the <a class="android-apk-current" href="">current</a> or <a class="android-apk-legacy" href="">legacy</a> app</span>
- <span id="download-mac-intel" hidden>or <a href="">download <strong>Intel</strong> processor build <i>(some older Macs)</i></a></span>
+ <div id="download-mac-alt" hidden>
+ <div id="download-mac-alt-apple-silicon" hidden>or <a href="/apps/download/mac-arm64">download <strong>Apple Silicon</strong> processor build <i>(M1, M2, M3, etc.)</i></a></div>
+ <div id="download-mac-alt-intel" hidden>or <a href="/apps/download/mac-intel">download <strong>Intel</strong> processor build <i>(some older Macs)</i></a></div>
+ </div>
<p class="download-instructions"></p>
</div>
</div>
diff --git a/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py b/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py
index 04f11c5ccda..dab2e5dc98e 100644
--- a/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py
+++ b/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py
@@ -52,3 +52,6 @@ class PorticoDocumentationSpider(BaseDocumentationSpider):
"http://localhost:9981/security/",
]
deny_domains: list[str] = []
+ # Exclude /apps/download/* URLs to prevent crawler from following redirects
+ # to desktop-download.zulip.com and attempting to fetch large .dmg/.exe files
+ deny = [r".*/apps/download/.*"]
diff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.py
index 8c2a916b6f4..34088b0b88b 100644
--- a/tools/lib/capitalization.py
+++ b/tools/lib/capitalization.py
@@ -14,6 +14,7 @@ IGNORED_PHRASES = [
r"AI",
r"API",
r"APNS",
+ r"Apple Silicon",
r"Botserver",
r"Cookie Bot",
r"DevAuthBackend",
@@ -27,6 +28,7 @@ IGNORED_PHRASES = [
r"ID",
r"IDs",
r"Inbox",
+ r"Intel",
r"IP",
r"JSON",
r"Jitsi",
@@ -57,6 +59,8 @@ IGNORED_PHRASES = [
r"Zulip Cloud Standard",
r"Zulip Cloud Plus",
r"Zulip Desktop",
+ r"Download Zulip for macOS \(Apple Silicon\)",
+ r"Download Zulip for macOS \(Intel\)",
r"BigBlueButton",
r"Constructor Groups",
# Code things
diff --git a/web/src/portico/legacy_landing_page.ts b/web/src/portico/legacy_landing_page.ts
index 71a458d95ba..56fc6714944 100644
--- a/web/src/portico/legacy_landing_page.ts
+++ b/web/src/portico/legacy_landing_page.ts
@@ -3,11 +3,63 @@ import assert from "minimalistic-assert";
import * as z from "zod/mini";
import {page_params} from "../base_page_params.ts";
+import {$t} from "../i18n.ts";
import type {UserOS} from "./tabbed-instructions.ts";
import {detect_user_os} from "./tabbed-instructions.ts";
import render_tabs from "./team.ts";
+// Type definitions for User-Agent Client Hints API
+// Documentation sources:
+// - MDN: NavigatorUAData and getHighEntropyValues()
+// https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData
+// - UA Client Hints specification (architecture field):
+// https://wicg.github.io/ua-client-hints/
+type UserAgentHints = {
+ platform?: string;
+ architecture?: string;
+};
+
+type NavigatorUAData = {
+ getHighEntropyValues?: (hints: readonly string[]) => Promise<UserAgentHints>;
+};
+
+// Type guard to check if navigator has userAgentData API (not available in Safari)
+function has_user_agent_data(n: unknown): n is {userAgentData: NavigatorUAData} {
+ return typeof n === "object" && n !== null && "userAgentData" in n;
+}
+
+// Detect macOS processor architecture using Navigator UA Client Hints API.
+// Returns "intel" for x86 architecture, "arm" for ARM64 (Apple Silicon), or null if detection fails.
+// This gracefully degrades in Safari and older browsers that don't support the API.
+async function detect_mac_architecture(): Promise<"intel" | "arm" | null> {
+ if (!has_user_agent_data(window.navigator)) {
+ return null;
+ }
+
+ const ua_data = window.navigator.userAgentData;
+ if (!ua_data || typeof ua_data.getHighEntropyValues !== "function") {
+ return null;
+ }
+
+ try {
+ const hints = await ua_data.getHighEntropyValues(["platform", "architecture"]);
+
+ if (hints.platform === "macOS") {
+ if (hints.architecture?.startsWith("x86")) {
+ return "intel";
+ }
+ if (hints.architecture === "arm64") {
+ return "arm";
+ }
+ }
+ } catch {
+ // Silently fail if API is unavailable
+ }
+
+ return null;
+}
+
type VersionInfo = {
description: string;
app_type: "mobile" | "desktop";
@@ -126,7 +178,7 @@ const apps_events = function (): void {
return result;
}
- const update_page: () => void = function () {
+ const update_page: () => Promise<void> = async function () {
const $download_instructions = $(".download-instructions");
const $third_party_apps = $("#third-party-apps");
const $download_android_apk = $("#download-android-apk");
@@ -135,7 +187,6 @@ const apps_events = function (): void {
const $download_from_google_play_store = $(".download-from-google-play-store");
const $download_from_apple_app_store = $(".download-from-apple-app-store");
const $download_from_microsoft_store = $("#download-from-microsoft-store");
- const $download_mac_intel = $("#download-mac-intel");
const $desktop_download_link = $(".desktop-download-link");
const version_info = info[version];
@@ -151,7 +202,31 @@ const apps_events = function (): void {
} else {
$desktop_download_link.attr("href", version_info.download_link);
if (version_info.alt === "macOS") {
- $download_mac_intel.find("a").attr("href", version_info.mac_intel_link);
+ // Detect macOS processor architecture and show/hide alternate download links accordingly.
+ // Disable button temporarily during async detection to prevent UI flickering.
+ $desktop_download_link.prop("disabled", true);
+ const arch = await detect_mac_architecture();
+
+ if (arch === "intel") {
+ $desktop_download_link.attr("href", version_info.mac_intel_link);
+ $desktop_download_link
+ .find("span.button")
+ .text($t({defaultMessage: "Download Zulip for macOS (Intel)"}));
+ $("#download-mac-alt").show();
+ $("#download-mac-alt-apple-silicon").show();
+ $("#download-mac-alt-intel").hide();
+ } else {
+ // Default to Apple Silicon experience for unknown or ARM
+ $desktop_download_link.attr("href", version_info.download_link);
+ $desktop_download_link
+ .find("span.button")
+ .text($t({defaultMessage: "Download Zulip for macOS (Apple Silicon)"}));
+ $("#download-mac-alt").show();
+ $("#download-mac-alt-apple-silicon").hide();
+ $("#download-mac-alt-intel").show();
+ }
+ // Re-enable button after detection is complete
+ $desktop_download_link.prop("disabled", false);
}
assert(version_info.download_instructions);
$download_instructions.html(version_info.download_instructions);
@@ -172,7 +247,7 @@ const apps_events = function (): void {
// init
version = get_version_from_path();
- update_page();
+ void update_page();
};
const events = function (): void {
diff --git a/web/src/portico/tabbed-instructions.ts b/web/src/portico/tabbed-instructions.ts
index b49349e14ad..29b0c7d5c1a 100644
--- a/web/src/portico/tabbed-instructions.ts
+++ b/web/src/portico/tabbed-instructions.ts
@@ -9,14 +9,19 @@ export function detect_user_os(): UserOS {
if (/iphone|ipad|ipod/i.test(navigator.userAgent)) {
return "ios";
}
- if (common.has_mac_keyboard()) {
- return "mac";
+ // Prioritize Linux detection before macOS heuristics.
+ // Linux/Android clients must be detected early to prevent misclassification as macOS
+ // via common.has_mac_keyboard(), which would cause them to enter the macOS-specific
+ // code path. This ensures Linux clients are classified correctly and don't hit
+ // macOS-only UI logic.
+ if (/linux/i.test(navigator.userAgent)) {
+ return "linux";
}
if (/win/i.test(navigator.userAgent)) {
return "windows";
}
- if (/linux/i.test(navigator.userAgent)) {
- return "linux";
+ if (common.has_mac_keyboard()) {
+ return "mac";
}
return "mac"; // if unable to determine OS return Mac by default
}
diff --git a/web/styles/zulip.css b/web/styles/zulip.css
index 9105a0b2c4d..0d7e67c6629 100644
--- a/web/styles/zulip.css
+++ b/web/styles/zulip.css
@@ -1,3 +1,7 @@
+#download-mac-alt {
+ margin-top: 10px;
+}
+
html {
overflow: hidden scroll;
overscroll-behavior-y: none;