Skip to content

Commit 9fc38ee

Browse files
authored
Merge branch 'main' into feature/fix/pr-detail-menu-icon-alignment
2 parents 5993b99 + d4d5d12 commit 9fc38ee

1,103 files changed

Lines changed: 80890 additions & 17802 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/ios-debugger-agent/SKILL.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Avoid generic Mac window automation for switching among Simulator windows. Expli
3131

3232
## Choose build or launch
3333

34+
For T3 Code Mobile, run `node scripts/mobile-native-client.ts ensure ios <simulator-udid>` from the checkout on the simulator host first. It checks the local Expo native fingerprint against the installed client and builds/installs when stale, missing, or unknown. Then launch with the intended Metro bundle. Authorized verification includes native builds and installs; do not stop because the existing client is old. Use `check` instead of `ensure` only when the user explicitly prohibits rebuilding or requests a read-only check.
35+
3436
- Use `build_run_sim` when native source, native dependencies, entitlements, or project configuration changed.
3537
- Use `test_sim` for the smallest relevant native test target or test cases; do not run an entire workspace test matrix routinely.
3638
- Use `launch_app_sim` when a compatible app is already installed and no native rebuild is needed.

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,28 @@ Inspect the host and the affected code before launching processes:
1515

1616
- On macOS with Xcode, prefer one representative iOS Simulator when the change is cross-platform so the user can watch through serve-sim. Load and follow [`ios-debugger-agent`](../ios-debugger-agent/SKILL.md), and load [`ios-simulator-browser`](../ios-simulator-browser/SKILL.md) when live streaming is available.
1717
- On macOS, Linux, or Windows with the Android SDK, use one Android Emulator when Android is the affected surface or iOS tooling is unavailable.
18-
- When the change is platform-specific, test that platform. When neither platform is viable, report the missing SDK, emulator, or dev-client prerequisite rather than claiming verification.
18+
- When the change is platform-specific, test that platform. When neither platform is viable, report the missing SDK or emulator prerequisite rather than claiming verification. A missing development client is a build step, not a blocker.
1919

2020
Do not treat unavailable iOS tooling as a blocker when Android is a valid representative target.
2121

22-
## Choose the lightest valid launch path
22+
## Ensure a compatible native client
2323

24-
- For JavaScript, TypeScript, or asset-only changes, reuse a compatible installed development client and start Metro. Do not rebuild native code merely to load a new bundle.
25-
- For native source, native dependencies, entitlements, config plugins, or generated project changes, rebuild the affected platform.
26-
- Use `vp run ios:dev` or `vp run android:dev` only when an Expo clean prebuild is actually required; both commands regenerate the native project.
27-
- If the user requested no native rebuild and no compatible app is installed, reuse an existing compatible `.app` or `.apk` artifact when available. Otherwise report the missing dev client instead of silently rebuilding.
24+
Authorized mobile verification includes building and installing a development client. A missing, stale, or unknown native client is not a reason to skip verification or leave a PR in draft. Build and install it, then continue. Respect an explicit user instruction not to rebuild; otherwise do not ask for separate permission.
2825

29-
The development identity on both platforms is:
26+
Run this from the checkout being tested, on the machine that hosts the selected simulator or emulator. Select and boot one explicit iOS UDID or Android emulator serial first:
3027

31-
- App: `T3 Code Dev`
32-
- Bundle/package identifier: `com.t3tools.t3code.dev`
33-
- URL scheme: `t3code-dev`
28+
```bash
29+
node scripts/mobile-native-client.ts ensure ios <simulator-udid>
30+
node scripts/mobile-native-client.ts ensure android <emulator-serial>
31+
```
32+
33+
`ensure` compares the checkout's local Expo development fingerprint and the installed app's binary contents against the last successful build record. It reuses a matching client; otherwise it runs a clean prebuild, builds and installs the development app, and records the successful result. It does not start Metro. Start Metro below after it succeeds. On hosts with an `agent-job` requirement, run the entire `ensure` command through that queue.
34+
35+
For a read-only decision, use `check` in place of `ensure`. Exit 0 means compatible, 2 means build required, and 1 means an operational error. An app installed outside this helper is initially unknown and gets rebuilt once. Records are local to the simulator host under `~/.cache/t3code/native-clients` and work across checkouts. Do not copy records between machines or write them manually.
36+
37+
A JavaScript-only diff, bundle identifier, app version, or recent install date does not prove native compatibility. Always check the whole checkout. Expo fingerprints are computed locally with `APP_VARIANT=development`; no EAS credentials or cloud build are required. Generated `ios/` and `android/` directories are excluded by `.fingerprintignore`, so edit native source modules or config plugins rather than generated output.
3438

