From ca93003572712853c7c8285f51f048802eb8d423 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 17 Feb 2026 04:47:28 +0000 Subject: [PATCH] Accept prebuilt desktop bundles in dev startup Co-authored-by: Julius Marminge --- apps/desktop/scripts/dev-electron.mjs | 79 +-------------------------- 1 file changed, 1 insertion(+), 78 deletions(-) diff --git a/apps/desktop/scripts/dev-electron.mjs b/apps/desktop/scripts/dev-electron.mjs index 00f22d7ca1..823201a12b 100644 --- a/apps/desktop/scripts/dev-electron.mjs +++ b/apps/desktop/scripts/dev-electron.mjs @@ -28,57 +28,6 @@ async function canConnect(host, probePort, timeoutMs = 1_000) { const f = (p) => path.join(import.meta.dirname, "..", p); -function collectFilesRecursively(rootDir) { - const files = []; - - const visit = (dir) => { - let entries = []; - try { - entries = fs.readdirSync(dir, { withFileTypes: true }); - } catch { - return; - } - - for (const entry of entries) { - const fullPath = path.join(dir, entry.name); - if (entry.isDirectory()) { - visit(fullPath); - continue; - } - if (entry.isFile()) { - files.push(fullPath); - } - } - }; - - visit(rootDir); - return files; -} - -function getDesktopBundleFreshnessFloor() { - const sourceFiles = [ - ...collectFilesRecursively(f("src")), - f("tsdown.config.ts"), - f("tsconfig.json"), - f("package.json"), - ]; - let newestMtimeMs = 0; - - for (const sourceFile of sourceFiles) { - try { - const stat = fs.statSync(sourceFile); - newestMtimeMs = Math.max(newestMtimeMs, stat.mtimeMs); - } catch { - // Best-effort: ignore transient or missing files in the readiness floor. - } - } - - return { - newestMtimeMs, - sourceFileCount: sourceFiles.length, - }; -} - function inspectBundleFile(bundleFile) { let stat = null; try { @@ -92,15 +41,6 @@ function inspectBundleFile(bundleFile) { }; } - if (bundleFile.freshnessFloorMs > 0 && stat.mtimeMs < bundleFile.freshnessFloorMs) { - return { - ...bundleFile, - status: "outdated", - mtimeMs: stat.mtimeMs, - reason: `mtime older than source floor by ${Math.round(bundleFile.freshnessFloorMs - stat.mtimeMs)}ms`, - }; - } - return { ...bundleFile, status: "ready", @@ -121,28 +61,18 @@ function describeBundleStates(states) { function waitForDesktopBundles(timeoutMs) { const startedAt = Date.now(); - const desktopFloor = getDesktopBundleFreshnessFloor(); - if (desktopFloor.newestMtimeMs > 0) { - console.log( - `[dev-electron] desktop bundle freshness floor=${new Date(desktopFloor.newestMtimeMs).toISOString()} from ${desktopFloor.sourceFileCount} source files`, - ); - } - const bundleFiles = [ { path: f("dist-electron/main.mjs"), label: "desktop/main.mjs", - freshnessFloorMs: desktopFloor.newestMtimeMs, }, { path: f("dist-electron/preload.cjs"), label: "desktop/preload.cjs", - freshnessFloorMs: desktopFloor.newestMtimeMs, }, { path: f("../server/dist/index.mjs"), label: "server/index.mjs", - freshnessFloorMs: 0, }, ]; let lastProgressLogAt = 0; @@ -151,9 +81,8 @@ function waitForDesktopBundles(timeoutMs) { const tick = () => { const states = bundleFiles.map(inspectBundleFile); const missing = states.filter((state) => state.status === "missing"); - const outdated = states.filter((state) => state.status === "outdated"); - if (missing.length === 0 && outdated.length === 0) { + if (missing.length === 0) { resolve(); return; } @@ -164,9 +93,6 @@ function waitForDesktopBundles(timeoutMs) { if (missing.length > 0) { parts.push(`missing: ${missing.map((state) => state.label).join(", ")}`); } - if (outdated.length > 0) { - parts.push(`outdated: ${outdated.map((state) => state.label).join(", ")}`); - } reject( new Error( `[dev-electron] timed out after ${timeoutMs}ms waiting for bundles (${parts.join("; ")})\n[dev-electron] bundle state: ${describeBundleStates(states)}`, @@ -181,9 +107,6 @@ function waitForDesktopBundles(timeoutMs) { if (missing.length > 0) { waitParts.push(`missing=${missing.map((state) => state.label).join(",")}`); } - if (outdated.length > 0) { - waitParts.push(`outdated=${outdated.map((state) => state.label).join(",")}`); - } console.log( `[dev-electron] still waiting for bundles after ${elapsedMs}ms (${waitParts.join("; ")})`, );