Skip to content

Commit af1290e

Browse files
teamleaderleoaustinywang
authored andcommitted
reload: add explicit build-only validation mode
1 parent 9c2ba78 commit af1290e

3 files changed

Lines changed: 40 additions & 8 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ Always build with a tag. **Never run bare `xcodebuild` or `open` an untagged `cm
1515
```bash
1616
./scripts/reload.sh --tag <branch-slug> # build Debug, kill same-tag app, do not launch
1717
./scripts/reload.sh --tag <branch-slug> --launch # also open it
18+
./scripts/reload.sh --tag <branch-slug> --build-only # validate without replacing the running app
1819
```
1920

2021
A tag gives the app its own name, bundle ID, socket, and derived data path, so it runs side-by-side with the user's main app. Report the build to the user as a markdown link to `http://127.0.0.1:17320/<tag>`. Never put a `file://` URL, a raw `.app` path, or `/tmp/cmux-<tag>/...` in chat output.
2122

23+
Use `--build-only` only when the task explicitly asks for compile/validation without a reload. It leaves the active tagged app, `cmuxd`, and tag state untouched and keeps the newly built bundle staged separately; it does not make the running app current.
24+
2225
Other variants: `reloadp.sh` (Release), `reloads.sh` (Release as isolated "cmux STAGING"), `reload2.sh --tag <tag>` (both).
2326

2427
## Shared Mac fleet capacity