35-
Bundle or package presence proves the correct variant, not native compatibility. Reuse it only when the current changes did not alter its Expo SDK, native dependencies, config plugins, entitlements, generated project, or native source.
39+
The development identity is `T3 Code Dev`, bundle/package `com.t3tools.t3code.dev`, scheme `t3code-dev`. If a build fails, investigate the build error and fix the local prerequisites. Report the concrete failure if it cannot be resolved, not “no compatible client.”
3640

3741
## Start one disposable T3 environment
3842

@@ -98,21 +102,19 @@ Use `ios-debugger-agent` to select one UDID and set these XcodeBuildMCP session
98102
- Simulator ID: the selected UDID
99103
- Bundle ID: `com.t3tools.t3code.dev`
100104

101-
Check the installed client with:
105+
After `ensure` succeeds, open the Metro URL:
102106

103107
```bash
104-
xcrun simctl get_app_container <simulator-udid> com.t3tools.t3code.dev app
105108
xcrun simctl openurl <simulator-udid> <printed-dev-client-url>
106109
```
107110

108111
Accept the iOS confirmation prompt and dismiss the developer menu when it obscures the app.
109112

110113
### Android launch
111114

112-
Select one running emulator serial from `adb devices` and check the installed client:
115+
Use the emulator serial already checked by `ensure`:
113116

