The best way to control Claude Code, Codex and more from any computer or phone
fix(ci): repair the mobile showcase screenshots workflow (#5057)
Julius Marminge committed
Jul 31, 2026 at 10:11 UTC
50a3d6b872406bb15af72d439740dd63e89f820d
3 files changed
+72
-18
.github/workflows/mobile-showcase-screenshots.yml
+2
@@ -52,6 +52,7 @@ jobs:
52
args:
53
- --filter=@t3tools/mobile...
54
- --filter=@t3tools/scripts...
55
+ - --filter=t3...
56
57
- name: Expose pnpm
58
run: |
@@ -100,6 +101,7 @@ jobs:
101
args:
102
- --filter=@t3tools/mobile...
103
- --filter=@t3tools/scripts...
104
+ - --filter=t3...
105
106
- name: Expose pnpm
107
run: |
scripts/mobile-showcase-environment.ts
+47
-12
@@ -1,4 +1,4 @@
1
-// @effect-diagnostics nodeBuiltinImport:off globalDate:off - This host-side fixture creates an isolated local T3 environment.
1
+// @effect-diagnostics nodeBuiltinImport:off globalTimers:off globalDate:off - This host-side fixture creates an isolated local T3 environment.
2
import * as NodeChildProcess from "node:child_process";
3
import * as NodeFSP from "node:fs/promises";
4
import * as NodePath from "node:path";
@@ -387,6 +387,48 @@ function insertThread(
387
.run(input.id, isWorking ? "running" : "ready", isWorking ? turnId : null, updatedAt);
388
}
389
390
+const SEEDED_PROJECTION_TABLES = [
391
+ "projection_pending_approvals",
392
+ "projection_thread_proposed_plans",
393
+ "projection_thread_activities",
394
+ "projection_thread_messages",
395
+ "projection_thread_sessions",
396
+ "projection_turns",
397
+ "projection_threads",
398
+ "projection_projects",
399
+ "projection_state",
400
+] as const;
401
+
402
+function hasSeedableSchema(dbPath: string): boolean {
403
+ let database: NodeSqlite.DatabaseSync;
404
+ try {
405
+ database = new NodeSqlite.DatabaseSync(dbPath, { readOnly: true });
406
+ } catch {
407
+ return false;
408
+ }
409
+ try {
410
+ const row = database
411
+ .prepare(
412
+ `SELECT COUNT(*) AS count FROM sqlite_master WHERE type = 'table' AND name IN (${SEEDED_PROJECTION_TABLES.map(() => "?").join(", ")})`,
413
+ )
414
+ .get(...SEEDED_PROJECTION_TABLES) as { count: number };
415
+ return row.count === SEEDED_PROJECTION_TABLES.length;
416
+ } catch {
417
+ return false;
418
+ } finally {
419
+ database.close();
420
+ }
421
+}
422
+
423
+async function waitForSeedableSchema(dbPath: string, timeoutMs = 60_000): Promise<void> {
424
+ const deadline = Date.now() + timeoutMs;
425
+ while (Date.now() < deadline) {
426
+ if (hasSeedableSchema(dbPath)) return;
427
+ await new Promise((resolve) => setTimeout(resolve, 250));
428
+ }
429
+ throw new Error(`The environment server did not migrate ${dbPath} within ${timeoutMs}ms.`);
430
+}
431
+
432
function seedDatabase(
433
dbPath: string,
434
workspaceRoots: ReadonlyMap<string, string>,
@@ -401,17 +443,7 @@ function seedDatabase(
443
const database = new NodeSqlite.DatabaseSync(dbPath, { timeout: 30_000 });
444
try {
445
database.exec("BEGIN IMMEDIATE");
404
- for (const table of [
405
- "projection_pending_approvals",
406
- "projection_thread_proposed_plans",
407
- "projection_thread_activities",
408
- "projection_thread_messages",
409
- "projection_thread_sessions",
410
- "projection_turns",
411
- "projection_threads",
412
- "projection_projects",
413
- "projection_state",
414
- ]) {
446
+ for (const table of SEEDED_PROJECTION_TABLES) {
447
database.exec(`DELETE FROM ${table}`);
448
}
449
const insertProject = database.prepare(
@@ -594,6 +626,9 @@ export async function seedShowcaseEnvironment(input: {
626
});
627
}),
628
);
629
+ // The environment server begins listening before it finishes migrating the
630
+ // database, so wait for the schema before deleting from and reseeding it.
631
+ await waitForSeedableSchema(dbPath);
632
seedDatabase(dbPath, workspaceRoots, projects, threads, now);
633
634
const terminalDirectory = NodePath.join(input.baseDir, "userdata", "logs", "terminals");
scripts/mobile-showcase.ts
+23
-6
@@ -500,6 +500,23 @@ async function waitForPort(port: number, label = "Process", timeoutMs = 60_000):
500
throw new Error(`${label} did not begin listening on port ${port} within ${timeoutMs}ms.`);
501
}
502
503
+async function waitForFileContent(
504
+ filePath: string,
505
+ label: string,
506
+ timeoutMs = 60_000,
507
+): Promise<string> {
508
+ const deadline = Date.now() + timeoutMs;
509
+ while (Date.now() < deadline) {
510
+ const content = await NodeFSP.readFile(filePath, "utf8").then(
511
+ (value) => value.trim(),
512
+ () => "",
513
+ );
514
+ if (content) return content;
515
+ await delay(250);
516
+ }
517
+ throw new Error(`${label} was not written to ${filePath} within ${timeoutMs}ms.`);
518
+}
519
+
520
async function reserveAvailablePort(): Promise<number> {
521
return await new Promise<number>((resolve, reject) => {
522
const server = NodeNet.createServer();
@@ -1225,12 +1242,12 @@ async function main(): Promise<void> {
1242
showcaseServers.push(server);
1243
await waitForPort(port, `${environment.label} server`);
1244
await seedShowcaseEnvironment({ baseDir, projectIds: environment.projectIds });
1228
- const environmentId = (
1229
- await NodeFSP.readFile(NodePath.join(baseDir, "userdata", "environment-id"), "utf8")
1230
- ).trim();
1231
- if (!environmentId) {
1232
- throw new Error(`${environment.label} did not persist an environment id.`);
1233
- }
1245
+ // The server begins listening before the ServerEnvironment layer
1246
+ // persists the environment id, so poll rather than read once.
1247
+ const environmentId = await waitForFileContent(
1248
+ NodePath.join(baseDir, "userdata", "environment-id"),
1249
+ `${environment.label} environment id`,
1250
+ );
1251
showcaseEnvironments.push({ baseDir, environmentId, label: environment.label, port });
1252
}
1253