Skip to content

Commit 4ded341

Browse files
authored
fix(ui): explain unavailable updates (#128958)
Co-authored-by: roboclaw-bot <[email protected]>
1 parent 3c7143d commit 4ded341

4 files changed

Lines changed: 118 additions & 22 deletions

File tree

‎ui/src/components/sidebar-update-card.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,34 @@ describe("SidebarUpdateCard", () => {
186186
);
187187
});
188188

189+
it("keeps an unauthorized update discoverable without allowing activation", async () => {
190+
const element = await mount(
191+
{
192+
currentVersion: "1.0.0",
193+
latestVersion: "2.0.0",
194+
channel: "stable",
195+
},
196+
null,
197+
false,
198+
);
199+
const onUpdate = vi.fn();
200+
element.onUpdate = onUpdate;
201+
202+
const action = element.querySelector<HTMLButtonElement>(".sidebar-update-card__action");
203+
const tooltip = action?.closest("openclaw-tooltip") as
204+
| (HTMLElement & { content?: string; updateComplete: Promise<boolean> })
205+
| null;
206+
await tooltip?.updateComplete;
207+
208+
expect(action?.disabled).toBe(false);
209+
expect(action?.getAttribute("aria-disabled")).toBe("true");
210+
expect(action?.getAttribute("aria-describedby")).not.toBeNull();
211+
expect(tooltip?.hasAttribute("open-on-click")).toBe(true);
212+
expect(tooltip?.content).toContain("Administrator access is required");
213+
action?.click();
214+
expect(onUpdate).not.toHaveBeenCalled();
215+
});
216+
189217
it("renders a quiet live countdown and stops ticking on disconnect", async () => {
190218
vi.useFakeTimers();
191219
vi.setSystemTime(1_000);

‎ui/src/components/sidebar-update-card.ts‎

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { OpenClawLightDomContentsElement } from "../lit/openclaw-element.ts";
1818
import { PollController } from "../lit/poll-controller.ts";
1919
import "../styles/sidebar-update-card.css";
2020
import { icons } from "./icons.ts";
21+
import "./tooltip.ts";
2122

2223
class SidebarUpdateCard extends OpenClawLightDomContentsElement {
2324
@property({ attribute: false }) compact = false;
@@ -339,6 +340,23 @@ class SidebarUpdateCard extends OpenClawLightDomContentsElement {
339340
// An outcome with nothing left to act on is the whole card: re-offering an
340341
// update the operator just ran would bury the reason it failed.
341342
const actionable = isUpdateActionable(update, this.updateSchedule, this.updateBusy);
343+
const updateAction = html`<button
344+
class="sidebar-update-card__action ${busy ? "sidebar-update-card__action--busy" : ""}"
345+
type="button"
346+
aria-disabled=${this.canUpdate ? nothing : "true"}
347+
?disabled=${busy}
348+
@click=${this.startUpdate}
349+
>
350+
<span class="sidebar-update-card__icon" aria-hidden="true"
351+
>${busy ? icons.refresh : icons.download}</span
352+
>
353+
<span
354+
class="sidebar-update-card__text"
355+
role=${countdownActive ? "timer" : nothing}
356+
aria-live=${countdownActive ? "off" : nothing}
357+
>${text}</span
358+
>
359+
</button>`;
342360
return html`
343361
<div
344362
class="sidebar-update-card"
@@ -348,25 +366,11 @@ class SidebarUpdateCard extends OpenClawLightDomContentsElement {
348366
${this.renderStatus()}
349367
${actionable
350368
? html`<div class="sidebar-update-card__actions">
351-
<button
352-
class="sidebar-update-card__action ${busy
353-
? "sidebar-update-card__action--busy"
354-
: ""}"
355-
type="button"
356-
title=${this.canUpdate ? nothing : t("updates.adminRequired")}
357-
?disabled=${busy || !this.canUpdate}
358-
@click=${this.startUpdate}
359-
>
360-
<span class="sidebar-update-card__icon" aria-hidden="true"
361-
>${busy ? icons.refresh : icons.download}</span
362-
>
363-
<span
364-
class="sidebar-update-card__text"
365-
role=${countdownActive ? "timer" : nothing}
366-
aria-live=${countdownActive ? "off" : nothing}
367-
>${text}</span
368-
>
369-
</button>
369+
${this.canUpdate
370+
? updateAction
371+
: html`<openclaw-tooltip open-on-click .content=${t("updates.adminRequired")}>
372+
${updateAction}
373+
</openclaw-tooltip>`}
370374
${showHold && campaign
371375
? html`
372376
<button

‎ui/src/e2e/update-coalesced.e2e.test.ts‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,70 @@ async function openUpdateConfirmation(page: Page): Promise<void> {
2727
}
2828

2929
suite.define(() => {
30+
it("explains a disabled update to a read-only mobile operator", async () => {
31+
const artifactDir = path.resolve(".artifacts/control-ui-e2e/update-read-only-mobile");
32+
await suite.withPage(
33+
{
34+
colorScheme: "dark",
35+
hasTouch: true,
36+
isMobile: true,
37+
locale: "en-US",
38+
recordVideo: { dir: artifactDir, size: { height: 1200, width: 555 } },
39+
serviceWorkers: "block",
40+
viewport: { height: 1200, width: 555 },
41+
},
42+
async ({ page }) => {
43+
const gateway = await installMockGateway(page, {
44+
operatorScopes: ["operator.read"],
45+
});
46+
47+
expect((await page.goto(`${suite.server.baseUrl}chat`))?.status()).toBe(200);
48+
await gateway.waitForRequest("chat.startup");
49+
await page.getByRole("button", { name: "Expand sidebar" }).click();
50+
await gateway.emitGatewayEvent("update.available", {
51+
updateAvailable: {
52+
channel: "stable",
53+
currentVersion: "1.0.0",
54+
latestVersion: "2.0.0",
55+
},
56+
});
57+
58+
await page.locator(".sidebar-issues-button").click();
59+
const updateIssue = page.locator(
60+
'openclaw-sidebar-update-card[data-attention-kind="updateAvailable"]',
61+
);
62+
await updateIssue.locator("summary").click();
63+
const action = updateIssue.locator(".sidebar-update-card__action");
64+
await expect.poll(() => action.getAttribute("aria-disabled")).toBe("true");
65+
expect(await action.evaluate((element) => (element as HTMLButtonElement).disabled)).toBe(
66+
false,
67+
);
68+
await page.screenshot({ path: path.join(artifactDir, "disabled-update.png") });
69+
70+
const actionBounds = await action.boundingBox();
71+
if (!actionBounds) {
72+
throw new Error("disabled update action is not visible");
73+
}
74+
const tooltip = updateIssue.locator("openclaw-tooltip wa-tooltip");
75+
await tooltip.evaluate((element) => {
76+
element.addEventListener(
77+
"wa-after-show",
78+
() => element.setAttribute("data-e2e-after-show", ""),
79+
{ once: true },
80+
);
81+
});
82+
await page.touchscreen.tap(
83+
actionBounds.x + actionBounds.width / 2,
84+
actionBounds.y + actionBounds.height / 2,
85+
);
86+
await expect.poll(() => tooltip.getAttribute("data-e2e-after-show")).not.toBeNull();
87+
expect(await tooltip.textContent()).toContain("Administrator access is required");
88+
expect(await gateway.getRequests("update.run")).toHaveLength(0);
89+
await page.screenshot({ path: path.join(artifactDir, "disabled-update-tooltip.png") });
90+
},
91+
);
92+
});
93+
3094
it("shows package update failure status after the Update click", async () => {
3195
const artifactDir = path.resolve(".artifacts/control-ui-e2e/update-package-status");
3296
await suite.withPage(

‎ui/src/styles/sidebar-update-card.css‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ html.openclaw-native-macos
6060
border-color var(--duration-fast) ease;
6161
}
6262

63-
.sidebar-update-card__action:hover:not(:disabled),
64-
.sidebar-update-card__action:focus-visible {
63+
.sidebar-update-card__action:hover:not(:disabled):not([aria-disabled="true"]),
64+
.sidebar-update-card__action:focus-visible:not([aria-disabled="true"]) {
6565
border-color: color-mix(in srgb, var(--accent) 36%, var(--border));
6666
background: color-mix(in srgb, var(--accent-subtle) 72%, var(--bg-elevated));
6767
}
@@ -96,7 +96,7 @@ html.openclaw-native-macos
9696
opacity: 0.66;
9797
}
9898

99-
.sidebar-update-card__action:disabled {
99+
.sidebar-update-card__action:is(:disabled, [aria-disabled="true"]) {
100100
cursor: not-allowed;
101101
opacity: 0.66;
102102
}

0 commit comments

Comments
 (0)