Skip to content

Commit 917fab2

Browse files
authored
fix(ui): align Inbox popover tabs with hub tabs and theme the mascot icon (#128256)
* fix(ui): align Inbox popover tabs with hub tabs and theme the mascot icon The sidebar Inbox popover reinvented its tab strip: pill-highlight tabs floating above an unrelated hairline, counts glued to labels as bare text, zero counts always rendered, and a doubled focus ring (Web Awesome's stock host outline plus the panel's own part ring). Replace the hand-rolled strip with the shared renderHubTabs sub variant so the popover gets the system's underline indicator, track hairline (doubling as the header separator), pill count badges, and single focus ring; zero counts drop their badge. The Ask OpenClaw lobster icon hardcoded a light-surface red gradient that sank into dark backgrounds; its colors now flow through --lobster-icon-* theme tokens (brighter stops in dark, original artwork in light). Also removes the dead focusTab branch in selectTab. * test(ui): match Inbox approvals tab accessible name to hub-tab content The hub-tab strip names tabs by visible content (label + badge count), not the removed per-tab aria-label. * fix(ui): forward hub-tab aria-label to the shadow tablist Web Awesome does not forward the host aria-label to its internal [role=tablist], so every renderHubTabs surface (and the Inbox popover after its hub-tab migration) lost the tablist's accessible name. Route the label through syncTabGroupLabel inside the shared renderer and assert the shadow tablist label.
1 parent 7941c05 commit 917fab2

9 files changed

Lines changed: 112 additions & 117 deletions

‎ui/src/components/hub-tabs.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,35 @@ describe("renderHubTabs", () => {
2828
expect(container.querySelector("#example-tab-memory .hub-tab__badge")?.textContent).toBe("New");
2929
});
3030

31+
it("forwards the aria-label to the shadow tablist", async () => {
32+
const container = document.createElement("div");
33+
document.body.append(container);
34+
try {
35+
render(
36+
renderHubTabs({
37+
id: "example",
38+
active: "files",
39+
tabs: [{ value: "files", label: "Files" }],
40+
ariaLabel: "Example sections",
41+
panelId: "example-panel",
42+
onSelect: () => undefined,
43+
}),
44+
container,
45+
);
46+
const group = container.querySelector<HTMLElement & { updateComplete: Promise<unknown> }>(
47+
"wa-tab-group",
48+
);
49+
await group?.updateComplete;
50+
// syncTabGroupLabel resolves on the same updateComplete chain; yield once more.
51+
await group?.updateComplete;
52+
expect(group?.shadowRoot?.querySelector('[role="tablist"]')?.getAttribute("aria-label")).toBe(
53+
"Example sections",
54+
);
55+
} finally {
56+
container.remove();
57+
}
58+
});
59+
3160
it("selects only enabled tabs from direct user activation", () => {
3261
const onSelect = vi.fn();
3362
const container = document.createElement("div");

‎ui/src/components/hub-tabs.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { html, nothing, type TemplateResult } from "lit";
22
import { ref } from "lit/directives/ref.js";
33
import "../styles/hub-tabs.css";
4-
import "./web-awesome-tabs.ts";
4+
import { syncTabGroupLabel } from "./web-awesome-tabs.ts";
55

66
export type HubTabOption<T extends string> = {
77
value: T;
@@ -73,6 +73,7 @@ export function renderHubTabs<T extends string>(props: HubTabsProps<T>): Templat
7373
.active=${props.active ?? NO_ACTIVE_TAB}
7474
activation="manual"
7575
without-scroll-controls
76+
${ref((element) => syncTabGroupLabel(element, props.ariaLabel))}
7677
>
7778
${props.tabs.map((tab) => {
7879
const selected = props.active === tab.value;

‎ui/src/components/icons-tools.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,13 @@ export const toolIcons = {
197197
lobster: html`
198198
<svg viewBox="0 0 120 120" fill="none">
199199
<defs>
200+
<!-- Gradient stops read theme tokens (base.css --lobster-icon-*): the
201+
shipped hex pair sank into dark backgrounds, so dark mode brightens
202+
both stops while light mode keeps the original artwork. var() is
203+
only valid in style="", not presentation attributes. -->
200204
<linearGradient id="lob-g" x1="0%" y1="0%" x2="100%" y2="100%">
201-
<stop offset="0%" stop-color="#ff4d4d" />
202-
<stop offset="100%" stop-color="#991b1b" />
205+
<stop offset="0%" style="stop-color: var(--lobster-icon-body, #ff4d4d)" />
206+
<stop offset="100%" style="stop-color: var(--lobster-icon-shade, #991b1b)" />
203207
</linearGradient>
204208
</defs>
205209
<path
@@ -211,10 +215,20 @@ export const toolIcons = {
211215
d="M100 45C115 40 120 50 115 60C110 70 100 65 95 55C92 48 95 45 100 45Z"
212216
fill="url(#lob-g)"
213217
/>
214-
<path d="M45 15Q35 5 30 8" stroke="#ff4d4d" stroke-width="3" stroke-linecap="round" />
215-
<path d="M75 15Q85 5 90 8" stroke="#ff4d4d" stroke-width="3" stroke-linecap="round" />
216-
<circle cx="45" cy="35" r="6" fill="#050810" />
217-
<circle cx="75" cy="35" r="6" fill="#050810" />
218+
<path
219+
d="M45 15Q35 5 30 8"
220+
style="stroke: var(--lobster-icon-body, #ff4d4d)"
221+
stroke-width="3"
222+
stroke-linecap="round"
223+
/>
224+
<path
225+
d="M75 15Q85 5 90 8"
226+
style="stroke: var(--lobster-icon-body, #ff4d4d)"
227+
stroke-width="3"
228+
stroke-linecap="round"
229+
/>
230+
<circle cx="45" cy="35" r="6" style="fill: var(--lobster-icon-eye, #050810)" />
231+
<circle cx="75" cy="35" r="6" style="fill: var(--lobster-icon-eye, #050810)" />
218232
<circle cx="46" cy="34" r="2.5" fill="#00e5cc" />
219233
<circle cx="76" cy="34" r="2.5" fill="#00e5cc" />
220234
</svg>

‎ui/src/components/sidebar-attention-layout.browser.test.ts‎

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
import { afterEach, describe, expect, it } from "vitest";
22
import "../test-helpers/load-styles.ts";
3+
import "../styles/hub-tabs.css";
34
import "../styles/sidebar-issues.css";
45
import "./web-awesome-tabs.ts";
56

67
afterEach(() => document.body.replaceChildren());
78

89
describe.runIf("__vitest_browser__" in globalThis)("Inbox panel layout", () => {
9-
it("keeps tabs compact and item rails flush with the scrollport", async () => {
10+
it("keeps hub tabs compact and item rails flush with the scrollport", async () => {
1011
const fixture = document.createElement("section");
1112
fixture.className = "sidebar-issues-panel";
1213
fixture.style.position = "static";
1314
fixture.style.width = "390px";
1415
fixture.style.height = "220px";
1516
fixture.innerHTML = `
16-
<wa-tab-group class="sidebar-issues-panel__tabs" without-scroll-controls>
17+
<wa-tab-group class="hub-tabs hub-tabs--sub sidebar-issues-panel__tabs" without-scroll-controls>
1718
${["All", "Approvals", "Automations", "System"]
1819
.map(
1920
(label, index) => `<wa-tab
2021
slot="nav"
21-
class="sidebar-issues-panel__tab"
22+
class="hub-tab"
2223
panel="tab-${index}"
2324
${index === 0 ? "active" : ""}
24-
><span>${label}</span><span class="sidebar-issues-panel__tab-count">${index}</span></wa-tab>`,
25+
>${label}${index > 0 ? `<span class="hub-tab__badge hub-tab__badge--count">${index}</span>` : ""}</wa-tab>`,
2526
)
2627
.join("")}
2728
</wa-tab-group>
@@ -45,32 +46,36 @@ describe.runIf("__vitest_browser__" in globalThis)("Inbox panel layout", () => {
4546
const header = document.createElement("header");
4647
header.className = "sidebar-issues-panel__header";
4748
fixture.prepend(header);
48-
const tab = fixture.querySelector<HTMLElement & { updateComplete: Promise<unknown> }>(
49-
".sidebar-issues-panel__tab",
50-
);
49+
const badgeTab = fixture.querySelectorAll<HTMLElement & { updateComplete: Promise<unknown> }>(
50+
".hub-tab",
51+
)[1];
5152
expect(group).not.toBeNull();
52-
expect(tab).not.toBeNull();
53+
expect(badgeTab).not.toBeNull();
5354
await group?.updateComplete;
54-
await tab?.updateComplete;
55+
await badgeTab?.updateComplete;
5556

56-
const base = tab?.shadowRoot?.querySelector<HTMLElement>("[part='base']");
57-
const label = tab?.querySelector<HTMLElement>("span:first-child");
58-
const count = tab?.querySelector<HTMLElement>(".sidebar-issues-panel__tab-count");
57+
const badge = badgeTab!.querySelector<HTMLElement>(".hub-tab__badge");
5958
const list = fixture.querySelector<HTMLElement>(".sidebar-issues-panel__list");
6059
const item = fixture.querySelector<HTMLElement>("[data-attention-kind]");
6160
const summary = fixture.querySelector<HTMLElement>(".sidebar-issues-panel__summary");
61+
const track = group!.shadowRoot?.querySelector<HTMLElement>(".tabs");
6262

6363
expect(group?.scrollWidth).toBe(group?.clientWidth);
6464
expect(getComputedStyle(group!).overflowX).toBe("hidden");
6565
expect(getComputedStyle(group!).backgroundColor).toBe(getComputedStyle(header).backgroundColor);
6666
expect(getComputedStyle(group!).backgroundColor).not.toBe(
6767
getComputedStyle(list!).backgroundColor,
6868
);
69-
expect(getComputedStyle(group!).borderBottomWidth).toBe("1px");
70-
expect(getComputedStyle(base!).padding).toBe("4px 8px");
71-
expect(
72-
count!.getBoundingClientRect().left - label!.getBoundingClientRect().right,
73-
).toBeGreaterThan(4);
69+
// The track hairline is the header/list separator; it must span the panel.
70+
expect(track).not.toBeNull();
71+
expect(Number.parseFloat(getComputedStyle(track!).borderBottomWidth)).toBeGreaterThan(0);
72+
expect(track!.getBoundingClientRect().width).toBeCloseTo(
73+
group!.getBoundingClientRect().width,
74+
1,
75+
);
76+
// Count badges render as pills separated from the tab label.
77+
expect(badge).not.toBeNull();
78+
expect(getComputedStyle(badge!).borderRadius).not.toBe("0px");
7479
expect(getComputedStyle(summary!).paddingBlock).toBe("8px");
7580
expect(item!.getBoundingClientRect().right).toBeCloseTo(list!.getBoundingClientRect().right, 1);
7681
});

‎ui/src/components/sidebar-attention-panel.runtime.ts‎

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { html, nothing, type TemplateResult } from "lit";
2-
import { ref } from "lit/directives/ref.js";
32
import type { NavigationRouteId } from "../app-navigation.ts";
43
import type { ApplicationContext } from "../app/context.ts";
54
import type { ExecApprovalDecision, ExecApprovalRequest } from "../app/exec-approval.ts";
65
import type { UpdateProgress } from "../app/update-confirmation.ts";
76
import { t } from "../i18n/index.ts";
87
import "../styles/sidebar-issues.css";
8+
import { renderHubTabs } from "./hub-tabs.ts";
99
import { icons } from "./icons.ts";
1010
import type { SidebarAttentionItem } from "./sidebar-attention-items.ts";
1111
import {
@@ -15,7 +15,6 @@ import {
1515
renderSidebarUpdateSurface,
1616
} from "./sidebar-issue-item.ts";
1717
import { ISSUE_TABS, issueTabLabel, type IssueTab } from "./sidebar-issues-tabs.ts";
18-
import { syncTabGroupLabel } from "./web-awesome-tabs.ts";
1918
import "./menu-surface.ts";
2019

2120
type SidebarAttentionPanelParams = {
@@ -39,28 +38,6 @@ type SidebarAttentionPanelParams = {
3938
watchUpdateProgress?: (listener: (progress: UpdateProgress) => void) => () => void;
4039
};
4140

42-
function isIssueTab(value: string): value is IssueTab {
43-
return ISSUE_TABS.some((tab) => tab === value);
44-
}
45-
46-
function renderTab(tab: IssueTab, count: number, selected: boolean) {
47-
const countLabel = t(count === 1 ? "attention.issueCount" : "attention.issueCountPlural", {
48-
count: String(count),
49-
});
50-
return html`<wa-tab
51-
slot="nav"
52-
id=${`sidebar-issues-tab-${tab}`}
53-
class="sidebar-issues-panel__tab"
54-
panel=${tab}
55-
aria-label=${`${issueTabLabel(tab)}, ${countLabel}`}
56-
aria-controls="sidebar-issues-tabpanel"
57-
?active=${selected}
58-
>
59-
<span>${issueTabLabel(tab)}</span>
60-
<span class="sidebar-issues-panel__tab-count" aria-hidden="true">${count}</span>
61-
</wa-tab>`;
62-
}
63-
6441
export function renderSidebarAttentionPanel(params: SidebarAttentionPanelParams): TemplateResult {
6542
const automationItems = params.items.filter(
6643
(item) => item.kind === "cronFailed" || item.kind === "cronOverdue",
@@ -154,21 +131,22 @@ export function renderSidebarAttentionPanel(params: SidebarAttentionPanelParams)
154131
${icons.x}
155132
</button>
156133
</header>
157-
<wa-tab-group
158-
class="sidebar-issues-panel__tabs"
159-
aria-label=${t("attention.tabs.label")}
160-
.active=${params.selectedTab}
161-
activation="auto"
162-
without-scroll-controls
163-
${ref((element) => syncTabGroupLabel(element, t("attention.tabs.label")))}
164-
@wa-tab-show=${(event: CustomEvent<{ name: string }>) => {
165-
if (isIssueTab(event.detail.name)) {
166-
params.onSelectTab(event.detail.name);
167-
}
168-
}}
169-
>
170-
${ISSUE_TABS.map((tab) => renderTab(tab, tabCounts[tab], tab === params.selectedTab))}
171-
</wa-tab-group>
134+
${renderHubTabs<IssueTab>({
135+
id: "sidebar-issues",
136+
active: params.selectedTab,
137+
tabs: ISSUE_TABS.map((tab) => ({
138+
value: tab,
139+
label: issueTabLabel(tab),
140+
// A zero count is the tab's resting state, not information — show
141+
// the badge only when the tab actually holds items.
142+
count: tabCounts[tab] > 0 ? tabCounts[tab] : null,
143+
})),
144+
ariaLabel: t("attention.tabs.label"),
145+
panelId: "sidebar-issues-tabpanel",
146+
className: "sidebar-issues-panel__tabs",
147+
variant: "sub",
148+
onSelect: params.onSelectTab,
149+
})}
172150
<div class="sidebar-issues-panel__list-wrap">
173151
<div
174152
id="sidebar-issues-tabpanel"

‎ui/src/components/sidebar-attention.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class SidebarAttention extends OpenClawLightDomContentsElement {
466466
}
467467
};
468468

469-
private selectTab(tab: IssueTab, focusTab = false) {
469+
private selectTab(tab: IssueTab) {
470470
this.selectedTab = tab;
471471
void this.updateComplete.then(() => {
472472
if (!this.panelOpen || this.selectedTab !== tab) {
@@ -477,9 +477,6 @@ class SidebarAttention extends OpenClawLightDomContentsElement {
477477
list.scrollTop = 0;
478478
}
479479
this.syncOverflowCue();
480-
if (focusTab) {
481-
this.querySelector<HTMLElement>(`#sidebar-issues-tab-${tab}`)?.focus();
482-
}
483480
});
484481
}
485482

‎ui/src/e2e/approval-flow.e2e.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ suite.define(() => {
137137
await inboxPanel.locator('[data-approval-id="approval-inline"]').waitFor();
138138
await inboxPanel.locator('[data-approval-id="approval-other"]').waitFor();
139139
await expect.poll(() => inboxPanel.locator("[data-approval-id]").count()).toBe(2);
140-
await inboxPanel.getByRole("tab", { name: "Approvals, 2 inbox items" }).waitFor();
140+
await inboxPanel.getByRole("tab", { name: "Approvals 2" }).waitFor();
141141
if (captureUiProof) {
142142
await currentPage.screenshot({ path: path.join(proofDir, "02-open-queue.png") });
143143
}

‎ui/src/styles/base.css‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@
8989
--inbox-attention-hover: color-mix(in srgb, var(--inbox-attention) 88%, black);
9090
--inbox-attention-foreground: #ffffff;
9191

92+
/* Lobster mascot icon (icons-tools.ts). Dark surfaces swallowed the shipped
93+
#ff4d4d→#991b1b gradient, so dark mode lifts both stops; light mode
94+
restores the original artwork below. */
95+
--lobster-icon-body: #ff6d5a;
96+
--lobster-icon-shade: #c2372b;
97+
--lobster-icon-eye: #050810;
98+
9299
/* Link text keeps the accent hue but cannot be --accent: chat paints user
93100
bubbles from that same token, so a link there fights its own background.
94101
Derived, not per-theme — --accent-hover is every palette's audited lifted
@@ -544,6 +551,11 @@
544551
--primary: #bd4531;
545552
--primary-foreground: #ffffff;
546553

554+
/* Original lobster artwork reads well on light surfaces. */
555+
--lobster-icon-body: #ff4d4d;
556+
--lobster-icon-shade: #991b1b;
557+
--lobster-icon-eye: #050810;
558+
547559
--secondary: #f4f1ec;
548560
--secondary-foreground: #403c35;
549561
--accent-2: #0d9488;

‎ui/src/styles/sidebar-issues.css‎

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -147,67 +147,26 @@
147147
scroll-padding-block-end: 58px;
148148
}
149149

150+
/* Hub-tab strip (shared hub-tabs.css owns the tab look); this block only
151+
places it in the popover: the track hairline doubles as the header/list
152+
separator, so it must span the full panel width. */
150153
.sidebar-issues-panel__tabs {
151154
display: block;
152155
flex: none;
153156
overflow: hidden;
154-
border-block-end: 1px solid var(--border);
155157
background: var(--secondary);
156-
--indicator-color: transparent;
157-
--track-color: transparent;
158-
--track-width: 0;
159158
}
160159

161160
.sidebar-issues-panel__tabs::part(tabs) {
162161
box-sizing: border-box;
163162
width: 100%;
164-
gap: 2px;
165-
padding: 0 6px 8px;
163+
padding-inline: 8px;
166164
}
167165

168-
.sidebar-issues-panel__tab {
169-
display: block;
170-
min-width: 0;
171-
flex: 1 1 0;
172-
padding: 0;
173-
border: 0;
174-
background: transparent;
175-
color: var(--muted);
176-
cursor: var(--cursor-action);
177-
font: inherit;
178-
font-size: var(--control-ui-text-xs);
179-
font-weight: 600;
180-
white-space: nowrap;
181-
}
182-
183-
.sidebar-issues-panel__tab::part(base) {
184-
box-sizing: border-box;
185-
width: 100%;
186-
min-height: 32px;
187-
justify-content: center;
188-
gap: 5px;
189-
padding: 4px 8px;
190-
border-radius: var(--radius-md);
191-
}
192-
193-
.sidebar-issues-panel__tab:hover::part(base) {
194-
background: var(--bg-hover);
195-
color: var(--text);
196-
}
197-
198-
.sidebar-issues-panel__tab:is([active], [aria-selected="true"])::part(base) {
199-
background: color-mix(in srgb, var(--bg-hover) 92%, var(--text) 8%);
200-
color: var(--text-strong);
201-
}
202-
203-
.sidebar-issues-panel__tab:focus-visible::part(base) {
204-
outline: none;
205-
box-shadow: var(--focus-ring);
206-
}
207-
208-
.sidebar-issues-panel__tab-count {
209-
color: var(--muted);
210-
font-variant-numeric: tabular-nums;
166+
.sidebar-issues-panel__tabs wa-tab.hub-tab::part(base) {
167+
/* Popover tabs are tap targets (mobile sheet); keep a taller hit area than
168+
the page-hub sub tabs. */
169+
padding-block: 6px 9px;
211170
}
212171

213172
.sidebar-issues-panel__list-wrap {

0 commit comments

Comments
 (0)