Skip to content

Commit 2103eb6

Browse files
committed
Merge remote-tracking branch 'upstream/main' into perf/windows-installer-file-count
2 parents cebcb55 + 9fd788b commit 2103eb6

475 files changed

Lines changed: 66956 additions & 5184 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/test-t3-mobile/SKILL.md‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,31 +125,29 @@ Do not start, stop, erase, or reconfigure an emulator owned by another task. Tra
125125

126126
## Pair each client once
127127

128-
Issue a fresh credential against the running backend's exact base directory:
128+
Use the bundled helper from the repository root. It issues a fresh credential against the running backend's exact base directory, opens the existing Add Environment route with the credential in an encoded query parameter, and asks that route to connect once:
129129

130130
```bash
131-
T3CODE_PORT=<server-port> node apps/server/src/bin.ts auth pairing create \
132-
--base-dir <base-dir> \
133-
--base-url <mobile-origin> \
134-
--ttl 15m \
135-
--label agent-mobile-<short-device-id>
131+
.agents/skills/test-t3-mobile/scripts/pair-client.sh \
132+
ios <simulator-udid> <server-port> <base-dir>
133+
134+
.agents/skills/test-t3-mobile/scripts/pair-client.sh \
135+
android <emulator-serial> <server-port> <base-dir>
136136
```
137137

138-
In PowerShell, set `$env:T3CODE_PORT = "<server-port>"` first and run the `node ... auth pairing create` command without the leading assignment.
138+
Run only the command for the selected platform. The helper uses `http://127.0.0.1:<server-port>` for iOS and `http://10.0.2.2:<server-port>` for Android. Pass a fifth argument only when testing a non-development URL scheme.
139139

140-
If the visible Add Environment action is not exposed as a semantic target, open the app's registered route instead of guessing coordinates:
140+
The helper opens this registered route:
141141

