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): play H.264, HEVC, and AAC video in the macOS app (#9222)
Eric Hayes655d77e0ed80
diff --git a/.github/workflows/build_cef_codecs.yml b/.github/workflows/build_cef_codecs.ymlnew file mode 100644index 0000000000..cfc6fe31f5--- /dev/null+++ b/.github/workflows/build_cef_codecs.yml@@ -0,0 +1,128 @@+# DO NOT EDIT — regenerate with `cargo x workflows` (from the repository root).+# Source: tooling/xtask/crates/xtask_workflows/src/workflows/build_cef_codecs.rs+name: Build CEF with codecs+'on':+ pull_request:+ branches:+ - main+ paths:+ - apps/web/tauri/desktop-cef/cef-codecs.json+ - tooling/xtask/crates/xtask_workflows/src/workflows/scripts/build_cef_codecs.sh+ - '.github/workflows/build_cef_codecs.yml'+ workflow_dispatch: {}+permissions:+ contents: write+jobs:+ build-cef:+ if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository+ name: Build CEF with proprietary codecs (macOS arm64)+ runs-on: nscloud-macos-sequoia-arm64-12x28+ timeout-minutes: 1440+ steps:+ - name: Checkout+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd+ with:+ clean: 'false'+ persist-credentials: 'false'+ - name: Build and publish CEF+ run: |+ set -euo pipefail++ # Builds the CEF minimal distribution named in cef-codecs.json with H.264,+ # HEVC, and AAC decoders, and publishes it as a prerelease asset. The CEF CDN+ # builds leave those codecs out, so the macOS app could not play most videos.+ manifest=apps/web/tauri/desktop-cef/cef-codecs.json+ cef_version=$(jq -er .cefVersion "$manifest")+ cef_commit=$(jq -er .cefCommit "$manifest")+ chromium_branch=$(jq -er .chromiumBranch "$manifest")+ release_tag=$(jq -er .releaseTag "$manifest")+ asset=$(jq -er .asset "$manifest")++ if gh release view "$release_tag" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name' 2>/dev/null |+ grep -qxF "$asset"; then+ echo "$release_tag already has $asset; nothing to build."+ exit 0+ fi++ if [ "$(uname -m)" != "arm64" ]; then+ echo "CEF codec builds must run on an arm64 runner, got $(uname -m)" >&2+ exit 1+ fi++ work="$RUNNER_TEMP/cef"+ mkdir -p "$work"+ df -h "$work"+ free_gb=$(df -g "$work" | awk 'NR==2 {print $4}')+ if [ "$free_gb" -lt 120 ]; then+ echo "Need at least 120 GB free to check out and build Chromium; $work has ${free_gb} GB." >&2+ exit 1+ fi++ xcode=$(find /Applications -maxdepth 1 -name 'Xcode*.app' | sort -V | tail -1)+ sudo xcode-select -s "$xcode/Contents/Developer"+ xcodebuild -version++ curl -fsSL --retry 5 \+ "https://raw.githubusercontent.com/chromiumembedded/cef/$chromium_branch/tools/automate/automate-git.py" \+ -o "$work/automate-git.py"++ export GN_DEFINES="is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome chrome_pgo_phase=0 symbol_level=0"+ export CEF_ARCHIVE_FORMAT=tar.bz2+ python3 "$work/automate-git.py" \+ --download-dir="$work/code" \+ --depot-tools-dir="$work/depot_tools" \+ --branch="$chromium_branch" \+ --checkout="$cef_commit" \+ --arm64-build \+ --no-debug-build \+ --minimal-distrib-only \+ --no-distrib-docs \+ --no-chromium-history \+ --build-target=cefsimple++ distrib="$work/code/chromium/src/cef/binary_distrib"+ built="$distrib/cef_binary_${cef_version}_macosarm64_minimal.tar.bz2"+ if [ ! -f "$built" ]; then+ echo "Expected $built; the CEF checkout produced:" >&2+ ls -la "$distrib" >&2+ exit 1+ fi++ gn_args="$work/code/chromium/src/out/Release_GN_arm64/args.gn"+ # args.gn has no spaces around '='; tolerate either form.+ for arg in 'proprietary_codecs *= *true' 'ffmpeg_branding *= *"Chrome"'; do+ if ! grep -qE "^$arg$" "$gn_args"; then+ echo "Release build is missing '$arg' in $gn_args" >&2+ cat "$gn_args" >&2+ exit 1+ fi+ done++ mkdir -p "$RUNNER_TEMP/out"+ cp "$built" "$RUNNER_TEMP/out/$asset"+ sha256=$(shasum -a 256 "$RUNNER_TEMP/out/$asset" | awk '{print $1}')++ if ! gh release view "$release_tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then+ gh release create "$release_tag" --repo "$GITHUB_REPOSITORY" \+ --target "$TARGET_SHA" --prerelease --latest=false \+ --title "CEF $cef_version with proprietary codecs (macOS arm64)" \+ --notes "Minimal CEF distribution for the macOS desktop app, built with proprietary_codecs=true and ffmpeg_branding=Chrome. sha256: $sha256"+ fi+ gh release upload "$release_tag" "$RUNNER_TEMP/out/$asset" --repo "$GITHUB_REPOSITORY"++ {+ echo "### CEF with proprietary codecs"+ echo+ echo "- Release: \`$release_tag\`"+ echo "- Asset: \`$asset\`"+ echo "- sha256: \`$sha256\`"+ echo+ echo "Set \`sha256\` in \`$manifest\` to this value."+ } >> "$GITHUB_STEP_SUMMARY"+ shell: bash+ env:+ GH_TOKEN: ${{ github.token }}+ TARGET_SHA: ${{ github.event.pull_request.head.sha || github.sha }}+concurrency:+ group: build-cef-codecs+ cancel-in-progress: falsediff --git a/apps/web/tauri/desktop-cef/AGENTS.md b/apps/web/tauri/desktop-cef/AGENTS.mdindex 9f2bdac377..1b02a7f59d 100644--- a/apps/web/tauri/desktop-cef/AGENTS.md+++ b/apps/web/tauri/desktop-cef/AGENTS.md@@ -48,7 +48,17 @@ thin binary over `../src-tauri` (`app_lib::run_with`) that selectswebview and termination details; the regular fork takes only a webview.Check both workspaces when changing shared callback registration.- Needs Rust 1.95 (the repo pins 1.94), `cmake`, and `ninja`; the first build- downloads about 1 GB of CEF into `~/Library/Caches/tauri-cef`.+ downloads about 1 GB of CEF into `~/Library/Caches/tauri-cef`. That CDN build+ has no H.264, HEVC, or AAC, so most videos won't play in a local build; set+ `CEF_PATH` to an extracted codec distribution (below) to test media.+- Releases embed CEF built with proprietary codecs, pinned in `cef-codecs.json`+ and laid out by `nix/tauri-desktop.nix`; Nix evaluation fails if that pin+ doesn't match the `cef` crate in `Cargo.lock`. To bump the `cef` crate, put+ the new CDN version (`cefVersion`, its `g<hash>` as `cefCommit`, the Chromium+ branch) and a new `releaseTag`/`asset` in the manifest with an empty `sha256`+ on a PR. The `Build CEF with codecs` workflow then builds and publishes it+ (several hours on the large Mac runner); copy the sha256 from its run summary+ into the manifest.- Nix pins Rust 1.95 and the `macro-cef` Tauri CLI separately for macOS. Keep`nix/tauri-desktop.nix` on this workspace and CLI; the stock CLI omits the CEFframework and helper apps from macOS bundles.diff --git a/apps/web/tauri/desktop-cef/cef-codecs.json b/apps/web/tauri/desktop-cef/cef-codecs.jsonnew file mode 100644index 0000000000..dfbdc0d56e--- /dev/null+++ b/apps/web/tauri/desktop-cef/cef-codecs.json@@ -0,0 +1,8 @@+{+ "cefVersion": "151.3.24+g2384915+chromium-151.0.7922.174",+ "cefCommit": "2384915",+ "chromiumBranch": "7922",+ "releaseTag": "cef-codecs-151.3.24-g2384915",+ "asset": "cef_binary_151.3.24_macosarm64_codecs_minimal.tar.bz2",+ "sha256": ""+}diff --git a/nix/tauri-desktop.nix b/nix/tauri-desktop.nixindex 05e4035c10..d4fa1825c0 100644--- a/nix/tauri-desktop.nix+++ b/nix/tauri-desktop.nix@@ -954,6 +954,43 @@cef.embed = true;};};+ # CEF CDN builds omit H.264, HEVC, and AAC, so the app could not play+ # most videos. The `Build CEF with codecs` workflow publishes the same+ # CEF version built with proprietary codecs; lay it out the way+ # `cef-dll-sys` caches a download (`<CEF_PATH>/<version>/cef_macos_aarch64`+ # plus `archive.json`), which the CEF Tauri CLI also reads, so neither+ # downloads from the CDN.+ cefCodecs = builtins.fromJSON (builtins.readFile ../apps/web/tauri/desktop-cef/cef-codecs.json);+ cefCodecsVersion = builtins.head (lib.splitString "+" cefCodecs.cefVersion);+ # The `cef` crate's build metadata is the CEF version it loads. A crate+ # bump without a new manifest would fall back to the codec-less CDN build.+ cefCrateVersion =+ let+ lock = builtins.fromTOML (builtins.readFile ../apps/web/tauri/desktop-cef/Cargo.lock);+ cef = lib.findFirst (p: p.name == "cef") null lock.package;+ in+ lib.last (lib.splitString "+" cef.version);+ cefCodecsArchive = pkgs.fetchurl {+ url = "https://github.com/macro-inc/macro/releases/download/${cefCodecs.releaseTag}/${cefCodecs.asset}";+ sha256 =+ assert lib.assertMsg (cefCodecsVersion == cefCrateVersion)+ "desktop-cef loads CEF ${cefCrateVersion} but cef-codecs.json pins ${cefCodecsVersion}; update the manifest and rebuild";+ assert lib.assertMsg (cefCodecs.sha256 != "")+ "apps/web/tauri/desktop-cef/cef-codecs.json has no sha256; run the `Build CEF with codecs` workflow and pin its output";+ cefCodecs.sha256;+ };+ cefCodecsDistribution = pkgs.runCommand "cef-codecs-${cefCodecsVersion}" { } ''+ tar -xjf ${cefCodecsArchive}+ src=$(echo cef_binary_*_macosarm64_minimal)+ dest="$out/${cefCodecsVersion}/cef_macos_aarch64"+ mkdir -p "$(dirname "$dest")"+ mv "$src/Release" "$dest"+ for entry in CMakeLists.txt cmake include libcef_dll CREDITS.html; do+ mv "$src/$entry" "$dest/$entry"+ done+ printf '{"type":"minimal","name":"%s","sha1":""}' "$src" > "$dest/archive.json"+ test -d "$dest/Chromium Embedded Framework.framework"+ '';tauriDesktopCefApp = cefCraneLib.mkCargoDerivation {pname = "macro-tauri-desktop-cef-app";version = appVersion;@@ -980,6 +1017,9 @@preBuild = ''export PATH="$PATH:/usr/bin:/bin:/usr/sbin:/sbin"export CEF_PATH="$TMPDIR/tauri-cef"+ mkdir -p "$CEF_PATH"+ cp -R ${cefCodecsDistribution}/. "$CEF_PATH/"+ chmod -R u+w "$CEF_PATH"cp ${../apps/web/package.json} apps/web/package.jsonrm -rf apps/web/distcp -r ${frontend} apps/web/distdiff --git a/tooling/xtask/crates/xtask_workflows/src/workflows.rs b/tooling/xtask/crates/xtask_workflows/src/workflows.rsindex 649ad567c6..b16d0598d9 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows.rs@@ -16,6 +16,7 @@ mod assign_author;mod assign_labels;mod build_agent_daemon_on_tag;mod build_appimage_on_tag;+mod build_cef_codecs;mod build_desktop_on_tag;mod build_dmg_on_tag;mod build_web_app;@@ -283,6 +284,11 @@ const WORKFLOWS: &[WorkflowFile] = &[file_name: "deploy_website.yml",render_yaml: || render_patched(deploy_website::deploy_website, deploy_website::patch),},+ WorkflowFile {+ slug: "build_cef_codecs",+ file_name: "build_cef_codecs.yml",+ render_yaml: || render_gh_workflow(build_cef_codecs::build_cef_codecs)(),+ },WorkflowFile {slug: "ensure_daytona_snapshot",file_name: "ensure_daytona_snapshot.yml",diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/build_cef_codecs.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/build_cef_codecs.rsnew file mode 100644index 0000000000..99ab546fea--- /dev/null+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/build_cef_codecs.rs@@ -0,0 +1,69 @@+//! `Build CEF with codecs` — builds the CEF minimal distribution pinned in+//! `apps/web/tauri/desktop-cef/cef-codecs.json` with proprietary codecs+//! (H.264, HEVC, AAC) and publishes it as a prerelease asset. The CEF CDN+//! builds omit those codecs, so the macOS app could not play most videos; the+//! DMG build fetches this asset instead. Generated into `build_cef_codecs.yml`.+//!+//! It runs when the manifest changes on a PR, so a CEF upgrade builds its+//! distribution before the pin lands, and is skipped when the release asset+//! already exists.++use gh_workflow::{+ Concurrency, Event, Expression, Job, Level, Permissions, PullRequest, Step, Workflow,+ WorkflowDispatch,+};++use crate::workflows::{runners, steps};++#[cfg(test)]+mod test;++/// Build the workflow.+pub fn build_cef_codecs() -> Workflow {+ Workflow::new("Build CEF with codecs")+ .permissions(Permissions {+ contents: Some(Level::Write),+ ..Default::default()+ })+ .on(Event::default()+ .pull_request(+ PullRequest::default()+ .add_branch("main")+ .add_path(xtask_paths::repo_glob!(+ "apps/web/tauri/desktop-cef/cef-codecs.json"+ ))+ .add_path(xtask_paths::repo_glob!(+ "tooling/xtask/crates/xtask_workflows/src/workflows/scripts/build_cef_codecs.sh"+ ))+ .add_path(xtask_paths::repo_glob!(".github/workflows/build_cef_codecs.yml")),+ )+ .workflow_dispatch(WorkflowDispatch::default()))+ // One Chromium build per manifest at a time; never cancel a build hours in.+ .concurrency(+ Concurrency::new(Expression::new("build-cef-codecs")).cancel_in_progress(false),+ )+ .add_job("build-cef", build_cef_job())+}++fn build_cef_job() -> Job {+ Job::default()+ .name("Build CEF with proprietary codecs (macOS arm64)")+ .runs_on(runners::Runner::MacOsArmLarge.to_string())+ // A full Chromium checkout and official build takes several hours.+ .timeout_minutes(1440u32)+ .cond(Expression::new(+ "github.event_name != 'pull_request' || \+ github.event.pull_request.head.repo.full_name == github.repository",+ ))+ .add_step(steps::checkout(false, false))+ .add_step(+ Step::new("Build and publish CEF")+ .run(include_str!("scripts/build_cef_codecs.sh"))+ .shell("bash")+ .add_env(("GH_TOKEN", "${{ github.token }}"))+ .add_env((+ "TARGET_SHA",+ "${{ github.event.pull_request.head.sha || github.sha }}",+ )),+ )+}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/build_cef_codecs/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/build_cef_codecs/test.rsnew file mode 100644index 0000000000..cfec4570bd--- /dev/null+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/build_cef_codecs/test.rs@@ -0,0 +1,23 @@+use super::*;++fn rendered() -> String {+ build_cef_codecs()+ .to_string()+ .expect("workflow should serialize")+}++#[test]+fn builds_on_the_large_mac_runner_without_cancelling() {+ let yaml = rendered();+ assert!(yaml.contains("nscloud-macos-sequoia-arm64-12x28"), "{yaml}");+ assert!(yaml.contains("cancel-in-progress: false"), "{yaml}");+ assert!(yaml.contains("contents: write"), "{yaml}");+}++#[test]+fn builds_with_proprietary_codecs() {+ let yaml = rendered();+ assert!(yaml.contains("proprietary_codecs=true"), "{yaml}");+ assert!(yaml.contains("ffmpeg_branding=Chrome"), "{yaml}");+ assert!(yaml.contains("--prerelease --latest=false"), "{yaml}");+}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/build_cef_codecs.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/build_cef_codecs.shnew file mode 100644index 0000000000..b6e968e2f9--- /dev/null+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/build_cef_codecs.sh@@ -0,0 +1,93 @@+set -euo pipefail++# Builds the CEF minimal distribution named in cef-codecs.json with H.264,+# HEVC, and AAC decoders, and publishes it as a prerelease asset. The CEF CDN+# builds leave those codecs out, so the macOS app could not play most videos.+manifest=apps/web/tauri/desktop-cef/cef-codecs.json+cef_version=$(jq -er .cefVersion "$manifest")+cef_commit=$(jq -er .cefCommit "$manifest")+chromium_branch=$(jq -er .chromiumBranch "$manifest")+release_tag=$(jq -er .releaseTag "$manifest")+asset=$(jq -er .asset "$manifest")++if gh release view "$release_tag" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name' 2>/dev/null |+ grep -qxF "$asset"; then+ echo "$release_tag already has $asset; nothing to build."+ exit 0+fi++if [ "$(uname -m)" != "arm64" ]; then+ echo "CEF codec builds must run on an arm64 runner, got $(uname -m)" >&2+ exit 1+fi++work="$RUNNER_TEMP/cef"+mkdir -p "$work"+df -h "$work"+free_gb=$(df -g "$work" | awk 'NR==2 {print $4}')+if [ "$free_gb" -lt 120 ]; then+ echo "Need at least 120 GB free to check out and build Chromium; $work has ${free_gb} GB." >&2+ exit 1+fi++xcode=$(find /Applications -maxdepth 1 -name 'Xcode*.app' | sort -V | tail -1)+sudo xcode-select -s "$xcode/Contents/Developer"+xcodebuild -version++curl -fsSL --retry 5 \+ "https://raw.githubusercontent.com/chromiumembedded/cef/$chromium_branch/tools/automate/automate-git.py" \+ -o "$work/automate-git.py"++export GN_DEFINES="is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome chrome_pgo_phase=0 symbol_level=0"+export CEF_ARCHIVE_FORMAT=tar.bz2+python3 "$work/automate-git.py" \+ --download-dir="$work/code" \+ --depot-tools-dir="$work/depot_tools" \+ --branch="$chromium_branch" \+ --checkout="$cef_commit" \+ --arm64-build \+ --no-debug-build \+ --minimal-distrib-only \+ --no-distrib-docs \+ --no-chromium-history \+ --build-target=cefsimple++distrib="$work/code/chromium/src/cef/binary_distrib"+built="$distrib/cef_binary_${cef_version}_macosarm64_minimal.tar.bz2"+if [ ! -f "$built" ]; then+ echo "Expected $built; the CEF checkout produced:" >&2+ ls -la "$distrib" >&2+ exit 1+fi++gn_args="$work/code/chromium/src/out/Release_GN_arm64/args.gn"+# args.gn has no spaces around '='; tolerate either form.+for arg in 'proprietary_codecs *= *true' 'ffmpeg_branding *= *"Chrome"'; do+ if ! grep -qE "^$arg$" "$gn_args"; then+ echo "Release build is missing '$arg' in $gn_args" >&2+ cat "$gn_args" >&2+ exit 1+ fi+done++mkdir -p "$RUNNER_TEMP/out"+cp "$built" "$RUNNER_TEMP/out/$asset"+sha256=$(shasum -a 256 "$RUNNER_TEMP/out/$asset" | awk '{print $1}')++if ! gh release view "$release_tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then+ gh release create "$release_tag" --repo "$GITHUB_REPOSITORY" \+ --target "$TARGET_SHA" --prerelease --latest=false \+ --title "CEF $cef_version with proprietary codecs (macOS arm64)" \+ --notes "Minimal CEF distribution for the macOS desktop app, built with proprietary_codecs=true and ffmpeg_branding=Chrome. sha256: $sha256"+fi+gh release upload "$release_tag" "$RUNNER_TEMP/out/$asset" --repo "$GITHUB_REPOSITORY"++{+ echo "### CEF with proprietary codecs"+ echo+ echo "- Release: \`$release_tag\`"+ echo "- Asset: \`$asset\`"+ echo "- sha256: \`$sha256\`"+ echo+ echo "Set \`sha256\` in \`$manifest\` to this value."+} >> "$GITHUB_STEP_SUMMARY"