Skip to content

Commit d56a270

Browse files
authored
fix(ui): keep the sidebar run indicator on the left (#113645)
1 parent 2579e4a commit d56a270

9 files changed

Lines changed: 203 additions & 87 deletions

File tree

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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type { AppSidebarSessionNavigationElement } from "./app-sidebar-session-n
2020
import type { SidebarRecentSession } from "./app-sidebar-session-types.ts";
2121
import type { SidebarWorkboardBoard } from "./app-sidebar-workboard.ts";
2222
import { icons } from "./icons.ts";
23+
import { renderSessionGlyph, renderSessionUnreadBadge } from "./session-glyph.ts";
2324
import { renderSessionRowBadges } from "./session-row-badges.ts";
2425

2526
type AppSidebarRenderHost = AppSidebarSessionNavigationElement & {
@@ -90,21 +91,15 @@ export function renderAppSidebarHomeRow(host: AppSidebarRenderHost) {
9091
const outboxCount = host.outboxCountForSessionKey(mainKey);
9192
const active =
9293
host.activeRouteId === "chat" && areUiSessionKeysEquivalent(host.getRouteSessionKey(), mainKey);
93-
const stateBadge = mainRow?.hasActiveRun
94-
? html`<openclaw-tooltip .content=${t("sessionsView.activeRun")}>
95-
<span
96-
class="session-run-spinner"
97-
role="img"
98-
aria-label=${t("sessionsView.activeRun")}
99-
></span>
100-
</openclaw-tooltip>`
101-
: mainRow?.unread === true && !active
102-
? html`<span
103-
class="session-unread-dot"
104-
role="img"
105-
aria-label=${t("sessionsView.unread")}
106-
></span>`
107-
: nothing;
94+
const running = mainRow?.hasActiveRun === true;
95+
const unread = mainRow?.unread === true && !active;
96+
// Home shares the sidebar's leading-slot contract: run state rings its icon
97+
// instead of drifting to the row edge, which stays reserved for counts.
98+
const homeGlyph = renderSessionGlyph({
99+
content: html`<span class="nav-item__icon" aria-hidden="true">${icons.home}</span>`,
100+
running,
101+
badge: unread ? renderSessionUnreadBadge() : nothing,
102+
});
108103
return html`
109104
<a
110105
href=${`${pathForRoute("chat", host.basePath)}${searchForSession(mainKey)}`}
@@ -118,7 +113,11 @@ export function renderAppSidebarHomeRow(host: AppSidebarRenderHost) {
118113
host.openMainSession(agentId);
119114
}}
120115
>
121-
<span class="nav-item__icon" aria-hidden="true">${icons.home}</span>
116+
${running
117+
? html`<openclaw-tooltip .content=${t("sessionsView.activeRun")}
118+
>${homeGlyph}</openclaw-tooltip
119+
>`
120+
: homeGlyph}
122121
<span class="nav-item__text">${t("nav.home")}</span>
123122
${sessionHasBoard(mainKey)
124123
? html`<openclaw-tooltip .content=${t("sessionsView.dashboardAvailable")}>
@@ -130,9 +129,8 @@ export function renderAppSidebarHomeRow(host: AppSidebarRenderHost) {
130129
>
131130
</openclaw-tooltip>`
132131
: nothing}
133-
${stateBadge !== nothing || approvalNeeded || outboxCount > 0
132+
${approvalNeeded || outboxCount > 0
134133
? html`<span class="nav-item__state sidebar-home-session-states">
135-
${stateBadge}
136134
${approvalNeeded
137135
? html`<openclaw-tooltip .content=${t("sessionsView.approvalNeeded")}>
138136
<span

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export function renderRecentSession(params: {
155155
? session.archivedBy
156156
: session.createdActor
157157
: undefined;
158-
const { running, pinnedState, leadingIndicator } = renderSessionLeadingState(
158+
const { running, leadingIndicator } = renderSessionLeadingState(
159159
session,
160160
pullRequestState,
161161
ownerActor,
@@ -274,7 +274,6 @@ export function renderRecentSession(params: {
274274
session.key,
275275
),
276276
})}
277-
${pinnedState}
278277
</a>
279278
${session.childSessionKeys.length > 0
280279
? html`<button

‎ui/src/components/session-glyph.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { html, nothing, type TemplateResult } from "lit";
2+
import { t } from "../i18n/index.ts";
3+
4+
export type SessionGlyphContent = TemplateResult | typeof nothing;
5+
6+
/**
7+
* The sidebar's leading slot. Every row kind (owner avatar, page icon,
8+
* attention glyph) renders its own artwork here and carries run state as a ring
9+
* around it, so the run indicator never migrates to the row's trailing edge.
10+
* Circular content already fits the ring; arbitrary square icons and thumbnails
11+
* scale down so their corners stay inside it.
12+
*/
13+
export function renderSessionGlyph(options: {
14+
content: SessionGlyphContent;
15+
running: boolean;
16+
circular?: boolean;
17+
badge?: SessionGlyphContent;
18+
}): TemplateResult {
19+
const { content, running, circular = false, badge = nothing } = options;
20+
const modifiers = `${circular ? " session-glyph--circular" : ""}${running ? " session-glyph--running" : ""}`;
21+
return html`<span class="session-glyph${modifiers}">
22+
<span class="session-glyph__content">${content}</span>
23+
${running
24+
? html`<span
25+
class="session-glyph__ring"
26+
role="img"
27+
aria-label=${t("sessionsView.activeRun")}
28+
></span>`
29+
: nothing}
30+
${badge}
31+
</span>`;
32+
}
33+
34+
export function renderSessionUnreadBadge(): TemplateResult {
35+
return html`<span
36+
class="session-glyph__badge session-glyph__badge--unread"
37+
role="img"
38+
aria-label=${t("sessionsView.unread")}
39+
></span>`;
40+
}

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

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,81 +6,82 @@ import {
66
renderSessionAttentionIcon,
77
renderSessionState,
88
} from "./session-attention-presentation.ts";
9+
import {
10+
renderSessionGlyph,
11+
renderSessionUnreadBadge,
12+
type SessionGlyphContent,
13+
} from "./session-glyph.ts";
914
import { resolveSessionIcon } from "./session-icon-registry.ts";
1015
import type { SessionPullRequestIndicatorState } from "./session-menu-work.ts";
1116
import { renderSessionOwnerChip, type SessionCreatedActor } from "./session-owner-chip.ts";
1217

18+
function renderGlyphBadge(
19+
session: SidebarRecentSession,
20+
pullRequestState: SessionPullRequestIndicatorState,
21+
): SessionGlyphContent {
22+
if (session.unread) {
23+
return renderSessionUnreadBadge();
24+
}
25+
if (pullRequestState === "none") {
26+
return nothing;
27+
}
28+
const label =
29+
pullRequestState === "open" ? t("sessionsView.openPullRequest") : t("chat.pullRequests.merged");
30+
return html`<span
31+
class="session-glyph__badge sidebar-session-pr-indicator--${pullRequestState}"
32+
data-session-pr-state=${pullRequestState}
33+
role="img"
34+
aria-label=${label}
35+
title=${label}
36+
></span>`;
37+
}
38+
1339
export function renderSessionLeadingState(
1440
session: SidebarRecentSession,
1541
pullRequestState: SessionPullRequestIndicatorState,
1642
ownerActor: SessionCreatedActor | null | undefined,
1743
attribution: "created" | "archived",
1844
) {
1945
const running = session.hasActiveRun || session.status === "running";
20-
const sessionState = renderSessionState(session);
21-
// Pinned rows keep their custom icon in the fixed leading slot and place
22-
// transient run/unread/terminal state at the row edge.
23-
const pinnedState =
24-
session.pinned && sessionState !== nothing
25-
? html`<span class="nav-item__state">${sessionState}</span>`
26-
: nothing;
2746

2847
if (session.attention.kind !== "none") {
2948
return {
3049
running,
31-
pinnedState,
32-
leadingIndicator: renderSessionAttentionIcon(session.attention),
50+
leadingIndicator: renderSessionGlyph({
51+
content: renderSessionAttentionIcon(session.attention),
52+
running,
53+
// Attention does not replace unread: a row waiting on the user can also
54+
// hold output the user has not seen.
55+
badge: renderGlyphBadge(session, pullRequestState),
56+
}),
3357
};
3458
}
3559
if (session.pinned) {
3660
return {
3761
running,
38-
pinnedState,
39-
leadingIndicator: html`<span class="sidebar-pinned-session__icon" aria-hidden="true"
40-
>${resolveSessionIcon(session.icon)}</span
41-
>`,
62+
leadingIndicator: renderSessionGlyph({
63+
content: html`<span class="sidebar-pinned-session__icon" aria-hidden="true"
64+
>${resolveSessionIcon(session.icon)}</span
65+
>`,
66+
running,
67+
badge: renderGlyphBadge(session, pullRequestState),
68+
}),
4269
};
4370
}
4471
if (!session.isChild && ownerActor?.id?.trim()) {
45-
const label =
46-
pullRequestState === "open"
47-
? t("sessionsView.openPullRequest")
48-
: t("chat.pullRequests.merged");
4972
return {
5073
running,
51-
pinnedState,
52-
leadingIndicator: html`<span
53-
class="sidebar-session-avatar ${running ? "sidebar-session-avatar--running" : ""}"
54-
>
55-
${renderSessionOwnerChip(ownerActor, "row", attribution)}
56-
${running
57-
? html`<span
58-
class="sidebar-session-avatar__running-ring"
59-
role="img"
60-
aria-label=${t("sessionsView.activeRun")}
61-
title=${t("sessionsView.activeRun")}
62-
></span>`
63-
: nothing}
64-
${session.unread
65-
? html`<span
66-
class="sidebar-session-avatar__badge sidebar-session-avatar__badge--unread"
67-
role="img"
68-
aria-label=${t("sessionsView.unread")}
69-
></span>`
70-
: pullRequestState !== "none"
71-
? html`<span
72-
class="sidebar-session-avatar__badge sidebar-session-pr-indicator--${pullRequestState}"
73-
data-session-pr-state=${pullRequestState}
74-
role="img"
75-
aria-label=${label}
76-
title=${label}
77-
></span>`
78-
: nothing}
79-
</span>`,
74+
leadingIndicator: renderSessionGlyph({
75+
content: renderSessionOwnerChip(ownerActor, "row", attribution),
76+
running,
77+
circular: true,
78+
badge: renderGlyphBadge(session, pullRequestState),
79+
}),
8080
};
8181
}
82+
// No artwork to ring: the bare spinner already sits in the leading slot.
8283
if (running) {
83-
return { running, pinnedState, leadingIndicator: sessionState };
84+
return { running, leadingIndicator: renderSessionState(session) };
8485
}
8586
if (pullRequestState !== "none") {
8687
const label =
@@ -89,7 +90,6 @@ export function renderSessionLeadingState(
8990
: t("chat.pullRequests.merged");
9091
return {
9192
running,
92-
pinnedState,
9393
leadingIndicator: html`<span
9494
class="sidebar-session-pr-indicator sidebar-session-pr-indicator--${pullRequestState}"
9595
data-session-pr-state=${pullRequestState}
@@ -100,9 +100,9 @@ export function renderSessionLeadingState(
100100
>`,
101101
};
102102
}
103+
const sessionState = renderSessionState(session);
103104
return {
104105
running,
105-
pinnedState,
106106
leadingIndicator:
107107
sessionState !== nothing
108108
? sessionState

‎ui/src/styles/components.css‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,37 @@ openclaw-session-owner-chip {
4545
font-size: 10px;
4646
}
4747

48-
.sidebar-session-avatar {
48+
/* Leading slot shared by every sidebar row: the row's own artwork plus a run
49+
ring and corner badge, so run state always reads at the row's left edge. */
50+
.session-glyph {
4951
position: relative;
5052
display: inline-flex;
5153
width: 16px;
5254
height: 16px;
5355
flex: 0 0 16px;
5456
}
5557

56-
.sidebar-session-avatar__running-ring {
58+
.session-glyph__content {
59+
display: inline-flex;
60+
align-items: center;
61+
justify-content: center;
62+
width: 16px;
63+
height: 16px;
64+
transition: transform var(--duration-fast) ease;
65+
}
66+
67+
/* The ring is a circle, so square artwork (page icons, thumbnails, arbitrary
68+
SVGs) must shrink to keep its corners inside it. Circular avatars already
69+
fit. A 16px square scaled below 0.75 clears the ring's 17px inner circle. */
70+
.session-glyph--running .session-glyph__content {
71+
transform: scale(0.72);
72+
}
73+
74+
.session-glyph--circular.session-glyph--running .session-glyph__content {
75+
transform: none;
76+
}
77+
78+
.session-glyph__ring {
5779
position: absolute;
5880
inset: -2px;
5981
box-sizing: border-box;
@@ -63,7 +85,7 @@ openclaw-session-owner-chip {
6385
pointer-events: none;
6486
}
6587

66-
.sidebar-session-avatar__badge {
88+
.session-glyph__badge {
6789
position: absolute;
6890
z-index: 1;
6991
top: -2px;
@@ -75,7 +97,7 @@ openclaw-session-owner-chip {
7597
box-shadow: 0 0 0 1.5px var(--bg);
7698
}
7799

78-
.sidebar-session-avatar__badge--unread {
100+
.session-glyph__badge--unread {
79101
color: var(--accent);
80102
}
81103

@@ -5698,7 +5720,7 @@ td.data-table-key-col {
56985720
}
56995721

57005722
.session-run-spinner,
5701-
.sidebar-session-avatar__running-ring {
5723+
.session-glyph__ring {
57025724
animation: session-run-spin 0.8s linear infinite;
57035725
}
57045726

@@ -5710,7 +5732,7 @@ td.data-table-key-col {
57105732

57115733
@media (prefers-reduced-motion: reduce) {
57125734
.session-run-spinner,
5713-
.sidebar-session-avatar__running-ring {
5735+
.session-glyph__ring {
57145736
animation: none;
57155737
border-color: var(--accent);
57165738
}

‎ui/src/styles/layout.css‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3004,7 +3004,8 @@ wa-dropdown.sidebar-session-sort-menu::part(menu) {
30043004
stroke-linejoin: round;
30053005
}
30063006

3007-
/* Home carries the main session's unread/running state at the row's edge. */
3007+
/* Home carries approval and outbox counts at the row's edge; run/unread state
3008+
rings the leading icon instead (see .session-glyph). */
30083009
.nav-item__state {
30093010
flex: none;
30103011
margin-left: auto;

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,16 @@ describe("AppSidebar agent chip", () => {
403403
expect(sidebar.querySelector(".sidebar-agent-card__subtitle")?.textContent).toContain(
404404
"Working",
405405
);
406-
const spinner = sidebar.querySelector(".nav-item--home .session-run-spinner");
407-
expect(spinner?.hasAttribute("title")).toBe(false);
406+
// Run state rings the Home icon in the leading slot; the row edge keeps
407+
// only approval/outbox counts.
408+
const ring = sidebar.querySelector(
409+
".nav-item--home .session-glyph--running .session-glyph__ring",
410+
);
411+
expect(ring).not.toBeNull();
412+
expect(sidebar.querySelector(".nav-item--home .nav-item__state")).toBeNull();
413+
expect(ring?.hasAttribute("title")).toBe(false);
408414
expect(
409-
(spinner?.closest("openclaw-tooltip") as (HTMLElement & { content?: string }) | null)
410-
?.content,
415+
(ring?.closest("openclaw-tooltip") as (HTMLElement & { content?: string }) | null)?.content,
411416
).toBe("Active run");
412417
});
413418

@@ -539,7 +544,7 @@ describe("AppSidebar agent chip", () => {
539544
// the global row's unread state.
540545
expect(sidebar.querySelector('[data-session-key="global"]')).toBeNull();
541546
expect(sidebar.querySelector('[data-session-key="agent:main:side-quest"]')).not.toBeNull();
542-
expect(sidebar.querySelector(".nav-item--home .session-unread-dot")).not.toBeNull();
547+
expect(sidebar.querySelector(".nav-item--home .session-glyph__badge--unread")).not.toBeNull();
543548
});
544549

545550
it("promotes main-session children to top-level threads, including alias parent keys", async () => {

0 commit comments

Comments
 (0)