142-
```bash
143-
xcrun simctl openurl <simulator-udid> 't3code-dev://connections/new'
144-
adb -s <emulator-serial> shell am start -W \
145-
-a android.intent.action.VIEW \
146-
-d 't3code-dev://connections/new' \
147-
com.t3tools.t3code.dev
142+
```text
143+
t3code-dev://connections/new?pairingUrl=<encoded-pairing-url>&autoConnect=1
148144
```
149145

150-
Run only the command for the selected platform.
146+
The Add Environment route owns the behavior: `pairingUrl` prefills its normal host and token inputs, while `autoConnect=1` submits once in development builds and returns to Home after success. Without `autoConnect`, the same route only prefills the form for manual inspection.
147+
148+
Do not enter pairing hosts or tokens through simulator keyboard automation. Xcode's semantic typer sends HID-style key events through the simulator's active keyboard state, which can corrupt uppercase tokens and punctuation even when the host Mac uses a U.S. input source. The one-shot route is the deterministic pairing path. Use the visible form only as a fallback, and paste credentials rather than typing them character by character.
151149

152-
In T3 Code Dev, open Add Environment and enter the complete `<mobile-origin>` and newly printed `Token`. Verify the expected seeded projects appear before exercising the affected flow.
150+
Verify the expected seeded projects appear before exercising the affected flow.
153151

154152
Pairing credentials are secret, short-lived, and single-use. Create a different credential for every simulator, emulator, physical device, or browser. If an attempt fails, issue a new credential rather than retrying the old one. Do not expose tokens in screenshots, commits, or final responses.
155153

@@ -183,6 +181,8 @@ Keep local verification focused. Do not turn this workflow into a full repositor
183181
- **Old UI or an old error appears:** verify Metro's worktree, variant, URL, and port before diagnosing the app.
184182
- **The environment remains empty:** verify the platform-specific HTTP origin, use a fresh token, and confirm project seeding used the identical base directory.
185183
- **A second client cannot pair:** pairing tokens are single-use; issue another token.
184+
- **The pairing form opens but does not connect:** confirm the deep link uses the existing `connections/new` route, includes `autoConnect=1`, and carries a freshly minted encoded `pairingUrl`.
185+
- **Pairing text changes case or punctuation:** do not retry semantic typing. Use `scripts/pair-client.sh`; the simulator keyboard layout and HID input path are not reliable for credentials.
186186
- **iOS semantic actions fail:** set explicit XcodeBuildMCP defaults and refresh with `snapshot_ui`.
187187
- **Android cannot reach Metro:** verify `adb reverse` for the exact Metro port and relaunch the development-client URL.
188188
- **Android cannot reach the backend:** use `10.0.2.2`, not `127.0.0.1`, for the Android Emulator.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
usage() {
6+
echo "Usage: $0 <ios|android> <device-id> <server-port> <base-dir> [url-scheme]" >&2
7+
exit 2
8+
}
9+
10+
[[ $# -ge 4 && $# -le 5 ]] || usage
11+
12+
platform="$1"
13+
device_id="$2"
14+
server_port="$3"
15+
base_dir="$4"
16+
url_scheme="${5:-t3code-dev}"
17+
18+
case "$platform" in
19+
ios)
20+
mobile_origin="http://127.0.0.1:${server_port}"
21+
;;
22+
android)
23+
mobile_origin="http://10.0.2.2:${server_port}"
24+
;;
25+
*)
26+
usage
27+
;;
28+
esac
29+
30+
repo_root="$(git rev-parse --show-toplevel)"
31+
cd "$repo_root"
32+
33+
if ! pairing_output="$({
34+
T3CODE_PORT="$server_port" node apps/server/src/bin.ts auth pairing create \
35+
--base-dir "$base_dir" \
36+
--base-url "$mobile_origin" \
37+
--ttl 15m \
38+
--label "agent-mobile-${device_id:0:8}"
39+
} 2>&1)"; then
40+
echo "Could not mint a mobile pairing credential." >&2
41+
exit 1
42+
fi
43+
44+
pairing_url="$(printf '%s\n' "$pairing_output" | sed -n 's/^Pair URL: //p' | tail -n 1)"
45+
if [[ -z "$pairing_url" ]]; then
46+
echo "Could not parse the mobile pairing URL." >&2
47+
exit 1
48+
fi
49+
50+
deep_link="$(PAIRING_URL="$pairing_url" URL_SCHEME="$url_scheme" node - <<'NODE'
51+
const query = new URLSearchParams({
52+
pairingUrl: process.env.PAIRING_URL,
53+
autoConnect: "1",
54+
});
55+
process.stdout.write(`${process.env.URL_SCHEME}://connections/new?${query}`);
56+
NODE
57+
)"
58+
59+
case "$platform" in
60+
ios)
61+
xcrun simctl openurl "$device_id" "$deep_link"
62+
;;
63+
android)
64+
# adb shell re-joins its arguments and evaluates them through the device
65+
# shell, so the deep link's `?`/`&` must be quoted once more for that shell.
66+
adb -s "$device_id" shell \
67+
"am start -W -a android.intent.action.VIEW -d '$deep_link' com.t3tools.t3code.dev" \
68+
>/dev/null
69+
;;
70+
esac
71+
72+
echo "Opened the existing Add Environment route with a fresh pairing credential."

‎.github/VOUCHED.td‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ github:shivamhwp
3737
github:jappyjan
3838
github:justsomelegs
3939
github:UtkarshUsername
40+
github:SunkenInTime
41+
github:bil0000

‎.github/workflows/mobile-eas-production.yml‎

