Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(desktop): include agent fold wasm in release bundles (#8374)
Eric Hayes8294af0de3e7
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex f72afcc35f..5e5bd448db 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -199,6 +199,14 @@ on focus/reconnect; route existing subscriptions to billing management. Keepknown management access through refetch failures, but hide unconfirmed trials.Reset rejected checkout offers before refetching eligibility.+## Desktop release builds: generated WASM++Keep `nix/tauri-desktop.nix` in sync with generated WASM dependencies: desktop+releases run Vite directly and do not call `just build-tauri` or `build-wasm`.+Build and copy the agent-fold JavaScript glue and WASM before Vite runs, and+check that both appear in the output. Without them, Vite leaves the worker's+relative imports unchanged and Tauri can serve HTML for the missing module.+## macOS desktop gotcha: third-party iframesWKWebView asks the desktop navigation plugin about iframe loads as well as page loads, and the plugin cannot tell them apart. A third-party iframe is classified as external: its load is cancelled and the page opens in the browser, leaving an empty frame in the app. List a third-party page the app frames in `EMBEDDED_DOCUMENTS` in `tauri/src-tauri/src/lib.rs`.diff --git a/nix/tauri-desktop.nix b/nix/tauri-desktop.nixindex 71598eeacd..f590986012 100644--- a/nix/tauri-desktop.nix+++ b/nix/tauri-desktop.nix@@ -77,6 +77,7 @@&& !(lib.hasPrefix "apps/web/dist/" rel)&& !(lib.hasPrefix "apps/web/tauri/target/" rel)&& !(lib.hasPrefix "apps/web/src/lib/graphql-cache/wasm/" rel)+ && !(lib.hasPrefix "apps/web/src/lib/core/agent-fold/wasm/" rel)&& !(lib.hasPrefix "packages/lexical-core/node_modules/" rel)&& !(lib.hasPrefix "services/lexical-service/node_modules/" rel)&& !(lib.hasPrefix "packages/loro-mirror/node_modules/" rel)@@ -87,7 +88,8 @@&& rel != "apps/web/node_modules"&& rel != "apps/web/dist"&& rel != "apps/web/tauri/target"- && rel != "apps/web/src/lib/graphql-cache/wasm";+ && rel != "apps/web/src/lib/graphql-cache/wasm"+ && rel != "apps/web/src/lib/core/agent-fold/wasm";};rootCargoVendorDir = craneLib.vendorCargoDeps {@@ -131,6 +133,34 @@src = jsRoot;};+ agentFoldWasmPackage = craneLib.mkCargoDerivation {+ pname = "macro-agent-fold-wasm";+ version = appVersion;+ src = jsSrc;+ cargoArtifacts = null;+ cargoVendorDir = rootCargoVendorDir;+ nativeBuildInputs = [+ pkgs.binaryen+ pkgs.wasm-bindgen-cli_0_2_126+ pkgs.wasm-pack+ ];+ doCheck = false;+ preBuild = cacheWasmPackage.preBuild;+ buildPhaseCargoCommand = ''+ wasm-pack build crates/folds/agent_fold \+ --target web \+ --release \+ --mode no-install \+ --out-dir "$PWD/apps/web/src/lib/core/agent-fold/wasm" \+ -- --no-default-features+ '';+ installPhaseCommand = ''+ mkdir -p $out+ cp -a apps/web/src/lib/core/agent-fold/wasm/. $out/+ '';+ doInstallCargoArtifacts = false;+ };+frontend = pkgs.stdenvNoCC.mkDerivation {pname = "macro-tauri-frontend";version = appVersion;@@ -150,41 +180,54 @@VITE_OTEL_ENV = otelEnv;buildPhase = ''- runHook preBuild-- cp -a ${nodeModules}/. .-- # Vite bundles TypeScript config files to a temporary sibling before- # loading them. The application config now lives at the app root,- # so make that directory writable inside the Nix build sandbox.- chmod u+w apps/web-- substituteInPlace apps/web/vite.base.ts \- --replace-fail \- " // NIX_TAURI_ALIAS" \- ' { find: /^@tauri-apps\/api/, replacement: resolve(__dirname, "../../node_modules/@tauri-apps/api") },'-- printf production > apps/web/tauri/src-tauri/.macro-tauri-env- mkdir -p apps/web/src/lib/graphql-cache/wasm- cp -a ${cacheWasmPackage}/. apps/web/src/lib/graphql-cache/wasm/- (- cd apps/web- MODE=production NODE_ENV=production bun ../../node_modules/vite/bin/vite.js build -c vite.config.ts- printf '${appVersion}+${gitRev}\n' > dist/semver.txt- BUNDLE_BUILD_NUMBER=${toString desktopRelease.bundleBuild} MIN_NATIVE_BUILD=0 bun scripts/write-bundle-manifest.mjs- )-- # A supplied key that never reaches the bundle means PostHog — and- # every feature flag behind it — is silently off in the shipped app.- # Fail the build instead, the way the signed DMG fails on a missing- # signing identity.- if [ -n "''${VITE_POSTHOG_API_KEY:-}" ] \- && ! grep -rqF -- "$VITE_POSTHOG_API_KEY" apps/web/dist; then- echo "VITE_POSTHOG_API_KEY was set but Vite did not inline it into apps/web/dist" >&2- exit 1- fi+ runHook preBuild- runHook postBuild+ cp -a ${nodeModules}/. .++ # Vite bundles TypeScript config files to a temporary sibling before+ # loading them. The application config now lives at the app root,+ # so make that directory writable inside the Nix build sandbox.+ chmod u+w apps/web++ substituteInPlace apps/web/vite.base.ts \+ --replace-fail \+ " // NIX_TAURI_ALIAS" \+ ' { find: /^@tauri-apps\/api/, replacement: resolve(__dirname, "../../node_modules/@tauri-apps/api") },'++ printf production > apps/web/tauri/src-tauri/.macro-tauri-env+ mkdir -p apps/web/src/lib/graphql-cache/wasm+ cp -a ${cacheWasmPackage}/. apps/web/src/lib/graphql-cache/wasm/+ mkdir -p apps/web/src/lib/core/agent-fold/wasm+ cp -a ${agentFoldWasmPackage}/. apps/web/src/lib/core/agent-fold/wasm/+ (+ cd apps/web+ MODE=production NODE_ENV=production bun ../../node_modules/vite/bin/vite.js build -c vite.config.ts+ printf '${appVersion}+${gitRev}\n' > dist/semver.txt+ BUNDLE_BUILD_NUMBER=${toString desktopRelease.bundleBuild} MIN_NATIVE_BUILD=0 bun scripts/write-bundle-manifest.mjs+ )++ # A supplied key that never reaches the bundle means PostHog — and+ # every feature flag behind it — is silently off in the shipped app.+ # Fail the build instead, the way the signed DMG fails on a missing+ # signing identity.+ if [ -n "''${VITE_POSTHOG_API_KEY:-}" ] \+ && ! grep -rqF -- "$VITE_POSTHOG_API_KEY" apps/web/dist; then+ echo "VITE_POSTHOG_API_KEY was set but Vite did not inline it into apps/web/dist" >&2+ exit 1+ fi++ runHook postBuild+ '';++ # Vite leaves new URL() imports unchanged when their generated source+ # files are absent. Reject that otherwise-successful but broken bundle.+ doCheck = true;+ checkPhase = ''+ runHook preCheck+ for asset in apps/web/dist/assets/agent_fold-*.js apps/web/dist/assets/agent_fold_bg-*.wasm; do+ test -s "$asset" || { echo "Missing agent fold bundle asset: $asset" >&2; exit 1; }+ done+ runHook postCheck'';installPhase = ''