fix(t3x): auto-build defects found running the LaunchAgent for real - #3
Merged
Conversation
Three defects surfaced by actually setting up the LaunchAgent end to end.
1. --print-launchd emitted a plist that could never run. macOS TCC gates
~/Documents, ~/Desktop, ~/Downloads and iCloud Drive. launchd jobs get no TCC
grant and never trigger a consent prompt, so a repo in one of those folders
yields EPERM: launchd cannot chdir to WorkingDirectory and /bin/bash cannot
read the script. The failure is near-invisible — bootstrap succeeds,
'launchctl print' shows the job loaded, and the only evidence is
'last exit code = 126'. Now detected up front: refuse to emit (exit 2) with
the three remedies, or --force past it.
2. --install --dry-run named the wrong app. It hardcoded
"${T3X_AUTOBUILD_APP_NAME:-T3 Code}.app" and never looked at the dmg, so it
always claimed 'T3 Code.app' while a real install replaced
'T3 Code (Alpha).app' — wrong about the one fact the preview exists to
establish. It also bailed before printing anything when no dmg existed yet,
i.e. for every first-time user. Now mounts the dmg read-only for ground
truth, falls back to a mirror of resolveDesktopProductName(), and warns when
the target app is absent (the 'creates a silent third app' footgun).
3. log() wrote every line twice under launchd. It pipes through
'tee -a "$LOG_FILE" >&2' while the plist points BOTH StandardOutPath and
StandardErrorPath at that same file, so one watcher's output reads exactly
like two racing. The plist now declares T3X_AUTOBUILD_STDERR_IS_LOG=1.
Detection via 'stat -f %d:%i /dev/fd/2' is deliberately NOT used: on macOS
that stats the devfs node, never the redirect target, so it can never match —
noted in-line so it doesn't get re-attempted.
Terminal behaviour is unchanged throughout; only the launchd path differs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Setting the auto-build up end-to-end on a real machine surfaced three defects. All three
were invisible to the test suite because they only manifest under
launchd, or only whenno build exists yet.
1.
--print-launchdemitted a plist that can never runmacOS TCC gates
~/Documents,~/Desktop,~/Downloadsand iCloud Drive. LaunchAgentsget no TCC grant and — unlike apps — never trigger a consent prompt; macOS just returns
EPERM.Verified with a probe agent that differed only by path:
~/Documents/t3code/…/tmp~/Documents/t3codeThe failure mode is the bad kind:
launchctl bootstrapsucceeds,launchctl printreportsthe job as loaded, and the only evidence is
last exit code = 126. It looks installed andsilently never builds.
Now refuses to emit (exit
2) with the three remedies, or--forcepast it.2.
--install --dry-runnamed the wrong appIt hardcoded
"${T3X_AUTOBUILD_APP_NAME:-T3 Code}.app"and never looked at the dmg — so italways reported
T3 Code.appwhile a real install replacedT3 Code (Alpha).app. Wrongabout the single fact the preview exists to establish. It also returned before printing
anything when no dmg had been built, i.e. for every first-time user.
Now mounts the dmg read-only for ground truth, falls back to a mirror of upstream's
resolveDesktopProductName(), and warns when the target app is absent — the footgunwhere
--installsilently creates a third app and leaves the one you actually run alone.3.
log()wrote every line twice under launchdtee -a "$LOG_FILE" >&2echoes to stderr, and the plist points bothStandardOutPathand
StandardErrorPathat that same file. One watcher's output reads exactly like tworacing — which is how this was noticed.
The plist now declares
T3X_AUTOBUILD_STDERR_IS_LOG=1. Detecting it viastat -f '%d:%i' /dev/fd/2is deliberately not used and is documented in-line: onmacOS that stats the devfs node (
2540177495:339), never the redirect target, so it cannever match. I tried it first; it silently didn't work.
Verification
~/Documents→ exit2, 0 bytes on stdout, remedies on stderr~/Developer→ exit0, valid 1302-byte plist (plutil -lintOK)--forcestill emitsread 'T3 Code (Alpha).app' from …; without dmg →predicted from apps/desktop/package.json; env override still wins/Applicationsverified untouched by all dry runsbash -nclean🤖 Generated with Claude Code