Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(release): preserve warm Windows frontend dependencies

Ezra Ellette5f1a11b62a87
diff --git a/.github/actions/install-windows-frontend-dependencies/action.yml b/.github/actions/install-windows-frontend-dependencies/action.yml
index 2712e5b63..cbd1ac0ed 100644
--- a/.github/actions/install-windows-frontend-dependencies/action.yml
+++ b/.github/actions/install-windows-frontend-dependencies/action.yml
@@ -25,22 +25,26 @@ runs:
Remove-Item -LiteralPath $destination -Recurse -Force
}
}
- # Bun's frozen install can retain packages removed from the lockfile.
- # Tauri scans installed plugins, so an orphan can fail its version gate.
- # Rebuild the installed tree; the persistent Bun download cache remains.
- $modules = Join-Path (Get-Location) 'node_modules'
- if (Test-Path -LiteralPath $modules) {
- Remove-Item -LiteralPath $modules -Recurse -Force
- }
$staged = Join-Path (Get-Location) '.release-workflows-ui'
+ if (Test-Path -LiteralPath $staged) {
+ Remove-Item -LiteralPath $staged -Recurse -Force
+ }
New-Item -ItemType Directory -Force -Path $staged | Out-Null
Copy-Item -LiteralPath "$source/package.json" -Destination $staged -Force
Copy-Item -LiteralPath "$source/src" -Destination $staged -Recurse -Force
foreach ($file in @('package.json', 'bun.lock')) {
$path = Join-Path (Get-Location) $file
$text = [IO.File]::ReadAllText($path)
- if (-not $text.Contains('file:../../packages/workflows-ui')) { throw "local dependency missing from $file" }
+ if (-not ($text.Contains('file:../../packages/workflows-ui') -or $text.Contains('file:./.release-workflows-ui'))) {
+ throw "local dependency missing from $file"
+ }
[IO.File]::WriteAllText($path, $text.Replace('file:../../packages/workflows-ui', 'file:./.release-workflows-ui'))
}
+ # Bun retains removed packages, which Tauri can mistake for live plugins.
+ # Prune only those packages; keep the rest of the installed tree warm.
+ bun "${{ github.action_path }}/prune-dependencies.ts"
+ if ($LASTEXITCODE -ne 0) { throw 'frontend dependency pruning failed' }
+ $installTimer = [Diagnostics.Stopwatch]::StartNew()
bun install --frozen-lockfile --backend=copyfile
if ($LASTEXITCODE -ne 0) { throw 'frontend dependency installation failed' }
+ Write-Host ("Frontend install completed in {0:N3}s" -f $installTimer.Elapsed.TotalSeconds)
diff --git a/.github/actions/install-windows-frontend-dependencies/prune-dependencies.test.ts b/.github/actions/install-windows-frontend-dependencies/prune-dependencies.test.ts
new file mode 100644
index 000000000..9366391ad
--- /dev/null
+++ b/.github/actions/install-windows-frontend-dependencies/prune-dependencies.test.ts
@@ -0,0 +1,62 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+
+import { afterEach, expect, test } from "bun:test";
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { pruneDependencies } from "./prune-dependencies";
+
+const roots: string[] = [];
+afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
+function fixture(packages: string[]) {
+ const root = mkdtempSync(join(tmpdir(), "release-dependencies-")); roots.push(root);
+ const lock = (names: string[]) => writeFileSync(join(root, "bun.lock"), JSON.stringify({ lockfileVersion: 1, packages: Object.fromEntries(names.map(name => [name, []])) }));
+ lock(packages);
+ const file = (path: string, content = "untouched") => {
+ const full = join(root, path); mkdirSync(join(full, ".."), { recursive: true }); writeFileSync(full, content); return full;
+ };
+ return { root, lock, file };
+}
+
+test("removes the orphan Tauri updater while retaining warm packages and Bun metadata", () => {
+ const f = fixture(["@tauri-apps/cli", "react"]);
+ const retained = f.file("node_modules/@tauri-apps/cli/warm-marker");
+ f.file("node_modules/@tauri-apps/plugin-updater/package.json", '{"version":"2.10.0"}');
+ const metadata = f.file("node_modules/.bun/install-cache");
+ expect(pruneDependencies(f.root)).toEqual(["@tauri-apps/plugin-updater"]);
+ expect(readFileSync(retained, "utf8")).toBe("untouched");
+ expect(existsSync(metadata)).toBe(true);
+ expect(pruneDependencies(f.root)).toEqual([]);
+});
+
+test("a changed lockfile prunes removed scoped and nested packages without rebuilding retained ones", () => {
+ const f = fixture(["parent", "parent/@scope/child", "@scope/parent", "@scope/parent/child", "@scope/parent/@scope/child"]);
+ const retained = f.file("node_modules/@scope/parent/node_modules/@scope/child/warm-marker");
+ const nested = f.file("node_modules/parent/node_modules/@scope/child/package.json");
+ const scoped = f.file("node_modules/@scope/parent/node_modules/child/package.json");
+ expect(pruneDependencies(f.root)).toEqual([]);
+ f.lock(["parent", "@scope/parent", "@scope/parent/@scope/child"]);
+ expect(pruneDependencies(f.root).sort()).toEqual(["@scope/parent/node_modules/child", "parent/node_modules/@scope/child"]);
+ expect(existsSync(nested)).toBe(false); expect(existsSync(scoped)).toBe(false);
+ expect(readFileSync(retained, "utf8")).toBe("untouched");
+});
+
+test("invalid or unsupported locks fail before deleting any installed package", () => {
+ const f = fixture(["react", "../outside"]);
+ const orphan = f.file("node_modules/orphan/package.json");
+ expect(() => pruneDependencies(f.root)).toThrow("Invalid Bun package key");
+ expect(existsSync(orphan)).toBe(true);
+ writeFileSync(join(f.root, "bun.lock"), '{"lockfileVersion":2,"packages":{"react":[]}}');
+ expect(() => pruneDependencies(f.root)).toThrow("Unsupported Bun lockfile");
+ expect(existsSync(orphan)).toBe(true);
+});
+
+test("removing an orphan junction does not delete its external target", () => {
+ const f = fixture(["react"]);
+ const external = f.file("external/package.json");
+ mkdirSync(join(f.root, "node_modules"));
+ symlinkSync(join(f.root, "external"), join(f.root, "node_modules/orphan"), process.platform === "win32" ? "junction" : "dir");
+ expect(pruneDependencies(f.root)).toEqual(["orphan"]);
+ expect(readFileSync(external, "utf8")).toBe("untouched");
+});
diff --git a/.github/actions/install-windows-frontend-dependencies/prune-dependencies.ts b/.github/actions/install-windows-frontend-dependencies/prune-dependencies.ts
new file mode 100644
index 000000000..1f7a70c53
--- /dev/null
+++ b/.github/actions/install-windows-frontend-dependencies/prune-dependencies.ts
@@ -0,0 +1,55 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+
+import { existsSync, lstatSync, readdirSync, readFileSync, rmSync } from "node:fs";
+import { join } from "node:path";
+
+// Bun's hoisted lockfile keys encode nested packages as parent/child, including
+// scoped names. Build the whole allowlist before deleting anything.
+export function pruneDependencies(appDirectory: string): string[] {
+ const lock = Bun.JSONC.parse(readFileSync(join(appDirectory, "bun.lock"), "utf8"));
+ if (lock?.lockfileVersion !== 1 || !lock.packages || typeof lock.packages !== "object" || Array.isArray(lock.packages)) {
+ throw new Error("Unsupported Bun lockfile; refusing to prune installed dependencies");
+ }
+ const expected = new Set<string>();
+ for (const key of Object.keys(lock.packages)) {
+ const names = key.match(/(?:@[^/]+\/)?[^/]+/g) ?? [];
+ if (!names.length || names.join("/") !== key || names.some(name => name.split("/").some(part => !part || part === "." || part === ".." || part.includes("\\") || part.includes(":")))) {
+ throw new Error(`Invalid Bun package key: ${key}`);
+ }
+ expected.add(names.join("/node_modules/"));
+ }
+ if (!expected.size) throw new Error("Empty Bun package list; refusing to prune installed dependencies");
+
+ const removed: string[] = [];
+ const visit = (modules: string, prefix = "") => {
+ if (!existsSync(modules)) return;
+ // Never follow a package's junction into an external dependency tree.
+ if (lstatSync(modules).isSymbolicLink()) throw new Error(`Refusing linked node_modules: ${modules}`);
+ const inspect = (name: string) => {
+ const path = join(modules, name);
+ const key = prefix + name;
+ if (!expected.has(key)) {
+ rmSync(path, { recursive: true, force: true });
+ removed.push(key);
+ } else if (!lstatSync(path).isSymbolicLink()) {
+ visit(join(path, "node_modules"), `${key}/node_modules/`);
+ }
+ };
+ for (const entry of readdirSync(modules, { withFileTypes: true })) {
+ if (entry.name.startsWith(".")) continue; // Bun metadata and executable shims.
+ if (entry.name.startsWith("@") && entry.isDirectory()) {
+ for (const child of readdirSync(join(modules, entry.name))) inspect(`${entry.name}/${child}`);
+ } else if (entry.isDirectory() || entry.isSymbolicLink()) {
+ inspect(entry.name);
+ }
+ }
+ };
+ visit(join(appDirectory, "node_modules"));
+ return removed;
+}
+
+if (import.meta.main) {
+ const removed = pruneDependencies(process.cwd());
+ console.log(`Pruned ${removed.length} obsolete installed package(s): ${removed.join(", ") || "none"}`);
+}
diff --git a/.github/workflows/test-release-workflows.yml b/.github/workflows/test-release-workflows.yml
index 6a2c6f024..fa7e62c38 100644
--- a/.github/workflows/test-release-workflows.yml
+++ b/.github/workflows/test-release-workflows.yml
@@ -63,7 +63,7 @@ jobs:
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.10"
- - run: bun test ./.github/scripts/release-workflows.test.ts ./.github/scripts/release-performance.test.ts
+ - run: bun test ./.github/scripts/release-workflows.test.ts ./.github/scripts/release-performance.test.ts ./.github/actions/install-windows-frontend-dependencies/prune-dependencies.test.ts
localization-generation:
if: github.event_name == 'workflow_dispatch'
@@ -161,12 +161,14 @@ jobs:
matrix:
os: [windows-latest, windows-11-arm]
runs-on: ${{ matrix.os }}
- timeout-minutes: 15
+ timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.10"
+ - name: Verify selective pruning on Windows
+ run: bun test ./.github/actions/install-windows-frontend-dependencies/prune-dependencies.test.ts
- name: Reproduce the persistent runner's removed updater package
shell: pwsh
working-directory: apps/screenpipe-app-tauri
@@ -174,7 +176,8 @@ jobs:
$orphan = 'node_modules/@tauri-apps/plugin-updater'
New-Item -ItemType Directory -Force -Path $orphan | Out-Null
Set-Content -LiteralPath "$orphan/package.json" -Value '{"name":"@tauri-apps/plugin-updater","version":"2.10.0"}'
- - uses: ./.github/actions/install-windows-frontend-dependencies
+ - name: Install dependencies from an empty tree
+ uses: ./.github/actions/install-windows-frontend-dependencies
- name: Verify the installed tree matches the release dependencies
shell: pwsh
working-directory: apps/screenpipe-app-tauri
@@ -198,3 +201,37 @@ jobs:
throw "local dependency differs from release source: $relative"
}
}
+ - name: Prepare a warm install with a removed package and changed local source
+ shell: pwsh
+ working-directory: apps/screenpipe-app-tauri
+ run: |
+ $orphan = 'node_modules/@tauri-apps/plugin-updater'
+ New-Item -ItemType Directory -Force -Path $orphan | Out-Null
+ Set-Content -LiteralPath "$orphan/package.json" -Value '{"name":"@tauri-apps/plugin-updater","version":"2.10.0"}'
+ Set-Content -LiteralPath 'node_modules/@tauri-apps/cli/warm-install-marker' -Value 'retain installed dependencies'
+ Set-Content -LiteralPath '.release-workflows-ui/src/removed-release-probe.txt' -Value 'must disappear'
+ Set-Content -LiteralPath 'node_modules/@screenpipe/workflows-ui/src/removed-release-probe.txt' -Value 'must disappear'
+ Set-Content -LiteralPath '../../packages/workflows-ui/src/current-release-probe.txt' -Value 'current release source'
+ - name: Reuse warm dependencies
+ uses: ./.github/actions/install-windows-frontend-dependencies
+ - name: Verify warm reuse and refreshed local source
+ shell: pwsh
+ working-directory: apps/screenpipe-app-tauri
+ run: |
+ $ErrorActionPreference = 'Stop'
+ if (-not (Test-Path -LiteralPath 'node_modules/@tauri-apps/cli/warm-install-marker')) {
+ throw 'warm install rebuilt an unchanged dependency'
+ }
+ if (Test-Path -LiteralPath 'node_modules/@tauri-apps/plugin-updater') {
+ throw 'warm install retained the removed updater plugin'
+ }
+ foreach ($root in @('.release-workflows-ui/src', 'node_modules/@screenpipe/workflows-ui/src')) {
+ if (Test-Path -LiteralPath "$root/removed-release-probe.txt") { throw "stale local source survived: $root" }
+ $probe = Get-Item -LiteralPath "$root/current-release-probe.txt"
+ if ($probe.Attributes -band [IO.FileAttributes]::ReparsePoint) { throw 'local source uses a symlink' }
+ if ((Get-Content -Raw -LiteralPath $probe.FullName).Trim() -ne 'current release source') {
+ throw "local source was not refreshed: $root"
+ }
+ }
+ - name: Repeat the warm install
+ uses: ./.github/actions/install-windows-frontend-dependencies
diff --git a/infra/release-windows-runner/status.ps1 b/infra/release-windows-runner/status.ps1
index f0c8ebfe5..501064b90 100644
--- a/infra/release-windows-runner/status.ps1
+++ b/infra/release-windows-runner/status.ps1
@@ -11,6 +11,7 @@ $env:Path = "${env:ProgramFiles}\Git\cmd;${env:ProgramFiles}\Git\bin;${env:Progr
$env:CARGO_HOME = [Environment]::GetEnvironmentVariable('CARGO_HOME', 'Machine')
$env:RUSTUP_HOME = [Environment]::GetEnvironmentVariable('RUSTUP_HOME', 'Machine')
$service = Get-Service 'actions.runner.*' -ErrorAction SilentlyContinue | Select-Object -First 1
+$runnerConfig = Get-Content 'C:\actions-runner\.runner' -Raw | ConvertFrom-Json
$disk = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='S:'"
$vswhere = 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe'
$vsComponent = if ($RunnerArchitecture -eq 'arm64') { 'Microsoft.VisualStudio.Component.VC.Tools.ARM64' } else { 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' }
@@ -38,6 +39,7 @@ $bootstrapTools = [ordered]@{
computer = $env:COMPUTERNAME
architecture = $RunnerArchitecture
service = if ($service) { $service.Status.ToString() } else { 'missing' }
+ workDirectory = $runnerConfig.workFolder
cacheFreeGiB = if ($disk) { [math]::Round($disk.FreeSpace / 1GB, 1) } else { 0 }
cacheUsedGiB = if ($disk) { [math]::Round(($disk.Size - $disk.FreeSpace) / 1GB, 1) } else { 0 }
allowedWorkflowRefs = [string[]] $allowedRefs