Skip to content

Commit f1491a2

Browse files
fix(ui): keep PR chip above transcript rows (#130224)
* fix(ui): keep PR chip above transcript rows Co-authored-by: Tak Hoffman <[email protected]> * fix(ui): keep PR chip above transcript rows OpenClaw-Publication: d6486664-bbca-4012-ae1d-0b5149319c9e --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
1 parent f7bd83d commit f1491a2

2 files changed

Lines changed: 109 additions & 1 deletion

File tree

‎ui/src/e2e/chat-pull-requests.e2e.test.ts‎

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Control UI tests cover session pull request chips above the chat composer.
22
import { mkdir } from "node:fs/promises";
33
import path from "node:path";
4-
import { chromium, type Browser, type BrowserContext } from "playwright";
4+
import { chromium, type Browser, type BrowserContext, type Page } from "playwright";
55
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
66
import { CONTROL_UI_SESSION_PULL_REQUESTS_CHANGED_EVENT } from "../../../src/gateway/control-ui-contract.js";
77
import { SESSION_PULL_REQUESTS_SUBSCRIBE_METHOD } from "../lib/session-pull-requests.ts";
@@ -25,6 +25,12 @@ const publicationProofDir = path.join(
2525
"control-ui-e2e",
2626
"github-publication",
2727
);
28+
const stackingProofDir = path.join(
29+
process.cwd(),
30+
".artifacts",
31+
"control-ui-e2e",
32+
"pr-chip-stacking",
33+
);
2834

2935
let server: ControlUiE2eServer;
3036
// Browser contexts preserve test isolation; keep one process warm for this file.
@@ -47,6 +53,45 @@ async function closeContexts(): Promise<void> {
4753
openContexts.clear();
4854
}
4955

56+
async function expectPullRequestChipOnTop(page: Page): Promise<void> {
57+
const chip = page.locator(".chat-pr").first();
58+
await chip.waitFor();
59+
const uncovered = await chip.evaluate((element) => {
60+
const bounds = element.getBoundingClientRect();
61+
const sampleY = Math.min(bounds.bottom - 1, bounds.top + 10);
62+
return [0.2, 0.5, 0.8].every((ratio) => {
63+
const sampleX = bounds.left + bounds.width * ratio;
64+
return document.elementFromPoint(sampleX, sampleY)?.closest(".chat-pr") === element;
65+
});
66+
});
67+
expect(uncovered).toBe(true);
68+
}
69+
70+
async function overlapLastTranscriptRowWithPullRequestChip(page: Page): Promise<void> {
71+
const row = page.locator(".chat-virtual-row").last();
72+
const chip = page.locator(".chat-pr").first();
73+
await row.waitFor();
74+
await chip.waitFor();
75+
await page.evaluate(() => {
76+
const rows = document.querySelectorAll<HTMLElement>(".chat-virtual-row");
77+
const rowElement = rows.item(rows.length - 1);
78+
const chipElement = document.querySelector<HTMLElement>(".chat-pr");
79+
if (!rowElement || !chipElement) {
80+
throw new Error("Expected a virtual transcript row and pull request chip");
81+
}
82+
const paintedRow = rowElement.querySelector<HTMLElement>(".chat-bubble") ?? rowElement;
83+
const paintedBounds = paintedRow.getBoundingClientRect();
84+
const chipBounds = chipElement.getBoundingClientRect();
85+
rowElement.style.top = `${chipBounds.top + 24 - paintedBounds.bottom}px`;
86+
});
87+
await page.evaluate(
88+
() =>
89+
new Promise<void>((resolve) => {
90+
requestAnimationFrame(() => resolve());
91+
}),
92+
);
93+
}
94+
5095
async function waitForWatchedSessionKey(
5196
gateway: Awaited<ReturnType<typeof installMockGateway>>,
5297
): Promise<string> {
@@ -222,6 +267,65 @@ describeControlUiE2e("session pull request chips", () => {
222267
.toBe("#103469");
223268
});
224269

270+
it.each([
271+
{ label: "desktop", viewport: { width: 1180, height: 800 } },
272+
{ label: "mobile", viewport: { width: 393, height: 852 } },
273+
])(
274+
"keeps the PR chip above an underlapping transcript on $label",
275+
async ({ label, viewport }) => {
276+
const context = await browser.newContext({
277+
colorScheme: "light",
278+
locale: "en-US",
279+
serviceWorkers: "block",
280+
viewport,
281+
});
282+
openContexts.add(context);
283+
const page = await context.newPage();
284+
const gateway = await installMockGateway(page, {
285+
featureMethods: ["chat.metadata", "chat.startup", SESSION_PULL_REQUESTS_SUBSCRIBE_METHOD],
286+
historyMessages: Array.from({ length: 25 }, (_, index) => ({
287+
role: index % 2 === 0 ? "user" : "assistant",
288+
content: `Transcript row ${index + 1}: paint-order regression fixture.`,
289+
timestamp: index + 1,
290+
})),
291+
methodResponses: {
292+
[SESSION_PULL_REQUESTS_SUBSCRIBE_METHOD]: { subscribed: true },
293+
},
294+
});
295+
await page.goto(`${server.baseUrl}chat`);
296+
const watchedKey = await waitForWatchedSessionKey(gateway);
297+
await gateway.emitGatewayEvent(CONTROL_UI_SESSION_PULL_REQUESTS_CHANGED_EVENT, {
298+
sessions: {
299+
[watchedKey]: {
300+
pullRequests: [
301+
{
302+
number: 123456,
303+
owner: "openclaw",
304+
repo: "openclaw",
305+
branch: "fix/pr-chip-stacking",
306+
title: "Keep the PR chip above the transcript",
307+
url: "https://github.com/openclaw/openclaw/pull/123456",
308+
state: "open",
309+
},
310+
],
311+
rateLimited: false,
312+
status: "ok",
313+
},
314+
},
315+
});
316+
317+
await overlapLastTranscriptRowWithPullRequestChip(page);
318+
if (captureUiProof) {
319+
await mkdir(stackingProofDir, { recursive: true });
320+
await page.screenshot({
321+
animations: "disabled",
322+
path: path.join(stackingProofDir, `${label}.png`),
323+
});
324+
}
325+
await expectPullRequestChipOnTop(page);
326+
},
327+
);
328+
225329
it("offers a Publish PR row with the stale warning while rate limited pre-PR", async () => {
226330
const context = await newBrowserContext();
227331
const page = await context.newPage();

‎ui/src/styles/chat/layout.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,10 @@ button.chat-reply-preview--message:disabled {
28902890
}
28912891

28922892
.chat-prs {
2893+
/* The transcript intentionally underlaps the composer stack; keep its
2894+
positioned virtual rows from painting over this interactive surface. */
2895+
position: relative;
2896+
z-index: 1;
28932897
display: grid;
28942898
gap: 6px;
28952899
/* Mirror .agent-chat__composer-shell sizing: the rows belong to the input

0 commit comments

Comments
 (0)