@devries-cameron20 / t3code Mirror · read-only / commits / 618761a2d6
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 20:45 UTC

build(setup): leaner installs on Mac and Linux, cross-device store warning, setup-done marker (#22718)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 21, 2026 at 00:50 UTC 618761a2d6d615b2c0a07e5de4d82384a583f717
5 files changed +107 -9
.pnpmfile.cjs new
+21
@@ -0,0 +1,21 @@
1 +// Windows WSL dev mode runs the server under Linux from the same node_modules
2 +// as the Windows client, so Windows installs also need Linux x64 glibc native
3 +// modules. Other platforms install only their own binaries; setting this
4 +// everywhere added ~2.2 GB of foreign binaries to every macOS install.
5 +// Release scripts stage their own installs with explicit architectures.
6 +module.exports = {
7 + hooks: {
8 + updateConfig(config) {
9 + // oxlint-disable-next-line t3code/no-global-process-runtime -- pnpm loads this file before any Effect runtime exists.
10 + if (process.platform !== "win32") return config;
11 + return {
12 + ...config,
13 + supportedArchitectures: {
14 + os: ["current", "linux"],
15 + cpu: ["current", "x64"],
16 + libc: ["current", "glibc"],
17 + },
18 + };
19 + },
20 + },
21 +};
AGENTS.md
+1
@@ -78,6 +78,7 @@ The most common defect in this repo is a change that works on the path you teste
78 ## Dev servers
79
80 - `vp i` installs. Worktrees get this from the t3.json setup script; if module resolution looks broken, it probably did not run.
81 +- Setup runs in the background. While `.t3/setup-running` names a live PID, wait for it and do not run `vp i`. It ends with `.t3/setup-done` or `.t3/setup-failed` (with the error tail). With no marker at all, setup never ran here, so run `vp i` yourself.
82 - `vp run dev` starts server and web. In a worktree, state defaults to that worktree's gitignored `.t3`, which deliberately outranks an ambient `T3CODE_HOME` so you cannot land on shared state by accident. An explicit `--home-dir` still wins.
83 - Ports derive from the worktree path and are stable across restarts, but read the real ones from the `[dev-runner]` line since occupied ports shift.
84 - Sharing over the tailnet is three steps: run `vp run dev --share` in the background, wait for the `pairingUrl:` line in its output, then give that full URL to an unpaired browser. Do not wire up `tailscale serve` by hand, open the URL yourself, or consume the user's pairing link. A browser with the reusable dev cookie can use the bare origin. If a normal one-time token was consumed, mint a fresh one with `node apps/server/src/bin.ts pair`. It carries standard scopes, while the startup URL carries admin scopes needed for Connections settings.
pnpm-lock.yaml
+2
@@ -166,6 +166,8 @@ overrides:
166
167 packageExtensionsChecksum: sha256-EowbsmlBFaoO0Ypufw901RnvdyjKG5dcdk2FRbc7Dr0=
168
169 +pnpmfileChecksum: sha256-lS/yS+IvX/sj4KLdjVeRsq/hRipJMILKWjIbzIC+czo=
170 +
171 patchedDependencies:
172 '@clerk/expo-native-components@0.2.0': 7a808b92da8460750b85818552e13be3fb73d111691c7db76965970351e124e4
173 '@effect/vitest@4.0.5': 2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02
pnpm-workspace.yaml
-5
@@ -373,8 +373,3 @@ peerDependencyRules:
373 # pnpm keeps optional deps inside the virtual store, so hoist it to the root.
374 publicHoistPattern:
375 - "@cursor/sdk-*"
376 -
377 -supportedArchitectures:
378 - cpu: [current, x64]
379 - libc: [current, glibc]
380 - os: [current, linux]
scripts/setup-worktree.ts
+83 -4
@@ -5,23 +5,102 @@ import * as NodePath from "node:path";
5
6 const ENV_FILES = [".env", NodePath.join("infra", "relay", ".env")];
7
8 +const worktree = NodePath.dirname(import.meta.dirname);
9 +
10 +// T3 runs setup in the background, so agents can start before it ends.
11 +// `setup-running` holds this PID until setup ends with `setup-done` or
12 +// `setup-failed`, so agents wait instead of racing it with their own `vp i`.
13 +const markerDir = NodePath.join(worktree, ".t3");
14 +const runningMarker = NodePath.join(markerDir, "setup-running");
15 +const doneMarker = NodePath.join(markerDir, "setup-done");
16 +const failedMarker = NodePath.join(markerDir, "setup-failed");
17 +NodeFS.rmSync(doneMarker, { force: true });
18 +NodeFS.rmSync(failedMarker, { force: true });
19 +NodeFS.mkdirSync(markerDir, { recursive: true });
20 +NodeFS.writeFileSync(runningMarker, `${process.pid}\n`);
21 +let failureDetail = "";
22 +process.on("uncaughtExceptionMonitor", (error) => {
23 + failureDetail = error.stack ?? String(error);
24 +});
25 +process.on("exit", (code) => {
26 + if (code === 0) NodeFS.writeFileSync(doneMarker, "");
27 + else NodeFS.writeFileSync(failedMarker, `Setup exited with code ${code}.\n${failureDetail}\n`);
28 + NodeFS.rmSync(runningMarker, { force: true });
29 +});
30 +// A cancelled setup must still leave a marker, or agents would wait forever.
31 +// During install, the signal goes on to the installer and setup exits when the
32 +// install output closes. Any child the shell leaves behind holds that output
33 +// open, so no marker appears while `vp i` can still write node_modules.
34 +let cancelSignal: NodeJS.Signals | undefined;
35 +let activeInstall: NodeChildProcess.ChildProcess | undefined;
36 +for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"] as const) {
37 + process.on(signal, () => {
38 + cancelSignal = signal;
39 + if (activeInstall) activeInstall.kill(signal);
40 + else process.exit(1);
41 + });
42 +}
43 +
44 const projectRoot = process.env.T3CODE_PROJECT_ROOT;
45 if (!projectRoot) {
46 throw new Error("T3CODE_PROJECT_ROOT is not set. Run this through the t3.json setup action.");
47 }
12 -const worktree = NodePath.dirname(import.meta.dirname);
48
49 // `shell` resolves `vp` through PATH, including Windows command shims.
50 // Setup has no one answering install prompts. Pass pnpm's confirmation flag
51 // through vp and leave stdin closed so other prompts fail instead of hanging.
52 // Install exactly the locked dependencies so setup never rewrites the lockfile.
53 // A stale lockfile must fail setup rather than silently resolving a new one.
19 -const install = NodeChildProcess.spawnSync("vp i --frozen-lockfile -- --yes", {
54 +// Output is piped, not inherited, so a failure can keep its tail in the marker.
55 +const install = NodeChildProcess.spawn("vp i --frozen-lockfile -- --yes", {
56 cwd: worktree,
57 shell: true,
22 - stdio: ["ignore", "inherit", "inherit"],
58 + stdio: ["ignore", "pipe", "pipe"],
59 });
24 -if (install.status !== 0) process.exit(install.status ?? 1);
60 +activeInstall = install;
61 +let installOutput = "";
62 +for (const [source, target] of [
63 + [install.stdout, process.stdout],
64 + [install.stderr, process.stderr],
65 +] as const) {
66 + source.setEncoding("utf8");
67 + source.on("data", (chunk: string) => {
68 + target.write(chunk);
69 + installOutput = (installOutput + chunk).slice(-8_000);
70 + });
71 +}
72 +const installStatus = await new Promise<number | null>((resolve) => install.on("close", resolve));
73 +activeInstall = undefined;
74 +if (installStatus !== 0 || cancelSignal) {
75 + failureDetail = cancelSignal
76 + ? `Cancelled by ${cancelSignal}.`
77 + : installOutput.trimEnd().split("\n").slice(-30).join("\n");
78 + process.exit(installStatus || 1);
79 +}
80 +
81 +// pnpm cannot clone or hardlink across filesystems, so a store on another
82 +// device silently turns every worktree install into a full copy.
83 +const storeDir: unknown = JSON.parse(
84 + NodeFS.readFileSync(NodePath.join(worktree, "node_modules", ".modules.yaml"), "utf8"),
85 +).storeDir;
86 +if (
87 + typeof storeDir === "string" &&
88 + NodeFS.statSync(storeDir).dev !== NodeFS.statSync(NodePath.join(worktree, "node_modules")).dev
89 +) {
90 + process.stderr.write(
91 + [
92 + "",
93 + "WARNING: the pnpm store is on a different filesystem than this worktree.",
94 + ` store: ${storeDir}`,
95 + ` worktree: ${worktree}`,
96 + "pnpm cannot hardlink or clone across filesystems, so it copied every package into node_modules.",
97 + "Fix: put the store on the worktree's filesystem, for example:",
98 + ` pnpm config set store-dir ${JSON.stringify(NodePath.join(NodePath.dirname(worktree), ".pnpm-store"))} --global`,
99 + "",
100 + "",
101 + ].join("\n"),
102 + );
103 +}
104
105 // Env files live as real files in the main checkout; worktrees only get
106 // symlinks to them. Only a symlink is ever replaced, so a real env file is