From e7e94bda1cc190d2a234d1f0e2bf770952880124 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sun, 25 Oct 2026 12:46:55 +0800 Subject: [PATCH] fix(webui): remove extra frames from activity logos --- webui/browser/activity-logos-fixture.tsx | 52 ++++++++++++++ webui/browser/activity-logos.spec.ts | 68 +++++++++++++++++++ webui/browser/fixture.tsx | 3 + .../thread/AgentActivityCluster.tsx | 30 ++------ 4 files changed, 129 insertions(+), 24 deletions(-) create mode 100644 webui/browser/activity-logos-fixture.tsx create mode 100644 webui/browser/activity-logos.spec.ts diff --git a/webui/browser/activity-logos-fixture.tsx b/webui/browser/activity-logos-fixture.tsx new file mode 100644 index 000000000..b22273802 --- /dev/null +++ b/webui/browser/activity-logos-fixture.tsx @@ -0,0 +1,52 @@ +import { useEffect, useState } from "react"; +import { AgentActivityCluster } from "@/components/thread/AgentActivityCluster"; +import { formatToolCallTrace } from "@/lib/tool-traces"; +import type { CliAppInfo, McpPresetInfo, UIMessage } from "@/lib/types"; + +const cliApp: CliAppInfo = { + name: "blender", display_name: "Blender", category: "3d", description: "Preview app", + requires: "", source: "harness", entry_point: "cli-anything-blender", + install_supported: true, installed: true, available: true, status: "installed", + logo_url: "https://cdn.simpleicons.org/blender", brand_color: "#E87D0D", skill_installed: true, +}; +const preset: McpPresetInfo = { + name: "linear", display_name: "Linear", category: "productivity", description: "Preview app", + docs_url: "https://linear.app", transport: "streamableHttp", requires: "", note: "", + install_supported: true, installed: true, configured: true, available: true, status: "configured", + logo_url: "https://icons.duckduckgo.com/ip3/linear.app.ico", brand_color: "#6D5DF6", + required_fields: [], connection_summary: "Preview only", +}; + +function messages(phase: "start" | "end" | "error"): UIMessage[] { + const toolEvents = [ + { name: "mcp_linear_get_workspace", args: {} }, + { name: "run_cli_app", args: { name: "blender", args: ["--background", "scene.blend"], json: true } }, + ].map(({ name, args }) => ({ phase, call_id: `${phase}-${name}`, name, arguments: args, + ...(phase === "error" ? { error: "Preview failure" } : {}) })); + const traces = toolEvents.map(event => formatToolCallTrace(event)!); + return [{ + id: `${phase}-tools`, role: "tool", kind: "trace", createdAt: 1, + content: traces.join("\n"), traces, toolEvents, + }]; +} + +export function ActivityLogosFixture({ parameters }: { parameters: URLSearchParams }) { + const [dark, setDark] = useState(parameters.has("dark")); + useEffect(() => { document.documentElement.classList.toggle("dark", dark); }, [dark]); + const fallback = parameters.has("fallback"); + return
+
+

Activity logo preview

+ +
+ {(["end", "start", "error"] as const).map((phase) => ( +
+

{phase === "start" ? "Running" : phase === "end" ? "Completed" : "Failed"}

+ +
+ ))} +
; +} diff --git a/webui/browser/activity-logos.spec.ts b/webui/browser/activity-logos.spec.ts new file mode 100644 index 000000000..09a562ca8 --- /dev/null +++ b/webui/browser/activity-logos.spec.ts @@ -0,0 +1,68 @@ +import { expect, test } from "@playwright/test"; + +// Opaque and transparent artwork exercise both common brand-image layouts offline. +const tile = ''; +const mark = ''; + +test.beforeEach(async ({ page }) => { + await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en")); + await page.route("https://icons.duckduckgo.com/ip3/linear.app.ico", route => route.fulfill({ contentType: "image/svg+xml", body: tile })); + await page.route("https://cdn.simpleicons.org/blender", route => route.fulfill({ contentType: "image/svg+xml", body: mark })); + await page.route("**/api/**", route => route.fulfill({ json: {} })); +}); + +for (const width of [1280, 360]) { + for (const dark of [false, true]) { + test.describe(`${width}px ${dark ? "dark" : "light"} activity logos`, () => { + test.use({ viewport: { width, height: 700 } }); + test("fits brand images directly to the rounded mark while preserving status and alignment", async ({ page }, testInfo) => { + await page.goto(`/browser/fixture.html?case=activity-logos${dark ? "&dark" : ""}`); + for (const phase of ["end", "start", "error"]) { + const section = page.getByRole("region", { name: phase, exact: true }); + const positions: number[] = []; + for (const id of ["activity-mcp-logo-linear", "activity-cli-logo-blender"]) { + const logo = section.getByTestId(id); + const image = logo.locator("img"); + await expect(image).toBeVisible(); + await expect.poll(() => image.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBe(32); + const imageBox = (await image.boundingBox())!; + const frame = (await logo.boundingBox())!; + expect(frame.width).toBe(16); + expect(frame.height).toBe(16); + expect(imageBox).toEqual(frame); + await expect(logo).toHaveCSS("background-color", "rgba(0, 0, 0, 0)"); + await expect(logo).toHaveCSS("border-top-width", "0px"); + await expect(logo).toHaveCSS("box-shadow", "none"); + await expect(logo).toHaveCSS("animation-name", phase === "start" ? "pulse" : "none"); + expect(await logo.evaluate(node => parseFloat(getComputedStyle(node).borderRadius))).toBeGreaterThan(0); + positions.push(frame.x); + } + expect(positions[0]).toBe(positions[1]); + } + await expect(page.getByRole("region", { name: "end", exact: true })).toContainText("Used Blender"); + await expect(page.getByRole("region", { name: "start", exact: true })).toContainText("Using Blender"); + await expect(page.getByRole("region", { name: "error", exact: true })).toContainText("Could not use Blender"); + expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBe(width); + await page.locator("main").screenshot({ path: testInfo.outputPath("activity-logos.png") }); + }); + }); + } +} + +test("keeps missing and failed logos identifiable in both themes", async ({ page }) => { + await page.route("**/browser/missing-activity-logo.svg", route => route.fulfill({ status: 404, body: "" })); + await page.goto("/browser/fixture.html?case=activity-logos&fallback"); + for (const dark of [false, true]) { + if (dark) await page.getByRole("button", { name: "Toggle theme" }).click(); + for (const phase of ["end", "start", "error"]) { + const section = page.getByRole("region", { name: phase, exact: true }); + await expect(section.getByTestId("activity-mcp-logo-linear")).toHaveText("L"); + await expect(section.getByTestId("activity-cli-logo-blender")).toHaveText("B"); + for (const logo of [section.getByTestId("activity-mcp-logo-linear"), section.getByTestId("activity-cli-logo-blender")]) { + await expect(logo).toHaveCSS("width", "16px"); + await expect(logo).toHaveCSS("color", "rgb(255, 255, 255)"); + expect(await logo.evaluate(node => getComputedStyle(node).backgroundColor)).not.toBe("rgba(0, 0, 0, 0)"); + } + } + } +}); diff --git a/webui/browser/fixture.tsx b/webui/browser/fixture.tsx index 41f38ed71..ce5bc7d66 100644 --- a/webui/browser/fixture.tsx +++ b/webui/browser/fixture.tsx @@ -29,6 +29,7 @@ import { ChatFailureFixture } from "./chat-failure-fixture"; import { ThreadLoadingFixture } from "./thread-loading-fixture"; import { AnswerOrderFixture } from "./answer-order-fixture"; import { SidebarActivityFixture } from "./sidebar-activity-fixture"; +import { ActivityLogosFixture } from "./activity-logos-fixture"; import { HistoryHydrationFixture } from "./history-hydration-fixture"; import { IdleCompactionFixture, installIdleCompactionApi } from "./idle-compaction-fixture"; import { FileEditPathFixture } from "./file-edit-path-fixture"; @@ -225,6 +226,8 @@ createRoot(document.getElementById("root")!).render( ? : parameters.get("case") === "answer-order" ? + : parameters.get("case") === "activity-logos" + ? : parameters.get("case") === "sidebar-activity" ? : parameters.get("case") === "chat-failure" diff --git a/webui/src/components/thread/AgentActivityCluster.tsx b/webui/src/components/thread/AgentActivityCluster.tsx index 429022a8b..232e87831 100644 --- a/webui/src/components/thread/AgentActivityCluster.tsx +++ b/webui/src/components/thread/AgentActivityCluster.tsx @@ -1268,14 +1268,10 @@ function CliRunRow({ run, active, app }: { run: CliRunSummary; active: boolean; {logoUrl ? ( @@ -1284,7 +1280,7 @@ function CliRunRow({ run, active, app }: { run: CliRunSummary; active: boolean; alt="" decoding="async" loading="lazy" - className="h-[78%] w-[78%] object-contain" + className="h-full w-full object-contain" onLoad={onLogoLoad} onError={onLogoError} /> @@ -1349,14 +1345,10 @@ function McpRunRow({ run, active, preset }: { run: McpRunSummary; active: boolea {logoUrl ? ( @@ -1365,7 +1357,7 @@ function McpRunRow({ run, active, preset }: { run: McpRunSummary; active: boolea alt="" decoding="async" loading="lazy" - className="h-[78%] w-[78%] object-contain" + className="h-full w-full object-contain" onLoad={onLogoLoad} onError={onLogoError} /> @@ -1379,13 +1371,3 @@ function McpRunRow({ run, active, preset }: { run: McpRunSummary; active: boolea /> ); } - -function alphaColor(color: string, percent: number): string { - if (/^#[0-9a-f]{6}$/i.test(color)) { - const alpha = Math.round((percent / 100) * 255) - .toString(16) - .padStart(2, "0"); - return `${color}${alpha}`; - } - return `color-mix(in srgb, ${color} ${percent}%, transparent)`; -}