Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/webui/docs/verification/browser-suite.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ pnpm test:webui-browser
The font files under `packages/webui/test/browser/fonts/` are committed to this repository.
The fixture server exposes those files as web fonts under the client's first sans and monospace
family names, and `openApp` waits for both faces and the initial layout observation before a test
measures geometry. This also pins macOS and Windows, whose font engines do not use fontconfig.
On Linux, `scripts/lib/webui-font-environment.mjs` additionally sets `FONTCONFIG_FILE` to expose
only the committed files and selects grayscale antialiasing. Native rasterization can still differ,
so screenshot baselines are platform-specific; review actual native captures before adding them.
measures geometry. The typeface is therefore the same on every platform, macOS and Windows included,
whose font engines do not use fontconfig. On Linux, `scripts/lib/webui-font-environment.mjs` additionally
sets `FONTCONFIG_FILE` to expose only the committed files and selects grayscale antialiasing. What the
typeface pin does not fix is the rasterizer: every platform draws the same outlines on its own pixels,
and two machines of one platform still differ by a handful, so screenshot baselines are platform-specific
and the pixel budget stays tight; review actual native captures before adding them.

Chromium uses its normal frame scheduling and graphics path. Live Markdown coalescing
is measured at the browser's paint opportunities rather than an artificially unbounded frame rate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export function ProjectList({
className="webui-pinned-session-card text-text_default_primary"
>
<WebuiIconSession className="flex-shrink-0" />
<WebuiMotionSlot kind="feedback-clip">
<WebuiMotionSlot kind="feedback-padding">
<span className="min-w-0 flex-1 truncate">{sessionLabel(session)}</span>
</WebuiMotionSlot>
<SessionActivityMeta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function ProjectExpansionView({
onContextMenu={(event) => onSessionContextMenu(event, session)}
className="webui-project-session-card text-text_default_primary"
>
<WebuiMotionSlot kind="feedback-clip">
<WebuiMotionSlot kind="feedback-padding">
<span className="min-w-0 flex-1 truncate">{sessionLabel(session)}</span>
</WebuiMotionSlot>
<SessionActivityMeta
Expand Down Expand Up @@ -213,7 +213,7 @@ function ProjectExpansionView({
className="webui-project-child-session-card text-text_default_primary"
>
<WebuiAgentAvatar agentName={child.agentName} size="compact" />
<WebuiMotionSlot kind="feedback-clip">
<WebuiMotionSlot kind="feedback-padding">
<span className="webui-project-child-session-title min-w-0 flex-1 truncate">{sessionLabel(child)}</span>
</WebuiMotionSlot>
<SessionActivityMeta
Expand Down
31 changes: 25 additions & 6 deletions packages/webui/src/client/features/sessions/ui/sessions.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,32 @@
line-height: var(--line_height_20);
}
.webui-pinned-session-card > span:first-of-type {
clip-path: inset(0 0 0 0);
padding-right: 0;
}
.webui-pinned-session-card:hover,
.webui-pinned-session-row:hover .webui-pinned-session-card {
color: var(--text_default_primary);
}
.webui-pinned-session-row:hover .webui-pinned-session-card > span:first-of-type,
.webui-pinned-session-row:has(:focus-visible) .webui-pinned-session-card > span:first-of-type {
clip-path: inset(0 88px 0 0);
/* Reserve the row actions with padding, not clip-path: a clip cuts the
* text away outright, so a title narrower than the reserve (88px) was
* erased entirely and only the floating buttons were left. */
padding-right: 88px;
}
.webui-project-section-content { min-width: 0; }
.webui-project-section-content-inner { min-height: 0; overflow: hidden; }
/* The base layer sets `scrollbar-gutter: stable` on every div/ul/section,
* so each of these nested rail containers reserved a 17px scrollbar slot.
* Five levels of nesting ate 85px and squeezed the session list down to
* 123px — narrower than the three inline row actions (90px), which left
* the session name nowhere to go. These levels never scroll, so the slot
* is pure loss; opt out the way the plugin and transcript panels do. */
.webui-disclosure-content,
.webui-project-section-content,
.webui-project-section-content-inner {
scrollbar-gutter: auto;
}
[data-webui-pinned-sessions="true"] { margin-bottom: var(--spacing_4); }
/* The section header is a full-width disclosure row, so its label belongs at
* the start of the row. The shared button base centres its content, and
Expand Down Expand Up @@ -309,11 +323,14 @@
padding: 0 var(--spacing_8);
}
.webui-project-session-card > span:first-child {
clip-path: inset(0 0 0 0);
padding-right: 0;
}
.webui-project-session-row:hover .webui-project-session-card > span:first-child,
.webui-project-session-row:has(:focus-visible) .webui-project-session-card > span:first-child {
clip-path: inset(0 88px 0 0);
/* Reserve the row actions with padding, not clip-path: a clip cuts the
* text away outright, so a title narrower than the reserve (88px) was
* erased entirely and only the floating buttons were left. */
padding-right: 88px;
}
.webui-pinned-session-row:hover .webui-rail-session-meta,
.webui-pinned-session-row:has(:focus-visible) .webui-rail-session-meta,
Expand Down Expand Up @@ -343,11 +360,13 @@
text-align: left;
}
.webui-project-child-session-title {
clip-path: inset(0 0 0 0);
padding-right: 0;
}
.webui-project-child-session-row:hover .webui-project-child-session-title,
.webui-project-child-session-row:has(:focus-visible) .webui-project-child-session-title {
clip-path: inset(0 28px 0 0);
/* Reserve the row action with padding, not clip-path: a clip cuts the
* text away outright instead of letting it end in an ellipsis. */
padding-right: 28px;
}
.webui-project-child-session-card:hover,
.webui-project-child-session-row:hover .webui-project-child-session-card,
Expand Down
5 changes: 5 additions & 0 deletions packages/webui/src/client/styles/motion.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
transition-timing-function: var(--webui-motion-ease-standard);
}
.webui-motion-feedback-clip { transition: clip-path var(--webui-motion-duration-feedback) var(--webui-motion-ease-standard); }
/* A title that reserves the row actions' room with padding rather than with a
* clip: the padding sits inside the title's own box, so the text ends in an
* ellipsis, a short title keeps its words, and the row does not move while it
* answers a hover. */
.webui-motion-feedback-padding { transition: padding-right var(--webui-motion-duration-feedback) var(--webui-motion-ease-standard); }
.webui-motion-feedback-opacity { transition: opacity var(--webui-motion-duration-feedback) var(--webui-motion-ease-standard); }
/* Shared progress motion for geometry-driven meters in any feature. */
.webui-motion-progress {
Expand Down
2 changes: 2 additions & 0 deletions packages/webui/src/client/ui/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export type WebuiMotionSlotKind =
| "feedback"
| "feedback-clip"
| "feedback-opacity"
| "feedback-padding"
| "panel-layout"
| "progress";

Expand All @@ -239,6 +240,7 @@ const WEBUI_MOTION_SLOT_CLASSES: Record<WebuiMotionSlotKind, string> = {
feedback: "webui-motion-feedback",
"feedback-clip": "webui-motion-feedback-clip",
"feedback-opacity": "webui-motion-feedback-opacity",
"feedback-padding": "webui-motion-feedback-padding",
"panel-layout": "webui-motion-panel-layout",
progress: "webui-motion-progress",
};
Expand Down
7 changes: 5 additions & 2 deletions packages/webui/test/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ pnpm build:webui # the suite drives the built client
pnpm test:webui-browser # uses the already installed Playwright Chromium; no system-package installation
```

The screenshot comparisons read the fonts in `fonts/`, not the ones the machine has installed, so
they produce the same result on any host. `LICENSE.noto-fonts` covers those files.
The screenshot comparisons read the fonts in `fonts/`, not the ones the machine has installed: the
fixture serves them as web fonts under the client's first family names, so the typeface is the same
everywhere. The pixels are not: every platform rasterizes those outlines its own way, so the
baselines are per-platform (`-darwin`, `-linux`, `-win32`) and a capture has to be recorded on the
platform whose baseline it replaces. `LICENSE.noto-fonts` covers those files.

How the fixture works, what the suite proves and what it does not, and which environment variables
change its server behaviour are documented in
Expand Down
16 changes: 10 additions & 6 deletions packages/webui/test/browser/harness.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ export async function attachJsonEvidence(name, value) {
*
* The committed baselines are recorded under the pinned font environment in
* `packages/webui/test/browser/fonts/`, so the glyphs are the same on every
* machine. What remains is the rasterizer's own rounding at a rounded
* corner: a bubble's right edge lands on a fractional pixel, and whether that
* edge rounds up or down shifts a handful of antialiased pixels from run to
* run. Measured over repeated runs of the browser suite, the widest such
* shift is seven pixels on the transcript surface and one on the plugin
* management list.
* machine. The pixels are not: every platform rasterizes those glyphs its own
* way, so each baseline is recorded on the platform that compares it, and two
* machines of one platform still differ by a handful of pixels.
*
* Within a platform, what remains is the rasterizer's own rounding at a
* rounded corner: a bubble's right edge lands on a fractional pixel, and
* whether that edge rounds up or down shifts a handful of antialiased pixels
* from run to run. Measured over repeated runs of the browser suite, the
* widest such shift is seven pixels on the transcript surface and one on the
* plugin management list.
*
* The budget is therefore seven pixels plus a little headroom, on a capture
* of well over a million pixels — under 0.001% of the image. A real layout
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 26 additions & 26 deletions packages/webui/test/browser/rail-pin.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,14 @@ function rowOf(page, sessionId) {
}

/**
* The right inset of a computed `inset()` clip, in pixels.
* The right padding of an element, in pixels.
*
* A clip of `inset(0px 88px 0px 0px)` hides the rightmost 88px of the
* element, so the element's visible right edge sits that far in from its
* layout box. Zero when the element is not clipped.
* A title that reserves the room for the row actions with padding keeps that
* room inside its own box, so the visible text ends that far in from the
* element's right edge. Zero when the element reserves nothing.
*/
function clipRightInset(clipPath) {
const match = /^inset\((.*)\)$/u.exec(String(clipPath).trim());
if (!match) return 0;
const parts = match[1].split(/\s+/u);
if (parts.length < 2) return 0;
return Number.parseFloat(parts[1]) || 0;
function rightPadding(paddingRight) {
return Number.parseFloat(String(paddingRight)) || 0;
}

/**
Expand Down Expand Up @@ -105,7 +101,7 @@ test("a pinned session row has one pin action and no duplicate pin marker", asyn
await expect(row.locator('[data-webui-rail-action="pin"][aria-label^="取消置顶"]')).toHaveCount(1);
});

test("hovering a child session keeps its avatar and clips only the title for the menu", async ({ page }) => {
test("hovering a child session keeps its avatar and reserves the menu's room in the title", async ({ page }) => {
await openApp(page, "#session=A");

const parentDisclosure = page.getByRole("button", { name: "展开子会话:Synthetic session A" });
Expand All @@ -124,7 +120,10 @@ test("hovering a child session keeps its avatar and clips only the title for the
await expect(avatar).toBeVisible();
await expect(action.getByRole("button", { name: "子任务 C 更多操作" })).toBeVisible();
expect(await avatar.evaluate((element) => getComputedStyle(element).clipPath)).toBe("none");
await expect.poll(() => title.evaluate((element) => getComputedStyle(element).clipPath)).toBe("inset(0px 28px 0px 0px)");
// The room for the row action is reserved with padding, so the title ends in
// an ellipsis instead of being cut away, and a title shorter than the
// reserve keeps its words.
await expect.poll(() => title.evaluate((element) => getComputedStyle(element).paddingRight)).toBe("28px");
const { titleBounds, actionBounds } = await childRow.evaluate((row) => {
const rect = (selector) => {
const { x, width } = row.querySelector(selector).getBoundingClientRect();
Expand Down Expand Up @@ -164,7 +163,7 @@ test("a running session title keeps its space before hover actions", async ({ pa
const labelBeforeHover = await label.evaluate((element) => {
const style = getComputedStyle(element);
const bounds = element.getBoundingClientRect();
return { clipPath: style.clipPath, boundsRight: bounds.right };
return { paddingRight: style.paddingRight, boundsRight: bounds.right };
});
const metadataBeforeHover = await metadata.boundingBox();
await row.hover();
Expand All @@ -174,7 +173,7 @@ test("a running session title keeps its space before hover actions", async ({ pa
const style = getComputedStyle(element);
const bounds = element.getBoundingClientRect();
return {
clipPath: style.clipPath,
paddingRight: style.paddingRight,
boundsRight: bounds.right,
transitionProperty: style.transitionProperty,
transitionDuration: style.transitionDuration,
Expand All @@ -189,20 +188,21 @@ test("a running session title keeps its space before hover actions", async ({ pa

expect(before).not.toBeNull();
expect(after).toBeNull();
// The space for the hover actions is kept by clipping the title's first
// span, not by padding it: the span is clipped from the right on hover, so
// the title's visible edge stops short of the actions. Clipping rather than
// padding keeps the row's own layout from moving while it answers a hover.
const clipBefore = clipRightInset(labelBeforeHover.clipPath);
const clipAfter = clipRightInset(labelLayout.clipPath);
const contentRightBefore = labelBeforeHover.boundsRight - clipBefore;
const contentRightAfter = labelLayout.boundsRight - clipAfter;
expect(clipBefore).toBe(0);
// The space for the hover actions is kept by padding the title's first
// span, not by clipping it: the padding is inside the span's own box, so
// the title's text ends that far short of the actions and the row's own
// layout does not move while it answers a hover. A title shorter than the
// reserve keeps its words, which a clip would have erased.
const padBefore = rightPadding(labelBeforeHover.paddingRight);
const padAfter = rightPadding(labelLayout.paddingRight);
const contentRightBefore = labelBeforeHover.boundsRight - padBefore;
const contentRightAfter = labelLayout.boundsRight - padAfter;
expect(padBefore).toBe(0);
expect(contentRightBefore).toBeLessThanOrEqual(metadataBeforeHover.x);
expect(clipAfter).toBe(88);
expect(padAfter).toBe(88);
expect(contentRightAfter).toBeLessThanOrEqual(actionsBounds.x);
expect(actionsBounds.x - contentRightAfter).toBeLessThanOrEqual(8);
expect(labelLayout.transitionProperty).toContain("clip-path");
expect(labelLayout.transitionProperty).toContain("padding-right");
expect(metaDisplay).toBe("none");
expect(actionStyle.opacity).toBe("1");
expect(actionStyle.transitionProperty).toContain("opacity");
Expand All @@ -211,7 +211,7 @@ test("a running session title keeps its space before hover actions", async ({ pa
await page.mouse.move(0, 0);
await expect(spinner).toBeVisible();
await expect(metadata).toBeVisible();
await expect.poll(() => label.evaluate((element) => getComputedStyle(element).clipPath)).toBe(labelBeforeHover.clipPath);
await expect.poll(() => label.evaluate((element) => getComputedStyle(element).paddingRight)).toBe(labelBeforeHover.paddingRight);
await expect.poll(() => actions.evaluate((element) => getComputedStyle(element).opacity)).toBe("0");
await page.screenshot({ path: test.info().outputPath("selected-running-session.png") });

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading