Skip to content

Commit 94c8e74

Browse files
committed
fix(ui): keep selected sessions clear of scrollbars
1 parent 8050684 commit 94c8e74

2 files changed

Lines changed: 84 additions & 1 deletion

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import fs from "node:fs/promises";
2+
import path from "node:path";
3+
import { expect, it } from "vitest";
4+
import { installMockGateway } from "../test-helpers/control-ui-e2e.ts";
5+
import { createControlUiE2eSuite } from "./control-ui-e2e-suite.test-support.ts";
6+
7+
const suite = createControlUiE2eSuite({
8+
name: "Control UI sidebar selection overflow",
9+
startServerBeforeBrowser: true,
10+
browserLaunchOptions: {
11+
args: ["--disable-features=OverlayScrollbar,FluentOverlayScrollbar,FluentScrollbar"],
12+
},
13+
});
14+
15+
const artifactDir = path.resolve(".artifacts/control-ui-e2e/sidebar-selection-overflow");
16+
17+
suite.define(() => {
18+
it("keeps the active session pill clear of a classic scrollbar", async () => {
19+
const captureProof = process.env.OPENCLAW_CAPTURE_UI_PROOF === "1";
20+
if (captureProof) {
21+
await fs.mkdir(artifactDir, { recursive: true });
22+
}
23+
const context = await suite.newBrowserContext({
24+
viewport: { height: 500, width: 1280 },
25+
});
26+
const page = await context.newPage();
27+
const sessionKey = "agent:main:dashboard:active-session";
28+
const sessions = Array.from({ length: 40 }, (_, index) => ({
29+
key: index === 0 ? sessionKey : `agent:main:dashboard:session-${index}`,
30+
kind: "direct",
31+
label: index === 0 ? "Selected session" : `Overflow session ${index}`,
32+
updatedAt: 40 - index,
33+
}));
34+
await installMockGateway(page, {
35+
methodResponses: {
36+
"sessions.list": {
37+
count: sessions.length,
38+
defaults: { contextTokens: null, model: "gpt-5.5", modelProvider: "openai" },
39+
path: "",
40+
sessions,
41+
ts: Date.now(),
42+
},
43+
},
44+
sessionKey,
45+
});
46+
47+
try {
48+
await page.goto(`${suite.server.baseUrl}chat`);
49+
const active = page.locator(
50+
`.sidebar-recent-session--active[data-session-key="${sessionKey}"]`,
51+
);
52+
await active.waitFor();
53+
const geometry = await active.evaluate((row) => {
54+
const section = row.closest<HTMLElement>(".sidebar-sessions");
55+
const scroller = row.closest<HTMLElement>(".sidebar-shell__body");
56+
if (!section || !scroller) {
57+
throw new Error("sidebar session geometry owner not found");
58+
}
59+
const rowRect = row.getBoundingClientRect();
60+
const sectionRect = section.getBoundingClientRect();
61+
return {
62+
inset: sectionRect.right - rowRect.right,
63+
overflows: scroller.scrollHeight > scroller.clientHeight,
64+
sectionPaddingEnd: Number.parseFloat(getComputedStyle(section).paddingRight),
65+
};
66+
});
67+
68+
expect(geometry.overflows).toBe(true);
69+
expect(geometry.inset, JSON.stringify(geometry)).toBeGreaterThanOrEqual(
70+
geometry.sectionPaddingEnd,
71+
);
72+
73+
if (captureProof) {
74+
await page.screenshot({
75+
path: path.join(artifactDir, "active-session-pill.png"),
76+
fullPage: true,
77+
});
78+
}
79+
} finally {
80+
await suite.closeBrowserContext(context);
81+
}
82+
});
83+
});

‎ui/src/styles/layout.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ body.update-dialog-open .sidebar-update-card__status {
14211421
display: flex;
14221422
flex-direction: column;
14231423
gap: var(--sidebar-group-gap);
1424-
margin: 0 -8px;
1424+
margin-inline: -8px 0;
14251425
/* Sessions are app chrome, not hyperlinks: the whole region follows the
14261426
base.css cursor policy so it tracks the window it is running in. */
14271427
cursor: var(--cursor-action);

0 commit comments

Comments
 (0)