Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

feat(desktop): build macOS previews from a PR label (#8182)

Theo Brownec6b8bb82575c
diff --git a/.github/workflows/desktop-macos-preview.yml b/.github/workflows/desktop-macos-preview.yml
new file mode 100644
index 000000000..6d1264aa7
--- /dev/null
+++ b/.github/workflows/desktop-macos-preview.yml
@@ -0,0 +1,165 @@
+name: Desktop macOS Preview
+
+on:
+ pull_request:
+ types: [labeled, synchronize, reopened]
+
+permissions:
+ contents: read
+ pull-requests: write
+
+concurrency:
+ group: desktop-macos-preview-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+
+jobs:
+ build:
+ name: Build macOS Apple Silicon preview
+ if: >-
+ github.event.pull_request.head.repo.full_name == github.repository &&
+ contains(github.event.pull_request.labels.*.name, 'preview:mac') &&
+ (github.event.action != 'labeled' || github.event.label.name == 'preview:mac')
+ runs-on: blacksmith-12vcpu-macos-26
+ timeout-minutes: 30
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ sparse-checkout: |
+ /*
+ !/.repos/
+ sparse-checkout-cone-mode: false
+
+ - name: Setup Vite+
+ uses: voidzero-dev/setup-vp@v1
+ with:
+ node-version-file: package.json
+ cache: true
+ run-install: false
+
+ - name: Install desktop dependencies
+ run: vp install --filter=@t3tools/desktop... --filter=t3... --filter=@t3tools/scripts...
+
+ - name: Cache resource monitor
+ id: resource_monitor_cache
+ uses: actions/cache@v6
+ with:
+ path: native/resource-monitor/target/aarch64-apple-darwin/release/t3-resource-monitor
+ key: resource-monitor-aarch64-apple-darwin-${{ hashFiles('native/resource-monitor/Cargo.lock', 'native/resource-monitor/Cargo.toml', 'native/resource-monitor/src/**') }}
+
+ - name: Setup Rust
+ if: steps.resource_monitor_cache.outputs.cache-hit != 'true'
+ uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: aarch64-apple-darwin
+
+ - id: version
+ name: Set preview version and public configuration
+ shell: bash
+ env:
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ run: |
+ set -euo pipefail
+
+ base_version="$(node -p "require('./apps/desktop/package.json').version")"
+ preview_version="${base_version}-pr.${PR_NUMBER}.${GITHUB_RUN_NUMBER}"
+ node scripts/update-release-package-versions.ts "$preview_version"
+ cp .env.example .env
+
+ echo "version=$preview_version" >> "$GITHUB_OUTPUT"
+
+ - id: build
+ name: Build unsigned macOS DMG
+ shell: bash
+ env:
+ T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: ${{ steps.resource_monitor_cache.outputs.cache-hit == 'true' }}
+ PREVIEW_VERSION: ${{ steps.version.outputs.version }}
+ run: |
+ set -euo pipefail
+
+ vp run dist:desktop:artifact \
+ --platform mac \
+ --target dmg \
+ --arch arm64 \
+ --build-version "$PREVIEW_VERSION" \
+ --verbose
+
+ shopt -s nullglob
+ dmg_files=(release/*.dmg)
+ if (( ${#dmg_files[@]} != 1 )); then
+ printf 'Expected one DMG, found %s.\n' "${#dmg_files[@]}" >&2
+ exit 1
+ fi
+ printf 'dmg_name=%s\n' "$(basename "${dmg_files[0]}")" >> "$GITHUB_OUTPUT"
+
+ - id: upload
+ name: Upload macOS DMG
+ uses: actions/upload-artifact@v7
+ with:
+ path: release/*.dmg
+ if-no-files-found: error
+ archive: false
+ overwrite: true
+ retention-days: 7
+
+ - name: Comment download link
+ uses: actions/github-script@v8
+ env:
+ ARTIFACT_URL: ${{ steps.upload.outputs.artifact-url }}
+ DMG_NAME: ${{ steps.build.outputs.dmg_name }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ PREVIEW_VERSION: ${{ steps.version.outputs.version }}
+ with:
+ script: |
+ const { data: pullRequest } = await github.rest.pulls.get({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: context.payload.pull_request.number,
+ });
+ if (pullRequest.head.sha !== process.env.HEAD_SHA) {
+ core.info("Skipping the outdated macOS preview comment.");
+ return;
+ }
+
+ const marker = "<!-- desktop-macos-preview -->";
+ const body = [
+ marker,
+ "### macOS preview",
+ "",
+ `[Download Apple Silicon DMG](${process.env.ARTIFACT_URL})`,
+ "",
+ `Version: ${process.env.PREVIEW_VERSION}`,
+ `Commit: ${process.env.HEAD_SHA.slice(0, 7)}`,
+ "",
+ "Unsigned build. Clear quarantine before opening:",
+ "```sh",
+ `xattr -d com.apple.quarantine ~/Downloads/${process.env.DMG_NAME}`,
+ "```",
+ "",
+ "The download requires GitHub access and expires after 7 days.",
+ ].join("\n");
+
+ const { data: comments } = await github.rest.issues.listComments({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: context.payload.pull_request.number,
+ per_page: 100,
+ });
+ const existing = comments.find((comment) => comment.body?.includes(marker));
+
+ if (existing) {
+ await github.rest.issues.updateComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ comment_id: existing.id,
+ body,
+ });
+ } else {
+ await github.rest.issues.createComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: context.payload.pull_request.number,
+ body,
+ });
+ }
diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts
index 1b9e9b434..a7bb1b9b7 100644
--- a/scripts/build-desktop-artifact.test.ts
+++ b/scripts/build-desktop-artifact.test.ts
@@ -223,6 +223,45 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
}),
);
+ it.effect("omits update feeds for pull request preview builds", () =>
+ Effect.gen(function* () {
+ const preview = yield* createBuildConfig(
+ "mac",
+ "dmg",
+ "0.0.33-pr.8182.1",
+ false,
+ false,
+ undefined,
+ undefined,
+ );
+ const release = yield* createBuildConfig(
+ "mac",
+ "dmg",
+ "0.0.33",
+ false,
+ false,
+ undefined,
+ undefined,
+ );
+
+ assert.notProperty(preview, "publish");
+ assert.deepStrictEqual(release.publish, [
+ {
+ provider: "github",
+ owner: "pingdotgg",
+ repo: "t3code",
+ releaseType: "release",
+ },
+ ]);
+ }).pipe(
+ Effect.provide(
+ ConfigProvider.layer(
+ ConfigProvider.fromEnv({ env: { GITHUB_REPOSITORY: "pingdotgg/t3code" } }),
+ ),
+ ),
+ ),
+ );
+
it("omits bundled workspace packages from staged desktop dependencies", () => {
assert.deepStrictEqual(
resolveDesktopRuntimeDependencies(
diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts
index a9803d2bf..dd8355e4c 100644
--- a/scripts/build-desktop-artifact.ts
+++ b/scripts/build-desktop-artifact.ts
@@ -2017,6 +2017,10 @@ export function resolveDesktopUpdateChannel(version: string): "latest" | "nightl
return /-nightly\.\d{8}\.\d+$/.test(version) ? "nightly" : "latest";
}
+function isDesktopPreviewVersion(version: string): boolean {
+ return /-pr\./.test(version);
+}
+
export function resolveDesktopWebAssetBrand(version: string): WebAssetBrand {
return resolveWebAssetBrandForChannel(resolveDesktopUpdateChannel(version));
}
@@ -2093,16 +2097,18 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
],
};
const updateChannel = resolveDesktopUpdateChannel(version);
- const publishConfig = yield* resolveGitHubPublishConfig(updateChannel);
- if (publishConfig) {
- buildConfig.publish = [publishConfig];
- } else if (mockUpdates) {
- buildConfig.publish = [
- {
- provider: "generic",
- url: resolveMockUpdateServerUrl(mockUpdateServerPort),
- },
- ];
+ if (!isDesktopPreviewVersion(version)) {
+ const publishConfig = yield* resolveGitHubPublishConfig(updateChannel);
+ if (publishConfig) {
+ buildConfig.publish = [publishConfig];
+ } else if (mockUpdates) {
+ buildConfig.publish = [
+ {
+ provider: "generic",
+ url: resolveMockUpdateServerUrl(mockUpdateServerPort),
+ },
+ ];
+ }
}
if (platform === "mac") {