perf(desktop): speed up Windows update installation #6169
MergedStiensWout(GitHub profile, opens in a new tab)merged 14 commits into
main fromrefs/pull/6169/headmerged by shivamhwp(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- .github/workflows/windows-package-smoke.yml lines 5 to 13OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -0,0 +1,13 @@1+name: Windows Package Smoke2+3+on:4+ pull_request:5+ paths:6+ - ".github/workflows/windows-package-smoke.yml"7+ - "apps/desktop/package.json"8+ - "apps/server/package.json"9+ - "patches/**"10+ - "pnpm-lock.yaml"11+ - "pnpm-workspace.yaml"12+ - "scripts/build-desktop-artifact.ts"13+ - "scripts/package.json"
- scripts/build-desktop-artifact.ts line 698OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -632,3 +692,7 @@632692 // so the SDK's optional platform packages (each a ~200MB bundled executable)633693 // are dead weight. The trailing dash keeps the SDK's own JS package.634694 "!**/node_modules/@anthropic-ai/claude-agent-sdk-*/**/*",695+ // Windows stages the server sidecar below prod-resources so electron-builder696+ // can copy it using project-relative extraResources matchers. Keep those697+ // staging inputs out of app.asar; they are emitted once at resources/.698+ "!apps/desktop/prod-resources/windows-server{,/**/*}",
t3-code-bot[bot](GitHub profile, opens in a new tab) requested changes
apps/desktop/src/app/DesktopEnvironment.ts line 169Resolvedby StiensWout(GitHub profile, opens in a new tab)@@ -157,3 +164,6 @@157164 });158165 const rootDir = path.resolve(input.dirname, "../../..");159166 const appRoot = input.isPackaged ? input.appPath : rootDir;167+ const serverRoot =168+ input.isPackaged && input.platform === "win32"169+ ? path.join(input.resourcesPath, "server.asar")github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/desktop/src/wsl/DesktopWslServerTree.ts line 87OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -0,0 +67,21 @@67+): Effect.Effect<void, PlatformError.PlatformError> =>68+ Effect.gen(function* () {69+ yield* fs.makeDirectory(to, { recursive: true });70+ const entries = yield* fs.readDirectory(from);71+ yield* Effect.forEach(72+ entries,73+ (entry) =>74+ Effect.gen(function* () {75+ const sourcePath = join(from, entry);76+ const targetPath = join(to, entry);77+ const info = yield* fs.stat(sourcePath);78+ if (info.type === "Directory") {79+ yield* copyTree(fs, join, sourcePath, targetPath);80+ } else if (info.type === "File") {81+ const bytes = yield* fs.readFile(sourcePath);82+ yield* fs.writeFile(targetPath, bytes);83+ }84+ }),85+ // Bounded concurrency keeps the extraction fast on real disks without86+ // exhausting file descriptors on huge node_modules directories.87+ { concurrency: 8, discard: true },
- scripts/build-desktop-artifact.ts line 2500OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -2052,0 +2480,21 @@2480+ reason: "sidecar-invalid",2481+ packagedAppDir,2482+ cause,2483+ }),2484+ });2485+ if (unpackedFiles.length === 0) {2486+ return yield* new WindowsPackagedPayloadValidationError({2487+ reason: "sidecar-invalid",2488+ packagedAppDir,2489+ cause: new Error("server.asar does not declare any unpacked native files"),2490+ });2491+ }2492+2493+ const missingFiles: string[] = [];2494+ for (const unpackedFile of unpackedFiles) {2495+ const unpackedPath = path.join(2496+ resourcesDir,2497+ `${WINDOWS_SERVER_ASAR_RESOURCE}.unpacked`,2498+ ...unpackedFile.split("/"),2499+ );2500+ if (!(yield* fs.exists(unpackedPath).pipe(Effect.orElseSucceed(() => false)))) {patches/@ff-labs__fff-node@0.9.4.patch lines 20 to 20OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -11,10 +11,10 @@1111 import { fileURLToPath } from "node:url";1212 import { getLibFilename, getNpmPackageName } from "./platform.js";1313 /**14-14+1515 // Fallback: assume we're one level deep in src/1616 return dirname(currentDir);1717 }1818 +function resolveUnpackedAsarPath(binaryPath) {19-+ const asarSegment = `${sep}app.asar${sep}`;20-+ if (!binaryPath.includes(asarSegment)) {19++ const pathSegments = binaryPath.split(sep);20++ const asarIndex = pathSegments.findIndex((segment) => segment.endsWith(".asar"));
t3-code-bot[bot](GitHub profile, opens in a new tab) requested changes
scripts/build-desktop-artifact.ts line 2345Resolvedby StiensWout(GitHub profile, opens in a new tab)@@ -2052,0 +2323,21 @@2323+ const entryPath = path.join(directory, entry);2324+ const stat = yield* fs.stat(entryPath);2325+ if (stat.type === "Directory") {2326+ pendingDirectories.push(entryPath);2327+ } else if (stat.type === "File") {2328+ count += 1;2329+ }2330+ }2331+ }2332+2333+ return count;2334+});2335+2336+export const verifyWindowsPrimaryFffNativeLoad = Effect.fn(2337+ "desktopArtifact.verifyWindowsPrimaryFffNativeLoad",2338+)(function* (input: {2339+ readonly packagedAppDir: string;2340+ readonly asarPath: string;2341+ readonly verbose: boolean;2342+}) {2343+ const hostPlatform = yield* HostProcessPlatform;apps/desktop/src/wsl/DesktopWslServerTree.ts line 73OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -0,0 +53,21 @@53+ // server.asar on first use.54+ readonly ensure: Effect.Effect<WslServerTreeResult>;55+ }56+>()("@t3tools/desktop/wsl/DesktopWslServerTree") {}57+58+// Recursively copy a directory using only readDirectory/stat/readFile/59+// writeFile, which Electron's asar-patched fs supports for paths inside an60+// archive. Symlinks are not expected (the sidecar tree is installed with a61+// hoisted, physical layout precisely so this copy stays trivial); anything62+// that is neither a file nor a directory is skipped.63+const copyTree = (64+ fs: FileSystem.FileSystem,65+ join: (first: string, ...rest: string[]) => string,66+ from: string,67+ to: string,68+ ioSemaphore: Semaphore.Semaphore,69+): Effect.Effect<void, PlatformError.PlatformError> =>70+ Effect.gen(function* () {71+ yield* ioSemaphore.withPermit(fs.makeDirectory(to, { recursive: true }));72+ const entries = yield* ioSemaphore.withPermit(fs.readDirectory(from));73+ yield* Effect.forEach(- scripts/build-desktop-artifact.ts line 2351OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -2052,0 +2331,21 @@2331+ }2332+2333+ return count;2334+});2335+2336+export const verifyWindowsPrimaryFffNativeLoad = Effect.fn(2337+ "desktopArtifact.verifyWindowsPrimaryFffNativeLoad",2338+)(function* (input: {2339+ readonly packagedAppDir: string;2340+ readonly asarPath: string;2341+ readonly targetArch: typeof BuildArch.Type;2342+ readonly verbose: boolean;2343+}) {2344+ const hostPlatform = yield* HostProcessPlatform;2345+ const hostArchitecture = yield* HostProcessArchitecture;2346+ if (hostPlatform !== "win32" || hostArchitecture !== input.targetArch) return;2347+2348+ const fs = yield* FileSystem.FileSystem;2349+ const path = yield* Path.Path;2350+ let executablePath: string | undefined;2351+ for (const entry of (yield* fs.readDirectory(input.packagedAppDir)).sort()) {
t3-code-bot[bot](GitHub profile, opens in a new tab) requested changes
scripts/build-desktop-artifact.ts line 2347OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -2052,0 +2327,21 @@2327+ } else if (stat.type === "File") {2328+ count += 1;2329+ }2330+ }2331+ }2332+2333+ return count;2334+});2335+2336+export const verifyWindowsPrimaryFffNativeLoad = Effect.fn(2337+ "desktopArtifact.verifyWindowsPrimaryFffNativeLoad",2338+)(function* (input: {2339+ readonly packagedAppDir: string;2340+ readonly asarPath: string;2341+ readonly appExecutableName: string;2342+ readonly targetArch: typeof BuildArch.Type;2343+ readonly verbose: boolean;2344+}) {2345+ const hostPlatform = yield* HostProcessPlatform;2346+ const hostArchitecture = yield* HostProcessArchitecture;2347+ if (hostPlatform !== "win32" || hostArchitecture !== input.targetArch) return;t3-code-bot[bot](GitHub profile, opens in a new tab) approved these changes
shivamhwp(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
571fd5f2-ac02-447c-abd9-ca7ab067f5cbYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share