test(host): stamp desktop parity metadata

This commit is contained in:
rookiestar28
2026-05-31 07:22:45 +08:00
parent 92ba574b99
commit fd21de18db
4 changed files with 47 additions and 2 deletions
+2 -2
View File
@@ -45,8 +45,8 @@ If `assist_streaming` is unavailable or the stream transport degrades, Planner/R
## Host-Surface Contract
- OpenClaw treats standalone `ComfyUI_frontend` and `desktop` as distinct frontend host surfaces.
- The sidebar stamps its resolved host surface at mount time so desktop bundle drift is explicit in diagnostics and regression tests.
- The standalone Remote Admin Console now stamps the same host-surface metadata on its document root, so host-sensitive sidebar and admin behavior can be validated against one shared contract.
- The sidebar stamps its resolved host surface and refreshed host-reference metadata at mount time so desktop bundle drift is explicit in diagnostics and regression tests.
- The standalone Remote Admin Console now stamps the same host-surface metadata on its document root, including desktop `0.9.4`, bundled core `0.22.3`, embedded frontend `1.43.18`, and lagging parity relative to standalone frontend `1.46.6`.
- Graph/widget compatibility code should route through shared host helpers to keep nested-subgraph and promoted-widget behavior aligned with current upstream host semantics.
## Standalone Remote Admin Console
@@ -25,6 +25,7 @@ test.describe('Desktop host parity lane', () => {
const host = page.locator('#sidebar-tab-comfyui-openclaw');
await expect(host).toHaveAttribute('data-openclaw-host-surface', 'standalone_frontend');
await expect(host).toHaveAttribute('data-openclaw-desktop-host', 'false');
await expect(host).toHaveAttribute('data-openclaw-reference-frontend', '1.46.6');
});
test('boots the sidebar under desktop host signals and keeps approvals interactive', async ({ page }) => {
@@ -36,6 +37,11 @@ test.describe('Desktop host parity lane', () => {
const host = page.locator('#sidebar-tab-comfyui-openclaw');
await expect(host).toHaveAttribute('data-openclaw-host-surface', 'desktop');
await expect(host).toHaveAttribute('data-openclaw-desktop-host', 'true');
await expect(host).toHaveAttribute('data-openclaw-reference-frontend', '1.46.6');
await expect(host).toHaveAttribute('data-openclaw-desktop-version', '0.9.4');
await expect(host).toHaveAttribute('data-openclaw-desktop-core-version', '0.22.3');
await expect(host).toHaveAttribute('data-openclaw-desktop-embedded-frontend', '1.43.18');
await expect(host).toHaveAttribute('data-openclaw-desktop-frontend-parity', 'lagging');
await clickTab(page, 'Approvals');
await expect(page.locator('#apr-list')).toContainText('apr-r166-001');
@@ -51,6 +57,11 @@ test.describe('Desktop host parity lane', () => {
await expect(page.locator('body')).toHaveAttribute('data-openclaw-host-surface', 'desktop');
await expect(page.locator('body')).toHaveAttribute('data-openclaw-desktop-host', 'true');
await expect(page.locator('body')).toHaveAttribute('data-openclaw-reference-frontend', '1.46.6');
await expect(page.locator('body')).toHaveAttribute('data-openclaw-desktop-version', '0.9.4');
await expect(page.locator('body')).toHaveAttribute('data-openclaw-desktop-core-version', '0.22.3');
await expect(page.locator('body')).toHaveAttribute('data-openclaw-desktop-embedded-frontend', '1.43.18');
await expect(page.locator('body')).toHaveAttribute('data-openclaw-desktop-frontend-parity', 'lagging');
await page.locator('#refreshApprovals').click();
await expect(page.locator('#approvalsList')).toContainText('apr-r166-001');
+26
View File
@@ -9,6 +9,19 @@ export const HOST_SURFACES = Object.freeze({
desktop: "desktop",
});
export const HOST_SURFACE_REFERENCES = Object.freeze({
[HOST_SURFACES.standaloneFrontend]: Object.freeze({
frontendVersion: "1.46.6",
}),
[HOST_SURFACES.desktop]: Object.freeze({
desktopVersion: "0.9.4",
coreVersion: "0.22.3",
embeddedFrontendVersion: "1.43.18",
standaloneFrontendVersion: "1.46.6",
frontendParity: "lagging",
}),
});
function normalizeSurfaceName(surface) {
if (surface === HOST_SURFACES.desktop || surface === "desktop") {
return HOST_SURFACES.desktop;
@@ -42,11 +55,13 @@ export function resolveHostSurface({ app = null, win = window } = {}) {
export function getHostSurfaceCapabilities(options = {}) {
const hostSurface = resolveHostSurface(options);
const reference = HOST_SURFACE_REFERENCES[hostSurface] || {};
return {
hostSurface,
isDesktop: hostSurface === HOST_SURFACES.desktop,
supportsElectronBridge:
hostSurface === HOST_SURFACES.desktop && !!options?.win?.electronAPI,
reference,
};
}
@@ -57,6 +72,17 @@ export function stampHostSurfaceMetadata(container, options = {}) {
container.dataset.openclawDesktopHost = capabilities.isDesktop
? "true"
: "false";
container.dataset.openclawReferenceFrontend = capabilities.isDesktop
? capabilities.reference.standaloneFrontendVersion || ""
: capabilities.reference.frontendVersion || "";
if (capabilities.isDesktop) {
container.dataset.openclawDesktopVersion = capabilities.reference.desktopVersion || "";
container.dataset.openclawDesktopCoreVersion = capabilities.reference.coreVersion || "";
container.dataset.openclawDesktopEmbeddedFrontend =
capabilities.reference.embeddedFrontendVersion || "";
container.dataset.openclawDesktopFrontendParity =
capabilities.reference.frontendParity || "";
}
}
return capabilities;
}
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import {
HOST_SURFACES,
HOST_SURFACE_REFERENCES,
getHostSurfaceCapabilities,
resolveHostSurface,
stampHostSurfaceMetadata,
@@ -32,9 +33,15 @@ describe("openclaw_host_surface", () => {
hostSurface: HOST_SURFACES.desktop,
isDesktop: true,
supportsElectronBridge: true,
reference: HOST_SURFACE_REFERENCES[HOST_SURFACES.desktop],
});
expect(container.dataset.openclawHostSurface).toBe("desktop");
expect(container.dataset.openclawDesktopHost).toBe("true");
expect(container.dataset.openclawReferenceFrontend).toBe("1.46.6");
expect(container.dataset.openclawDesktopVersion).toBe("0.9.4");
expect(container.dataset.openclawDesktopCoreVersion).toBe("0.22.3");
expect(container.dataset.openclawDesktopEmbeddedFrontend).toBe("1.43.18");
expect(container.dataset.openclawDesktopFrontendParity).toBe("lagging");
});
it("falls back to standalone frontend when desktop-only signals are absent", () => {
@@ -46,6 +53,7 @@ describe("openclaw_host_surface", () => {
hostSurface: HOST_SURFACES.standaloneFrontend,
isDesktop: false,
supportsElectronBridge: false,
reference: HOST_SURFACE_REFERENCES[HOST_SURFACES.standaloneFrontend],
});
});
});