114117
```bash
115-
adb -s <emulator-serial> shell pm path com.t3tools.t3code.dev
116118
adb -s <emulator-serial> reverse tcp:<metro-port> tcp:<metro-port>
117119
adb -s <emulator-serial> shell am start -W \
118120
-a android.intent.action.VIEW \

‎.github/VOUCHED.td‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ github:D3OXY
2525
github:dbalders
2626
github:eggfriedrice24
2727
github:extoci
28+
github:f-trycua
2829
github:flamboh
2930
github:FllipEis
3031
github:gbarros-dev

‎.github/scripts/check-nightly-release.cjs‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
const MINIMUM_RELEASE_GAP_MS = 6 * 60 * 60 * 1000;
22

3+
function repositoryDefaultBranch(context) {
4+
const branch = context.payload.repository?.default_branch;
5+
if (!branch) {
6+
throw new Error("GitHub did not provide the repository default branch.");
7+
}
8+
return branch;
9+
}
10+
11+
async function assertCommitOnDefaultBranch({ github, context, sha }) {
12+
const defaultBranch = repositoryDefaultBranch(context);
13+
const { data: comparison } = await github.rest.repos.compareCommitsWithBasehead({
14+
...context.repo,
15+
basehead: `${sha}...${defaultBranch}`,
16+
per_page: 1,
17+
});
18+
if (comparison.status !== "ahead" && comparison.status !== "identical") {
19+
throw new Error(
20+
`Release commit ${sha} is not contained in ${defaultBranch} (${comparison.status}).`,
21+
);
22+
}
23+
}
24+
25+
async function assertReleaseSource({ github, context, releaseChannel }) {
26+
if (releaseChannel === "preview") return;
27+
if (releaseChannel !== "stable" && releaseChannel !== "nightly") {
28+
throw new Error(`Unsupported release channel: ${releaseChannel}`);
29+
}
30+
31+
const defaultBranch = repositoryDefaultBranch(context);
32+
if (context.eventName === "workflow_dispatch" && context.ref !== `refs/heads/${defaultBranch}`) {
33+
throw new Error(
34+
`${releaseChannel} releases must be dispatched from ${defaultBranch}; selected ${context.ref}. Use the preview channel for branch builds.`,
35+
);
36+
}
37+
38+
await assertCommitOnDefaultBranch({ github, context, sha: context.sha });
39+
}
40+
341
const isNightlyTag = (tag) => /^v.*-nightly\./.test(tag) || tag.startsWith("nightly-v");
442

543
// Newest published nightly by publication time, or undefined when none exists.
@@ -64,4 +102,9 @@ async function resolveLatestNightlyCommit({ github, context, core }) {
64102
return { tag, sha: commit.sha, version };
65103
}
66104

67-
module.exports = { shouldReleaseNightly, resolveLatestNightlyCommit };
105+
module.exports = {
106+
assertCommitOnDefaultBranch,
107+
assertReleaseSource,
108+
shouldReleaseNightly,
109+
resolveLatestNightlyCommit,
110+
};

‎.github/scripts/check-nightly-release.test.cjs‎

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
const assert = require("node:assert/strict");
22
const test = require("node:test");
3-
const { shouldReleaseNightly } = require("./check-nightly-release.cjs");
3+
const {
4+
assertCommitOnDefaultBranch,
5+
assertReleaseSource,
6+
shouldReleaseNightly,
7+
} = require("./check-nightly-release.cjs");
48

59
const now = Date.parse("2026-09-05T12:00:00Z");
610
const hour = 60 * 60 * 1000;
@@ -11,6 +15,77 @@ const nightly = (hoursAgo, overrides = {}) => ({
1115
...overrides,
1216
});
1317

18+
function releaseSourceFixture({
19+
comparisonStatus = "ahead",
20+
eventName = "workflow_dispatch",
21+
ref = "refs/heads/main",
22+
sha = "candidate",
23+
} = {}) {
24+
const calls = [];
25+
return {
26+
calls,
27+
options: {
28+
context: {
29+
eventName,
30+
payload: { repository: { default_branch: "main" } },
31+
ref,
32+
repo: { owner: "example", repo: "app" },
33+
sha,
34+
},
35+
github: {
36+
rest: {
37+
repos: {
38+
async compareCommitsWithBasehead(params) {
39+
calls.push(params);
40+
return { data: { status: comparisonStatus } };
41+
},
42+
},
43+
},
44+
},
45+
},
46+
};
47+
}
48+
49+
test("allows preview releases from any branch without consulting main", async () => {
50+
const { options, calls } = releaseSourceFixture({ ref: "refs/heads/feature" });
51+
await assertReleaseSource({ ...options, releaseChannel: "preview" });
52+
assert.equal(calls.length, 0);
53+
});
54+
55+
for (const releaseChannel of ["stable", "nightly"]) {
56+
test(`rejects a manual ${releaseChannel} release from a feature branch`, async () => {
57+
const { options, calls } = releaseSourceFixture({ ref: "refs/heads/feature" });
58+
await assert.rejects(
59+
assertReleaseSource({ ...options, releaseChannel }),
60+
new RegExp(`${releaseChannel} releases must be dispatched from main`),
61+
);
62+
assert.equal(calls.length, 0);
63+
});
64+
65+
test(`allows a manual ${releaseChannel} release from main`, async () => {
66+
const { options, calls } = releaseSourceFixture();
67+
await assertReleaseSource({ ...options, releaseChannel });
68+
assert.equal(calls[0].basehead, "candidate...main");
69+
});
70+
}
71+
72+
for (const comparisonStatus of ["behind", "diverged"]) {
73+
test(`rejects a release commit that is ${comparisonStatus} from main`, async () => {
74+
const { options } = releaseSourceFixture({ comparisonStatus, eventName: "push" });
75+
await assert.rejects(
76+
assertCommitOnDefaultBranch({ ...options, sha: "release-commit" }),
77+
new RegExp(`not contained in main \\(${comparisonStatus}\\)`),
78+
);
79+
});
80+
}
81+
82+
test("accepts a release commit already contained in main", async () => {
83+
for (const comparisonStatus of ["ahead", "identical"]) {
84+
const { options } = releaseSourceFixture({ comparisonStatus, eventName: "push" });
85+
await assertCommitOnDefaultBranch({ ...options, sha: "release-commit" });
86+
}
87+
});
88+
1489
function fixture({ releases = [nightly(7)], comparisonStatus = "ahead" } = {}) {
1590
const calls = [];
1691
return {
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"""Stage an untrusted preview ZIP without letting it replace packaging code."""
2+
3+
import shutil
4+
import stat
5+
import sys
6+
import zipfile
7+
from pathlib import Path
8+
9+
ROOTS = ("server/dist", "desktop/dist-electron")
10+
REQUIRED_FILES = {
11+
"server/dist/bin.mjs",
12+
"server/dist/client/index.html",
13+
"desktop/dist-electron/main.cjs",
14+
}
15+
# The current bundle is about 32 MiB compressed. Bound extraction on the
16+
# trusted runner even when the PR replaces the uploader entirely.
17+
MAX_ARCHIVE_BYTES = 512 * 1024 * 1024
18+
MAX_EXPANDED_BYTES = 2 * 1024 * 1024 * 1024
19+
MAX_ENTRIES = 50_000
20+
21+
22+
def stage_bundle(archive: Path, destination: Path):
23+
if archive.stat().st_size > MAX_ARCHIVE_BYTES:
24+
raise ValueError("Preview archive is too large")
25+
with zipfile.ZipFile(archive) as bundle:
26+
entries = bundle.infolist()
27+
if len(entries) > MAX_ENTRIES:
28+
raise ValueError("Preview archive has too many entries")
29+
if sum(entry.file_size for entry in entries) > MAX_EXPANDED_BYTES:
30+
raise ValueError("Expanded preview bundle is too large")
31+
seen = set()
32+
files = set()
33+
for entry in entries:
34+
name = entry.filename.removesuffix("/")
35+
parts = name.split("/")
36+
# Reject ambiguous paths before normalization, including names
37+
# that would alias on the macOS signing runner.
38+
if (
39+
entry.orig_filename != entry.filename
40+
or any(part in ("", ".", "..") for part in parts)
41+
or any(char in name for char in "\\:")
42+
or not name.isascii()
43+
or any(ord(char) < 32 or ord(char) == 127 for char in name)
44+
):
45+
raise ValueError(f"Unsafe preview path: {entry.filename!r}")
46+
allowed = any(name.startswith(root + "/") for root in ROOTS)
47+
if entry.is_dir():
48+
allowed |= any(root == name or root.startswith(name + "/") for root in ROOTS)
49+
if not allowed:
50+
raise ValueError(f"Unexpected preview path: {name!r}")
51+
kind = stat.S_IFMT(entry.external_attr >> 16)
52+
if kind not in (0, stat.S_IFDIR if entry.is_dir() else stat.S_IFREG):
53+
raise ValueError(f"Non-regular preview entry: {name!r}")
54+
if name.casefold() in seen:
55+
raise ValueError(f"Duplicate preview path: {name!r}")
56+
seen.add(name.casefold())
57+
if not entry.is_dir():
58+
files.add(name)
59+
if not REQUIRED_FILES <= files:
60+
raise ValueError("Preview bundle is missing required entry points")
61+
# Validate all names before writing anything. This is a fresh directory
62+
# outside the checkout; neither pre-existing links nor trusted files
63+
# can be followed or overwritten. ZIP permissions are never restored.
64+
destination.mkdir(parents=True, exist_ok=False)
65+
for entry in entries:
66+
target = destination / entry.filename
67+
if entry.is_dir():
68+
target.mkdir(parents=True, exist_ok=True)
69+
else:
70+
target.parent.mkdir(parents=True, exist_ok=True)
71+
with bundle.open(entry) as source, target.open("xb") as output:
72+
shutil.copyfileobj(source, output)
73+
74+
75+
if __name__ == "__main__":
76+
stage_bundle(Path(sys.argv[1]), Path(sys.argv[2]))

0 commit comments

Comments
 (0)