Skip to content

Commit 295f2c0

Browse files
authored
fix(ui): align the sidebar to a shared grid and dedupe owner presence (#123938)
* test(ui): add sidebar alignment capture harness * fix(ui): align sidebar rows to shared grid * fix(ui): distinguish sidebar owner presence * fix(ui): visually hide sidebar pages label * fix(ui): collapse the hidden pages head row * fix(ui): keep the floating pages action clickable * fix(ui): scope facepile dedup to the rendered lead and reveal the pages editor on touch ClawSweeper P1s on #123938: the facepile unconditionally excluded the session creator even when the lead chip showed the archivist or nothing at all, hiding a live viewer; renderSessionLeadingState now returns the rendered owner identity as the single dedup source. The hover-revealed pages editor gains the standard hoverless-pointer visibility override.
1 parent 4f4cef6 commit 295f2c0

18 files changed

Lines changed: 374 additions & 91 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export function renderAppSidebarHomeRow(host: AppSidebarRenderHost) {
227227
export function renderAppSidebarPagesHead(host: AppSidebarRenderHost) {
228228
return html`
229229
<div class="sidebar-nav__head">
230-
<span class="sidebar-recent-sessions__label-text">${t("nav.pages")}</span>
230+
<span class="sidebar-recent-sessions__label-text sr-only">${t("nav.pages")}</span>
231231
<button
232232
type="button"
233233
class="sidebar-nav__head-action"

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ function renderCatalogHostGroup(
313313
aria-label=${errorHelp ? `${host.label}: ${errorHelp}` : host.label}
314314
title=${errorHelp ?? host.label}
315315
>
316+
<span class="sidebar-session-group-toggle__lead" aria-hidden="true">
317+
<span class="sidebar-session-group-toggle__icon">${icons.monitor}</span>
318+
</span>
316319
<span class="sidebar-session-catalog-host__label">${host.label}</span>
317320
<span
318321
class="sidebar-session-catalog-host__count ${host.error
@@ -475,6 +478,7 @@ function renderCatalogSessionRow(
475478
}
476479
}}
477480
>
481+
<span class="sidebar-session-indicator"></span>
478482
<span class="sidebar-recent-session__text">
479483
<span class="sidebar-recent-session__name hover-marquee">${label}</span>
480484
</span>

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

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
resolveSidebarSessionSubtitle,
4141
} from "./session-row-subtitle.ts";
4242
import type { SidebarMenusController } from "./sidebar-menus-controller.ts";
43+
import { projectPresencePayload } from "./viewer-facepile.ts";
4344
import "./elapsed-time.ts";
4445

4546
const SIDEBAR_VISIBLE_CHILD_SESSION_LIMIT = 4;
@@ -180,12 +181,22 @@ export function renderRecentSession(params: {
180181
? session.archivedBy
181182
: session.createdActor
182183
: undefined;
183-
const { running, leadingIndicator, trailingIndicator } = renderSessionLeadingState(
184-
session,
185-
pullRequestState,
186-
ownerActor,
187-
ownerAttribution,
188-
);
184+
const ownerId = ownerActor?.id?.trim();
185+
const ownerViewing = ownerId
186+
? projectPresencePayload(
187+
host.sessionData.presencePayload,
188+
host.sessionDataContext?.gateway.snapshot.selfUser?.id,
189+
host.sessionData.presenceInstanceId,
190+
).users.some((user) => user.id === ownerId && user.watchedSessions.includes(session.key))
191+
: undefined;
192+
const { running, leadingIndicator, trailingIndicator, renderedOwnerId } =
193+
renderSessionLeadingState(
194+
session,
195+
pullRequestState,
196+
ownerActor,
197+
ownerAttribution,
198+
ownerViewing,
199+
);
189200
const trailingDescription = session.isChild
190201
? ""
191202
: describeSessionTrailingState(session, pullRequestState);
@@ -242,8 +253,7 @@ export function renderRecentSession(params: {
242253
requiredScope: "operator.write",
243254
});
244255
const rowDraggable = !session.isChild && groupWriteAccess.allowed;
245-
// Empty 16/20px lead columns indent titles past section labels and siblings.
246-
const showLead = leadingIndicator !== nothing || session.visibility === "draft";
256+
// Always reserve the lead so every title shares the section-label text line.
247257
const row = html`
248258
<div
249259
class=${rowClass}
@@ -278,18 +288,14 @@ export function renderRecentSession(params: {
278288
aria-describedby=${[stateId, metaId].filter(Boolean).join(" ") || nothing}
279289
@click=${(event: MouseEvent) => host.handleSessionRowClick(event, session)}
280290
>
281-
${showLead
282-
? html`<span class="sidebar-session-indicator"
283-
>${leadingIndicator}
284-
${session.visibility === "draft"
285-
? html`<span
286-
class="session-row-draft-indicator"
287-
title=${t("chat.sessionSharing.draft")}
288-
>👻</span
289-
>`
290-
: nothing}</span
291-
>`
292-
: nothing}
291+
<span class="sidebar-session-indicator"
292+
>${leadingIndicator}
293+
${session.visibility === "draft"
294+
? html`<span class="session-row-draft-indicator" title=${t("chat.sessionSharing.draft")}
295+
>👻</span
296+
>`
297+
: nothing}</span
298+
>
293299
<span class="sidebar-recent-session__text">
294300
<span class="sidebar-recent-session__name hover-marquee"
295301
>${session.archived
@@ -317,6 +323,7 @@ export function renderRecentSession(params: {
317323
.selfUserId=${host.sessionDataContext?.gateway.snapshot.selfUser?.id}
318324
.selfInstanceId=${host.sessionData.presenceInstanceId}
319325
.sessionKey=${session.key}
326+
.excludeUserId=${renderedOwnerId}
320327
.maxVisible=${3}
321328
variant="session"
322329
></openclaw-viewer-facepile>

‎ui/src/components/session-leading-indicator.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { html, nothing } from "lit";
1+
import { html, nothing, type TemplateResult } from "lit";
22
import { t } from "../i18n/index.ts";
33
import type { SidebarRecentSession } from "./app-sidebar-session-types.ts";
44
import { icons } from "./icons.ts";
@@ -106,7 +106,13 @@ export function renderSessionLeadingState(
106106
pullRequestState: SessionPullRequestIndicatorState,
107107
ownerActor: SessionCreatedActor | null | undefined,
108108
attribution: "created" | "archived",
109-
) {
109+
ownerViewing?: boolean,
110+
): {
111+
running: boolean;
112+
leadingIndicator: TemplateResult | typeof nothing;
113+
trailingIndicator: TemplateResult | typeof nothing;
114+
renderedOwnerId?: string;
115+
} {
110116
const running = session.hasActiveRun;
111117
const trailingIndicator = session.isChild
112118
? nothing
@@ -159,11 +165,14 @@ export function renderSessionLeadingState(
159165
return {
160166
running,
161167
leadingIndicator: renderSessionGlyph({
162-
content: renderSessionOwnerChip(ownerActor, "row", attribution),
168+
content: renderSessionOwnerChip(ownerActor, "row", attribution, ownerViewing),
163169
running: false,
164170
circular: true,
165171
}),
166172
trailingIndicator,
173+
// Single source for facepile dedup: only the identity actually shown in
174+
// the lead may be excluded, else attention/archived rows hide a viewer.
175+
renderedOwnerId: ownerActor.id,
167176
};
168177
}
169178
return {

‎ui/src/components/session-owner-chip.ts‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ export function renderSessionOwnerChip(
4848
createdActor: SessionCreatedActor | null | undefined,
4949
size: "row" | "header",
5050
attribution: "created" | "archived" = "created",
51+
viewingNow?: boolean,
5152
) {
5253
return createdActor?.id
5354
? html`<openclaw-session-owner-chip
5455
.createdActor=${createdActor}
5556
size=${size}
5657
attribution=${attribution}
58+
.viewingNow=${viewingNow}
5759
></openclaw-session-owner-chip>`
5860
: nothing;
5961
}
@@ -84,18 +86,17 @@ function ownerHue(id: string): number {
8486
}
8587

8688
/**
87-
* Permanent session-owner avatar. Ownership is provenance, not presence:
88-
* this chip is solid and never pulses/expires, in deliberate contrast to the
89-
* translucent, ring-styled live-presence chips. Render only when the gateway
90-
* has 2+ distinct creator identities (solo mode shows no attribution chrome).
91-
* Human actors use only the durable profile projection carried by the session
92-
* record. Actors without that source keep stable initials because provenance
93-
* outlives live connection presence.
89+
* Permanent session-owner avatar. Ownership is provenance, so the chip remains
90+
* when its owner leaves; live viewing only changes avatar saturation. Render
91+
* only when the gateway has 2+ distinct creator identities (solo mode shows no
92+
* attribution chrome). Human actors use the durable profile projection carried
93+
* by the session record; actors without it keep stable initials.
9494
*/
9595
class SessionOwnerChip extends OpenClawLightDomElement {
9696
@property({ attribute: false }) createdActor: SessionCreatedActor | null = null;
9797
@property({ type: String }) size: "row" | "header" = "row";
9898
@property({ type: String }) attribution: "created" | "archived" = "created";
99+
@property({ attribute: false }) viewingNow?: boolean;
99100

100101
override render() {
101102
const createdActor = this.createdActor;
@@ -107,10 +108,13 @@ class SessionOwnerChip extends OpenClawLightDomElement {
107108
return nothing;
108109
}
109110
const title = createdActor.label || createdActor.id;
110-
const accessibleLabel = t(
111+
const attributionLabel = t(
111112
this.attribution === "archived" ? "sessionsView.archivedBy" : "sessionsView.createdBy",
112113
{ name: title },
113114
);
115+
const accessibleLabel = this.viewingNow
116+
? `${attributionLabel} · ${t("sessionsView.viewingNow")}`
117+
: attributionLabel;
114118
const avatar = createdActor.avatarUrl
115119
? resolveAvatar({
116120
id: createdActor.id,
@@ -120,7 +124,9 @@ class SessionOwnerChip extends OpenClawLightDomElement {
120124
: null;
121125
return html`
122126
<span
123-
class="session-owner-chip session-owner-chip--${this.size}"
127+
class="session-owner-chip session-owner-chip--${this.size} ${this.viewingNow === false
128+
? "session-owner-chip--away"
129+
: ""}"
124130
style="--owner-hue: ${ownerHue(createdActor.id)}"
125131
role="img"
126132
aria-label=${accessibleLabel}

‎ui/src/components/viewer-facepile.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ type ViewerFacepileElement = HTMLElement & {
153153
selfUserId?: string;
154154
selfInstanceId?: string;
155155
sessionKey?: string;
156+
excludeUserId?: string;
157+
maxVisible: number;
156158
variant: "session" | "footer";
157159
buildInfo: ControlUiBuildInfo;
158160
gatewayVersion: string | null;
@@ -274,6 +276,37 @@ it("keeps session facepiles as plain non-interactive avatar clusters", async ()
274276
expect(facepile.querySelectorAll("openclaw-tooltip")).toHaveLength(1);
275277
});
276278

279+
it("excludes the session creator before choosing visible avatars and overflow", async () => {
280+
const facepile = document.createElement("openclaw-viewer-facepile") as ViewerFacepileElement;
281+
facepile.variant = "session";
282+
facepile.sessionKey = "agent:main:active";
283+
facepile.excludeUserId = "owner";
284+
facepile.maxVisible = 2;
285+
facepile.presencePayload = {
286+
presence: ["owner", "alice", "bob", "carol"].map((id) => ({
287+
instanceId: `${id}-instance`,
288+
user: { id, name: id },
289+
watchedSessions: ["agent:main:active"],
290+
})),
291+
};
292+
document.body.append(facepile);
293+
294+
await vi.waitFor(async () => {
295+
await facepile.updateComplete;
296+
expect(
297+
[...facepile.querySelectorAll("[data-viewer-id]")].map((avatar) =>
298+
avatar.getAttribute("data-viewer-id"),
299+
),
300+
).toEqual(["alice", "bob"]);
301+
});
302+
expect(facepile.querySelector(".viewer-facepile")?.getAttribute("data-viewer-count")).toBe("3");
303+
expect(facepile.querySelector(".viewer-avatar--overflow")?.textContent?.trim()).toBe("+1");
304+
expect(facepile.querySelector('[data-viewer-id="owner"]')).toBeNull();
305+
expect(facepile.querySelector(".viewer-avatar--overflow")?.getAttribute("aria-label")).toBe(
306+
"carol",
307+
);
308+
});
309+
277310
it("detects only other viewers watching the requested session", () => {
278311
const payload = {
279312
presence: [

‎ui/src/components/viewer-facepile.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ let cachedAuthenticatedSelfUserId: string | undefined;
8484
let cachedSelfInstanceId: string | undefined;
8585
let cachedPresenceProjection: ReturnType<typeof projectPresenceViewers> | undefined;
8686

87-
function projectPresencePayload(
87+
export function projectPresencePayload(
8888
value: unknown,
8989
authenticatedSelfUserId?: string,
9090
selfInstanceId?: string,
@@ -189,6 +189,7 @@ class ViewerFacepile extends OpenClawLightDomContentsElement {
189189
@property({ attribute: false }) selfUserId?: string;
190190
@property({ attribute: false }) selfInstanceId?: string;
191191
@property({ attribute: false }) sessionKey?: string;
192+
@property({ attribute: false }) excludeUserId?: string;
192193
@property({ type: Number, attribute: "max-visible" }) maxVisible = 3;
193194
@property() variant: "session" | "footer" = "session";
194195
@property({ attribute: false }) buildInfo: ControlUiBuildInfo = CONTROL_UI_BUILD_INFO;
@@ -201,9 +202,13 @@ class ViewerFacepile extends OpenClawLightDomContentsElement {
201202
this.selfInstanceId,
202203
);
203204
const sessionKey = this.sessionKey;
205+
const excludeUserId = normalized(this.excludeUserId);
204206
const users = sessionKey
205207
? projection.users.filter(
206-
(user) => user.id !== projection.selfUserId && user.watchedSessions.includes(sessionKey),
208+
(user) =>
209+
user.id !== projection.selfUserId &&
210+
user.id !== excludeUserId &&
211+
user.watchedSessions.includes(sessionKey),
207212
)
208213
: this.variant === "footer"
209214
? projection.users.filter((user) => user.id !== projection.selfUserId)

0 commit comments

Comments
 (0)