Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
241 lines
8.8 KiB
TypeScript
241 lines
8.8 KiB
TypeScript
// Control UI tests cover session management through the sidebar and chat picker.
|
|
import { mkdir } from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { chromium, type Browser, type Locator, type Page } from "playwright";
|
|
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
import {
|
|
canRunPlaywrightChromium,
|
|
installMockGateway,
|
|
resolvePlaywrightChromiumExecutablePath,
|
|
startControlUiE2eServer,
|
|
type ControlUiE2eServer,
|
|
type MockGatewayControls,
|
|
type MockGatewayRequest,
|
|
} from "../test-helpers/control-ui-e2e.ts";
|
|
|
|
const chromiumExecutablePath = resolvePlaywrightChromiumExecutablePath(chromium.executablePath());
|
|
const chromiumAvailable = canRunPlaywrightChromium(chromiumExecutablePath);
|
|
const allowMissingChromium = process.env.OPENCLAW_UI_E2E_ALLOW_MISSING_CHROMIUM === "1";
|
|
const describeControlUiE2e = chromiumAvailable || !allowMissingChromium ? describe : describe.skip;
|
|
|
|
let browser: Browser;
|
|
let server: ControlUiE2eServer;
|
|
|
|
function sessionRow(
|
|
key: string,
|
|
label: string,
|
|
updatedAt: number,
|
|
options: { pinned?: boolean; pinnedAt?: number; hasActiveRun?: boolean; status?: string } = {},
|
|
) {
|
|
return {
|
|
contextTokens: null,
|
|
displayName: label,
|
|
hasActiveRun: false,
|
|
key,
|
|
kind: "direct",
|
|
label,
|
|
model: "gpt-5.5",
|
|
modelProvider: "openai",
|
|
status: "done",
|
|
totalTokens: 0,
|
|
updatedAt,
|
|
...options,
|
|
};
|
|
}
|
|
|
|
function sessionsListResponse(sessions: unknown[]) {
|
|
return {
|
|
count: sessions.length,
|
|
defaults: {
|
|
contextTokens: null,
|
|
model: "gpt-5.5",
|
|
modelProvider: "openai",
|
|
},
|
|
hasMore: false,
|
|
limitApplied: 50,
|
|
nextOffset: null,
|
|
offset: 0,
|
|
path: "",
|
|
sessions,
|
|
totalCount: sessions.length,
|
|
ts: Date.now(),
|
|
};
|
|
}
|
|
|
|
function requireRecord(value: unknown): Record<string, unknown> {
|
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
throw new Error("Expected object value");
|
|
}
|
|
return value as Record<string, unknown>;
|
|
}
|
|
|
|
async function waitForPatch(
|
|
gateway: MockGatewayControls,
|
|
predicate: (params: Record<string, unknown>) => boolean,
|
|
): Promise<MockGatewayRequest> {
|
|
const deadline = Date.now() + 10_000;
|
|
let requests: MockGatewayRequest[] = [];
|
|
while (Date.now() < deadline) {
|
|
requests = await gateway.getRequests("sessions.patch");
|
|
const match = requests.find((request) => predicate(requireRecord(request.params)));
|
|
if (match) {
|
|
return match;
|
|
}
|
|
await new Promise((resolve) => {
|
|
setTimeout(resolve, 50);
|
|
});
|
|
}
|
|
throw new Error(`No matching sessions.patch request found: ${JSON.stringify(requests)}`);
|
|
}
|
|
|
|
function actionOpacity(button: Locator): Promise<string> {
|
|
return button.evaluate((element) => globalThis.getComputedStyle(element).opacity);
|
|
}
|
|
|
|
async function captureUiProof(page: Page, fileName: string) {
|
|
if (process.env.OPENCLAW_CAPTURE_UI_PROOF !== "1") {
|
|
return;
|
|
}
|
|
const artifactDir = path.join(process.cwd(), ".artifacts", "control-ui-e2e", "thread-management");
|
|
await mkdir(artifactDir, { recursive: true });
|
|
await page.screenshot({ fullPage: true, path: path.join(artifactDir, fileName) });
|
|
}
|
|
|
|
describeControlUiE2e("Control UI session management mocked Gateway E2E", () => {
|
|
beforeAll(async () => {
|
|
if (!chromiumAvailable) {
|
|
throw new Error(
|
|
`Playwright Chromium is not installed or cannot start at ${chromiumExecutablePath}. Run \`pnpm --dir ui exec playwright install --with-deps chromium\`, or set OPENCLAW_UI_E2E_ALLOW_MISSING_CHROMIUM=1 only when intentionally skipping this lane.`,
|
|
);
|
|
}
|
|
server = await startControlUiE2eServer();
|
|
browser = await chromium.launch({ executablePath: chromiumExecutablePath });
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await browser?.close();
|
|
await server?.close();
|
|
});
|
|
|
|
it("manages sessions through the sidebar and chat picker", async () => {
|
|
const baseTime = Date.parse("2026-07-01T16:00:00.000Z");
|
|
const context = await browser.newContext({
|
|
locale: "en-US",
|
|
serviceWorkers: "block",
|
|
viewport: { height: 900, width: 1280 },
|
|
});
|
|
const page = await context.newPage();
|
|
const gateway = await installMockGateway(page, {
|
|
methodResponses: {
|
|
"sessions.list": sessionsListResponse([
|
|
sessionRow("agent:main:main", "Main", baseTime),
|
|
sessionRow("agent:main:release", "Release planning", baseTime - 60_000, {
|
|
pinned: true,
|
|
pinnedAt: baseTime - 30_000,
|
|
}),
|
|
sessionRow("agent:main:migration", "Data migration", baseTime - 90_000, {
|
|
hasActiveRun: true,
|
|
status: "running",
|
|
}),
|
|
sessionRow("agent:main:research", "Research notes", baseTime - 120_000),
|
|
]),
|
|
"sessions.patch": {},
|
|
},
|
|
sessionKey: "agent:main:main",
|
|
});
|
|
|
|
try {
|
|
await page.goto(`${server.baseUrl}chat`);
|
|
|
|
// Sidebar recents: pinned first, live-run spinner, hover-revealed actions.
|
|
const sidebarRows = page.locator(".sidebar-recent-sessions__list .sidebar-recent-session");
|
|
await sidebarRows.first().waitFor({ state: "visible", timeout: 10_000 });
|
|
await expect.poll(() => sidebarRows.first().textContent()).toContain("Release planning");
|
|
const sidebarMigration = sidebarRows.filter({ hasText: "Data migration" });
|
|
await expect
|
|
.poll(() => sidebarMigration.locator(".session-run-spinner").isVisible())
|
|
.toBe(true);
|
|
|
|
const sidebarResearch = sidebarRows.filter({ hasText: "Research notes" });
|
|
const sidebarResearchPin = sidebarResearch.getByRole("button", { name: "Pin session" });
|
|
await page.mouse.move(900, 500);
|
|
await expect.poll(() => actionOpacity(sidebarResearchPin)).toBe("0");
|
|
const sidebarReleasePin = sidebarRows
|
|
.filter({ hasText: "Release planning" })
|
|
.getByRole("button", { name: "Unpin session" });
|
|
// Pinned badge stays visible without hover.
|
|
await expect.poll(() => actionOpacity(sidebarReleasePin)).toBe("1");
|
|
await sidebarResearch.hover();
|
|
await expect.poll(() => actionOpacity(sidebarResearchPin)).toBe("1");
|
|
await captureUiProof(page, "sidebar-sessions.png");
|
|
|
|
// Chat picker: single-line rows with hover-revealed management actions.
|
|
await page.getByRole("button", { name: "Search sessions" }).click();
|
|
const releaseRow = page
|
|
.locator(".chat-session-picker__option-row")
|
|
.filter({ hasText: "Release planning" });
|
|
await releaseRow.waitFor({ state: "visible", timeout: 10_000 });
|
|
await expect.poll(() => releaseRow.getByRole("button").count()).toBe(3);
|
|
|
|
const migrationRow = page
|
|
.locator(".chat-session-picker__option-row")
|
|
.filter({ hasText: "Data migration" });
|
|
await expect.poll(() => migrationRow.locator(".session-run-spinner").isVisible()).toBe(true);
|
|
|
|
const mainRow = page.locator(".chat-session-picker__option-row").filter({ hasText: "Main" });
|
|
await expect
|
|
.poll(() => mainRow.getByRole("button", { name: "Archive session" }).isDisabled())
|
|
.toBe(true);
|
|
|
|
const researchRow = page
|
|
.locator(".chat-session-picker__option-row")
|
|
.filter({ hasText: "Research notes" });
|
|
const researchArchive = researchRow.getByRole("button", { name: "Archive session" });
|
|
await page.mouse.move(900, 500);
|
|
await expect.poll(() => actionOpacity(researchArchive)).toBe("0");
|
|
await expect
|
|
.poll(() => actionOpacity(releaseRow.getByRole("button", { name: "Unpin session" })))
|
|
.toBe("1");
|
|
await researchRow.hover();
|
|
await expect.poll(() => actionOpacity(researchArchive)).toBe("1");
|
|
await captureUiProof(page, "chat-session-management.png");
|
|
|
|
await releaseRow.hover();
|
|
await releaseRow.getByRole("button", { name: "Unpin session" }).click();
|
|
const pinPatch = await waitForPatch(
|
|
gateway,
|
|
(params) => params.key === "agent:main:release" && params.pinned === false,
|
|
);
|
|
expect(requireRecord(pinPatch.params)).toMatchObject({
|
|
key: "agent:main:release",
|
|
pinned: false,
|
|
});
|
|
|
|
page.once("dialog", (dialog) => dialog.accept("Launch plan"));
|
|
await releaseRow.hover();
|
|
await releaseRow.getByRole("button", { name: "Rename session" }).click();
|
|
const renamePatch = await waitForPatch(
|
|
gateway,
|
|
(params) => params.key === "agent:main:release" && params.label === "Launch plan",
|
|
);
|
|
expect(requireRecord(renamePatch.params)).toMatchObject({
|
|
key: "agent:main:release",
|
|
label: "Launch plan",
|
|
});
|
|
|
|
await researchRow.hover();
|
|
await researchArchive.click();
|
|
const archivePatch = await waitForPatch(
|
|
gateway,
|
|
(params) => params.key === "agent:main:research" && params.archived === true,
|
|
);
|
|
expect(requireRecord(archivePatch.params)).toMatchObject({
|
|
archived: true,
|
|
key: "agent:main:research",
|
|
});
|
|
} finally {
|
|
await context.close();
|
|
}
|
|
});
|
|
});
|