mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
fix(ui): remove Labs reset buttons (#121427)
* fix(ui): remove Labs reset buttons * test(ui): update Labs default E2E flow
This commit is contained in:
committed by
GitHub
parent
deb63f9db3
commit
293de99da8
@@ -132,12 +132,13 @@ suite.define(() => {
|
||||
const labsLink = page.locator('.settings-sidebar__item[href="/settings/labs"]');
|
||||
await expect.poll(() => labsLink.getAttribute("aria-current")).toBe("page");
|
||||
const codeModeRow = settingsRow(page, "Code Mode");
|
||||
await codeModeRow.getByRole("switch", { name: "Code Mode", exact: true }).waitFor();
|
||||
const codeModeSwitch = codeModeRow.getByRole("switch", { name: "Code Mode", exact: true });
|
||||
await codeModeSwitch.waitFor();
|
||||
await expect.poll(() => codeModeRow.textContent()).toContain("Default: Enabled");
|
||||
|
||||
const configGetsBeforePatch = (await gateway.getRequests("config.get")).length;
|
||||
await gateway.deferNext("config.patch");
|
||||
await codeModeRow.getByRole("button", { name: "Reset to default" }).click();
|
||||
await codeModeRow.locator("wa-switch").click();
|
||||
const patchParams = mutationParams(await gateway.waitForRequest("config.patch"));
|
||||
expect(patchParams.baseHash).toBe("snapshot-1");
|
||||
expect(patchParams.sessionKey).toBe("main");
|
||||
|
||||
@@ -120,7 +120,7 @@ suite.define(() => {
|
||||
|
||||
const configGetsBeforeLabsReset = (await gateway.getRequests("config.get")).length;
|
||||
await gateway.deferNext("config.patch");
|
||||
await codeModeRow.getByRole("button", { name: "Reset to default" }).click();
|
||||
await codeModeRow.locator("wa-switch").click();
|
||||
const labsPatch = requestRaw(await gateway.waitForRequest("config.patch"));
|
||||
expect(labsPatch).toEqual({ tools: { codeMode: { enabled: null } } });
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ describe("LabsPage", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("shows default provenance and reset actions only for overrides", async () => {
|
||||
it("shows default provenance without reset actions", async () => {
|
||||
const inherited = await mountPage({});
|
||||
expect(labRow(inherited.page, "Code Mode").textContent).toContain("Using default: Enabled");
|
||||
expect(labRow(inherited.page, "Swarm").textContent).toContain("Using default: Disabled");
|
||||
@@ -284,7 +284,7 @@ describe("LabsPage", () => {
|
||||
expect(labRow(overridden.page, "Code Mode").textContent).toContain("Default: Enabled");
|
||||
expect(labRow(overridden.page, "Swarm").textContent).toContain("Default: Disabled");
|
||||
expect(overridden.page.querySelectorAll("button[aria-label='Reset to default']")).toHaveLength(
|
||||
2,
|
||||
0,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -343,9 +343,9 @@ describe("LabsPage", () => {
|
||||
},
|
||||
});
|
||||
|
||||
labRow(page, "Lean tools for local models")
|
||||
.querySelector<HTMLButtonElement>("button[aria-label='Reset to default']")
|
||||
?.click();
|
||||
const toggle = labToggle(page, "Lean tools for local models");
|
||||
toggle.checked = false;
|
||||
toggle.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
|
||||
|
||||
await vi.waitFor(() => expect(runtimeConfig.patch).toHaveBeenCalledOnce());
|
||||
expect(runtimeConfig.patch).toHaveBeenCalledWith({
|
||||
@@ -356,36 +356,6 @@ describe("LabsPage", () => {
|
||||
note: "labs: update localModelLean",
|
||||
});
|
||||
});
|
||||
|
||||
it("restores an object gate without deleting sibling settings", async () => {
|
||||
const { page, runtimeConfig } = await mountPage({
|
||||
tools: { loopDetection: { enabled: true, warningThreshold: 12 } },
|
||||
});
|
||||
|
||||
labRow(page, "Tool-loop detection")
|
||||
.querySelector<HTMLButtonElement>("button[aria-label='Reset to default']")
|
||||
?.click();
|
||||
|
||||
await vi.waitFor(() => expect(runtimeConfig.patch).toHaveBeenCalledOnce());
|
||||
expect(runtimeConfig.patch).toHaveBeenCalledWith({
|
||||
raw: { tools: { loopDetection: { enabled: null } } },
|
||||
note: "labs: update loopDetection",
|
||||
});
|
||||
});
|
||||
|
||||
it("restores a shorthand gate at its owning parent path", async () => {
|
||||
const { page, runtimeConfig } = await mountPage({ tools: { codeMode: "auto" } });
|
||||
|
||||
labRow(page, "Code Mode")
|
||||
.querySelector<HTMLButtonElement>("button[aria-label='Reset to default']")
|
||||
?.click();
|
||||
|
||||
await vi.waitFor(() => expect(runtimeConfig.patch).toHaveBeenCalledOnce());
|
||||
expect(runtimeConfig.patch).toHaveBeenCalledWith({
|
||||
raw: { tools: { codeMode: null } },
|
||||
note: "labs: update codeMode",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("LabsPage code mode enablement", () => {
|
||||
@@ -507,22 +477,6 @@ describe("LabsPage tool search enablement", () => {
|
||||
note: "labs: update toolSearch",
|
||||
});
|
||||
});
|
||||
|
||||
it("resets an explicit enabled override as a Tool Search unit", async () => {
|
||||
const { page, runtimeConfig } = await mountPage({
|
||||
tools: { toolSearch: { enabled: true } },
|
||||
});
|
||||
|
||||
labRow(page, "Tool Search")
|
||||
.querySelector<HTMLButtonElement>("button[aria-label='Reset to default']")
|
||||
?.click();
|
||||
|
||||
await vi.waitFor(() => expect(runtimeConfig.patch).toHaveBeenCalledOnce());
|
||||
expect(runtimeConfig.patch).toHaveBeenCalledWith({
|
||||
raw: { tools: { toolSearch: null } },
|
||||
note: "labs: update toolSearch",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("LabsPage tool loop detection enablement", () => {
|
||||
|
||||
@@ -5,7 +5,6 @@ import { titleForRoute } from "../../app-navigation.ts";
|
||||
import { applicationContext, type ApplicationContext } from "../../app/context.ts";
|
||||
import {
|
||||
renderDocsLink,
|
||||
renderSettingsDefaultState,
|
||||
renderSettingsPage,
|
||||
renderSettingsRow,
|
||||
renderSettingsSection,
|
||||
@@ -113,39 +112,26 @@ class LabsPage extends OpenClawLightDomElement {
|
||||
);
|
||||
}
|
||||
|
||||
private resetFeature(feature: LabFeature) {
|
||||
const config = this.editableConfig();
|
||||
const featureState = resolveLabFeatureState(config, feature);
|
||||
const resetPatch = labFeatureResetPatch(config, feature);
|
||||
if (!resetPatch) {
|
||||
return;
|
||||
}
|
||||
void this.updateFeature(feature, featureState.defaultEnabled, resetPatch);
|
||||
}
|
||||
|
||||
private renderFeature(feature: LabFeature) {
|
||||
const title = feature.title();
|
||||
const featureState = resolveLabFeatureState(this.editableConfig(), feature);
|
||||
const canToggle = this.canToggle();
|
||||
const defaultState = renderSettingsDefaultState({
|
||||
value: featureState.defaultEnabled ? t("common.enabled") : t("common.disabled"),
|
||||
overridden: featureState.overridden,
|
||||
disabled: !canToggle,
|
||||
onReset: () => this.resetFeature(feature),
|
||||
});
|
||||
const defaultDescription = t(
|
||||
featureState.overridden ? "configForm.defaultValue" : "configForm.usingDefault",
|
||||
{ value: featureState.defaultEnabled ? t("common.enabled") : t("common.disabled") },
|
||||
);
|
||||
const description = html`
|
||||
${feature.description()}
|
||||
<a href=${feature.docsUrl} target=${EXTERNAL_LINK_TARGET} rel=${buildExternalLinkRel()}
|
||||
>${t("labsPage.documentation")}</a
|
||||
>${feature.restartHint ? html` <span>${feature.restartHint()}</span>` : nothing}
|
||||
<span>${defaultState.description}</span>
|
||||
<span>${defaultDescription}</span>
|
||||
`;
|
||||
return renderSettingsToggleRow({
|
||||
title,
|
||||
description,
|
||||
checked: this.featureEnabled(feature),
|
||||
disabled: !canToggle,
|
||||
actions: defaultState.action,
|
||||
onChange: (enabled) => this.setFeatureEnabled(feature, enabled),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user