Skip to content

feat(t3x): auto-build the desktop app from origin/main in a dedicated worktree - #28

Merged
radroid merged 1 commit into
mainfrom
t3x/autobuild-origin-main
Jul 27, 2026
Merged

feat(t3x): auto-build the desktop app from origin/main in a dedicated worktree#28
radroid merged 1 commit into
mainfrom
t3x/autobuild-origin-main

Conversation

@radroid

@radroid radroid commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Why

The desktop auto-build watcher never fetched — it compared the local checkout's HEAD against the last-built marker, so the installed app only updated after a manual git pull, and any agent switching branches in ~/Developer/t3code could change (or break) what gets built and installed.

Raj asked for the watcher to track origin/main so local agents can work on repo branches without affecting the app (see docs/superpowers/specs/2026-07-27-autobuild-origin-main-design.md).

What

New --ref <remote>/<branch> mode for scripts/t3x/auto-build-desktop.sh:

  • Each tick: git fetch → resolve the remote-tracking sha → pin a dedicated build worktree (T3X_AUTOBUILD_WORKTREE, default <repo>-build) to it with a detached forced checkout → build there. The main checkout is never read for builds.
  • Fresh-worktree bootstrap: deps install when node_modules is missing, not only on a lockfile diff (a new worktree with an unchanged lockfile would otherwise always fail its first build).
  • Fetch failure → fetch-failed status, marker not advanced, retried next tick under the existing backoff.
  • --ref forwards through the caffeinate re-exec and is emitted by --print-launchd (+ T3X_AUTOBUILD_WORKTREE env). Emitted WorkingDirectory stays the main repo — launchd refuses a job whose working directory doesn't exist yet.
  • Guard: the build worktree may not be the repo itself (forced checkout would clobber it).

Deployment (separate, machine-side): the dev.t3x.autobuild LaunchAgent gains --ref origin/main --relaunch so unattended installs reopen the app and the Tailscale surface self-heals.

Testing

  • bash -n; flag validation (ref format, unknown remote, self-worktree guard)
  • Dry-run with no worktree: previews create/sync without touching anything
  • Real run: worktree created at exactly origin/main's sha; bootstrap install triggered; failure wrote build-failed and did not advance the marker; stale worktree re-synced on next run
  • --print-launchd output passes plutil -lint

Zero upstream seams — everything under scripts/t3x/ + docs/.

🤖 Generated with Claude Code

The desktop watcher compared the local checkout's HEAD against the
last-built marker but never fetched, so the installed app only updated
when local main was manually pulled — and any agent switching branches
in that checkout could change what gets built and installed.

Add --ref <remote>/<branch>: each tick fetches the remote, pins a
dedicated build worktree (T3X_AUTOBUILD_WORKTREE, default <repo>-build)
to that ref's sha with a detached forced checkout, and builds there. The
main checkout is never read for builds.

- Source of truth is the remote-tracking ref (worktrees share refs); the
  worktree is only checkout machinery, created on first use.
- Fresh worktree bootstrap: install deps when node_modules is missing,
  not only when the lockfile diff says so — a new worktree with an
  unchanged lockfile would otherwise always fail its first build.
- Fetch failure writes fetch-failed status and retries next tick without
  advancing the marker.
- --ref forwards through the caffeinate re-exec and is emitted by
  --print-launchd; the emitted WorkingDirectory stays the main repo
  because launchd refuses a job whose working directory is missing.
- Guard against pointing the build worktree at the repo itself (the
  forced checkout would clobber the working tree).

Zero upstream seams: everything lives under scripts/t3x/ + docs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 403fe5a9-351e-422b-922f-1e9f8344b45d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3x/autobuild-origin-main

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@radroid
radroid merged commit 3f13841 into main Jul 27, 2026
2 checks passed
@radroid
radroid deleted the t3x/autobuild-origin-main branch July 30, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant