Skip to content

Commit 6704d0a

Browse files
1052326311steipete
andauthored
fix(scripts): include ui:build in build-all full and ciArtifacts profiles (#86010)
* fix(scripts): include ui:build in build-all full and ciArtifacts profiles Closes #85206. scripts/build-all.mjs only ran ui:build via a separate `pnpm ui:build` command. Because `pnpm build` invokes tsdown which removes `dist/`, a backend rebuild silently deletes any previously generated dist/control-ui assets, leaving the gateway to serve the "Control UI assets not found" message at startup. Documentation and startup auto-repair masked the bug at the worst possible time (LaunchAgent readiness / remote recovery) instead of guaranteeing the build artifact contract. This change adds ui:build as a build-all step after copy-export-html-templates and before write-build-info, and includes it in the full and ciArtifacts profiles. Minimal backend dev profiles (gatewayWatch, cliStartup) keep their existing fast-loop step lists and do not run ui:build. Regression coverage: - ciArtifacts step list assertion updated to match the new ordering. - Three new resolveBuildAllSteps assertions: ui:build is in full and ciArtifacts and runs after tsdown/runtime-postbuild-stamp and before write-build-info; ui:build is excluded from gatewayWatch/cliStartup; ui:build cache outputs declare dist/control-ui. * fix(scripts): leave ui:build uncached so dist/control-ui never restores stale build IDs ClawSweeper review on #86010 flagged that the original ui:build cache only hashed ui/, scripts/ui.js, and scripts/lib/copy-assets.ts, but ui/vite.config.ts also reads package.json plus git HEAD and the OPENCLAW_CONTROL_UI_BUILD_ID/OPENCLAW_VERSION env vars to embed a build ID into the app and service worker. A file-input cache signature cannot exactly invalidate those metadata sources, so a warm build-all hit could restore a previously generated dist/control-ui after tsdown clears dist and ship stale service-worker/app cache metadata. Leaving the step uncached keeps the contract simple: every pnpm build re-runs Vite, which is fast for the Control UI bundle and matches the existing behavior of every other un-cached build-all step. Backend-only profiles (gatewayWatch, cliStartup) are still unchanged. Tests: - Updated the ui:build cache assertion to require step.cache to be undefined and explain the metadata-input reason. - Existing presence/order/exclusion assertions for ui:build are unchanged and still cover the full and ciArtifacts profile contract. * fix(scripts): keep ui build fallback pnpm-free --------- Co-authored-by: 1052326311 <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
1 parent 73189e3 commit 6704d0a

5 files changed

Lines changed: 76 additions & 21 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Docs: https://docs.openclaw.ai
77
### Changes
88

99
- Control UI: add an ephemeral Activity tab for sanitized live tool activity summaries without persisting raw telemetry. Fixes #12831. Thanks @BunsDev.
10-
10+
- Build: include `ui:build` in the `full` and `ciArtifacts` profiles of `scripts/build-all.mjs` so `pnpm build` always rebuilds `dist/control-ui` after `tsdown` cleans `dist`, removing the second-command requirement and the missing-asset failure mode for source/runtime installs and CI artifact uploads. (#85206)
1111
### Fixes
1212

1313
- WebChat: keep message-tool replies visible in the chat while still summarizing internal tool results for the model. Fixes #86347. Thanks @shakkernerd.
@@ -76,7 +76,6 @@ Docs: https://docs.openclaw.ai
7676
- Tests: fail Docker resource-ceiling checks when stats samples or configured limits are invalid instead of silently reporting zero peaks.
7777
- Agents: fail closed when provider-less session models match multiple provider-prefixed runtime policies so CLI runtime routing no longer depends on config order. (#85970) Thanks @potterdigital.
7878
- Control UI/agents: keep collapsed tool rows readable without early ellipses, preserve raw expanded tool details, and make post-compaction AGENTS.md reinjection opt-in to avoid duplicated project context. Fixes #45649 and #45488. Thanks @BunsDev.
79-
8079
## 2026.5.24
8180

8281
### Changes

‎scripts/build-all.mjs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const PNPM_STEP_NODE_FALLBACKS = new Map([
1717
["scripts/run-tsgo.mjs", "-p", "tsconfig.plugin-sdk.dts.json", "--declaration", "true"],
1818
],
1919
["plugins:assets:copy", ["scripts/bundled-plugin-assets.mjs", "--phase", "copy"]],
20+
["ui:build", ["scripts/ui.js", "build"]],
2021
]);
2122
export const BUILD_ALL_STEPS = [
2223
{ label: "plugins:assets:build", kind: "pnpm", pnpmArgs: ["plugins:assets:build"] },
@@ -84,6 +85,16 @@ export const BUILD_ALL_STEPS = [
8485
outputs: ["dist/export-html"],
8586
},
8687
},
88+
{
89+
label: "ui:build",
90+
kind: "pnpm",
91+
pnpmArgs: ["ui:build"],
92+
// No build-all cache: ui/vite.config.ts derives the Control UI build ID
93+
// from package.json, git HEAD, and OPENCLAW_CONTROL_UI_BUILD_ID env, so a
94+
// file-input signature cannot exactly invalidate generated assets and a
95+
// warm hit could restore stale service-worker/app cache metadata.
96+
cache: undefined,
97+
},
8798
{
8899
label: "write-build-info",
89100
kind: "node",
@@ -116,6 +127,7 @@ export const BUILD_ALL_PROFILES = {
116127
"plugins:assets:copy",
117128
"copy-hook-metadata",
118129
"copy-export-html-templates",
130+
"ui:build",
119131
"write-build-info",
120132
"write-cli-startup-metadata",
121133
"write-cli-compat",

‎scripts/ui.js‎

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -168,42 +168,34 @@ export function main(argv = process.argv.slice(2)) {
168168
process.exit(2);
169169
}
170170

171-
const runner = resolveRunner();
172-
if (!runner) {
173-
process.stderr.write("Missing UI runner: install pnpm, then retry.\n");
174-
process.exit(1);
175-
}
176-
177171
const script = resolveScriptAction(action);
178172
if (action !== "install" && !script) {
179173
usage();
180174
process.exit(2);
181175
}
182176

177+
if (process.env.OPENCLAW_BUILD_ALL_NO_PNPM === "1" && action === "build") {
178+
run(process.execPath, [path.join(repoRoot, "node_modules/vite/bin/vite.js"), "build", ...rest]);
179+
return;
180+
}
181+
182+
const runner = resolveRunner();
183+
if (!runner) {
184+
process.stderr.write("Missing UI runner: install pnpm, then retry.\n");
185+
process.exit(1);
186+
}
187+
183188
if (action === "install") {
184189
run(runner.cmd, ["install", ...rest]);
185190
return;
186191
}
187192

188193
if (!depsInstalled(action === "test" ? "test" : "build")) {
189-
if (process.env.OPENCLAW_BUILD_ALL_NO_PNPM === "1" && action === "build") {
190-
run(process.execPath, [
191-
path.join(repoRoot, "node_modules/vite/bin/vite.js"),
192-
"build",
193-
...rest,
194-
]);
195-
return;
196-
}
197194
const installEnv = process.env;
198195
const installArgs = ["install"];
199196
runSync(runner.cmd, installArgs, installEnv);
200197
}
201198

202-
if (process.env.OPENCLAW_BUILD_ALL_NO_PNPM === "1" && action === "build") {
203-
run(process.execPath, [path.join(repoRoot, "node_modules/vite/bin/vite.js"), "build", ...rest]);
204-
return;
205-
}
206-
207199
run(runner.cmd, ["run", script, ...rest]);
208200
}
209201

‎test/scripts/build-all.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ describe("resolveBuildAllSteps", () => {
171171
"plugins:assets:copy",
172172
"copy-hook-metadata",
173173
"copy-export-html-templates",
174+
"ui:build",
174175
"write-build-info",
175176
"write-cli-startup-metadata",
176177
"write-cli-compat",
@@ -209,6 +210,39 @@ describe("resolveBuildAllSteps", () => {
209210
);
210211
});
211212

213+
it("includes ui:build in the full and ciArtifacts profiles after runtime postbuild", () => {
214+
for (const profile of ["full", "ciArtifacts"]) {
215+
const labels = resolveBuildAllSteps(profile).map((step) => step.label);
216+
expect(labels).toContain("ui:build");
217+
// Control UI bundling must run after tsdown clears dist so that
218+
// dist/control-ui survives `pnpm build` without a second command.
219+
expect(labels.indexOf("ui:build")).toBeGreaterThan(labels.indexOf("tsdown"));
220+
expect(labels.indexOf("ui:build")).toBeGreaterThan(labels.indexOf("runtime-postbuild-stamp"));
221+
// ui:build must run before write-build-info so the build manifest can
222+
// see the final dist/control-ui assets.
223+
expect(labels.indexOf("ui:build")).toBeLessThan(labels.indexOf("write-build-info"));
224+
}
225+
});
226+
227+
it("keeps ui:build out of minimal backend-only profiles", () => {
228+
for (const profile of ["gatewayWatch", "cliStartup"]) {
229+
const labels = resolveBuildAllSteps(profile).map((step) => step.label);
230+
expect(labels).not.toContain("ui:build");
231+
}
232+
});
233+
234+
it("does not cache ui:build because Vite reads package.json, git HEAD, and env metadata", () => {
235+
// ui/vite.config.ts derives the Control UI build ID from package.json,
236+
// git HEAD, and OPENCLAW_CONTROL_UI_BUILD_ID env, so a file-input
237+
// signature cannot exactly invalidate generated assets. Leaving this
238+
// step uncached avoids restoring stale service-worker/app cache
239+
// metadata after `tsdown` clears `dist`.
240+
const step = getBuildAllStep("ui:build");
241+
expect(step.kind).toBe("pnpm");
242+
expect(step.pnpmArgs).toEqual(["ui:build"]);
243+
expect(step.cache).toBeUndefined();
244+
});
245+
212246
it("does not cache plugin-sdk entry shims over compiled JS", () => {
213247
const step = getBuildAllStep("write-plugin-sdk-entry-dts");
214248
expect(step.cache).toBeUndefined();

‎test/scripts/ui.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { spawnSync } from "node:child_process";
12
import path from "node:path";
23
import { describe, expect, it } from "vitest";
34
import {
@@ -101,4 +102,21 @@ describe("scripts/ui windows spawn behavior", () => {
101102

102103
expect(isDirectScriptExecution(junctionScriptPath, realScriptPath, realpath)).toBe(true);
103104
});
105+
106+
it("honors build-all no-pnpm mode before requiring a pnpm runner", () => {
107+
const result = spawnSync(process.execPath, ["scripts/ui.js", "build", "--help"], {
108+
cwd: path.resolve("."),
109+
encoding: "utf8",
110+
env: {
111+
...process.env,
112+
OPENCLAW_BUILD_ALL_NO_PNPM: "1",
113+
PATH: "",
114+
},
115+
});
116+
117+
const output = `${result.stdout}${result.stderr}`;
118+
expect(result.status).toBe(0);
119+
expect(output).not.toContain("Missing UI runner");
120+
expect(output).toContain("vite");
121+
});
104122
});

0 commit comments

Comments
 (0)