scripts/reload.sh

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ BUNDLE_SET=0
1616
DERIVED_SET=0
1717
TAG=""
1818
LAUNCH=0
19+
BUILD_ONLY=0
1920
CMUX_DEBUG_LOG=""
2021
CMUX_DEV_PORT=""
2122
CMUX_DEV_PORT_END=""
@@ -893,6 +894,9 @@ Options:
893894
so macOS launches the freshly-built binary on cmd-click or --launch.
894895
--launch Launch the app after building. Without this flag, the script
895896
builds and prints the app path but does not open it.
897+
--build-only Build and validate a tagged app without replacing or
898+
stopping the running tagged app, daemon, or tag state.
899+
Cannot be combined with --launch.
896900
--prod-auth Point this tagged Debug build at production Stack auth,
897901
cmux APIs, and the production Iroh broker.
898902
--credentials-file <path>
@@ -1141,6 +1145,10 @@ while [[ $# -gt 0 ]]; do
11411145
LAUNCH=1
11421146
shift
11431147
;;
1148+
--build-only)
1149+
BUILD_ONLY=1
1150+
shift
1151+
;;
11441152
--prod-auth)
11451153
PROD_AUTH=1
11461154
shift
@@ -1204,6 +1212,11 @@ while [[ $# -gt 0 ]]; do
12041212
esac
12051213
done
12061214

1215+
if [[ "$BUILD_ONLY" -eq 1 && "$LAUNCH" -eq 1 ]]; then
1216+
echo "error: --build-only cannot be combined with --launch" >&2
1217+
exit 1
1218+
fi
1219+
12071220
if [[ -z "$TAG" ]]; then
12081221
echo "error: --tag is required (example: ./scripts/reload.sh --tag fix-sidebar-theme)" >&2
12091222
usage
@@ -1395,7 +1408,10 @@ reload_finalize() {
13951408
echo "Swift workaround:"
13961409
echo " batch mode, debug symbols, and AArch64 GlobalISel disabled for this reload"
13971410
fi
1398-
if [[ "$LAUNCH" -eq 0 ]]; then
1411+
if [[ "$BUILD_ONLY" -eq 1 ]]; then
1412+
echo
1413+
echo "Build-only validation complete. The running tagged app, cmuxd, and tag state were left unchanged."
1414+
elif [[ "$LAUNCH" -eq 0 ]]; then
13991415
echo
14001416
echo "Build complete. Pass --launch to open the app, or cmd-click the path above."
14011417
fi
@@ -1735,8 +1751,12 @@ if [[ -n "$TAG" && "$APP_NAME" != "$SEARCH_APP_NAME" ]]; then
17351751
set_plist_env "$INFO_PLIST" CMUX_SOCKET_MODE "allowAll"
17361752
set_plist_env "$INFO_PLIST" CMUX_REMOTE_DAEMON_ALLOW_LOCAL_BUILD "1"
17371753
set_plist_env "$INFO_PLIST" CMUXTERM_REPO_ROOT "$PWD"
1738-
set_plist_env "$INFO_PLIST" CMUX_BUNDLED_CLI_PATH "$TAG_APP_FINAL_PATH/Contents/Resources/bin/cmux"
1739-
set_plist_env "$INFO_PLIST" CMUX_SHELL_INTEGRATION_DIR "$TAG_APP_FINAL_PATH/Contents/Resources/shell-integration"
1754+
BUNDLED_APP_PATH="$TAG_APP_FINAL_PATH"
1755+
if [[ "$BUILD_ONLY" -eq 1 ]]; then
1756+
BUNDLED_APP_PATH="$TAG_APP_STAGING_PATH"
1757+
fi
1758+
set_plist_env "$INFO_PLIST" CMUX_BUNDLED_CLI_PATH "$BUNDLED_APP_PATH/Contents/Resources/bin/cmux"
1759+
set_plist_env "$INFO_PLIST" CMUX_SHELL_INTEGRATION_DIR "$BUNDLED_APP_PATH/Contents/Resources/shell-integration"
17401760
set_plist_env "$INFO_PLIST" CMUX_PORT "$CMUX_DEV_PORT"
17411761
set_plist_env "$INFO_PLIST" CMUX_PORT_END "$CMUX_DEV_PORT_END"
17421762
set_plist_env "$INFO_PLIST" CMUX_PORT_RANGE "$CMUX_DEV_PORT_RANGE"
@@ -1764,7 +1784,7 @@ if [[ -n "$TAG" && "$APP_NAME" != "$SEARCH_APP_NAME" ]]; then
17641784
set_plist_env "$INFO_PLIST" CMUX_DEV_AUTH_PROFILE "$AUTH_PROFILE"
17651785
set_plist_env "$INFO_PLIST" CMUX_DEV_AUTH_REPLACE_SESSION "1"
17661786
fi
1767-
if [[ -S "$CMUXD_SOCKET" ]]; then
1787+
if [[ "$BUILD_ONLY" -ne 1 && -S "$CMUXD_SOCKET" ]]; then
17681788
for PID in $(lsof -t "$CMUXD_SOCKET" 2>/dev/null); do
17691789
kill "$PID" 2>/dev/null || true
17701790
done
@@ -1838,7 +1858,11 @@ if ! /usr/bin/codesign --force --sign - --timestamp=none --generate-entitlement-
18381858
exit 1
18391859
fi
18401860
fi
1841-
if [[ -n "${TAG_APP_FINAL_PATH:-}" && -n "${TAG_APP_STAGING_PATH:-}" ]]; then
1861+
if [[ "$BUILD_ONLY" -eq 1 && -n "${TAG_APP_STAGING_PATH:-}" ]]; then
1862+
# Keep the staged artifact separate from the running tagged app. This mode is
1863+
# explicitly for compilation/validation and must not mutate the active bundle.
1864+
APP_PATH="$TAG_APP_STAGING_PATH"
1865+
elif [[ -n "${TAG_APP_FINAL_PATH:-}" && -n "${TAG_APP_STAGING_PATH:-}" ]]; then
18421866
rm -rf "$TAG_APP_FINAL_PATH"
18431867
mv "$TAG_APP_STAGING_PATH" "$TAG_APP_FINAL_PATH"
18441868
APP_PATH="$TAG_APP_FINAL_PATH"
@@ -1856,7 +1880,7 @@ fi
18561880
# even without --launch. A stale tagged app pinned to this bundle id would otherwise
18571881
# keep running against freshly-overwritten resources, and macOS would foreground it
18581882
# instead of launching the newly built binary when the user cmd-clicks the .app.
1859-
if [[ -n "$TAG" ]]; then
1883+
if [[ -n "$TAG" && "$BUILD_ONLY" -ne 1 ]]; then
18601884
/usr/bin/osascript -e "tell application id \"${BUNDLE_ID}\" to quit" >/dev/null 2>&1 || true
18611885
sleep 0.3
18621886
pkill -f "${APP_NAME}.app/Contents/MacOS/${BASE_APP_NAME}" || true
@@ -1868,7 +1892,10 @@ if [[ -n "$TAG" ]]; then
18681892
/bin/launchctl remove "$TAG_LAUNCHD_LABEL" >/dev/null 2>&1 || true
18691893
fi
18701894

1871-
if [[ -n "$TAG" ]] && ! wait_for_tag_socket_lock_release "/tmp/cmux-debug-${TAG_SLUG}.sock"; then
1895+
if [[ "$BUILD_ONLY" -eq 1 ]]; then
1896+
CAN_PUBLISH_RELOAD_STATE=0
1897+
RELOAD_PUBLICATION_SKIP_REASON="build-only mode left the running tagged app and tag state unchanged"
1898+
elif [[ -n "$TAG" ]] && ! wait_for_tag_socket_lock_release "/tmp/cmux-debug-${TAG_SLUG}.sock"; then
18721899
CAN_PUBLISH_RELOAD_STATE=0
18731900
fi
18741901
if [[ "$CAN_PUBLISH_RELOAD_STATE" -eq 1 && -n "${TAG_SLUG:-}" ]]; then

skills/cmux-dev-workflow/references/tagged-builds.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
Tagged builds isolate app name, bundle ID, debug socket, and DerivedData path so multiple agents and the user's normal app do not collide.
44

55
```bash
6-
./scripts/reload.sh --tag <tag> # build only (default)
6+
./scripts/reload.sh --tag <tag> # build and replace same-tag runtime
77
./scripts/reload.sh --tag <tag> --launch # build, then open
8+
./scripts/reload.sh --tag <tag> --build-only # validate without replacing the running app
89
```
910

1011
After a successful build `reload.sh` terminates any running app with the same tag, so opening the printed app path launches the fresh binary.
12+
Use `--build-only` only for an explicit compile/validation pass. It leaves the running tagged app, `cmuxd`, and tag state untouched, and stages the new bundle separately; the active app remains on its previous revision.
1113

1214
## App path links
1315

0 commit comments

Comments
 (0)