Skip to content

Commit 916eef4

Browse files
fix(ui): balance completed-work spacing (#126303)
* fix(ui): balance completed-work spacing * fix(ui): preserve touch work spacing * fix(ui): balance touch work spacing * fix(ui): open completed-work spacing
1 parent 441f0a3 commit 916eef4

2 files changed

Lines changed: 86 additions & 5 deletions

File tree

‎ui/src/pages/chat/chat-responsive.browser.test.ts‎

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,47 @@ function activityAlignmentHtml() {
248248
`;
249249
}
250250

251+
function completedWorkSpacingHtml() {
252+
return `
253+
<div class="chat-thread" role="log">
254+
<div class="chat-thread-inner chat-thread-inner--virtual">
255+
<div class="chat-virtual-sizer" style="height: 400px;">
256+
<div class="chat-virtual-row" data-spacing-row="prompt">
257+
<div class="chat-group user chat-group--with-footer">
258+
<div class="chat-group-messages">
259+
<div class="chat-bubble"><div class="chat-text">Prompt</div></div>
260+
</div>
261+
<div class="chat-group-footer"><span class="chat-sender-name">You</span></div>
262+
</div>
263+
</div>
264+
<div class="chat-virtual-row" data-spacing-row="work">
265+
<div class="chat-group tool chat-group--work">
266+
<div class="chat-group-messages">
267+
<div class="chat-activity-group chat-work-group">
268+
<button class="chat-inline-disclosure chat-activity-group__summary" type="button">
269+
<span class="chat-tool-disclosure__content">
270+
<span class="chat-activity-group__label">Worked for 10s</span>
271+
</span>
272+
</button>
273+
<div class="chat-work-group__separator"></div>
274+
</div>
275+
</div>
276+
</div>
277+
</div>
278+
<div class="chat-virtual-row" data-spacing-row="reply">
279+
<div class="chat-group assistant chat-group--with-footer">
280+
<div class="chat-group-messages">
281+
<div class="chat-bubble"><div class="chat-text">Final reply</div></div>
282+
</div>
283+
<div class="chat-group-footer"><span class="chat-sender-name">Assistant</span></div>
284+
</div>
285+
</div>
286+
</div>
287+
</div>
288+
</div>
289+
`;
290+
}
291+
251292
function chatFooterActionsHtml() {
252293
return `
253294
<div class="chat-group-footer-actions">
@@ -596,14 +637,14 @@ async function openFixture(width: number, height: number, opts: ChatFixtureOptio
596637
async function openBrowserPage(
597638
width: number,
598639
height: number,
599-
options: { isolated?: boolean } = {},
640+
options: { hasTouch?: boolean; isolated?: boolean } = {},
600641
): Promise<Page> {
601642
sharedBrowser ??= await chromium.launch({
602643
executablePath: chromiumExecutablePath,
603644
headless: true,
604645
});
605646
if (options.isolated) {
606-
return await sharedBrowser.newPage({ viewport: { width, height } });
647+
return await sharedBrowser.newPage({ hasTouch: options.hasTouch, viewport: { width, height } });
607648
}
608649
// Static setContent fixtures do not mutate context-owned storage or routes,
609650
// so they can share one context while their pages remain concurrent.
@@ -1225,6 +1266,46 @@ describeBrowserLayout.concurrent("chat responsive browser layout", () => {
12251266
}
12261267
});
12271268

1269+
it.each([
1270+
{ label: "desktop", width: 1366, hasTouch: false, expectedGap: 9 },
1271+
{ label: "narrow touch", width: 430, hasTouch: true, expectedGap: 23 },
1272+
{ label: "wide touch", width: 1366, hasTouch: true, expectedGap: 23 },
1273+
])("balances completed-work spacing on $label", async ({ width, hasTouch, expectedGap }) => {
1274+
const page = await openBrowserPage(width, 720, { hasTouch, isolated: true });
1275+
try {
1276+
await page.setContent(
1277+
`<!doctype html><html><head><style>${readUiCss()}</style></head><body>${completedWorkSpacingHtml()}</body></html>`,
1278+
);
1279+
await waitForLayoutSettled(page, "[data-spacing-row], .chat-group--work");
1280+
1281+
const gaps = await page.evaluate(() => {
1282+
const rows = [...document.querySelectorAll<HTMLElement>("[data-spacing-row]")];
1283+
let offset = 0;
1284+
for (const row of rows) {
1285+
row.style.transform = `translateY(${offset}px)`;
1286+
offset += row.getBoundingClientRect().height;
1287+
}
1288+
const prompt = document.querySelector<HTMLElement>(
1289+
'[data-spacing-row="prompt"] .chat-group',
1290+
)!;
1291+
const summary = document.querySelector<HTMLElement>(".chat-work-group > button")!;
1292+
const separator = document.querySelector<HTMLElement>(".chat-work-group__separator")!;
1293+
const reply = document.querySelector<HTMLElement>(
1294+
'[data-spacing-row="reply"] .chat-group',
1295+
)!;
1296+
return {
1297+
after: reply.getBoundingClientRect().top - separator.getBoundingClientRect().bottom,
1298+
before: summary.getBoundingClientRect().top - prompt.getBoundingClientRect().bottom,
1299+
};
1300+
});
1301+
1302+
expect(gaps.before).toBeCloseTo(expectedGap, 0);
1303+
expect(gaps.after).toBeCloseTo(expectedGap, 0);
1304+
} finally {
1305+
await closeBrowserPage(page);
1306+
}
1307+
});
1308+
12281309
it("insets only the bundled logo inside the unchanged avatar box", async () => {
12291310
const page = await openBrowserPage(430, 720);
12301311
try {

‎ui/src/styles/chat/tool-cards.css‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,10 +1130,10 @@
11301130
}
11311131

11321132
/* Completed-turn work rollup: slim "Worked for X" disclosure standing in for
1133-
the turn's intermediate tool/commentary groups. Sits snug above the final
1134-
reply, aligned with the message column via a gutter matching the avatar. */
1133+
the turn's intermediate tool/commentary groups. Keep it equally separated
1134+
from the prompt and final reply. */
11351135
.chat-group--work {
1136-
padding-bottom: 8px;
1136+
padding-block: 9px;
11371137
}
11381138

11391139
.chat-work-group .chat-activity-group__label {

0 commit comments

Comments
 (0)