fix packaged control ui asset lookup (#53081)

This commit is contained in:
Val Alexander
2026-03-23 13:45:04 -05:00
committed by GitHub
parent 323ae73b30
commit 7a459045de
3 changed files with 23 additions and 1 deletions

View File

@@ -246,6 +246,17 @@ else
echo "WARN: model catalog missing at $MODEL_CATALOG_SRC (continuing)" >&2
fi
echo "📦 Copying Control UI assets"
CONTROL_UI_SRC="$ROOT_DIR/dist/control-ui"
CONTROL_UI_DEST="$APP_ROOT/Contents/Resources/control-ui"
if [ -d "$CONTROL_UI_SRC" ] && [ -f "$CONTROL_UI_SRC/index.html" ]; then
rm -rf "$CONTROL_UI_DEST"
cp -R "$CONTROL_UI_SRC" "$CONTROL_UI_DEST"
else
echo "ERROR: Control UI assets missing at $CONTROL_UI_SRC. Run pnpm ui:build first." >&2
exit 1
fi
echo "📦 Copying OpenClawKit resources"
OPENCLAWKIT_BUNDLE="$(build_path_for_arch "$PRIMARY_ARCH")/$BUILD_CONFIG/OpenClawKit_OpenClawKit.bundle"
if [ -d "$OPENCLAWKIT_BUNDLE" ]; then

View File

@@ -214,6 +214,16 @@ describe("control UI assets helpers (fs-mocked)", () => {
expect(resolveControlUiRootSync({ moduleUrl })).toBe(uiDir);
});
it("prefers packaged app Control UI assets in Contents/Resources", () => {
const execPath = abs("fixtures/OpenClaw.app/Contents/MacOS/OpenClaw");
const bundledUiDir = abs("fixtures/OpenClaw.app/Contents/Resources/control-ui");
setFile(path.join(bundledUiDir, "index.html"), "<html></html>\n");
state.realpaths.set(execPath, execPath);
expect(resolveControlUiRootSync({ execPath })).toBe(bundledUiDir);
});
it("resolves control-ui root for symlinked argv1 via realpath", () => {
const pkgRoot = abs("fixtures/bun-global/openclaw");
const wrapperArgv1 = abs("fixtures/bin/openclaw");

View File

@@ -215,7 +215,8 @@ export function resolveControlUiRootSync(opts: ControlUiRootResolveOptions = {})
cwd,
});
// Packaged app: control-ui lives alongside the executable.
// Packaged app: prefer bundled resources, then support legacy alongside-executable layout.
addCandidate(candidates, execDir ? path.join(execDir, "../Resources/control-ui") : null);
addCandidate(candidates, execDir ? path.join(execDir, "control-ui") : null);
if (moduleDir) {
// dist/<bundle>.js -> dist/control-ui