A local-first multi-agent app development platform, built on PenguinHarness
fix(ui): 默认头像与智能体头像改用 Adelie 图标
lmliheng9597f3c3dd73
diff --git a/packages/ui/src/components/icons/avatars/agent-avatar.tsx b/packages/ui/src/components/icons/avatars/agent-avatar.tsxindex e9e7c5c1..f27c06f6 100644--- a/packages/ui/src/components/icons/avatars/agent-avatar.tsx+++ b/packages/ui/src/components/icons/avatars/agent-avatar.tsx@@ -1,48 +1,29 @@/**- * An agent's avatar: its initial as coloured ink on a light tinted tile (the letter-tile style- * `ProviderLogo` also draws for user-defined model groups).+ * An agent's avatar.*- * The colour hashes the agent's id — not its display name — so it survives renames; the initial- * comes from the display name when the caller has one, falling back to the id. The ink follows- * the colour scheme through one `light-dark()` value, keeping ≥ 4.5:1 on the tile for every hue- * in both modes (see `avatar.ts`).+ * An agent has no picture of its own, so it draws the Adelie mark — the same brand emblem the app+ * icon and the account's own default avatar carry. This used to be a letter tile: the agent's+ * initial as coloured ink on a hue hashed from its id. That told agents apart at a glance, but it+ * also made every agent a different colour of the same placeholder, and a product whose agents are+ * its subject should sign them with its own mark (user decision, 2026-10-06: "默认智能体头像改成+ * Adelie 图标").+ *+ * `id` and `name` stay in the signature — every call site passes them, and a caller that knows an+ * agent's name is not wrong to say so — but the mark needs neither. The letter-tile helpers in+ * `avatar.ts` are still what `ProviderLogo` draws a user-defined model group with.*/-import { avatarInitial, avatarTile } from "./avatar";+import { AdelieMark } from "../logos/adelie-mark";export function AgentAvatar({- id,- name,size = 18,className,}: {+ /** The agent's id. No longer drawn; kept so call sites stay as they are. */id: string;- /** Display name supplying the initial; omitted, the id's initial is used. */+ /** Display name. No longer drawn, for the reason above. */name?: string;size?: number;className?: string;}) {- const tile = avatarTile(id);- return (- <svg- width={size}- height={size}- viewBox="0 0 24 24"- className={className}- aria-hidden- role="img"- >- <rect x="0" y="0" width="24" height="24" rx="5" fill={tile.bg} />- <text- x="12"- y="12"- textAnchor="middle"- dominantBaseline="central"- fontSize="13"- fontWeight="700"- style={{ fill: tile.ink }}- >- {avatarInitial(name ?? "", id)}- </text>- </svg>- );+ return <AdelieMark size={size} className={`rounded-full ${className ?? ""}`} />;}diff --git a/packages/ui/src/components/icons/avatars/avatar-stack.tsx b/packages/ui/src/components/icons/avatars/avatar-stack.tsxindex 19874616..886b70e5 100644--- a/packages/ui/src/components/icons/avatars/avatar-stack.tsx+++ b/packages/ui/src/components/icons/avatars/avatar-stack.tsx@@ -3,9 +3,9 @@* a benchmark has tested. The avatars are decorative — the names belong to the caller's tooltip* or label, since a row of initials names nobody — while the count stays readable text.*- * Each avatar is ringed in the canvas colour so overlapping tiles stay apart; the ring follows- * the avatar's own outline (a disc for an account, the tile's fixed corner for an agent), which- * is geometry of the tile rather than a theme radius.+ * Each avatar is ringed in the canvas colour so overlapping discs stay apart; every avatar is a+ * disc now that both defaults are the Adelie mark, so the ring is one geometry, not a theme+ * radius.*/import { AgentAvatar } from "./agent-avatar";import { UserAvatar } from "./user-avatar";@@ -21,9 +21,6 @@ export interface AvatarStackItem {src?: string;}-/** An agent tile's corner: `rx="5"` on its 24-unit box, at the rendered size. */-const tileRadius = (size: number) => (size * 5) / 24;-export function AvatarStack({items,max = 3,@@ -45,8 +42,7 @@ export function AvatarStack({{shown.map((item) => (<spankey={`${item.kind ?? "agent"}:${item.id}`}- className="flex shrink-0 ring-2 ring-canvas"- style={{ borderRadius: item.kind === "user" ? "50%" : tileRadius(size) }}+ className="flex shrink-0 rounded-full ring-2 ring-canvas">{item.kind === "user" ? (<UserAvatar userId={item.id} displayName={item.name} avatar={item.src} size={size} />diff --git a/packages/ui/src/components/icons/avatars/user-avatar.tsx b/packages/ui/src/components/icons/avatars/user-avatar.tsxindex 6792a457..202d728e 100644--- a/packages/ui/src/components/icons/avatars/user-avatar.tsx+++ b/packages/ui/src/components/icons/avatars/user-avatar.tsx@@ -3,19 +3,17 @@* account menu's header, a profile page's preview.** Two states, one component. With an avatar stored it is that image, cropped to the circle;- * without one it is a letter disc — the foreground colour with the initial in the canvas colour,- * which is deliberately NOT the tinted hashed tile `AgentAvatar` uses: an account is the one- * identity the viewer already knows, so it does not need a colour to be told apart from its- * neighbours, and there is only ever one of it on screen. The initial follows the nickname once- * there is one, falling back to the id, so the disc changes with the name rather than- * contradicting it.+ * without one it is the Adelie mark — the account has not said who it is, so it is the app that+ * answers, rather than a letter disc that would be a name (the first letter of the nickname, or+ * of the id) dressed up as a picture. The stored image still wins: the mark is the default, not a+ * badge.*- * `size` is in pixels and the letter's size is derived from it, rather than both coming from the- * type scale: the disc is a fixed box, so a letter that grew with the user's font-size setting- * would outgrow it at the largest tier.+ * `size` is in pixels and the mark is scaled to it, rather than both coming from the type scale:+ * the disc is a fixed box, so a mark that grew with the user's font-size setting would outgrow it+ * at the largest tier.*/import type { CSSProperties, ReactNode } from "react";-import { avatarInitial } from "./avatar";+import { AdelieMark } from "../logos/adelie-mark";/*** The sizes a user avatar is drawn at, named by the slot rather than by the number (the@@ -25,22 +23,17 @@ import { avatarInitial } from "./avatar";*/export const USER_AVATAR_SIZE = { tile: 28, preview: 64 } as const;-/** The letter's share of the disc: large enough to read at 28px, still inside the circle at 64. */-const INITIAL_RATIO = 0.45;-export function UserAvatar({- userId,- displayName,avatar,size = USER_AVATAR_SIZE.tile,className,children,}: {- /** The account's id — the fallback initial. */+ /** The account's id. Unused while no image is stored — the mark carries no initial. */userId: string;- /** Nickname, when set: it supplies the initial. */+ /** Nickname, when set. Unused while no image is stored, for the reason above. */displayName?: string;- /** Stored avatar as a URL (a data URL from a profile upload); absent, the letter disc is drawn. */+ /** Stored avatar as a URL (a data URL from a profile upload); absent, the Adelie mark is drawn. */avatar?: string;/** Edge length in pixels — pass a `USER_AVATAR_SIZE` rung. */size?: number;@@ -48,29 +41,22 @@ export function UserAvatar({/** Overlay slot, positioned against this disc: a trigger hangs its update dot here. */children?: ReactNode;}) {- const who = displayName ?? userId;const box: CSSProperties = { width: size, height: size };if (avatar !== undefined) {return (<span className={`relative block shrink-0 ${className ?? ""}`} style={box}>{/* object-cover, though a stored avatar is usually square already: one written by an APIclient rather than by a cropping upload must still fill the circle, not stretch into- it. alt="" for the reason the letter disc is aria-hidden — see below. */}+ it. alt="" because the mark below is decorative too: the avatar is never the account's+ name — every anchor it sits in already names the account. */}<img src={avatar} alt="" className="h-full w-full rounded-full object-cover" style={box} />{children}</span>);}return (- <span- // Decorative, like the image above: the mark is never the account's name. Every anchor- // this sits in already names the account, in its own accessible name or in the text- // beside it, so announcing a bare initial as well would only repeat the first letter.- aria-hidden- className={`relative flex shrink-0 items-center justify-center rounded-full bg-fg font-bold text-canvas ${className ?? ""}`}- style={{ ...box, fontSize: Math.round(size * INITIAL_RATIO) }}- >- {avatarInitial(who, userId)}+ <span className={`relative block shrink-0 ${className ?? ""}`} style={box}>+ <AdelieMark size={size} className="rounded-full" />{children}</span>);diff --git a/packages/ui/src/components/icons/logos/adelie-mark.tsx b/packages/ui/src/components/icons/logos/adelie-mark.tsxnew file mode 100644index 00000000..26a5dca3--- /dev/null+++ b/packages/ui/src/components/icons/logos/adelie-mark.tsx@@ -0,0 +1,104 @@+/**+ * The Adelie brand emblem inlined as a component: the penguin — the white ring around each eye is+ * the species' signature — standing inside the harness's blue orbit, on the white plate the app+ * icon draws it on.+ *+ * It lives here rather than being loaded from `packages/web/public/adelie-icon.svg`: that asset+ * belongs to the Web App (it is also the favicon), and the UI package must not depend on a+ * consumer's public directory. The plate is kept underneath rather than dropped — the penguin's+ * back is nearly black, so without it the mark would vanish against a dark surface; the visible+ * crop is drawn tighter than the asset's own square, because the asset carries padding meant for+ * an app icon and the mark is also drawn at 18px here.+ *+ * Decorative like the avatars that use it — the mark is never the name of the thing it is drawn+ * for — so it is `aria-hidden` and takes no label.+ *+ * `useId` keeps the gradient definitions distinct per instance (colour and bill reference them by+ * id, and a page holds hundreds of these); the colons React puts in its ids are stripped because+ * they are not valid inside an SVG `url(#…)` reference.+ */+import { useId } from "react";++/** The crop drawn inside the asset's 1024-unit square: the orbit (197–827 × 215–845) with a little air. */+const VIEW_BOX = "170 170 684 684";++export function AdelieMark({ size = 24, className }: { size?: number; className?: string }) {+ const uid = useId().replace(/[^a-zA-Z0-9]/g, "");+ const body = `${uid}body`;+ const orbit = `${uid}orbit`;+ const bill = `${uid}bill`;+ return (+ <svg+ width={size}+ height={size}+ viewBox={VIEW_BOX}+ role="img"+ aria-hidden+ className={`shrink-0 ${className ?? ""}`}+ >+ <defs>+ <linearGradient+ id={body}+ x1="318"+ y1="225"+ x2="706"+ y2="840"+ gradientUnits="userSpaceOnUse"+ >+ <stop offset="0" stopColor="#1a2a49" />+ <stop offset=".5" stopColor="#0e1c37" />+ <stop offset="1" stopColor="#070f1e" />+ </linearGradient>+ <linearGradient+ id={orbit}+ x1="212"+ y1="830"+ x2="812"+ y2="230"+ gradientUnits="userSpaceOnUse"+ >+ <stop offset="0" stopColor="#0b2963" />+ <stop offset=".45" stopColor="#054ac8" />+ <stop offset="1" stopColor="#015dfc" />+ </linearGradient>+ <linearGradient+ id={bill}+ x1="474"+ y1="415"+ x2="550"+ y2="534"+ gradientUnits="userSpaceOnUse"+ >+ <stop offset="0" stopColor="#054ac8" />+ <stop offset="1" stopColor="#015dfc" />+ </linearGradient>+ </defs>++ {/* the plate: the white rounded square Adelie draws its penguin on (its own corners are cut+ by the caller's shape — the crop above never reaches them) */}+ <rect width="1024" height="1024" fill="#fefefe" />++ {/* orbit: the harness's blue sweep; the penguin stands in it, so only its two tails show */}+ <circle cx="512" cy="530" r="300" fill="none" stroke={`url(#${orbit})`} strokeWidth="30" />++ {/* the Adelie: bowling-pin silhouette, black back and head, white belly */}+ <path+ d="M 512 225 C 596 225 652 296 662 388 C 684 470 706 560 706 660 C 706 780 664 840 512 840+ C 360 840 318 780 318 660 C 318 560 340 470 362 388 C 372 296 428 225 512 225 Z"+ fill={`url(#${body})`}+ />+ <ellipse cx="512" cy="705" rx="124" ry="130" fill="#fefefe" />++ {/* the species' signature: the white ring around each eye */}+ <circle cx="448" cy="356" r="46" fill="none" stroke="#fefefe" strokeWidth="24" />+ <circle cx="576" cy="356" r="46" fill="none" stroke="#fefefe" strokeWidth="24" />++ {/* bill */}+ <path+ d="M 512 415 C 542 440 552 470 549 492 C 546 514 532 528 512 534 C 492 528 478 514 475 492+ C 472 470 482 440 512 415 Z"+ fill={`url(#${bill})`}+ />+ </svg>+ );+}diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.tsindex ad3761e7..8de68acd 100644--- a/packages/ui/src/index.ts+++ b/packages/ui/src/index.ts@@ -21,6 +21,7 @@ export * from "./components/icons/marks/marks";export * from "./components/icons/spinner/spinner";export * from "./components/icons/logos/provider-logo";export * from "./components/icons/logos/app-logo";+export * from "./components/icons/logos/adelie-mark";export * from "./components/icons/avatars/avatar";export * from "./components/icons/avatars/agent-avatar";export * from "./components/icons/avatars/user-avatar";diff --git a/packages/ui/test/adelie-mark.test.ts b/packages/ui/test/adelie-mark.test.tsnew file mode 100644index 00000000..6adf6e36--- /dev/null+++ b/packages/ui/test/adelie-mark.test.ts@@ -0,0 +1,45 @@+/**+ * The inlined brand mark: it must stay the asset's own drawing. The Web App's+ * `public/adelie-icon.svg` is what the favicon, the desktop icon set and the landing page are+ * generated from, and this component is the copy the UI package draws avatars with — two copies+ * that must not drift, so every path of the asset is checked to be in the component's markup.+ */+import { readFileSync } from "node:fs";+import { join } from "node:path";+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { AdelieMark } from "../src/components/icons/logos/adelie-mark";+import { renderStatic } from "../src/testing";+import { REPO_ROOT } from "./helpers/paths";++const ASSET = join(REPO_ROOT, "packages", "web", "public", "adelie-icon.svg");+const collapse = (s: string) => s.replace(/\s+/g, " ");++describe("AdelieMark", () => {+ it("draws every path of the brand asset", () => {+ const source = readFileSync(ASSET, "utf8");+ const html = collapse(renderStatic(createElement(AdelieMark, { size: 24 })));+ // (`\s` first, so `id="plate"` is not read as a path.)+ const paths = [...source.matchAll(/\sd="([^"]+)"/g)].map((m) => m[1]!);+ expect(paths.length).toBeGreaterThan(1);+ for (const d of paths) expect(html).toContain(collapse(`d="${d}"`));+ });++ it("is sized to the caller and decorative", () => {+ const html = renderStatic(createElement(AdelieMark, { size: 40, className: "rounded-full" }));+ expect(html).toContain('width="40"');+ expect(html).toContain('height="40"');+ expect(html).toContain('aria-hidden="true"');+ expect(html).toContain("rounded-full");+ });++ it("gives each instance its own gradient ids, valid inside a url(#…) reference", () => {+ const html = renderStatic(+ createElement("div", null, createElement(AdelieMark, {}), createElement(AdelieMark, {})),+ );+ const ids = [...html.matchAll(/id="([^"]+)"/g)].map((m) => m[1]!);+ expect(new Set(ids).size).toBe(ids.length);+ for (const id of ids) expect(id).toMatch(/^[A-Za-z0-9]+$/);+ for (const ref of html.matchAll(/url\(#([^)]+)\)/g)) expect(ids).toContain(ref[1]!);+ });+});diff --git a/packages/ui/test/avatars.test.ts b/packages/ui/test/avatars.test.tsindex 5f30993d..f3c6d3a0 100644--- a/packages/ui/test/avatars.test.ts+++ b/packages/ui/test/avatars.test.ts@@ -1,36 +1,39 @@/**- * The avatars' markup: an agent tile inks its initial through one scheme-following value (no- * dark-mode class), an account's disc is drawn in tokens, and a stack shows a few avatars then- * a count, with the avatars themselves hidden from assistive technology.+ * The avatars' markup: both defaults are the Adelie mark — an account that stored no image, and an+ * agent, which never has one — a stored account image still wins over it, and a stack shows a few+ * discs then a count, with the avatars themselves hidden from assistive technology.*/import { createElement } from "react";import { describe, expect, it } from "vitest";import { AgentAvatar } from "../src/components/icons/avatars/agent-avatar";-import { avatarTile } from "../src/components/icons/avatars/avatar";import { AvatarStack } from "../src/components/icons/avatars/avatar-stack";import { USER_AVATAR_SIZE, UserAvatar } from "../src/components/icons/avatars/user-avatar";import { classTokens, renderStatic } from "../src/testing";+/** The mark's white plate — what tells an Adelie mark apart from any other inline svg. */+const PLATE = "#fefefe";+describe("AgentAvatar", () => {- it("draws the name's initial on the id's tile, inked with light-dark()", () => {+ it("draws the Adelie mark, not the initial's letter tile", () => {const html = renderStatic(createElement(AgentAvatar, { id: "docs-expert", name: "docs" }));- const tile = avatarTile("docs-expert");- expect(html).toContain(`fill="${tile.bg}"`);- expect(html).toContain(`fill:${tile.ink}`);- expect(html).toContain(">D</text>");- expect(html).not.toContain("dark:");+ expect(html).toContain("<svg");+ expect(html).toContain(PLATE);expect(html).toContain('aria-hidden="true"');+ expect(html).not.toContain("</text>");+ expect(html).not.toContain(">D<");});});describe("UserAvatar", () => {- it("draws the nickname's initial on a token disc when no image is stored", () => {+ it("draws the Adelie mark when no image is stored, circle-cropped", () => {const html = renderStatic(createElement(UserAvatar, { userId: "admin", displayName: "zoe", size: 28 }),);- expect(classTokens(html)).toEqual(expect.arrayContaining(["bg-fg", "text-canvas"]));- expect(html).toContain(">Z</span>");- expect(html).toContain('aria-hidden="true"');+ expect(html).toContain("<svg");+ expect(html).toContain(PLATE);+ expect(classTokens(html)).toContain("rounded-full");+ expect(html).toContain("width:28px");+ expect(html).not.toContain(">Z<");});it("shows a stored image cropped to the circle, with no alternative text of its own", () => {@@ -44,6 +47,7 @@ describe("UserAvatar", () => {expect(html).toContain('src="data:image/png;base64,AAAA"');expect(html).toContain('alt=""');expect(html).toContain("width:64px");+ expect(html).not.toContain(PLATE);});});@@ -61,7 +65,7 @@ describe("AvatarStack", () => {expect(html).not.toMatch(/>\+\d/);});- it("hides the avatars from assistive technology and draws an account as a disc", () => {+ it("hides the avatars from assistive technology and rings every disc the same way", () => {const html = renderStatic(createElement(AvatarStack, {items: [@@ -72,7 +76,8 @@ describe("AvatarStack", () => {}),);expect(html).toMatch(/^<span class="[^"]*"><span class="flex -space-x-1" aria-hidden="true">/);- expect(html).toContain("border-radius:50%");- expect(classTokens(html)).toEqual(expect.arrayContaining(["ring-canvas", "bg-fg"]));+ expect(classTokens(html)).toEqual(+ expect.arrayContaining(["ring-canvas", "rounded-full", "ring-2"]),+ );});});diff --git a/packages/ui/test/deslop.test.ts b/packages/ui/test/deslop.test.tsindex 8811c984..640f518f 100644--- a/packages/ui/test/deslop.test.ts+++ b/packages/ui/test/deslop.test.ts@@ -64,10 +64,12 @@ const POLICY: DeslopPolicy = {pulseHomes: ["dot.tsx", "skeleton.tsx", "streaming-caret.tsx"],// Rule 11: the one Spinner (K-redesign §5.1).spinnerHomes: ["components/icons/spinner/spinner.tsx"],- // Rule 20: tokens only; hex colours in the avatar palette and in the contract, whose accent- // presets carry the swatch a picker paints for a preset the active theme does not apply.+ // Rule 20: tokens only; hex colours in the avatar palette, in the contract (whose accent+ // presets carry the swatch a picker paints for a preset the active theme does not apply) and+ // in the brand mark, which is the app icon's own artwork inlined — its three gradients and its+ // white plate are the brand's identity data, the same exemption the avatar palette has.tokensOnly: true,- hexHomes: ["avatar.ts", "tokens.ts"],+ hexHomes: ["avatar.ts", "tokens.ts", "adelie-mark.tsx"],};/** Occurrences a named wave removes, by root-relative path. The package starts with none. */diff --git a/packages/web/test/icon-scale.test.ts b/packages/web/test/icon-scale.test.tsindex 4e20609d..bde355fc 100644--- a/packages/web/test/icon-scale.test.ts+++ b/packages/web/test/icon-scale.test.ts@@ -102,8 +102,13 @@ describe("stroke weights", () => {// A theme's lighter or heavier line family (1.6, 1.4) is never a literal: it is the// `--ui-icon-stroke` token below, which GlyphIcon reads.const allowed = new Set(["1", "1.5", "1.7", "2", "2.2"]);+ // The brand mark is not a line-family glyph: it is the app icon's own artwork inlined+ // (`logos/adelie-mark.tsx`), so its weights — 30 and 24 — are the asset's 1024-unit grid,+ // the same way the caret's 1.5 belongs to its smaller one.+ const BRAND_MARK = "packages/ui/src/components/icons/logos/adelie-mark.tsx";const strays: string[] = [];for (const [id, src] of FILES) {+ if (id === BRAND_MARK) continue;for (const m of src.matchAll(/strokeWidth="([0-9.]+)"/g)) {if (!allowed.has(m[1] ?? "")) strays.push(`${id}: ${m[1]}`);}