Skip to content

Commit 779c66d

Browse files
committed
fix(ui): reduce sidebar title movement on hover
1 parent ffdc6c1 commit 779c66d

3 files changed

Lines changed: 76 additions & 3 deletions

File tree

‎ui/src/e2e/chat-flow.sidebar-presentation.e2e.test.ts‎

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,25 +342,34 @@ suite.define(() => {
342342
const busyKey = "agent:main:busy-session";
343343
const plainKey = "agent:main:plain-session";
344344
const longKey = "agent:main:long-title-session";
345+
const unreadKey = "agent:main:unread-session";
345346
const homeKey = "agent:main:main";
346347
await installMockGateway(page, {
347348
featureMethods: [...defaultControlUiFeatureMethods, "board.get"],
348349
methodResponses: {
349350
"board.get": {
350-
cases: [homeKey, busyKey, plainKey, longKey].map((sessionKey) => ({
351+
cases: [homeKey, busyKey, plainKey, longKey, unreadKey].map((sessionKey) => ({
351352
match: { sessionKey },
352353
response: {
353354
sessionKey,
354355
revision: 1,
355356
tabs:
356-
sessionKey === homeKey || sessionKey === busyKey
357+
sessionKey === homeKey || sessionKey === busyKey || sessionKey === unreadKey
357358
? [{ tabId: "overview", title: "Overview", position: 0, chatDock: "right" }]
358359
: [],
359360
widgets: [],
360361
},
361362
})),
362363
},
363364
"sessions.list": chatSessionListResponse([
365+
{
366+
key: unreadKey,
367+
kind: "direct",
368+
label: "Movies and recommendations for the weekend",
369+
icon: "🎬",
370+
updatedAt: 3,
371+
unread: true,
372+
},
364373
{
365374
key: busyKey,
366375
kind: "direct",
@@ -609,6 +618,38 @@ suite.define(() => {
609618
expect(intrinsicAtomWidth).toBeGreaterThan(0);
610619
expect(longLayout.endcapWidth).toBeGreaterThanOrEqual(intrinsicAtomWidth);
611620

621+
const unreadRow = page.locator(`.sidebar-recent-session[data-session-key="${unreadKey}"]`);
622+
const unreadDot = unreadRow.locator(".session-unread-dot");
623+
const unreadTitle = unreadRow.locator(".sidebar-recent-session__name");
624+
await unreadDot.waitFor({ state: "visible" });
625+
const restingWidth = await unreadTitle.evaluate((element) => element.clientWidth);
626+
await unreadRow.hover();
627+
if (captureUiProofEnabled) {
628+
await shellNav.screenshot({
629+
animations: "disabled",
630+
path: path.join(sessionSecondRowProofDir, "03-unread-hover.png"),
631+
});
632+
}
633+
await unreadDot.waitFor({ state: "hidden" });
634+
const hoverWidth = await unreadTitle.evaluate((element) => element.clientWidth);
635+
const actionReserve = await unreadRow.evaluate((element) =>
636+
Number.parseFloat(
637+
getComputedStyle(element).getPropertyValue("--session-row-actions-reserve"),
638+
),
639+
);
640+
// Collapsing the unread track gives its width back to the title; merely
641+
// making the dot transparent would still squeeze the text by the full reserve.
642+
expect(restingWidth - hoverWidth).toBeLessThan(actionReserve);
643+
await unreadRow
644+
.getByRole("img", { name: "Dashboard available" })
645+
.waitFor({ state: "visible" });
646+
await page.mouse.move(900, 400);
647+
await unreadDot.waitFor({ state: "visible" });
648+
await unreadRow.locator("[data-session-menu]").focus();
649+
await unreadDot.waitFor({ state: "hidden" });
650+
await sidebarResizer.focus();
651+
await unreadDot.waitFor({ state: "visible" });
652+
612653
await busyRow.hover();
613654
await expect
614655
.poll(() =>

‎ui/src/e2e/session-management.trailing-state.e2e.test.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ suite.define(() => {
252252
}
253253
});
254254

255-
it("keeps the trailing unread dot on one axis with and without a pull-request icon", async () => {
255+
it("aligns trailing unread dots and trades unread/PR icons for hover actions", async () => {
256256
const plainKey = "agent:main:unread-plain";
257257
const pullRequestKey = "agent:main:unread-pr";
258258
const context = await suite.browser.newContext({
@@ -261,6 +261,9 @@ suite.define(() => {
261261
viewport: { height: 900, width: 1280 },
262262
});
263263
const page = await context.newPage();
264+
await page.addInitScript(() => {
265+
localStorage.setItem("openclaw:sidebar:sessions:show-preview", "false");
266+
});
264267
const gateway = await installMockGateway(page, {
265268
featureMethods: ["chat.metadata", "chat.startup", SESSION_PULL_REQUESTS_SUBSCRIBE_METHOD],
266269
methodResponses: {
@@ -342,6 +345,23 @@ suite.define(() => {
342345
await dotInsetFromRowRight(plainRow),
343346
0,
344347
);
348+
const pullRequestIcon = pullRequestRow.locator("[data-pull-request-state='merged']");
349+
const unreadDot = pullRequestRow.locator(".session-unread-dot");
350+
const trailingState = pullRequestRow.locator(".session-row-state");
351+
await captureUiProof(page, "sidebar-pr-before-hover.png");
352+
await pullRequestRow.hover();
353+
await captureUiProof(page, "sidebar-pr-hover.png");
354+
await pullRequestIcon.waitFor({ state: "hidden" });
355+
await unreadDot.waitFor({ state: "hidden" });
356+
await trailingState.waitFor({ state: "hidden" });
357+
await page.mouse.move(0, 0);
358+
await pullRequestIcon.waitFor({ state: "visible" });
359+
await unreadDot.waitFor({ state: "visible" });
360+
await pullRequestRow.getByRole("button", { name: "Open session menu" }).focus();
361+
await trailingState.waitFor({ state: "hidden" });
362+
await codingToggle.focus();
363+
await pullRequestIcon.waitFor({ state: "visible" });
364+
await unreadDot.waitFor({ state: "visible" });
345365
} finally {
346366
await context.close();
347367
}

‎ui/src/styles/layout.css‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,18 @@ openclaw-settings-save-indicator:empty {
21162116
padding-right: var(--session-row-actions-reserve);
21172117
}
21182118

2119+
/* Trade unread/PR tracks for action space, keeping active state and second-line
2120+
metadata visible. Collapse empty containers too so their gaps cannot squeeze the title. */
2121+
.sidebar-recent-session--single-line:not(.sidebar-recent-session--child):is(:hover, :focus-within)
2122+
:is(
2123+
.session-unread-dot,
2124+
.session-row-badge--pull-request,
2125+
.session-row-aside:has(> .session-row-state > .session-unread-dot:only-child),
2126+
.session-row-badges:has(> openclaw-tooltip:only-child > .session-row-badge--pull-request)
2127+
) {
2128+
display: none;
2129+
}
2130+
21192131
.nav-collapse-toggle__icon {
21202132
display: flex;
21212133
align-items: center;

0 commit comments

Comments
 (0)