Skip to content

Commit a8d8aa9

Browse files
vincentkocZYV5ge
andcommitted
fix(ui): remove redundant Labs config refresh
Let the runtime config patch owner complete its authoritative refresh instead of starting a second Labs-page refresh. Tighten unit and mocked browser coverage around the single refresh and visible settings state. Co-authored-by: ZYV5ge <[email protected]> Punchcard-Session: amber-workshop-workshop-36
1 parent 6f56d79 commit a8d8aa9

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎ui/src/e2e/config-safe-write.e2e.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ suite.define(() => {
129129
});
130130

131131
expect((await page.goto(`${suite.server.baseUrl}settings/labs`))?.status()).toBe(200);
132+
const labsLink = page.locator('.settings-sidebar__item[href="/settings/labs"]');
133+
await expect.poll(() => labsLink.getAttribute("aria-current")).toBe("page");
132134
const codeModeRow = settingsRow(page, "Code Mode");
133135
await codeModeRow.getByRole("switch", { name: "Code Mode", exact: true }).waitFor();
134136
await expect.poll(() => codeModeRow.textContent()).toContain("Default: Enabled");
@@ -151,14 +153,18 @@ suite.define(() => {
151153
});
152154
await expect
153155
.poll(async () => (await gateway.getRequests("config.get")).length)
154-
.toBeGreaterThan(configGetsBeforePatch);
156+
.toBe(configGetsBeforePatch + 1);
155157
await expect.poll(() => codeModeRow.textContent()).toContain("Using default: Enabled");
158+
await expect.poll(() => labsLink.getAttribute("aria-current")).toBe("page");
159+
await capture(page, "00-labs-canonical-refresh.png");
156160

157161
expect(
158162
(
159163
await page.goto(`${suite.server.baseUrl}settings/advanced?section=laboratory`)
160164
)?.status(),
161165
).toBe(200);
166+
const advancedLink = page.locator('.settings-sidebar__item[href="/settings/advanced"]');
167+
await expect.poll(() => advancedLink.getAttribute("aria-current")).toBe("page");
162168
const endpoint = page.getByRole("textbox", { name: "Endpoint", exact: true });
163169
await expect.poll(() => endpoint.inputValue()).toBe("local-api");
164170

‎ui/src/pages/labs/labs-page.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe("LabsPage", () => {
124124
expect(codeModeToggle(page).checked).toBe(true);
125125
});
126126

127-
it("writes an explicit false in the RFC 7396 merge patch when disabling", async () => {
127+
it("delegates refresh ownership to the canonical patch flow when disabling", async () => {
128128
const { page, runtimeConfig } = await mountPage({
129129
tools: { codeMode: { enabled: true } },
130130
});
@@ -138,7 +138,7 @@ describe("LabsPage", () => {
138138
raw: { tools: { codeMode: { enabled: false } } },
139139
note: "labs: update codeMode",
140140
});
141-
expect(runtimeConfig.refresh).toHaveBeenCalledOnce();
141+
expect(runtimeConfig.refresh).not.toHaveBeenCalled();
142142
});
143143

144144
it.each([

‎ui/src/pages/labs/labs-page.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ class LabsPage extends OpenClawLightDomElement {
9090
});
9191
if (!patched) {
9292
this.saveError = runtimeConfig.state.lastError ?? t("labsPage.saveFailed");
93-
return;
94-
}
95-
if (this.context.runtimeConfig === runtimeConfig) {
96-
await runtimeConfig.refresh();
9793
}
9894
} catch (error) {
9995
this.saveError = String(error);

0 commit comments

Comments
 (0)