From d7d1270cedbdb8706953c175cc697efa84666683 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 21 Apr 2026 04:07:58 +0100 Subject: [PATCH] build: keep a2ui bundle stable --- scripts/bundle-a2ui.mjs | 6 +----- scripts/test-projects.test-support.mjs | 7 +++++++ src/canvas-host/a2ui/.bundle.hash | 2 +- test/scripts/bundle-a2ui.test.ts | 10 +++++----- test/scripts/changed-lanes.test.ts | 11 +++++++++++ 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/scripts/bundle-a2ui.mjs b/scripts/bundle-a2ui.mjs index ffc9757cbec..4eb847194d9 100644 --- a/scripts/bundle-a2ui.mjs +++ b/scripts/bundle-a2ui.mjs @@ -12,10 +12,8 @@ const hashFile = path.join(rootDir, "src", "canvas-host", "a2ui", ".bundle.hash" const outputFile = path.join(rootDir, "src", "canvas-host", "a2ui", "a2ui.bundle.js"); const a2uiRendererDir = path.join(rootDir, "vendor", "a2ui", "renderers", "lit"); const a2uiAppDir = path.join(rootDir, "apps", "shared", "OpenClawKit", "Tools", "CanvasA2UI"); -const rootPackageFile = path.join(rootDir, "package.json"); -const pnpmLockFile = path.join(rootDir, "pnpm-lock.yaml"); const uiPackageFile = path.join(rootDir, "ui", "package.json"); -const repoInputPaths = [rootPackageFile, pnpmLockFile, uiPackageFile, a2uiRendererDir, a2uiAppDir]; +const repoInputPaths = [uiPackageFile, a2uiRendererDir, a2uiAppDir]; const ignoredBundleHashInputPrefixes = ["vendor/a2ui/renderers/lit/dist"]; const relativeRepoInputPaths = repoInputPaths.map((inputPath) => normalizePath(path.relative(rootDir, inputPath)), @@ -67,8 +65,6 @@ export function getLocalRolldownCliCandidates(repoRoot = rootDir) { export function getBundleHashRepoInputPaths(repoRoot = rootDir) { return [ - path.join(repoRoot, "package.json"), - path.join(repoRoot, "pnpm-lock.yaml"), path.join(repoRoot, "ui", "package.json"), path.join(repoRoot, "vendor", "a2ui", "renderers", "lit"), path.join(repoRoot, "apps", "shared", "OpenClawKit", "Tools", "CanvasA2UI"), diff --git a/scripts/test-projects.test-support.mjs b/scripts/test-projects.test-support.mjs index 28305525028..8bd67948856 100644 --- a/scripts/test-projects.test-support.mjs +++ b/scripts/test-projects.test-support.mjs @@ -201,6 +201,10 @@ const TOOLING_TEST_TARGETS = new Map([ ["test/scripts/vitest-local-scheduling.test.ts"], ], ]); +const GENERATED_CHANGED_TEST_TARGETS = new Set([ + "src/canvas-host/a2ui/.bundle.hash", + "src/canvas-host/a2ui/a2ui.bundle.js", +]); const VITEST_CONFIG_TARGET_KIND_BY_PATH = new Map( Object.entries(VITEST_CONFIG_BY_KIND).map(([kind, config]) => [config, kind]), ); @@ -404,6 +408,9 @@ function resolveToolingChangedTestTargets(changedPaths) { } function isRoutableChangedTarget(changedPath) { + if (GENERATED_CHANGED_TEST_TARGETS.has(changedPath)) { + return false; + } return /^(?:src|test|extensions|ui|packages)(?:\/|$)/u.test(changedPath); } diff --git a/src/canvas-host/a2ui/.bundle.hash b/src/canvas-host/a2ui/.bundle.hash index 8cda681955a..ebd4cbde0ab 100644 --- a/src/canvas-host/a2ui/.bundle.hash +++ b/src/canvas-host/a2ui/.bundle.hash @@ -1 +1 @@ -445aaac0723949e8cee66e9bfa82ba789531c2cf3990e74a240939bc49e5933f +e597313a5df1b115ee4f2883b9cd96d3aefe13ebedfb052bef51f6e31bd4b3cd diff --git a/test/scripts/bundle-a2ui.test.ts b/test/scripts/bundle-a2ui.test.ts index cd64197de87..7cf75b19a5b 100644 --- a/test/scripts/bundle-a2ui.test.ts +++ b/test/scripts/bundle-a2ui.test.ts @@ -51,21 +51,21 @@ describe("scripts/bundle-a2ui.mjs", () => { ]); }); - it("tracks repo dependency manifests through lockfile inputs", () => { + it("keeps unrelated repo dependency churn out of bundle hash inputs", () => { const repoRoot = path.resolve("repo-root"); const inputPaths = getBundleHashRepoInputPaths(repoRoot); - expect(inputPaths).toContain(path.join(repoRoot, "package.json")); - expect(inputPaths).toContain(path.join(repoRoot, "pnpm-lock.yaml")); expect(inputPaths).toContain(path.join(repoRoot, "ui", "package.json")); + expect(inputPaths).not.toContain(path.join(repoRoot, "package.json")); + expect(inputPaths).not.toContain(path.join(repoRoot, "pnpm-lock.yaml")); }); it("keeps local node_modules state out of bundle hash inputs", () => { const repoRoot = process.cwd(); const inputPaths = getBundleHashInputPaths(repoRoot); - expect(inputPaths).toContain(path.join(repoRoot, "package.json")); - expect(inputPaths).toContain(path.join(repoRoot, "pnpm-lock.yaml")); + expect(inputPaths).not.toContain(path.join(repoRoot, "package.json")); + expect(inputPaths).not.toContain(path.join(repoRoot, "pnpm-lock.yaml")); expect(inputPaths).not.toContain(path.join(repoRoot, "node_modules", "lit", "package.json")); expect(inputPaths).not.toContain( path.join(repoRoot, "ui", "node_modules", "lit", "package.json"), diff --git a/test/scripts/changed-lanes.test.ts b/test/scripts/changed-lanes.test.ts index 997c0a2a38e..45b15434188 100644 --- a/test/scripts/changed-lanes.test.ts +++ b/test/scripts/changed-lanes.test.ts @@ -190,6 +190,17 @@ describe("scripts/changed-lanes", () => { expect(plan.runFullTests).toBe(false); }); + it("does not route generated A2UI artifacts as direct Vitest targets", () => { + const result = detectChangedLanes([ + "src/canvas-host/a2ui/.bundle.hash", + "test/scripts/bundle-a2ui.test.ts", + ]); + const plan = createChangedCheckPlan(result); + + expect(plan.testTargets).toEqual(["test/scripts/bundle-a2ui.test.ts"]); + expect(plan.runChangedTestsBroad).toBe(false); + }); + it("routes changed extension Vitest configs to only their owning shard", () => { const result = detectChangedLanes(["test/vitest/vitest.extension-discord.config.ts"]); const plan = createChangedCheckPlan(result);