Lines changed: 176 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ name: Mobile EAS Production
55
# in the same OS/pnpm as the EAS build; a macOS `eas build` computes a different
66
# fingerprint (platform-specific deps + pnpm version) and errors. On this Linux
77
# runner, with corepack pinning pnpm 10.24 in eas.json, local == build.
8+
#
9+
# Every merge to main that touches the mobile app reconciles, per platform:
10+
# 1. Store builds: if the latest production build's version differs from
11+
# app.config.ts, cut a new build and submit it (TestFlight + Play internal
12+
# track). Bumping `version` is therefore all it takes to
13+
# start the next release train — the first build of a version enters
14+
# external-TestFlight beta review immediately, and later builds of the
15+
# same version auto-approve until that version is released. After App
16+
# Store approval, Apple closes the release train and `version` must be
17+
# bumped before another iOS build can be submitted. Releasing to the App
18+
# Store stays a manual App Store Connect step.
19+
# 2. OTA: publish a production-channel update for each platform where at
20+
# least one finished production build matches the current native
21+
# fingerprint. Old-version binaries with a matching fingerprint receive
22+
# it too. When native drift means no binary could install the update,
23+
# it is skipped and flagged in the job summary instead of published
24+
# into the void.
25+
# workflow_dispatch remains as a manual override for both modes (e.g. to
26+
# retry an errored build or force an OTA).
827
on:
928
workflow_dispatch:
1029
inputs:
@@ -25,14 +44,38 @@ on:
2544
- ios
2645
- android
2746
- all
47+
version:
48+
description: "Optional build version override (blank uses app.config.ts; an override is committed before building)"
49+
required: false
50+
type: string
2851
message:
2952
description: "OTA update message (mode=update only)"
3053
required: false
3154
type: string
55+
push:
56+
branches: [main]
57+
paths:
58+
- apps/mobile/**
59+
- packages/client-runtime/**
60+
- packages/contracts/**
61+
- packages/shared/**
62+
- assets/**
63+
- scripts/**
64+
- patches/**
65+
- pnpm-lock.yaml
66+
- pnpm-workspace.yaml
67+
- .github/workflows/mobile-eas-production.yml
68+
69+
# Serialize runs so OTAs publish in merge order. GitHub keeps at most one
70+
# queued run per group, so a burst of merges collapses into one run of the
71+
# newest commit — intermediate commits don't need their own OTA.
72+
concurrency:
73+
group: mobile-eas-production
74+
cancel-in-progress: false
3275

3376
jobs:
3477
production:
35-
name: EAS Production ${{ inputs.mode }}
78+
name: EAS Production ${{ github.event_name == 'push' && 'auto' || inputs.mode }}
3679
runs-on: blacksmith-8vcpu-ubuntu-2404
3780
permissions:
3881
contents: read
@@ -52,11 +95,21 @@ jobs:
5295
echo "EXPO_TOKEN is not available; skipping EAS production job."
5396
fi
5497
98+
- id: version_app_token
99+
name: Mint release app token for version override
100+
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' && inputs.version != ''
101+
uses: actions/create-github-app-token@v2
102+
with:
103+
app-id: ${{ secrets.RELEASE_APP_ID }}
104+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
105+
owner: ${{ github.repository_owner }}
106+
55107
- name: Checkout
56108
if: steps.expo-token.outputs.present == 'true'
57109
uses: actions/checkout@v6
58110
with:
59111
fetch-depth: 0
112+
token: ${{ steps.version_app_token.outputs.token || github.token }}
60113
# No sparse-checkout here: it makes actions/checkout fetch with
61114
# --filter=blob:none, and eas-cli archives the project via
62115
# `git clone --depth 1 file://<workspace>`, which fails (exit 128)
@@ -98,15 +151,74 @@ jobs:
98151
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
99152
run: eas env:pull production --non-interactive
100153

101-
- name: Build and submit
102-
if: steps.expo-token.outputs.present == 'true' && inputs.mode == 'build'
154+
- name: Apply manual version override
155+
if: steps.version_app_token.outcome == 'success'
156+
env:
157+
GH_TOKEN: ${{ steps.version_app_token.outputs.token }}
158+
APP_SLUG: ${{ steps.version_app_token.outputs.app-slug }}
159+
RELEASE_VERSION: ${{ inputs.version }}
160+
run: |
161+
if [ "$GITHUB_REF_TYPE" != "branch" ]; then
162+
echo "Version overrides require dispatching this workflow from a branch; received $GITHUB_REF_TYPE '$GITHUB_REF_NAME'." >&2
163+
exit 1
164+
fi
165+
if ! [[ "$RELEASE_VERSION" =~ ^[0-9]+(\.[0-9]+){1,2}$ ]]; then
166+
echo "Version override must contain two or three dot-separated integers; received '$RELEASE_VERSION'." >&2
167+
exit 1
168+
fi
169+
170+
node --input-type=module -e '
171+
import fs from "node:fs";
172+
const path = "apps/mobile/app.config.ts";
173+
const source = fs.readFileSync(path, "utf8");
174+
const next = source.replace(
175+
/^( version: ")[^"]+(".*)$/m,
176+
`$1${process.env.RELEASE_VERSION}$2`,
177+
);
178+
if (next === source && !source.includes(` version: "${process.env.RELEASE_VERSION}"`)) {
179+
throw new Error("Could not update app version");
180+
}
181+
fs.writeFileSync(path, next);
182+
'
183+
vp fmt apps/mobile/app.config.ts
184+
185+
if git diff --quiet -- apps/mobile/app.config.ts; then
186+
echo "app.config.ts is already at $RELEASE_VERSION; no version commit needed."
187+
exit 0
188+
fi
189+
190+
user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
191+
git config user.name "${APP_SLUG}[bot]"
192+
git config user.email "${user_id}+${APP_SLUG}[bot]@users.noreply.github.com"
193+
git add apps/mobile/app.config.ts
194+
git commit \
195+
-m "chore(mobile): bump app version to $RELEASE_VERSION" \
196+
-m "Co-authored-by: codex <[email protected]>"
197+
git push origin "HEAD:refs/heads/${GITHUB_REF_NAME}"
198+
199+
- name: Summarize manual build version
200+
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build'
201+
working-directory: apps/mobile
202+
run: |
203+
version="$(npx expo config --json --type public | jq -r '.version')"
204+
{
205+
echo "## Manual production build"
206+
echo
207+
echo "- App version: \`$version\`"
208+
echo "- Platform: \`${{ inputs.platform }}\`"
209+
echo
210+
echo "> Apple closes an iOS release train after App Store approval. Before building iOS, confirm \`$version\` is newer than the approved App Store version."
211+
} >> "$GITHUB_STEP_SUMMARY"
212+
213+
- name: Build and submit (manual)
214+
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build'
103215
working-directory: apps/mobile
104216
env:
105217
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
106218
run: eas build --platform ${{ inputs.platform }} --profile production --auto-submit --non-interactive --no-wait
107219

108-
- name: Publish OTA update
109-
if: steps.expo-token.outputs.present == 'true' && inputs.mode == 'update'
220+
- name: Publish OTA update (manual)
221+
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'update'
110222
working-directory: apps/mobile
111223
env:
112224
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
@@ -117,3 +229,62 @@ jobs:
117229
--platform ${{ inputs.platform }} \
118230
--message "${{ inputs.message || format('Production OTA ({0})', github.sha) }}" \
119231
--non-interactive
232+
233+
# No --status filter on build:list: an in-queue/in-progress build must
234+
# count as existing, or every merge during the build window would cut a
235+
# duplicate. After an errored build, retry via workflow_dispatch
236+
# mode=build — pushes won't re-trigger it until the app version changes.
237+
- id: store_builds
238+
name: Ensure store builds exist for the current app version
239+
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'push'
240+
continue-on-error: true
241+
working-directory: apps/mobile
242+
env:
243+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
244+
run: |
245+
failed=0
246+
version="$(npx expo config --json --type public | jq -r '.version')"
247+
for platform in ios android; do
248+
latest="$(eas build:list --platform "$platform" --build-profile production --limit 1 --json --non-interactive | jq -r '.[0].appVersion // "none"')"
249+
if [ "$latest" = "$version" ]; then
250+
echo "$platform: production build for $version already exists (or is in progress)"
251+
continue
252+
fi
253+
echo "$platform: latest production build is $latest, app.config.ts says $version — building"
254+
if eas build --platform "$platform" --profile production --auto-submit --non-interactive --no-wait; then
255+
echo ":building_construction: $platform: scheduled production build and submission for $version" >> "$GITHUB_STEP_SUMMARY"
256+
else
257+
failed=1
258+
echo ":x: $platform: production build or submission failed for $version" >> "$GITHUB_STEP_SUMMARY"
259+
fi
260+
done
261+
exit "$failed"
262+
263+
- name: Publish fingerprint-gated OTA
264+
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'push'
265+
working-directory: apps/mobile
266+
env:
267+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
268+
run: |
269+
message="$(git log -1 --pretty=%s | head -c 120) ($(git rev-parse --short=9 HEAD))"
270+
for platform in ios android; do
271+
# eas-cli prints an environment-loaded notice to stdout before the
272+
# JSON even with --json, so discard everything before the document.
273+
hash="$(eas fingerprint:generate --platform "$platform" --environment production --json --non-interactive | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')"
274+
matching="$(eas build:list --platform "$platform" --build-profile production --status finished --fingerprint-hash "$hash" --limit 1 --json --non-interactive | jq 'length')"
275+
if [ "$matching" -gt 0 ]; then
276+
eas update \
277+
--channel production \
278+
--environment production \
279+
--platform "$platform" \
280+
--message "$message" \
281+
--non-interactive
282+
echo ":white_check_mark: $platform: OTA published to production (fingerprint \`$hash\`)" >> "$GITHUB_STEP_SUMMARY"
283+
else
284+
echo ":warning: $platform: no finished production build matches fingerprint \`$hash\` — OTA skipped; JS changes reach $platform only once a matching build ships" >> "$GITHUB_STEP_SUMMARY"
285+
fi
286+
done
287+
288+
- name: Propagate store build failure
289+
if: steps.store_builds.outcome == 'failure'
290+
run: exit 1

0 commit comments

Comments
 (0)