Skip to content

Commit 49cdd54

Browse files
authored
feat(control-ui): move the Ask OpenClaw toggle to the sidebar footer (#125486)
* feat(control-ui): move the Ask OpenClaw toggle to the sidebar footer The sidebar bottom now mirrors its top: big agent selector with inline chevron + small new-session square above, big account identity card with inline chevron + small lobster toggle below. The account chevron moves from the row's far right to directly after the name, matching the top header treatment; the freed edge hosts the toggle. The old top-left shell-chrome placement is removed along with its four-button width reservation (which read-scoped clients paid for without seeing the button). Scope gating, palette entry, and panel wiring are unchanged; gating regressions moved to the sidebar cases. * fix(control-ui): keep Ask OpenClaw reachable while the nav is collapsed Address the ClawSweeper P1: desktop collapse hides the sidebar entirely (display:none, no rail), which would have removed the toggle's only persistent surface. The lobster now joins the chrome strip exactly while the nav is collapsed — the footer stays its home — and the strip's collapsed width reserves four controls for that state. Regression covers collapsed-present/expanded-absent/read-scope-absent.
1 parent 0e7f320 commit 49cdd54

7 files changed

Lines changed: 112 additions & 53 deletions

File tree

‎docs/web/control-ui.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Theme, theme mode, language, and chat display preferences sync through the gatew
141141

142142
## OpenClaw system care
143143

144-
Open **Settings → Ask OpenClaw** to talk to the system setup and repair agent. Toggle it from anywhere with the lobster button in the shell chrome or the **Ask OpenClaw** command-palette action. The full page and dockable panel share one machine-wide conversation whose durable history lives on the Gateway. Closing the UI never cancels a turn; reopening Ask OpenClaw shows the completed conversation. The panel docks on the right or bottom, remembers its placement and size in the browser profile, and hides itself while the full page is open.
144+
Open **Settings → Ask OpenClaw** to talk to the system setup and repair agent. Toggle it from anywhere with the lobster button in the sidebar footer or the **Ask OpenClaw** command-palette action. The full page and dockable panel share one machine-wide conversation whose durable history lives on the Gateway. Closing the UI never cancels a turn; reopening Ask OpenClaw shows the completed conversation. The panel docks on the right or bottom, remembers its placement and size in the browser profile, and hides itself while the full page is open.
145145

146146
Each chat message carries the Control UI page you are currently viewing as an untrusted ambient hint, so requests like "configure this channel" or "why is this page empty?" resolve against the page you are looking at.
147147

‎ui/src/app/app-host.dock-suppression.test.ts‎

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { afterEach, describe, expect, it, vi } from "vitest";
55
import type { GatewayBrowserClient } from "../api/gateway.ts";
66
import type { GatewaySessionRow } from "../api/types.ts";
77
import type { RouteId } from "../app-routes.ts";
8-
import { CUSTODIAN_PANEL_TOGGLE_EVENT } from "../components/panel-toggle-contract.ts";
98
import { createStorageMock } from "../test-helpers/storage.ts";
109
import { resetAppHostTestGlobals } from "./app-host.test-support.ts";
1110
import "./app-host.ts";
@@ -163,15 +162,6 @@ describe("OpenClaw shell dock suppression", () => {
163162

164163
shell.routeState = { routeId: "chat" };
165164
renderLit(shell.render(), container);
166-
const custodianToggle = container.querySelector<HTMLButtonElement>(
167-
".shell-chrome-controls__custodian",
168-
);
169-
expect(custodianToggle).not.toBeNull();
170-
const toggleListener = vi.fn();
171-
window.addEventListener(CUSTODIAN_PANEL_TOGGLE_EVENT, toggleListener);
172-
custodianToggle?.click();
173-
window.removeEventListener(CUSTODIAN_PANEL_TOGGLE_EVENT, toggleListener);
174-
expect(toggleListener).toHaveBeenCalledOnce();
175165
expect(
176166
(
177167
container.querySelector("openclaw-terminal-panel") as HTMLElement & {
@@ -229,22 +219,12 @@ describe("OpenClaw shell dock suppression", () => {
229219
renderLit(shell.render(), container);
230220
expect(desktopAvailable()).toBe(true);
231221

232-
context.gateway.snapshot.hello!.features!.methods = [
233-
"terminal.open",
234-
"browser.request",
235-
"desktop.observe",
236-
];
237-
renderLit(shell.render(), container);
222+
// Collapsed-nav fallback: the Ask OpenClaw toggle joins the chrome strip
223+
// only while the sidebar (its footer home) is hidden, and stays admin-gated.
238224
expect(container.querySelector(".shell-chrome-controls__custodian")).toBeNull();
239-
240-
// Advertised but read-scoped: openclaw.chat requires operator.admin, so the
241-
// control must hide instead of opening a panel the store refuses to use.
242-
context.gateway.snapshot.hello!.features!.methods = [
243-
"terminal.open",
244-
"browser.request",
245-
"openclaw.chat",
246-
"desktop.observe",
247-
];
225+
context.navigation.snapshot.navCollapsed = true;
226+
renderLit(shell.render(), container);
227+
expect(container.querySelector(".shell-chrome-controls__custodian")).not.toBeNull();
248228
context.gateway.snapshot.hello!.auth = { role: "operator", scopes: ["operator.read"] };
249229
renderLit(shell.render(), container);
250230
expect(container.querySelector(".shell-chrome-controls__custodian")).toBeNull();

‎ui/src/app/app-shell-view.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ export function renderApplicationShell(host: ShellViewHost) {
549549
${icons.search}
550550
</button>
551551
</openclaw-tooltip>
552-
${custodianPanelAvailable
552+
${navCollapsed && custodianPanelAvailable
553553
? html`<openclaw-tooltip .content=${t("nav.askOpenClaw")}>
554554
<button
555555
type="button"

‎ui/src/components/app-sidebar-render.ts‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { t } from "../i18n/index.ts";
1414
import { normalizeAgentLabel, resolveAgentTextAvatar } from "../lib/agents/display.ts";
1515
import { deriveAvatarInitial, resolveAgentAvatarUrl } from "../lib/avatar.ts";
1616
import { sessionHasBoard } from "../lib/board/provider.ts";
17+
import { canCallGatewayMethod } from "../lib/gateway-methods.ts";
1718
import { shouldHandleNavigationClick } from "../lib/navigation-click.ts";
1819
import {
1920
resolveSessionPreferredFace,
@@ -30,6 +31,7 @@ import type { AppSidebarSessionNavigationElement } from "./app-sidebar-session-n
3031
import type { SidebarRecentSession } from "./app-sidebar-session-types.ts";
3132
import type { SidebarWorkboardBoard } from "./app-sidebar-workboard.ts";
3233
import { icons } from "./icons.ts";
34+
import { CUSTODIAN_PANEL_TOGGLE_EVENT } from "./panel-toggle-contract.ts";
3335
import {
3436
renderSessionAttentionIcon,
3537
renderSessionRunSpinner,
@@ -249,6 +251,11 @@ export function renderAppSidebarPagesHead(host: AppSidebarRenderHost) {
249251

250252
/** Zone 5: product chrome recedes to one slim footer bar. */
251253
export function renderAppSidebarFooterBar(host: AppSidebarRenderHost) {
254+
const custodianPanelAvailable = canCallGatewayMethod(
255+
host.sessionDataContext?.gateway.snapshot,
256+
"openclaw.chat",
257+
"operator.admin",
258+
);
252259
const selfUser = resolveCurrentSelfUser({
253260
snapshotUser: host.sessionDataContext?.gateway.snapshot.selfUser,
254261
presenceEntries: readPresenceEntries(host.sessionData.presencePayload),
@@ -287,7 +294,11 @@ export function renderAppSidebarFooterBar(host: AppSidebarRenderHost) {
287294
>
288295
<openclaw-viewer-avatar .user=${avatarUser} variant="footer"></openclaw-viewer-avatar>
289296
<span class="sidebar-identity-card__text">
290-
<span class="sidebar-identity-card__name">${selfLabel}</span>
297+
<span class="sidebar-identity-card__name"
298+
>${selfLabel}<span class="sidebar-identity-card__chevron" aria-hidden="true"
299+
>${icons.chevronDown}</span
300+
></span
301+
>
291302
${host.offline
292303
? html`<span class="sidebar-identity-card__subtitle" aria-hidden="true"
293304
>${t("connection.reconnecting")}</span
@@ -314,14 +325,23 @@ export function renderAppSidebarFooterBar(host: AppSidebarRenderHost) {
314325
>`
315326
: nothing}
316327
</span>
317-
<span class="sidebar-identity-card__chevron" aria-hidden="true"
318-
>${icons.chevronDown}</span
328+
<span class="sidebar-identity-card__status" role="status" aria-live="polite"
329+
>${host.offline ? t("connection.reconnecting") : ""}</span
319330
>
320331
</button>
321332
</openclaw-tooltip>
322-
<span class="sidebar-identity-card__status" role="status" aria-live="polite"
323-
>${host.offline ? t("connection.reconnecting") : ""}</span
324-
>
333+
${custodianPanelAvailable
334+
? html`<openclaw-tooltip .content=${t("nav.askOpenClaw")}>
335+
<button
336+
type="button"
337+
class="sidebar-brand__icon sidebar-footer-bar__custodian"
338+
aria-label=${t("nav.askOpenClaw")}
339+
@click=${() => window.dispatchEvent(new CustomEvent(CUSTODIAN_PANEL_TOGGLE_EVENT))}
340+
>
341+
${icons.lobster}
342+
</button>
343+
</openclaw-tooltip>`
344+
: nothing}
325345
</div>
326346
`;
327347
}

‎ui/src/e2e/custodian-panel-toggle.e2e.test.ts‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describeControlUiE2e("Control UI Ask OpenClaw panel toggle mocked Gateway E2E",
6262
await server?.close();
6363
});
6464

65-
it("hides the chrome toggle when openclaw.chat is not advertised", async () => {
65+
it("hides the sidebar footer toggle when openclaw.chat is not advertised", async () => {
6666
const context = await browser.newContext({
6767
colorScheme: "dark",
6868
locale: "en-US",
@@ -76,7 +76,8 @@ describeControlUiE2e("Control UI Ask OpenClaw panel toggle mocked Gateway E2E",
7676
const response = await page.goto(`${server.baseUrl}chat`);
7777
expect(response?.status()).toBe(200);
7878
await page.locator(".shell-chrome-controls__search").waitFor();
79-
await expect.poll(() => page.locator(".shell-chrome-controls__custodian").count()).toBe(0);
79+
await page.locator(".sidebar-identity-card").waitFor();
80+
await expect.poll(() => page.locator(".sidebar-footer-bar__custodian").count()).toBe(0);
8081
await page.screenshot({
8182
animations: "disabled",
8283
path: path.join(artifactDir, "00-gated-off-no-button.png"),
@@ -86,7 +87,7 @@ describeControlUiE2e("Control UI Ask OpenClaw panel toggle mocked Gateway E2E",
8687
}
8788
});
8889

89-
it("toggles the panel from chrome and palette and reuses the persisted session id", async () => {
90+
it("toggles the panel from the sidebar and palette and reuses the persisted session id", async () => {
9091
const context = await browser.newContext({
9192
colorScheme: "dark",
9293
locale: "en-US",
@@ -101,16 +102,16 @@ describeControlUiE2e("Control UI Ask OpenClaw panel toggle mocked Gateway E2E",
101102
const response = await page.goto(`${server.baseUrl}chat`);
102103
expect(response?.status()).toBe(200);
103104

104-
// The lobster chrome button renders only while openclaw.chat is advertised.
105-
const chromeToggle = page.locator(".shell-chrome-controls__custodian");
106-
await chromeToggle.waitFor();
105+
// The lobster footer button renders only while openclaw.chat is advertised.
106+
const footerToggle = page.locator(".sidebar-footer-bar__custodian");
107+
await footerToggle.waitFor();
107108
await page.screenshot({
108109
animations: "disabled",
109-
path: path.join(artifactDir, "01-chrome-button.png"),
110+
path: path.join(artifactDir, "01-sidebar-footer-button.png"),
110111
});
111112

112113
// Opening the panel renders the durable machine-wide history from the Gateway.
113-
await chromeToggle.click();
114+
await footerToggle.click();
114115
const panel = page.locator("openclaw-custodian-panel");
115116
await panel.getByText("Channel repaired.").waitFor();
116117
const chatRequest = await gateway.waitForRequest("openclaw.chat");
@@ -122,13 +123,13 @@ describeControlUiE2e("Control UI Ask OpenClaw panel toggle mocked Gateway E2E",
122123
});
123124

124125
// The same button closes it again.
125-
await chromeToggle.click();
126+
await footerToggle.click();
126127
await panel.getByText("Channel repaired.").waitFor({ state: "hidden" });
127128

128129
// The command palette exposes the same toggle from anywhere. Its action
129-
// dispatches the identical toggle event the chrome button uses (pinned by
130+
// dispatches the identical toggle event the footer button uses (pinned by
130131
// the palette unit test), so this asserts the gated entry exists and
131-
// reopens through the chrome path — the palette click-through composition
132+
// reopens through the footer path — the palette click-through composition
132133
// proved timing-flaky on loaded CI runners without adding coverage.
133134
await page.locator(".shell-chrome-controls__search").click();
134135
await page.getByPlaceholder("Search chats and commands…").fill("Ask OpenClaw");
@@ -139,7 +140,7 @@ describeControlUiE2e("Control UI Ask OpenClaw panel toggle mocked Gateway E2E",
139140
path: path.join(artifactDir, "03-palette-item.png"),
140141
});
141142
await page.keyboard.press("Escape");
142-
await chromeToggle.click();
143+
await footerToggle.click();
143144
await panel.getByText("Channel repaired.").waitFor();
144145

145146
// The server-confirmed session id persists and is reused after a full reload.

‎ui/src/styles/layout.css‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
--shell-chrome-controls-inset: 10px;
1111
--shell-chrome-control-size: 32px;
1212
--shell-chrome-controls-gap: 4px;
13+
/* Four controls: the admin-gated Ask OpenClaw fallback joins the strip only
14+
while the nav is collapsed, which is exactly when this width applies. */
1315
--shell-chrome-controls-collapsed-width: calc(
1416
var(--shell-chrome-control-size) + var(--shell-chrome-control-size) +
1517
var(--shell-chrome-control-size) + var(--shell-chrome-control-size) +
@@ -998,13 +1000,15 @@ openclaw-settings-save-indicator {
9981000
stroke-linejoin: round;
9991001
}
10001002

1001-
.sidebar-brand__new-thread {
1003+
.sidebar-brand__new-thread,
1004+
.sidebar-footer-bar__custodian {
10021005
width: 32px;
10031006
height: 32px;
10041007
color: var(--text);
10051008
}
10061009

1007-
.sidebar-brand__new-thread svg {
1010+
.sidebar-brand__new-thread svg,
1011+
.sidebar-footer-bar__custodian svg {
10081012
width: 18px;
10091013
height: 18px;
10101014
}
@@ -3353,12 +3357,14 @@ wa-dropdown-item.session-menu__item::part(submenu-icon) {
33533357
.sidebar-footer-bar {
33543358
display: flex;
33553359
align-items: center;
3360+
gap: 8px;
33563361
padding: 6px 12px;
33573362
}
33583363

33593364
.sidebar-identity-card {
33603365
display: flex;
33613366
align-items: center;
3367+
flex: 1 1 auto;
33623368
gap: 8px;
33633369
width: 100%;
33643370
min-width: 0;
@@ -3407,6 +3413,9 @@ wa-dropdown-item.session-menu__item::part(submenu-icon) {
34073413
}
34083414

34093415
.sidebar-identity-card__name {
3416+
display: flex;
3417+
align-items: center;
3418+
gap: 4px;
34103419
color: var(--text-strong);
34113420
font-size: calc(13px * var(--control-ui-text-scale));
34123421
font-weight: 600;

‎ui/src/test-helpers/app-sidebar-cases/basics.ts‎

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { describe, expect, it, vi } from "vitest";
22
import type { GatewayBrowserClient } from "../../api/gateway.ts";
33
import type { AgentsListResult } from "../../api/types.ts";
44
import { sessionRefFromPath } from "../../app-session-route-paths.ts";
5+
import type { ApplicationGatewaySnapshot } from "../../app/context.ts";
6+
import { CUSTODIAN_PANEL_TOGGLE_EVENT } from "../../components/panel-toggle-contract.ts";
57
import {
68
clearSessionBoardAvailability,
79
recordSessionBoardAvailability,
@@ -195,7 +197,7 @@ describe("AppSidebar viewer presence", () => {
195197
).toEqual(["Alice", "[email protected]", "Carol", "Dave\nErin\nFrank"]);
196198

197199
const identityCard = sidebar.querySelector<HTMLButtonElement>(".sidebar-identity-card");
198-
expect(identityCard?.querySelector(".sidebar-identity-card__name")?.textContent).toBe(
200+
expect(identityCard?.querySelector(".sidebar-identity-card__name")?.textContent?.trim()).toBe(
199201
"Self User",
200202
);
201203
expect(identityCard?.querySelector('[data-viewer-id="00-self"]')).not.toBeNull();
@@ -208,7 +210,7 @@ describe("AppSidebar viewer presence", () => {
208210
expect(footer?.querySelector(".sidebar-brand__logo-slot")).toBeNull();
209211
expect([...(footer?.children ?? [])].map((element) => element.localName)).toEqual([
210212
"openclaw-tooltip",
211-
"span",
213+
"openclaw-tooltip",
212214
]);
213215
gatewayHarness.gateway.updateSelfUser?.({
214216
name: "Augusta Ada",
@@ -217,14 +219,16 @@ describe("AppSidebar viewer presence", () => {
217219
await sidebar.updateComplete;
218220

219221
// Profile mutations update gateway state directly; no presence event follows them.
220-
expect(identityCard?.querySelector(".sidebar-identity-card__name")?.textContent).toBe(
222+
expect(identityCard?.querySelector(".sidebar-identity-card__name")?.textContent?.trim()).toBe(
221223
"Augusta Ada",
222224
);
223225
expect(avatar?.getAttribute("src")).toBe("/api/users/00-self/avatar?v=4");
224226

225227
sidebar.connected = false;
226228
await sidebar.updateComplete;
227-
expect(sidebar.querySelector(".sidebar-identity-card__name")?.textContent).toBe("Augusta Ada");
229+
expect(sidebar.querySelector(".sidebar-identity-card__name")?.textContent?.trim()).toBe(
230+
"Augusta Ada",
231+
);
228232
});
229233

230234
it("renders an Account fallback for an unidentified connection", async () => {
@@ -244,7 +248,7 @@ describe("AppSidebar viewer presence", () => {
244248
await sidebar.updateComplete;
245249

246250
const identityCard = sidebar.querySelector(".sidebar-identity-card");
247-
expect(identityCard?.querySelector(".sidebar-identity-card__name")?.textContent).toBe(
251+
expect(identityCard?.querySelector(".sidebar-identity-card__name")?.textContent?.trim()).toBe(
248252
"Account",
249253
);
250254
expect(identityCard?.querySelector('[data-viewer-id="account"]')?.textContent).toContain("A");
@@ -295,6 +299,49 @@ describe("AppSidebar brand actions", () => {
295299
});
296300
});
297301

302+
describe("AppSidebar footer actions", () => {
303+
it("gates Ask OpenClaw on the advertised method and admin scope", async () => {
304+
const gatewayHarness = createGatewayHarness({} as GatewayBrowserClient);
305+
const { sidebar } = await mountSidebar(
306+
gatewayHarness.gateway,
307+
createSessions("main", ["agent:main:main"]),
308+
);
309+
310+
gatewayHarness.publish({
311+
hello: {
312+
auth: { role: "operator", scopes: ["operator.admin"] },
313+
features: { methods: ["openclaw.chat"] },
314+
} as ApplicationGatewaySnapshot["hello"],
315+
});
316+
await sidebar.updateComplete;
317+
const toggle = sidebar.querySelector<HTMLButtonElement>(".sidebar-footer-bar__custodian");
318+
expect(toggle?.getAttribute("aria-label")).toBe("Ask OpenClaw");
319+
const toggleListener = vi.fn();
320+
window.addEventListener(CUSTODIAN_PANEL_TOGGLE_EVENT, toggleListener);
321+
toggle?.click();
322+
window.removeEventListener(CUSTODIAN_PANEL_TOGGLE_EVENT, toggleListener);
323+
expect(toggleListener).toHaveBeenCalledOnce();
324+
325+
gatewayHarness.publish({
326+
hello: {
327+
auth: { role: "operator", scopes: ["operator.admin"] },
328+
features: { methods: [] as string[] },
329+
} as ApplicationGatewaySnapshot["hello"],
330+
});
331+
await sidebar.updateComplete;
332+
expect(sidebar.querySelector(".sidebar-footer-bar__custodian")).toBeNull();
333+
334+
gatewayHarness.publish({
335+
hello: {
336+
auth: { role: "operator", scopes: ["operator.read"] },
337+
features: { methods: ["openclaw.chat"] },
338+
} as ApplicationGatewaySnapshot["hello"],
339+
});
340+
await sidebar.updateComplete;
341+
expect(sidebar.querySelector(".sidebar-footer-bar__custodian")).toBeNull();
342+
});
343+
});
344+
298345
describe("AppSidebar agent chip", () => {
299346
it("qualifies unscoped session rows with the selected agent", async () => {
300347
const gateway = createGateway({} as GatewayBrowserClient);
@@ -431,7 +478,9 @@ describe("AppSidebar agent chip", () => {
431478
sidebar.offline = true;
432479
await sidebar.updateComplete;
433480
const card = sidebar.querySelector<HTMLButtonElement>(".sidebar-identity-card");
434-
expect(card?.querySelector(".sidebar-identity-card__name")?.textContent).toBe("Account");
481+
expect(card?.querySelector(".sidebar-identity-card__name")?.textContent?.trim()).toBe(
482+
"Account",
483+
);
435484
expect(card?.querySelector(".sidebar-identity-card__subtitle")?.textContent).toBe(
436485
"Reconnecting…",
437486
);

0 commit comments

Comments
 (0)