refactor(ui): reuse Control UI bootstrap path constant

This commit is contained in:
Peter Steinberger
2026-02-16 03:35:31 +01:00
parent 8985f23de7
commit abd26b6e54
2 changed files with 9 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
/* @vitest-environment jsdom */
import { describe, expect, it, vi } from "vitest";
import { CONTROL_UI_BOOTSTRAP_CONFIG_PATH } from "../../../../src/gateway/control-ui-contract.js";
import { loadControlUiBootstrapConfig } from "./control-ui-bootstrap.ts";
describe("loadControlUiBootstrapConfig", () => {
@@ -26,7 +27,7 @@ describe("loadControlUiBootstrapConfig", () => {
await loadControlUiBootstrapConfig(state);
expect(fetchMock).toHaveBeenCalledWith(
"/openclaw/__openclaw/control-ui-config.json",
`/openclaw${CONTROL_UI_BOOTSTRAP_CONFIG_PATH}`,
expect.objectContaining({ method: "GET" }),
);
expect(state.assistantName).toBe("Ops");
@@ -50,7 +51,7 @@ describe("loadControlUiBootstrapConfig", () => {
await loadControlUiBootstrapConfig(state);
expect(fetchMock).toHaveBeenCalledWith(
"/__openclaw/control-ui-config.json",
CONTROL_UI_BOOTSTRAP_CONFIG_PATH,
expect.objectContaining({ method: "GET" }),
);
expect(state.assistantName).toBe("Assistant");

View File

@@ -1,13 +1,10 @@
import {
CONTROL_UI_BOOTSTRAP_CONFIG_PATH,
type ControlUiBootstrapConfig,
} from "../../../../src/gateway/control-ui-contract.js";
import { normalizeAssistantIdentity } from "../assistant-identity.ts";
import { normalizeBasePath } from "../navigation.ts";
type ControlUiBootstrapConfig = {
basePath?: string;
assistantName?: string;
assistantAvatar?: string;
assistantAgentId?: string;
};
export type ControlUiBootstrapState = {
basePath: string;
assistantName: string;
@@ -25,8 +22,8 @@ export async function loadControlUiBootstrapConfig(state: ControlUiBootstrapStat
const basePath = normalizeBasePath(state.basePath ?? "");
const url = basePath
? `${basePath}/__openclaw/control-ui-config.json`
: "/__openclaw/control-ui-config.json";
? `${basePath}${CONTROL_UI_BOOTSTRAP_CONFIG_PATH}`
: CONTROL_UI_BOOTSTRAP_CONFIG_PATH;
try {
const res = await fetch(url, {