Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(ci): repair the mobile showcase screenshots workflow (#5057)
Julius Marminge50a3d6b87240
diff --git a/.github/workflows/mobile-showcase-screenshots.yml b/.github/workflows/mobile-showcase-screenshots.ymlindex 0aa9f30a2..3eaaf508e 100644--- a/.github/workflows/mobile-showcase-screenshots.yml+++ b/.github/workflows/mobile-showcase-screenshots.yml@@ -52,6 +52,7 @@ jobs:args:- --filter=@t3tools/mobile...- --filter=@t3tools/scripts...+ - --filter=t3...- name: Expose pnpmrun: |@@ -100,6 +101,7 @@ jobs:args:- --filter=@t3tools/mobile...- --filter=@t3tools/scripts...+ - --filter=t3...- name: Expose pnpmrun: |diff --git a/scripts/mobile-showcase-environment.ts b/scripts/mobile-showcase-environment.tsindex 9c04c7e9d..f78546753 100644--- a/scripts/mobile-showcase-environment.ts+++ b/scripts/mobile-showcase-environment.ts@@ -1,4 +1,4 @@-// @effect-diagnostics nodeBuiltinImport:off globalDate:off - This host-side fixture creates an isolated local T3 environment.+// @effect-diagnostics nodeBuiltinImport:off globalTimers:off globalDate:off - This host-side fixture creates an isolated local T3 environment.import * as NodeChildProcess from "node:child_process";import * as NodeFSP from "node:fs/promises";import * as NodePath from "node:path";@@ -387,6 +387,48 @@ function insertThread(.run(input.id, isWorking ? "running" : "ready", isWorking ? turnId : null, updatedAt);}+const SEEDED_PROJECTION_TABLES = [+ "projection_pending_approvals",+ "projection_thread_proposed_plans",+ "projection_thread_activities",+ "projection_thread_messages",+ "projection_thread_sessions",+ "projection_turns",+ "projection_threads",+ "projection_projects",+ "projection_state",+] as const;++function hasSeedableSchema(dbPath: string): boolean {+ let database: NodeSqlite.DatabaseSync;+ try {+ database = new NodeSqlite.DatabaseSync(dbPath, { readOnly: true });+ } catch {+ return false;+ }+ try {+ const row = database+ .prepare(+ `SELECT COUNT(*) AS count FROM sqlite_master WHERE type = 'table' AND name IN (${SEEDED_PROJECTION_TABLES.map(() => "?").join(", ")})`,+ )+ .get(...SEEDED_PROJECTION_TABLES) as { count: number };+ return row.count === SEEDED_PROJECTION_TABLES.length;+ } catch {+ return false;+ } finally {+ database.close();+ }+}++async function waitForSeedableSchema(dbPath: string, timeoutMs = 60_000): Promise<void> {+ const deadline = Date.now() + timeoutMs;+ while (Date.now() < deadline) {+ if (hasSeedableSchema(dbPath)) return;+ await new Promise((resolve) => setTimeout(resolve, 250));+ }+ throw new Error(`The environment server did not migrate ${dbPath} within ${timeoutMs}ms.`);+}+function seedDatabase(dbPath: string,workspaceRoots: ReadonlyMap<string, string>,@@ -401,17 +443,7 @@ function seedDatabase(const database = new NodeSqlite.DatabaseSync(dbPath, { timeout: 30_000 });try {database.exec("BEGIN IMMEDIATE");- for (const table of [- "projection_pending_approvals",- "projection_thread_proposed_plans",- "projection_thread_activities",- "projection_thread_messages",- "projection_thread_sessions",- "projection_turns",- "projection_threads",- "projection_projects",- "projection_state",- ]) {+ for (const table of SEEDED_PROJECTION_TABLES) {database.exec(`DELETE FROM ${table}`);}const insertProject = database.prepare(@@ -594,6 +626,9 @@ export async function seedShowcaseEnvironment(input: {});}),);+ // The environment server begins listening before it finishes migrating the+ // database, so wait for the schema before deleting from and reseeding it.+ await waitForSeedableSchema(dbPath);seedDatabase(dbPath, workspaceRoots, projects, threads, now);const terminalDirectory = NodePath.join(input.baseDir, "userdata", "logs", "terminals");diff --git a/scripts/mobile-showcase.ts b/scripts/mobile-showcase.tsindex 35d6ffd52..56bb37cc0 100644--- a/scripts/mobile-showcase.ts+++ b/scripts/mobile-showcase.ts@@ -500,6 +500,23 @@ async function waitForPort(port: number, label = "Process", timeoutMs = 60_000):throw new Error(`${label} did not begin listening on port ${port} within ${timeoutMs}ms.`);}+async function waitForFileContent(+ filePath: string,+ label: string,+ timeoutMs = 60_000,+): Promise<string> {+ const deadline = Date.now() + timeoutMs;+ while (Date.now() < deadline) {+ const content = await NodeFSP.readFile(filePath, "utf8").then(+ (value) => value.trim(),+ () => "",+ );+ if (content) return content;+ await delay(250);+ }+ throw new Error(`${label} was not written to ${filePath} within ${timeoutMs}ms.`);+}+async function reserveAvailablePort(): Promise<number> {return await new Promise<number>((resolve, reject) => {const server = NodeNet.createServer();@@ -1225,12 +1242,12 @@ async function main(): Promise<void> {showcaseServers.push(server);await waitForPort(port, `${environment.label} server`);await seedShowcaseEnvironment({ baseDir, projectIds: environment.projectIds });- const environmentId = (- await NodeFSP.readFile(NodePath.join(baseDir, "userdata", "environment-id"), "utf8")- ).trim();- if (!environmentId) {- throw new Error(`${environment.label} did not persist an environment id.`);- }+ // The server begins listening before the ServerEnvironment layer+ // persists the environment id, so poll rather than read once.+ const environmentId = await waitForFileContent(+ NodePath.join(baseDir, "userdata", "environment-id"),+ `${environment.label} environment id`,+ );showcaseEnvironments.push({ baseDir, environmentId, label: environment.label, port });}