fix(webui): keep activity header stable when toggling (#6664)
* fix(webui): keep activity header stable when toggling * fix(webui): keep activity spacing compact
This commit is contained in:
1 parent
13279f4f2b
commit
d35b755fc2
3 files changed
+36
-15
No files matched your search
@@ -116,7 +116,7 @@ test("narrow reduced-motion preview replaces the row without scrolling the page"
|
|||||||
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBe(360);
|
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBe(360);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("the elapsed label does not shift the collapsed activity horizontally", async ({ page }) => {
|
test("the elapsed label keeps a compact gap before the collapsed activity", async ({ page }) => {
|
||||||
await page.setViewportSize({ width: 960, height: 740 });
|
await page.setViewportSize({ width: 960, height: 740 });
|
||||||
const start = new Date("2026-01-01T00:00:00Z");
|
const start = new Date("2026-01-01T00:00:00Z");
|
||||||
await page.clock.install({ time: start });
|
await page.clock.install({ time: start });
|
||||||
@@ -126,14 +126,43 @@ test("the elapsed label does not shift the collapsed activity horizontally", asy
|
|||||||
const wheel = page.getByTestId("latest-activity-wheel");
|
const wheel = page.getByTestId("latest-activity-wheel");
|
||||||
await expect(wheel).toBeVisible();
|
await expect(wheel).toBeVisible();
|
||||||
|
|
||||||
let initialX: number | undefined;
|
let initialGap: number | undefined;
|
||||||
let elapsed = 0;
|
let elapsed = 0;
|
||||||
for (const [seconds, label] of [[1, "1s"], [9, "9s"], [10, "10s"], [20, "20s"], [59, "59s"], [60, "1m"], [61, "1m 1s"]] as const) {
|
for (const [seconds, label] of [[1, "1s"], [9, "9s"], [10, "10s"], [20, "20s"], [59, "59s"], [60, "1m"], [61, "1m 1s"]] as const) {
|
||||||
await page.clock.fastForward((seconds - elapsed) * 1000);
|
await page.clock.fastForward((seconds - elapsed) * 1000);
|
||||||
elapsed = seconds;
|
elapsed = seconds;
|
||||||
await expect(toggle).toHaveAccessibleName(`处理中 ${label}`);
|
await expect(toggle).toHaveAccessibleName(`处理中 ${label}`);
|
||||||
const { x } = (await wheel.boundingBox())!;
|
const wheelBox = (await wheel.boundingBox())!;
|
||||||
initialX ??= x;
|
const headerBox = (await toggle.boundingBox())!;
|
||||||
expect(Math.abs(x - initialX), `wheel displacement at ${label}`).toBeLessThan(0.2);
|
const gap = wheelBox.x - (headerBox.x + headerBox.width);
|
||||||
|
initialGap ??= gap;
|
||||||
|
expect(Math.abs(gap - initialGap), `activity gap at ${label}`).toBeLessThan(0.2);
|
||||||
|
expect(gap).toBeLessThanOrEqual(8);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the working label stays in place when activity is expanded and collapsed", async ({ page }) => {
|
||||||
|
for (const width of [960, 360]) {
|
||||||
|
await page.setViewportSize({ width, height: 740 });
|
||||||
|
const toggle = page.getByRole("button", { name: /处理中/ });
|
||||||
|
const labelPosition = () => toggle.evaluate((button) => {
|
||||||
|
const label = button.querySelector("[data-sheen-text]")!;
|
||||||
|
const range = document.createRange();
|
||||||
|
range.selectNodeContents(label);
|
||||||
|
const { x, y } = range.getBoundingClientRect();
|
||||||
|
return { x, y, width: button.getBoundingClientRect().width };
|
||||||
|
});
|
||||||
|
const collapsed = await labelPosition();
|
||||||
|
await toggle.click();
|
||||||
|
await expect(toggle).toHaveAttribute("aria-expanded", "true");
|
||||||
|
const expanded = await labelPosition();
|
||||||
|
expect(Math.abs(expanded.x - collapsed.x)).toBeLessThan(0.2);
|
||||||
|
expect(Math.abs(expanded.y - collapsed.y)).toBeLessThan(0.2);
|
||||||
|
expect(Math.abs(expanded.width - collapsed.width)).toBeLessThan(0.2);
|
||||||
|
await toggle.click();
|
||||||
|
await expect(toggle).toHaveAttribute("aria-expanded", "false");
|
||||||
|
const collapsedAgain = await labelPosition();
|
||||||
|
expect(Math.abs(collapsedAgain.x - collapsed.x)).toBeLessThan(0.2);
|
||||||
|
expect(Math.abs(collapsedAgain.y - collapsed.y)).toBeLessThan(0.2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -409,7 +409,6 @@ function FoldedAgentActivity({
|
|||||||
collapseLabel={t("message.collapseActivity")}
|
collapseLabel={t("message.collapseActivity")}
|
||||||
contentId={detailsId}
|
contentId={detailsId}
|
||||||
label={activityLabel}
|
label={activityLabel}
|
||||||
reservedLabel={showActivityPreview ? workingLabel("00m 00s") : undefined}
|
|
||||||
preview={showActivityPreview ? (
|
preview={showActivityPreview ? (
|
||||||
<CollapsedActivityPreview
|
<CollapsedActivityPreview
|
||||||
messages={activityMessages}
|
messages={activityMessages}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ interface ThinkingReasoningShellProps {
|
|||||||
collapseLabel?: string;
|
collapseLabel?: string;
|
||||||
contentId?: string;
|
contentId?: string;
|
||||||
label: string;
|
label: string;
|
||||||
reservedLabel?: string;
|
|
||||||
preview?: ReactNode;
|
preview?: ReactNode;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
hasDetails?: boolean;
|
hasDetails?: boolean;
|
||||||
@@ -26,7 +25,6 @@ export function ThinkingReasoningShell({
|
|||||||
collapseLabel,
|
collapseLabel,
|
||||||
contentId: providedContentId,
|
contentId: providedContentId,
|
||||||
label,
|
label,
|
||||||
reservedLabel,
|
|
||||||
preview,
|
preview,
|
||||||
children,
|
children,
|
||||||
hasDetails = true,
|
hasDetails = true,
|
||||||
@@ -40,7 +38,7 @@ export function ThinkingReasoningShell({
|
|||||||
"touch-target inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-1.5",
|
"touch-target inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-1.5",
|
||||||
preview && "max-sm:self-start",
|
preview && "max-sm:self-start",
|
||||||
);
|
);
|
||||||
const labelClassName = "min-w-0 truncate text-[12px] font-normal leading-4";
|
const labelClassName = "min-w-0 truncate text-[12px] font-normal leading-4 tabular-nums";
|
||||||
const headerLabel = (
|
const headerLabel = (
|
||||||
<span
|
<span
|
||||||
data-sheen-text={active ? label : undefined}
|
data-sheen-text={active ? label : undefined}
|
||||||
@@ -54,12 +52,7 @@ export function ThinkingReasoningShell({
|
|||||||
<Activity className={cn("h-3.5 w-3.5 shrink-0", active ? "activity-current" : "text-muted-foreground")} strokeWidth={1.5} aria-hidden>
|
<Activity className={cn("h-3.5 w-3.5 shrink-0", active ? "activity-current" : "text-muted-foreground")} strokeWidth={1.5} aria-hidden>
|
||||||
{active ? <path className="activity-current-trace" pathLength={100} d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2" /> : null}
|
{active ? <path className="activity-current-trace" pathLength={100} d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2" /> : null}
|
||||||
</Activity>
|
</Activity>
|
||||||
{reservedLabel ? (
|
{headerLabel}
|
||||||
<span className="grid min-w-0 tabular-nums [&>span]:col-start-1 [&>span]:row-start-1">
|
|
||||||
{headerLabel}
|
|
||||||
<span className={cn(labelClassName, "invisible")} aria-hidden>{reservedLabel}</span>
|
|
||||||
</span>
|
|
||||||
) : headerLabel}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in new issue
Block a user