Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
refactor(web): own seeded avatar visuals
Gener53dfeaa4efb0
diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex a0bcbaf75..7de06197f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -378,9 +378,6 @@ importers:better-auth:specifier: ^1.6.25version: 1.6.25(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])- boring-avatars:- specifier: ^2.0.4class-variance-authority:specifier: ^0.7.1version: 0.7.1@@ -4420,12 +4417,6 @@ packages:resolution: {integrity: sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==}engines: {node: '>=18'}- resolution: {integrity: sha512-xhZO/w/6aFmRfkaWohcl2NfyIy87gK5SBbys8kctZeTGF1Apjpv/10pfUuv+YEfVPkESU/h2Y6tt/Dwp+bIZPw==}- peerDependencies:- react: '>=18.0.0'- react-dom: '>=18.0.0'-resolution: {integrity: sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg==}@@ -12975,11 +12966,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- react: 19.2.8- react-dom: 19.2.8([email protected])-diff --git a/src/web/package.json b/src/web/package.jsonindex 610ddee68..b54b057ec 100644--- a/src/web/package.json+++ b/src/web/package.json@@ -61,7 +61,6 @@"@types/mdx": "^2.0.14","@xyflow/react": "^12.11.1","better-auth": "^1.6.25",- "boring-avatars": "^2.0.4","class-variance-authority": "^0.7.1","clsx": "^2.1.1","driver.js": "^1.8.0",diff --git a/src/web/src/app/(app)/w/[slug]/issues/page.tsx b/src/web/src/app/(app)/w/[slug]/issues/page.tsxindex 434ff9d26..1e2da2555 100644--- a/src/web/src/app/(app)/w/[slug]/issues/page.tsx+++ b/src/web/src/app/(app)/w/[slug]/issues/page.tsx@@ -12,7 +12,7 @@ import type { TaskApi } from "@alook/shared";import { Button } from "@/components/ui/button";import { Badge } from "@/components/ui/badge";import { Skeleton } from "@/components/ui/skeleton";-import { BoringAvatar } from "@/components/avatar";+import { GeneratedAvatar } from "@/components/avatar";import { resolveAvatar } from "@/lib/avatar/resolve";import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "@/components/ui/context-menu";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";@@ -42,7 +42,7 @@ function AgentAvatar({ agent, size = 24 }: { agent?: Agent | null; size?: numberif (resolved.kind === "photo") {return <img src={resolved.url} alt={agent?.name ?? ""} className="shrink-0 rounded-full object-cover" style={{ width: size, height: size }} />;}- return <BoringAvatar seed={resolved.seed} size={size} className="shrink-0 rounded-full" />;+ return <GeneratedAvatar seed={resolved.seed} size={size} className="shrink-0 rounded-full" />;}function IssueCard({diff --git a/src/web/src/app/(app)/w/[slug]/traces/[traceId]/page.tsx b/src/web/src/app/(app)/w/[slug]/traces/[traceId]/page.tsxindex b5a11ad90..4852990f8 100644--- a/src/web/src/app/(app)/w/[slug]/traces/[traceId]/page.tsx+++ b/src/web/src/app/(app)/w/[slug]/traces/[traceId]/page.tsx@@ -9,7 +9,7 @@ import { getTrace, type TraceTask } from "@/lib/api";import { trackThreadViewed } from "@/lib/analytics";import { Skeleton } from "@/components/ui/skeleton";import { ArrowLeft } from "lucide-react";-import { BoringAvatar } from "@/components/avatar";+import { GeneratedAvatar } from "@/components/avatar";import { resolveAvatar } from "@/lib/avatar/resolve";function relativeTime(dateStr: string): string {@@ -70,7 +70,7 @@ function AgentAvatar({ name, avatarUrl, seed, size = 14 }: { name?: string; avatif (resolved.kind === "photo") {return <img src={resolved.url} alt={name ?? ""} className="rounded-full shrink-0 object-cover" style={{ width: size, height: size }} />;}- return <BoringAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;+ return <GeneratedAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;}interface TreeNode extends TraceTask {diff --git a/src/web/src/app/(app)/w/[slug]/traces/page.tsx b/src/web/src/app/(app)/w/[slug]/traces/page.tsxindex 963aad696..815c90dfc 100644--- a/src/web/src/app/(app)/w/[slug]/traces/page.tsx+++ b/src/web/src/app/(app)/w/[slug]/traces/page.tsx@@ -16,7 +16,7 @@ import {SelectItem,} from "@/components/ui/select";import { GitBranch, RefreshCw } from "lucide-react";-import { BoringAvatar } from "@/components/avatar";+import { GeneratedAvatar } from "@/components/avatar";import { resolveAvatar } from "@/lib/avatar/resolve";import { Button } from "@/components/ui/button";import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";@@ -78,7 +78,7 @@ function AgentAvatar({ name, avatarUrl, seed, size = 14 }: { name?: string; avatif (resolved.kind === "photo") {return <img src={resolved.url} alt={name ?? ""} className="rounded-full shrink-0 object-cover" style={{ width: size, height: size }} />;}- return <BoringAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;+ return <GeneratedAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;}function TraceRow({ trace, slug }: { trace: TraceListItem; slug: string }) {diff --git a/src/web/src/components/avatar/agent-avatar.test.ts b/src/web/src/components/avatar/agent-avatar.test.tsindex 0ff979ab2..ba731b8b7 100644--- a/src/web/src/components/avatar/agent-avatar.test.ts+++ b/src/web/src/components/avatar/agent-avatar.test.ts@@ -1,6 +1,6 @@import { describe, it, expect } from "vitest"import { AgentAvatar } from "./agent-avatar"-import { BoringAvatar } from "./boring-avatar"+import { GeneratedAvatar } from "./generated-avatar"import { serializeBeamSeed } from "@/lib/avatar/seed-url"// A legacy procedural config value (the format the removed engine used to@@ -8,7 +8,7 @@ import { serializeBeamSeed } from "@/lib/avatar/seed-url"const LEGACY_CONFIG = 'avatar:{"shape":"book","eye":"happy","nose":"dash","bg":1}'type ImgEl = { type: "img"; props: { src: string; alt: string; style: { width: number; height: number } } }-type BeamEl = { type: typeof BoringAvatar; props: { seed: string; size: number } }+type BeamEl = { type: typeof GeneratedAvatar; props: { seed: string; size: number } }describe("AgentAvatar", () => {it("renders an <img> for a photo URL (https)", () => {@@ -30,20 +30,20 @@ describe("AgentAvatar", () => {it("renders beam with the stored seed for a avatar:beam value", () => {const el = AgentAvatar({ name: "Bot", avatarUrl: serializeBeamSeed("seed-123"), seed: "agent-1", size: 32 }) as unknown as BeamEl- expect(el.type).toBe(BoringAvatar)+ expect(el.type).toBe(GeneratedAvatar)expect(el.props.seed).toBe("seed-123")expect(el.props.size).toBe(32)})it("ignores a legacy avatar:{shape…} config and beams by the fallback seed", () => {const el = AgentAvatar({ name: "Bot", avatarUrl: LEGACY_CONFIG, seed: "agent-1", size: 32 }) as unknown as BeamEl- expect(el.type).toBe(BoringAvatar)+ expect(el.type).toBe(GeneratedAvatar)expect(el.props.seed).toBe("agent-1")})it("beams by the id seed when avatarUrl is null", () => {const el = AgentAvatar({ name: "Zara", avatarUrl: null, seed: "agent-9", size: 32 }) as unknown as BeamEl- expect(el.type).toBe(BoringAvatar)+ expect(el.type).toBe(GeneratedAvatar)expect(el.props.seed).toBe("agent-9")})diff --git a/src/web/src/components/avatar/agent-avatar.tsx b/src/web/src/components/avatar/agent-avatar.tsxindex f23af2b06..2cda5aa2d 100644--- a/src/web/src/components/avatar/agent-avatar.tsx+++ b/src/web/src/components/avatar/agent-avatar.tsx@@ -1,6 +1,6 @@"use client";-import { BoringAvatar } from "./boring-avatar";+import { GeneratedAvatar } from "./generated-avatar";import { resolveAvatar } from "@/lib/avatar/resolve";export function AgentAvatar({ name, avatarUrl, seed, size = 32 }: { name?: string | null; avatarUrl?: string | null; seed?: string | null; size?: number }) {@@ -17,5 +17,5 @@ export function AgentAvatar({ name, avatarUrl, seed, size = 32 }: { name?: strin/>);}- return <BoringAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;+ return <GeneratedAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;}diff --git a/src/web/src/components/avatar/animated-avatar.tsx b/src/web/src/components/avatar/animated-avatar.tsxindex 649b33f12..620128162 100644--- a/src/web/src/components/avatar/animated-avatar.tsx+++ b/src/web/src/components/avatar/animated-avatar.tsx@@ -1,7 +1,7 @@"use client";import { useEffect, useRef, useState } from "react";-import { BoringAvatar } from "./boring-avatar";+import { GeneratedAvatar } from "./generated-avatar";import { resolveAvatar } from "@/lib/avatar/resolve";// beam is a static SVG with no animatable internal parts, so only the@@ -55,7 +55,7 @@ export function AnimatedAvatar({ seed, avatarUrl, size, className, isHovered, is{resolved.kind === "photo" ? (<img src={resolved.url} alt="" className={`object-cover align-middle ${className ?? ""}`} style={{ width: size, height: size }} />) : (- <BoringAvatar seed={resolved.seed} size={size} className={className} />+ <GeneratedAvatar seed={resolved.seed} size={size} className={className} />)}</div>);diff --git a/src/web/src/components/avatar/avatar-picker-dialog.tsx b/src/web/src/components/avatar/avatar-picker-dialog.tsxindex 964e009ac..a001ea521 100644--- a/src/web/src/components/avatar/avatar-picker-dialog.tsx+++ b/src/web/src/components/avatar/avatar-picker-dialog.tsx@@ -2,7 +2,7 @@import { useState } from "react";import { Shuffle } from "lucide-react";-import { BoringAvatar } from "./boring-avatar";+import { GeneratedAvatar } from "./generated-avatar";import { serializeBeamSeed, parseBeamSeed } from "@/lib/avatar/seed-url";interface AvatarPickerDialogProps {@@ -17,9 +17,7 @@ function randomSeed(): string {}/**- * Beam avatar picker: a preview + a "shuffle" button that rerolls the seed.- * boring-avatars has no editable model (shape/eye/nose), so "generate" is just- * a fresh random seed; the chosen seed persists as `avatar:beam:{seed}`.+ * Generated avatar picker: a preview and Shuffle control that rerolls the stored seed.*/export function AvatarPickerDialog({ value, onChange }: AvatarPickerDialogProps) {const [seed, setSeed] = useState<string>(() => parseBeamSeed(value) ?? randomSeed());@@ -34,7 +32,7 @@ export function AvatarPickerDialog({ value, onChange }: AvatarPickerDialogProps)<div className="flex flex-col items-center gap-3"><div className="rounded-2xl bg-background p-2 shadow-sm border border-border"><span className="block size-20 overflow-hidden rounded-2xl">- <BoringAvatar seed={seed} size={80} className="size-full" />+ <GeneratedAvatar seed={seed} size={80} className="size-full" /></span></div><buttondiff --git a/src/web/src/components/avatar/boring-avatar.test.ts b/src/web/src/components/avatar/boring-avatar.test.tsdeleted file mode 100644index 305bb30f7..000000000--- a/src/web/src/components/avatar/boring-avatar.test.ts+++ /dev/null@@ -1,63 +0,0 @@-import { describe, it, expect } from "vitest"-import Avatar from "boring-avatars"-import { BoringAvatar } from "./boring-avatar"--// BoringAvatar returns a wrapper <span> (co-locating the caller's radius-// className with overflow-hidden so a square SVG gets cropped to the container-// shape). Its child depends on variant:-// - beam (default): our own face renderer, injected as SVG via a span.-// - marble: the boring-avatars <Avatar> (gradient background).-type SpanEl = {- type: "span"- props: {- className: string- style: { width: number | string; height: number | string }- children: unknown- }-}-type AvatarEl = { type: typeof Avatar; props: { square: boolean; size: number | string; className: string; variant: string; preserveAspectRatio?: string } }--function child(el: unknown): unknown {- return (el as SpanEl).props.children-}--describe("BoringAvatar", () => {- it("renders our generated face SVG for the default (beam) variant", () => {- const el = BoringAvatar({ seed: "s1" }) as unknown as SpanEl- expect(el.type).toBe("span")- const inner = child(el) as { props: { dangerouslySetInnerHTML: { __html: string } } }- // beam is our face renderer, not the lib — injected as an SVG string.- expect(inner.props.dangerouslySetInnerHTML.__html).toContain("<svg")- expect(inner.props.dangerouslySetInnerHTML.__html).toContain('viewBox="0 0 36 36"')- })-- it("is deterministic — same seed renders the same beam face", () => {- const a = BoringAvatar({ seed: "s1" }) as unknown as SpanEl- const b = BoringAvatar({ seed: "s1" }) as unknown as SpanEl- const ha = (child(a) as { props: { dangerouslySetInnerHTML: { __html: string } } }).props.dangerouslySetInnerHTML.__html- const hb = (child(b) as { props: { dangerouslySetInnerHTML: { __html: string } } }).props.dangerouslySetInnerHTML.__html- expect(ha).toBe(hb)- })-- it("co-locates the caller's radius className with overflow-hidden on the wrapper", () => {- const el = BoringAvatar({ seed: "s1", className: "rounded-full" }) as unknown as SpanEl- expect(el.props.className).toContain("rounded-full")- expect(el.props.className).toContain("overflow-hidden")- })-- it("gives the wrapper an explicit box from size", () => {- const el = BoringAvatar({ seed: "s1", size: 40 }) as unknown as SpanEl- expect(el.props.style).toEqual({ width: 40, height: 40 })- })-- it("forwards variant/square/preserveAspectRatio to the lib for marble (background)", () => {- const el = BoringAvatar({ seed: "s1", variant: "marble", size: "100%", preserveAspectRatio: "none", square: false }) as unknown as SpanEl- const inner = child(el) as AvatarEl- expect(inner.type).toBe(Avatar)- expect(inner.props.variant).toBe("marble")- expect(inner.props.preserveAspectRatio).toBe("none")- expect(inner.props.square).toBe(false)- expect(inner.props.size).toBe("100%")- expect(el.props.style).toEqual({ width: "100%", height: "100%" })- })-})diff --git a/src/web/src/components/avatar/boring-avatar.tsx b/src/web/src/components/avatar/boring-avatar.tsxdeleted file mode 100644index 1d2efa516..000000000--- a/src/web/src/components/avatar/boring-avatar.tsx+++ /dev/null@@ -1,64 +0,0 @@-"use client";--import Avatar from "boring-avatars";-import { paletteFromSeed } from "@/lib/avatar/boring-palettes";-import { renderFaceSvg } from "@/lib/avatar/face";-import { cn } from "@/lib/utils";--/**- * The single wrapper around boring-avatars. Every generated avatar/gradient in- * the app renders through here so the library stays isolated behind one- * component. `seed` maps to boring-avatars' `name` prop (deterministic), and- * the palette is chosen deterministically from the same seed.- *- * `beam` (default) is the face fallback — rendered by our own `renderFaceSvg`- * (richer shape/eye/mouth vocabulary than the lib's fixed beam), same 36-unit- * canvas + seed-derived palette so it drops into the same crop. `marble` is the- * gradient background (server/channel icons, profile banner) and stays on the- * lib.- *- * `square` defaults to true so the underlying SVG is a full square that the- * container's radius crops — matching how photo `object-cover` avatars behave.- * The crop is done here, at one place, by a wrapper span that co-locates the- * caller's `className` (which carries the radius, e.g. `rounded-full` /- * `rounded-xl`) with `overflow-hidden`: `overflow-hidden` clips to the- * border-box, so the radius must live on the SAME element or a circular caller- * would clip to a rectangle. The span gets an explicit box (`inline-flex` +- * `size`) because standalone callers pass a numeric `size` with no flex parent,- * and a bare inline span would ignore width/height and collapse.- */-export function BoringAvatar({- seed,- size = 40,- variant = "beam",- square = true,- className,- preserveAspectRatio,-}: {- seed: string;- size?: number | string;- variant?: "beam" | "marble";- square?: boolean;- className?: string;- preserveAspectRatio?: string;-}) {- return (- <span className={cn("inline-flex overflow-hidden align-middle", className)} style={{ width: size, height: size }}>- {variant === "beam" ? (- // Our generated face — self-contained SVG (viewBox 0 0 36 36, 100% w/h),- // fills the crop span exactly like the lib's `size="100%"` did.- <span className="size-full [&>svg]:block [&>svg]:size-full" dangerouslySetInnerHTML={{ __html: renderFaceSvg(seed, paletteFromSeed(seed)) }} />- ) : (- <Avatar- size="100%"- name={seed}- variant={variant}- colors={paletteFromSeed(seed)}- square={square}- className="size-full"- preserveAspectRatio={preserveAspectRatio}- />- )}- </span>- );-}diff --git a/src/web/src/components/avatar/bot-avatar-picker-dialog.tsx b/src/web/src/components/avatar/bot-avatar-picker-dialog.tsxindex fab8ce347..2c5eb5fdc 100644--- a/src/web/src/components/avatar/bot-avatar-picker-dialog.tsx+++ b/src/web/src/components/avatar/bot-avatar-picker-dialog.tsx@@ -15,7 +15,7 @@ import { ImageCropDialog } from "@/components/community/image-crop-dialog";import { validateIconSourceFile } from "@/lib/community/image-crop";import { toast } from "sonner";import { type AvatarDraft, isPhotoAvatarUrl } from "./photo";-import { BoringAvatar } from "./boring-avatar";+import { GeneratedAvatar } from "./generated-avatar";import { serializeBeamSeed, parseBeamSeed } from "@/lib/avatar/seed-url";import { useIsMobile } from "@/hooks/use-mobile";@@ -31,10 +31,7 @@ function randomSeed(): string {}/**- * Dual-mode ("Generate" | "Photo") bot avatar picker. "Generate" is a beam- * avatar with a shuffle button (boring-avatars has no editable model); the- * chosen seed persists as `avatar:beam:{seed}`. `AvatarPickerDialog` (the- * workspace-agent picker) is the single-mode variant.+ * Dual-mode generated or photo bot avatar picker. Generated choices persist as `avatar:beam:{seed}`.*/export function BotAvatarPickerDialog({ image, onChange }: BotAvatarPickerDialogProps) {const [open, setOpen] = useState(false);@@ -137,7 +134,7 @@ export function BotAvatarPickerDialog({ image, onChange }: BotAvatarPickerDialog<img src={triggerPreview} alt="" className="size-20 rounded-2xl object-cover" />) : (<span className="block size-20 overflow-hidden rounded-2xl">- <BoringAvatar seed={seed} size={80} className="size-full" />+ <GeneratedAvatar seed={seed} size={80} className="size-full" /></span>)}</DialogTrigger>@@ -166,7 +163,7 @@ export function BotAvatarPickerDialog({ image, onChange }: BotAvatarPickerDialog<TabsContent value="generate"><div className="flex flex-col items-center gap-3 py-6"><span className="block size-32 overflow-hidden rounded-full">- <BoringAvatar seed={seed} size={128} className="size-full" />+ <GeneratedAvatar seed={seed} size={128} className="size-full" /></span><Button type="button" variant="secondary" size="sm" onClick={shuffle}><Shuffle className="size-3.5" />diff --git a/src/web/src/components/avatar/generated-avatar.test.ts b/src/web/src/components/avatar/generated-avatar.test.tsnew file mode 100644index 000000000..d0478d3e8--- /dev/null+++ b/src/web/src/components/avatar/generated-avatar.test.ts@@ -0,0 +1,36 @@+import { describe, expect, it } from "vitest"+import { GeneratedAvatar } from "./generated-avatar"++type SpanElement = {+ type: "span"+ props: {+ className: string+ style: { width: number | string; height: number | string }+ children: unknown+ }+}++function child(element: unknown): unknown {+ return (element as SpanElement).props.children+}++describe("GeneratedAvatar", () => {+ it("renders the deterministic 36-unit generated face", () => {+ const element = GeneratedAvatar({ seed: "s1" }) as unknown as SpanElement+ const inner = child(element) as { props: { dangerouslySetInnerHTML: { __html: string } } }+ expect(element.type).toBe("span")+ expect(inner.props.dangerouslySetInnerHTML.__html).toContain('viewBox="0 0 36 36"')+ expect(GeneratedAvatar({ seed: "s1" })).toEqual(GeneratedAvatar({ seed: "s1" }))+ })++ it("keeps radius and overflow clipping on the same Safari-safe wrapper", () => {+ const element = GeneratedAvatar({ seed: "s1", className: "rounded-full" }) as unknown as SpanElement+ expect(element.props.className).toContain("rounded-full")+ expect(element.props.className).toContain("overflow-hidden")+ })++ it("preserves numeric and string size contracts", () => {+ expect((GeneratedAvatar({ seed: "s1", size: 40 }) as unknown as SpanElement).props.style).toEqual({ width: 40, height: 40 })+ expect((GeneratedAvatar({ seed: "s1", size: "100%" }) as unknown as SpanElement).props.style).toEqual({ width: "100%", height: "100%" })+ })+})diff --git a/src/web/src/components/avatar/generated-avatar.tsx b/src/web/src/components/avatar/generated-avatar.tsxnew file mode 100644index 000000000..2534520b2--- /dev/null+++ b/src/web/src/components/avatar/generated-avatar.tsx@@ -0,0 +1,21 @@+import { renderFaceSvg } from "@/lib/avatar/face"+import { cn } from "@/lib/utils"++export function GeneratedAvatar({+ seed,+ size = 40,+ className,+}: {+ seed: string+ size?: number | string+ className?: string+}) {+ return (+ <span className={cn("inline-flex overflow-hidden align-middle", className)} style={{ width: size, height: size }}>+ <span+ className="size-full [&>svg]:block [&>svg]:size-full"+ dangerouslySetInnerHTML={{ __html: renderFaceSvg(seed) }}+ />+ </span>+ )+}diff --git a/src/web/src/components/avatar/index.ts b/src/web/src/components/avatar/index.tsindex bc8435f5f..1912cfdea 100644--- a/src/web/src/components/avatar/index.ts+++ b/src/web/src/components/avatar/index.ts@@ -1,7 +1,7 @@export { type AvatarDraft, isPhotoAvatarUrl } from "./photo";-export { BoringAvatar } from "./boring-avatar";-export { MarbleBackground } from "./marble-background";+export { GeneratedAvatar } from "./generated-avatar";+export { SeededBackdrop } from "./seeded-backdrop";export { AnimatedAvatar } from "./animated-avatar";export { AvatarPickerDialog } from "./avatar-picker-dialog";export { BotAvatarPickerDialog } from "./bot-avatar-picker-dialog";diff --git a/src/web/src/components/avatar/marble-background.tsx b/src/web/src/components/avatar/marble-background.tsxdeleted file mode 100644index a5a0569e3..000000000--- a/src/web/src/components/avatar/marble-background.tsx+++ /dev/null@@ -1,20 +0,0 @@-"use client";--import { BoringAvatar } from "./boring-avatar";--/**- * A seeded marble gradient that fills its positioned parent — the SVG- * replacement for the old `style={{ background: gradientFromSeed(id) }}`.- *- * Render it as the first child of a `relative overflow-hidden` container; the- * letter/content that used to sit on the CSS gradient stays on top. `object-fit`- * doesn't apply to an inline `<svg>`, so we size the SVG to 100% and let the- * container clip it.- */-export function MarbleBackground({ seed }: { seed: string }) {- return (- <span aria-hidden className="pointer-events-none absolute inset-0 [&>svg]:size-full">- <BoringAvatar seed={seed} variant="marble" square size="100%" preserveAspectRatio="none" />- </span>- );-}diff --git a/src/web/src/components/avatar/photo.ts b/src/web/src/components/avatar/photo.tsindex 7903c2a6a..07b21df20 100644--- a/src/web/src/components/avatar/photo.ts+++ b/src/web/src/components/avatar/photo.ts@@ -1,6 +1,4 @@-// Photo-avatar detection + the dual-mode draft used by the bot picker. These-// outlived the procedural avatar engine (removed in favor of boring-avatars):-// a stored avatar value is either a real photo URL or a `avatar:beam:{seed}`.+// Photo-avatar detection and the dual-mode draft used by the bot picker.export function isPhotoAvatarUrl(url: string | null | undefined): boolean {return !!url && (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("/"));diff --git a/src/web/src/components/avatar/seeded-backdrop.test.ts b/src/web/src/components/avatar/seeded-backdrop.test.tsnew file mode 100644index 000000000..e566c33ea--- /dev/null+++ b/src/web/src/components/avatar/seeded-backdrop.test.ts@@ -0,0 +1,14 @@+import { describe, expect, it } from "vitest"+import { SeededBackdrop } from "./seeded-backdrop"++describe("SeededBackdrop", () => {+ it("fills its positioned parent with the requested native SVG variant", () => {+ const profile = SeededBackdrop({ seed: "profile", variant: "profile" }) as unknown as {+ props: { "aria-hidden": boolean; className: string; dangerouslySetInnerHTML: { __html: string } }+ }+ expect(profile.props["aria-hidden"]).toBe(true)+ expect(profile.props.className).toContain("absolute inset-0")+ expect(profile.props.dangerouslySetInnerHTML.__html).toContain('viewBox="0 0 80 80"')+ expect(profile.props.dangerouslySetInnerHTML.__html).toContain('preserveAspectRatio="none"')+ })+})diff --git a/src/web/src/components/avatar/seeded-backdrop.tsx b/src/web/src/components/avatar/seeded-backdrop.tsxnew file mode 100644index 000000000..e1bc60dcf--- /dev/null+++ b/src/web/src/components/avatar/seeded-backdrop.tsx@@ -0,0 +1,11 @@+import { renderSeededBackdropSvg, type SeededBackdropVariant } from "@/lib/avatar/backdrop"++export function SeededBackdrop({ seed, variant }: { seed: string; variant: SeededBackdropVariant }) {+ return (+ <span+ aria-hidden+ className="pointer-events-none absolute inset-0 [&>svg]:block [&>svg]:size-full"+ dangerouslySetInnerHTML={{ __html: renderSeededBackdropSvg(seed, variant) }}+ />+ )+}diff --git a/src/web/src/components/canvas/active-tasks-float.tsx b/src/web/src/components/canvas/active-tasks-float.tsxindex 77617d9e5..2617bd4fa 100644--- a/src/web/src/components/canvas/active-tasks-float.tsx+++ b/src/web/src/components/canvas/active-tasks-float.tsx@@ -6,7 +6,7 @@ import { X } from "lucide-react";import { useAgentContext } from "@/contexts/agent-context";import { useWorkspace } from "@/contexts/workspace-context";import { useIsMobile } from "@/hooks/use-mobile";-import { BoringAvatar } from "@/components/avatar";+import { GeneratedAvatar } from "@/components/avatar";import { resolveAvatar } from "@/lib/avatar/resolve";import type { WorkspaceActiveTask } from "@/lib/api";import { relativeTime } from "@/lib/time";@@ -17,7 +17,7 @@ function AgentAvatar({ name, avatarUrl, seed, size = 20 }: { name?: string; avatif (resolved.kind === "photo") {return <img src={resolved.url} alt={name ?? ""} className="rounded-full shrink-0 object-cover" style={{ width: size, height: size }} />;}- return <BoringAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;+ return <GeneratedAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;}function TaskRow({diff --git a/src/web/src/components/canvas/link-sidecar.tsx b/src/web/src/components/canvas/link-sidecar.tsxindex b2285b9fe..53f4fa187 100644--- a/src/web/src/components/canvas/link-sidecar.tsx+++ b/src/web/src/components/canvas/link-sidecar.tsx@@ -12,7 +12,7 @@ import { Button } from "@/components/ui/button";import { MarkdownEditor } from "@/components/ui/markdown-editor";import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";import { Trash2 } from "lucide-react";-import { BoringAvatar } from "@/components/avatar";+import { GeneratedAvatar } from "@/components/avatar";import { resolveAvatar } from "@/lib/avatar/resolve";import { ConfirmDialog } from "@/components/ui/confirm-dialog";@@ -110,7 +110,7 @@ export function LinkSidecar({if (resolved.kind === "photo") {return <img src={resolved.url} alt={agent.name} className="shrink-0 rounded-xl object-cover" style={{ width: 32, height: 32 }} />;}- return <BoringAvatar seed={resolved.seed} size={32} className="shrink-0 rounded-xl" />;+ return <GeneratedAvatar seed={resolved.seed} size={32} className="shrink-0 rounded-xl" />;};return (diff --git a/src/web/src/components/canvas/upcoming-events-float.tsx b/src/web/src/components/canvas/upcoming-events-float.tsxindex b027bf088..1ec902f77 100644--- a/src/web/src/components/canvas/upcoming-events-float.tsx+++ b/src/web/src/components/canvas/upcoming-events-float.tsx@@ -6,7 +6,7 @@ import { CalendarDays, X } from "lucide-react";import { useAgentContext } from "@/contexts/agent-context";import { useWorkspace } from "@/contexts/workspace-context";import { useIsMobile } from "@/hooks/use-mobile";-import { BoringAvatar } from "@/components/avatar";+import { GeneratedAvatar } from "@/components/avatar";import { resolveAvatar } from "@/lib/avatar/resolve";import { listCalendarEvents } from "@/lib/api";import type { CalendarEvent } from "@alook/shared";@@ -16,7 +16,7 @@ function AgentAvatar({ name, avatarUrl, seed, size = 20 }: { name?: string; avatif (resolved.kind === "photo") {return <img src={resolved.url} alt={name ?? ""} className="rounded-full shrink-0 object-cover" style={{ width: size, height: size }} />;}- return <BoringAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;+ return <GeneratedAvatar seed={resolved.seed} size={size} className="rounded-full shrink-0" />;}interface AgentEventSummary {diff --git a/src/web/src/components/community/avatar.test.ts b/src/web/src/components/community/avatar.test.tsindex cff793974..d70a4ffa4 100644--- a/src/web/src/components/community/avatar.test.ts+++ b/src/web/src/components/community/avatar.test.ts@@ -4,12 +4,8 @@ import { renderToStaticMarkup } from "react-dom/server"import { Avatar } from "./avatar"import { serializeBeamSeed } from "@/lib/avatar/seed-url"-// React's `useId` embeds a per-render counter (`_R_1_`, `_R_2_`, …) into the-// SVG mask/gradient ids, so two independent renders never match byte-for-byte-// even when the derived avatar is identical. Strip those so equality checks-// compare the derived avatar, not the render ordinal.function normalize(html: string): string {- return html.replace(/_R_[0-9a-z]+_/g, "_ID_").replace(/\bmarble_[0-9a-z]+\b/g, "id").replace(/#[0-9a-z]+_ID_/g, "#_ID_")+ return html.replace(/_R_[0-9a-z]+_/g, "_ID_").replace(/#[0-9a-z]+_ID_/g, "#_ID_")}function render(props: Parameters<typeof Avatar>[0]): string {diff --git a/src/web/src/components/community/avatar.tsx b/src/web/src/components/community/avatar.tsxindex 7a10215f9..ef0e4f8e3 100644--- a/src/web/src/components/community/avatar.tsx+++ b/src/web/src/components/community/avatar.tsx@@ -1,6 +1,6 @@import type React from "react"import { Avatar as UiAvatar, AvatarImage, AvatarFallback, AvatarBadge } from "@/components/ui/avatar"-import { BoringAvatar } from "@/components/avatar"+import { GeneratedAvatar } from "@/components/avatar"import { parseBeamSeed } from "@/lib/avatar/seed-url"import { avatarInitial } from "@/lib/community/avatar"import type { Presence } from "./_types"@@ -49,7 +49,7 @@ export function Avatar({ label, seed, src, size = 40, dim = false, presence, rin// Priority: image URL > beam (from stored seed or id) > single letter. Radix// `AvatarFallback` renders whenever no `AvatarImage` is present, so we must- // NOT emit it when we've already drawn a beam via `<span><BoringAvatar/></span>`+ // NOT emit it when we've already drawn a beam via `<span><GeneratedAvatar/></span>`// — otherwise both stack on top of each other (the "two-avatar-in-one-place" bug).return (<UiAvatar@@ -65,14 +65,14 @@ export function Avatar({ label, seed, src, size = 40, dim = false, presence, rin</>) : beamSeed ? (<span className="size-full rounded-full overflow-hidden">- {/* rounded-full must live on BoringAvatar's OWN wrapper (which carries+ {/* rounded-full must live on GeneratedAvatar's OWN wrapper (which carriesoverflow-hidden), not only on this outer span: the beam SVG has a`<g transform>`, and WebKit/Safari does not clip a transformeddescendant to an ancestor's border-radius — so an outer-onlyradius leaks the beam's square background as a rounded-square(the pinned-panel "clipped avatar" bug, WebKit-only). Every other- BoringAvatar caller co-locates the radius on it for this reason. */}- <BoringAvatar seed={beamSeed} size={size} className="size-full rounded-full" />+ GeneratedAvatar caller co-locates the radius on it for this reason. */}+ <GeneratedAvatar seed={beamSeed} size={size} className="size-full rounded-full" /></span>) : (<AvatarFallback className="font-medium" style={{ fontSize: size * 0.4 }}>diff --git a/src/web/src/components/community/channel-header.tsx b/src/web/src/components/community/channel-header.tsxindex 4d97123ff..0fd495cf9 100644--- a/src/web/src/components/community/channel-header.tsx+++ b/src/web/src/components/community/channel-header.tsx@@ -15,7 +15,7 @@ import { ChannelIcon } from "./channel-icon"import { EntityIcon } from "./entity-icon"import { SlugHint } from "./slug-hint"import { previewSlug } from "@/lib/community/slug-preview"-import { MarbleBackground } from "@/components/avatar"+import { SeededBackdrop } from "@/components/avatar"import type { RightPanel } from "./_types"import { CreateDialogShell } from "./create-dialog-shell"@@ -173,14 +173,12 @@ function ServerCrumb({ id, name, icon, size = 5, className = "" }: { id: string;const initialTextCls = size === 7 ? "text-base" : size === 6 ? "text-sm" : "text-xs"return (<span- // No icon → the same deterministic marble fallback used by the rail- // (`sortable-server.tsx`) and folder rows, so a server reads as "the- // same server" everywhere it shows up, not a flat generic tile here.+ // The deterministic fallback matches the rail and folder rows.className={`relative grid shrink-0 place-items-center overflow-hidden rounded-md ${icon ? `font-semibold ${iconTextCls} bg-secondary text-foreground` : `font-brand font-bold ${initialTextCls} text-white [text-shadow:0_1px_2px_rgb(0_0_0/0.35)]`} ${sizeCls} ${className}`}aria-label={name}title={name}>- {icon ? <img src={icon} alt="" className="size-full object-cover" /> : <><MarbleBackground seed={id} /><span className="relative -translate-x-px [-webkit-text-stroke:0.5px_currentColor]">{avatarInitial(name)}</span></>}+ {icon ? <img src={icon} alt="" className="size-full object-cover" /> : <><SeededBackdrop variant="icon" seed={id} /><span className="relative -translate-x-px [-webkit-text-stroke:0.5px_currentColor]">{avatarInitial(name)}</span></>}</span>)}diff --git a/src/web/src/components/community/create-server-dialog.tsx b/src/web/src/components/community/create-server-dialog.tsxindex a7a8a8b33..dcbef419c 100644--- a/src/web/src/components/community/create-server-dialog.tsx+++ b/src/web/src/components/community/create-server-dialog.tsx@@ -3,7 +3,7 @@import { useId, useRef, useState } from "react"import { ImagePlus } from "lucide-react"import { toast } from "sonner"-import { MarbleBackground } from "@/components/avatar"+import { SeededBackdrop } from "@/components/avatar"import { Button } from "@/components/ui/button"import { avatarInitial } from "@/lib/community/avatar"import { validateIconSourceFile } from "@/lib/community/image-crop"@@ -141,7 +141,7 @@ export function CreateServerDialog({ onClose, onCreateServer }: {<img src={iconPreview} alt="" className="size-full object-cover" />) : (<>- <MarbleBackground seed={previewSeed} />+ <SeededBackdrop variant="icon" seed={previewSeed} />{initial ? (<span className="relative -translate-x-0.5 font-brand text-[2rem] font-bold leading-none [-webkit-text-stroke:0.5px_currentColor]">{initial}diff --git a/src/web/src/components/community/machines/machine-list.tsx b/src/web/src/components/community/machines/machine-list.tsxindex be5e7b10e..df8174367 100644--- a/src/web/src/components/community/machines/machine-list.tsx+++ b/src/web/src/components/community/machines/machine-list.tsx@@ -10,7 +10,7 @@ import { isPresenceOnline } from "@alook/shared"import { Button } from "@/components/ui/button"import { Card } from "@/components/ui/card"import { Skeleton } from "@/components/ui/skeleton"-import { BoringAvatar } from "@/components/avatar"+import { GeneratedAvatar } from "@/components/avatar"import {AlertDialog,AlertDialogContent,@@ -237,7 +237,7 @@ export function MachineList({ onBack }: { onBack?: () => void } = {}) {{onboardingState === null ? (<span className="community-guide-me-orbit" aria-hidden="true"><span className="community-guide-me-avatar">- <BoringAvatar+ <GeneratedAvatarseed={guideAvatarSeed}size={24}className="rounded-full ring-2 ring-background shadow-sm"diff --git a/src/web/src/components/community/onboarding/community-onboarding-guide.tsx b/src/web/src/components/community/onboarding/community-onboarding-guide.tsxindex a1d478f84..33b674d17 100644--- a/src/web/src/components/community/onboarding/community-onboarding-guide.tsx+++ b/src/web/src/components/community/onboarding/community-onboarding-guide.tsx@@ -3,7 +3,7 @@import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";import { createPortal } from "react-dom";import { usePathname, useRouter } from "next/navigation";-import { BoringAvatar } from "@/components/avatar";+import { GeneratedAvatar } from "@/components/avatar";import { Button } from "@/components/ui/button";import { driver, type Driver } from "driver.js";import { isPresenceOnline, type CommunityMachineSummary } from "@alook/shared";@@ -635,7 +635,7 @@ export function CommunityOnboardingGuide() {: null}{targetAvatarContainer? createPortal(- <BoringAvatar+ <GeneratedAvatarseed={state.guideAvatarSeed ?? "alook-guide"}size={28}className="rounded-full ring-2 ring-background shadow-md"diff --git a/src/web/src/components/community/profile-card.test.ts b/src/web/src/components/community/profile-card.test.tsindex 7495b0baf..43f46ff30 100644--- a/src/web/src/components/community/profile-card.test.ts+++ b/src/web/src/components/community/profile-card.test.ts@@ -1,5 +1,23 @@import { describe, it, expect } from "vitest"-import { resolveCardStatus } from "./profile-card"+import { resolveCardStatus, resolveProfileBackdropSeed } from "./profile-card"+import { serializeBeamSeed } from "@/lib/avatar/seed-url"++describe("resolveProfileBackdropSeed", () => {+ it("uses the stored generated seed so Shuffle changes face and backdrop together", () => {+ expect(resolveProfileBackdropSeed(serializeBeamSeed("shuffle-seed"), "user-id", "Renamed"))+ .toBe("shuffle-seed")+ })++ it("uses the stable identity fallback when no avatar is stored", () => {+ expect(resolveProfileBackdropSeed(null, "user-id", "Renamed"))+ .toBe("user-id")+ })++ it("keeps photo backdrops stable on identity instead of sampling the image", () => {+ expect(resolveProfileBackdropSeed("https://cdn.example.com/photo.png", "user-id", "Renamed"))+ .toBe("user-id")+ })+})describe("resolveCardStatus — WS overlay wins over row seed", () => {it("uses the overlay entry when one exists", () => {diff --git a/src/web/src/components/community/profile-card.tsx b/src/web/src/components/community/profile-card.tsxindex b8a8e34c9..8c7f2dccc 100644--- a/src/web/src/components/community/profile-card.tsx+++ b/src/web/src/components/community/profile-card.tsx@@ -5,7 +5,8 @@ import { MessagesSquare, Shield } from "lucide-react"import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover"import { Badge } from "@/components/ui/badge"import { Avatar } from "./avatar"-import { MarbleBackground } from "@/components/avatar"+import { SeededBackdrop } from "@/components/avatar"+import { resolveAvatar } from "@/lib/avatar/resolve"import { StatusEditor, hasStatus } from "./status-editor"import type { Profile } from "./_types"import type { Breakpoint } from "@/hooks/use-mobile"@@ -30,6 +31,16 @@ export function resolveCardStatus(return { emoji: seedEmoji ?? null, text: seedText ?? null }}+export function resolveProfileBackdropSeed(+ avatar: string | null | undefined,+ userId: string | null | undefined,+ name: string,+): string {+ const fallbackSeed = userId ?? name+ const resolved = resolveAvatar(avatar, fallbackSeed)+ return resolved.kind === "beam" ? resolved.seed : fallbackSeed+}+// Profile card — popover anchored at the click point on desktop, bottom sheet on mobile.// Status (emoji + text) is read live from `useCommunityWsStore.userStatuses` —// the same overlay the member list, friends list, and UserBar consume. The@@ -58,6 +69,7 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpdaconst mobile = bp === "mobile"const liveStatus = useCommunityWsStore((s) => (data.userId ? s.userStatuses.get(data.userId) : undefined))const { emoji: statusEmoji, text: statusText } = resolveCardStatus(liveStatus, initialStatusEmoji, initialStatusText)+ const backdropSeed = resolveProfileBackdropSeed(data.avatar, data.userId, data.name)const close = () => setOpen(false)const send = () => {const text = msg.trim()@@ -69,10 +81,8 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpda}const card = (<>- {/* banner — seeded marble fill, clipped by the wide-bar container- (object-fit doesn't apply to an inline <svg>, so the SVG fills 100%). */}<div className="relative -m-2 mb-0 h-16 overflow-hidden rounded-t-lg">- <MarbleBackground seed={data.userId ?? data.name} />+ <SeededBackdrop variant="profile" seed={backdropSeed} /></div><div className="px-2 pb-2">{/* `pl-4` — the card body below has its own `p-4`, so its text sitsdiff --git a/src/web/src/components/community/rail-folder.tsx b/src/web/src/components/community/rail-folder.tsxindex 3775d4aed..af56d6c6e 100644--- a/src/web/src/components/community/rail-folder.tsx+++ b/src/web/src/components/community/rail-folder.tsx@@ -5,7 +5,7 @@ import { CSS } from "@dnd-kit/utilities"import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem } from "@/components/ui/context-menu"import { RailIndicator } from "./rail-indicator"import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip"-import { MarbleBackground } from "@/components/avatar"+import { SeededBackdrop } from "@/components/avatar"import type { FolderServer } from "./_types"export function RailFolder({@@ -53,7 +53,7 @@ export function RailFolder({s.icon ? "bg-card text-muted-foreground" : "text-white [text-shadow:0_1px_1px_rgb(0_0_0/0.35)]",].join(" ")}>- {s.icon ? <img src={s.icon} alt={s.name} className="size-full object-cover" /> : <><MarbleBackground seed={s.id} /><span className="relative">{s.initial}</span></>}+ {s.icon ? <img src={s.icon} alt={s.name} className="size-full object-cover" /> : <><SeededBackdrop variant="icon" seed={s.id} /><span className="relative">{s.initial}</span></>}</span>) : (<span key={i} className="aspect-square rounded-sm bg-card/50" />diff --git a/src/web/src/components/community/server-icon.test.ts b/src/web/src/components/community/server-icon.test.tsnew file mode 100644index 000000000..9a98b1930--- /dev/null+++ b/src/web/src/components/community/server-icon.test.ts@@ -0,0 +1,41 @@+import { createElement } from "react"+import { renderToStaticMarkup } from "react-dom/server"+import { describe, expect, it } from "vitest"+import { ServerIcon } from "./server-icon"++describe("ServerIcon seeded fallback", () => {+ it.each([16, 20, 40, 64])("keeps a white initial over the native icon backdrop at %ipx", (size) => {+ const html = renderToStaticMarkup(createElement(ServerIcon, {+ id: "server-id",+ name: "Alook",+ initial: "A",+ size,+ }))+ expect(html).toContain(`width:${size}px;height:${size}px`)+ expect(html).toContain('viewBox="0 0 80 80"')+ expect(html).toContain("text-white")+ expect(html).toContain(">A</span>")+ })++ it("keeps the seeded SVG stable across server renames", () => {+ const render = (name: string) => renderToStaticMarkup(createElement(ServerIcon, {+ id: "server-id",+ name,+ initial: name[0],+ size: 40,+ }))+ const svg = (html: string) => html.match(/<svg[\s\S]*<\/svg>/)?.[0]+ expect(svg(render("Alook"))).toBe(svg(render("Renamed")))+ })++ it("leaves uploaded icons untouched", () => {+ const html = renderToStaticMarkup(createElement(ServerIcon, {+ id: "server-id",+ name: "Alook",+ initial: "A",+ icon: "/icon.png",+ }))+ expect(html).toContain('<img src="/icon.png" alt="Alook"')+ expect(html).not.toContain("<svg")+ })+})diff --git a/src/web/src/components/community/server-icon.tsx b/src/web/src/components/community/server-icon.tsxindex c7557786a..987a69e7c 100644--- a/src/web/src/components/community/server-icon.tsx+++ b/src/web/src/components/community/server-icon.tsx@@ -1,15 +1,14 @@-import { MarbleBackground } from "@/components/avatar"+import { SeededBackdrop } from "@/components/avatar"import { cn } from "@/lib/utils"// The one server icon/avatar. A custom uploaded `icon` shows as a cropped-// image; otherwise the fallback is a seeded marble gradient + the server's+// image; otherwise the fallback is a seeded native backdrop + the server's// initial in the brand font (white, subtle shadow + text-stroke). This is the// canonical treatment the server rail uses — Settings, the invite card, and// anywhere else that shows a server MUST route through here so the fallback// never diverges into a flat colored box again.//-// `seed` should be the stable server id (marble is deterministic per seed, so-// the gradient never flickers or shifts on rename). `size` sets the box;+// `seed` should be the stable server id so the backdrop never shifts on rename. `size` sets the box;// `rounded`/`className` let callers tune the corner + framing per surface.export function ServerIcon({id,@@ -39,7 +38,7 @@ export function ServerIcon({<img src={icon} alt={name} className="size-full object-cover" />) : (<>- <MarbleBackground seed={id} />+ <SeededBackdrop variant="icon" seed={id} /><span className="relative -translate-x-0.5 [-webkit-text-stroke:0.5px_currentColor]">{initial}</span></>)}diff --git a/src/web/src/components/community/server-rail.tsx b/src/web/src/components/community/server-rail.tsxindex 775092878..db17aaa45 100644--- a/src/web/src/components/community/server-rail.tsx+++ b/src/web/src/components/community/server-rail.tsx@@ -15,7 +15,7 @@ import { SortableServer } from "./sortable-server"import { RailFolder } from "./rail-folder"import { CreateServerDialog } from "./create-server-dialog"import { useRailOrder, isFolderKey, extractFolderId } from "./use-rail-order"-import { MarbleBackground } from "@/components/avatar"+import { SeededBackdrop } from "@/components/avatar"import type { Server, CommunityFolder, MobileZone, View } from "./_types"import {completeCommunityOnboarding,@@ -212,7 +212,7 @@ export const ServerRail = memo(function ServerRail({s.icon ? "bg-card text-muted-foreground" : "text-white [text-shadow:0_1px_1px_rgb(0_0_0/0.35)]",].join(" ")}>- {s.icon ? <img src={s.icon} alt={s.name} className="size-full object-cover" /> : <><MarbleBackground seed={s.id} /><span className="relative -translate-x-0.5 [-webkit-text-stroke:0.5px_currentColor]">{s.initial}</span></>}+ {s.icon ? <img src={s.icon} alt={s.name} className="size-full object-cover" /> : <><SeededBackdrop variant="icon" seed={s.id} /><span className="relative -translate-x-0.5 [-webkit-text-stroke:0.5px_currentColor]">{s.initial}</span></>}</span>) : (<span key={idx} className="aspect-square rounded-sm bg-card/50" />@@ -231,7 +231,7 @@ export const ServerRail = memo(function ServerRail({icon ? "bg-secondary text-foreground" : "text-white [text-shadow:0_1px_2px_rgb(0_0_0/0.35)]",].join(" ")}>- {icon ? <img src={icon} alt={s.name} className="size-full object-cover" /> : <><MarbleBackground seed={s.id} /><span className="relative -translate-x-0.5 [-webkit-text-stroke:0.5px_currentColor]">{s.initial}</span></>}+ {icon ? <img src={icon} alt={s.name} className="size-full object-cover" /> : <><SeededBackdrop variant="icon" seed={s.id} /><span className="relative -translate-x-0.5 [-webkit-text-stroke:0.5px_currentColor]">{s.initial}</span></>}</div>)})()}diff --git a/src/web/src/components/community/sortable-server.tsx b/src/web/src/components/community/sortable-server.tsxindex 664835430..ffd40fa94 100644--- a/src/web/src/components/community/sortable-server.tsx+++ b/src/web/src/components/community/sortable-server.tsx@@ -18,7 +18,7 @@ import {} from "@/components/ui/tooltip";import { ConfirmDialog } from "@/components/ui/confirm-dialog";import { NumberTicker } from "@/components/ui/number-ticker";-import { MarbleBackground } from "@/components/avatar";+import { SeededBackdrop } from "@/components/avatar";import { tid } from "@/lib/community/testids";import type { Server } from "./_types";@@ -129,7 +129,7 @@ function SortableServerImpl({/>) : (<>- <MarbleBackground seed={server.id} />+ <SeededBackdrop variant="icon" seed={server.id} /><span className="relative -translate-x-0.5 [-webkit-text-stroke:0.5px_currentColor]">{server.initial}</span>diff --git a/src/web/src/components/home/demo-pad/demo-dashboard.tsx b/src/web/src/components/home/demo-pad/demo-dashboard.tsxindex a67d21d02..c55745bbc 100644--- a/src/web/src/components/home/demo-pad/demo-dashboard.tsx+++ b/src/web/src/components/home/demo-pad/demo-dashboard.tsx@@ -6,7 +6,7 @@ import { MessageCluster } from "@/components/chat-primitives/message-cluster";import { PresenceLine } from "@/components/agent-chat/presence-line";import { EmailCard } from "@/components/agent-chat/event-cards/email-card";import { AnimatedAvatar } from "@/components/avatar/animated-avatar";-import { BoringAvatar } from "@/components/avatar/boring-avatar";+import { GeneratedAvatar } from "@/components/avatar/generated-avatar";import { Logo } from "@/components/logo";import { cn } from "@/lib/utils";@@ -69,7 +69,7 @@ export function DemoDashboard({ state, config, className }: { state: DashboardSt: "ring-transparent hover:ring-border/60",)}>- <BoringAvatar seed={a.seed} size={32} />+ <GeneratedAvatar seed={a.seed} size={32} /></div>);})}diff --git a/src/web/src/components/home/demo-pad/demo-mobile.tsx b/src/web/src/components/home/demo-pad/demo-mobile.tsxindex d22c7cd03..55f7023d6 100644--- a/src/web/src/components/home/demo-pad/demo-mobile.tsx+++ b/src/web/src/components/home/demo-pad/demo-mobile.tsx@@ -3,7 +3,7 @@import { ArrowUp, Home, CalendarDays, CircleDot } from "lucide-react";import { MessageBubble } from "@/components/chat-primitives/message-bubble";import { AnimatedAvatar } from "@/components/avatar/animated-avatar";-import { BoringAvatar } from "@/components/avatar/boring-avatar";+import { GeneratedAvatar } from "@/components/avatar/generated-avatar";import { Logo } from "@/components/logo";import { cn } from "@/lib/utils";import type { DashboardState, DashboardConfig } from "./demo-dashboard";@@ -35,7 +35,7 @@ export function DemoMobile({ state, config, className }: { state: DashboardStateisActive && "shadow-[inset_0_0_0_1.5px_hsl(var(--primary))]",)}>- <BoringAvatar seed={a.seed} size={16} />+ <GeneratedAvatar seed={a.seed} size={16} /></div>);})}diff --git a/src/web/src/components/home/landing-page.tsx b/src/web/src/components/home/landing-page.tsxindex ad92abe04..8af501d4d 100644--- a/src/web/src/components/home/landing-page.tsx+++ b/src/web/src/components/home/landing-page.tsx@@ -3,7 +3,7 @@import Image from "next/image"import Link from "next/link"import { useEffect, useRef, type PointerEvent as ReactPointerEvent } from "react"-import { BoringAvatar } from "@/components/avatar"+import { GeneratedAvatar } from "@/components/avatar"import { ProfileCard } from "@/components/community/profile-card"import { ProviderLogo } from "@/components/provider-logo"import { HeroSection } from "./hero-section"@@ -358,7 +358,7 @@ export function LandingPage({ isLoggedIn }: { isLoggedIn: boolean }) {className={`${styles.closingCompanion} ${companion.className}`}aria-hidden="true">- <BoringAvatar seed={companion.seed} size="100%" className={styles.closingAvatar} />+ <GeneratedAvatar seed={companion.seed} size="100%" className={styles.closingAvatar} /></span>))}<Linkdiff --git a/src/web/src/components/issues/issue-sheet.tsx b/src/web/src/components/issues/issue-sheet.tsxindex f658425ed..af765172d 100644--- a/src/web/src/components/issues/issue-sheet.tsx+++ b/src/web/src/components/issues/issue-sheet.tsx@@ -43,7 +43,7 @@ import { formatSize } from "@/components/agent-chat/artifact-sheet";import { isTerminalIssueStatus, toAlookAddress } from "@alook/shared";import type { TraceTask } from "@/lib/api";import { updateIssue } from "@/lib/api";-import { BoringAvatar } from "@/components/avatar";+import { GeneratedAvatar } from "@/components/avatar";import { resolveAvatar } from "@/lib/avatar/resolve";import { ConfirmDialog } from "@/components/ui/confirm-dialog";import { Kbd } from "@/components/ui/kbd";@@ -72,7 +72,7 @@ function AgentAvatar({ agent, size = 24 }: { agent?: Agent | null; size?: numberif (resolved.kind === "photo") {return <img src={resolved.url} alt={agent?.name ?? ""} className="shrink-0 rounded-full object-cover" style={{ width: size, height: size }} />;}- return <BoringAvatar seed={resolved.seed} size={size} className="shrink-0 rounded-full" />;+ return <GeneratedAvatar seed={resolved.seed} size={size} className="shrink-0 rounded-full" />;}function AgentIdentity({ agent, size = 24 }: { agent: Agent; size?: number }) {diff --git a/src/web/src/components/studio-onboarding/team-preview.tsx b/src/web/src/components/studio-onboarding/team-preview.tsxindex c1c5462c4..aedc8f5be 100644--- a/src/web/src/components/studio-onboarding/team-preview.tsx+++ b/src/web/src/components/studio-onboarding/team-preview.tsx@@ -4,7 +4,7 @@ import { cn } from "@/lib/utils";import { Button } from "@/components/ui/button";import { Card } from "@/components/ui/card";import { RefreshCw } from "lucide-react";-import { BoringAvatar } from "@/components/avatar";+import { GeneratedAvatar } from "@/components/avatar";import { resolveAvatar } from "@/lib/avatar/resolve";import {Select,@@ -75,7 +75,7 @@ export function TeamPreview({{resolved.kind === "photo" ? (<img src={resolved.url} alt={m.name} className="size-9 rounded-xl object-cover shrink-0" />) : (- <BoringAvatar seed={resolved.seed} size={36} className="rounded-xl shrink-0" />+ <GeneratedAvatar seed={resolved.seed} size={36} className="rounded-xl shrink-0" />)}<div className="flex flex-col items-start gap-1"><span className="text-sm font-medium">{m.name}</span>diff --git a/src/web/src/lib/avatar/backdrop.test.ts b/src/web/src/lib/avatar/backdrop.test.tsnew file mode 100644index 000000000..90f1b7269--- /dev/null+++ b/src/web/src/lib/avatar/backdrop.test.ts@@ -0,0 +1,56 @@+import { describe, expect, it } from "vitest"+import { renderSeededBackdropSvg } from "./backdrop"++describe("renderSeededBackdropSvg", () => {+ it.each([+ {+ seed: "Alice",+ colors: ["#ffab62", "#ffe0a6", "#432526"],+ first: "translate(0 0) rotate(176 40 40) scale(1.2)",+ second: "translate(0 0) rotate(-264 40 40) scale(1.2)",+ },+ {+ seed: "server-id",+ colors: ["#25294f", "#4d5c9a", "#7587d6"],+ first: "translate(6 6) rotate(70 40 40) scale(1.3)",+ second: "translate(-1 1) rotate(-105 40 40) scale(1.3)",+ },+ {+ seed: "avatar:stable-seed",+ colors: ["#8a5a9e", "#e0729a", "#ffb26b"],+ first: "translate(4 -4) rotate(172 40 40) scale(1.4)",+ second: "translate(2 -2) rotate(258 40 40) scale(1.4)",+ },+ ])("matches boring-avatars 2.0.4 marble fixtures for $seed", ({ seed, colors, first, second }) => {+ const svg = renderSeededBackdropSvg(seed, "icon")+ expect(svg).toContain(`<rect width="80" height="80" fill="${colors[0]}"/>`)+ expect(svg).toContain(`fill="${colors[1]}" transform="${first}"`)+ expect(svg).toContain(`fill="${colors[2]}" transform="${second}"`)+ })++ it("keeps the upstream 80px marble composition and stretching behavior", () => {+ const svg = renderSeededBackdropSvg("profile-id", "profile")+ expect(svg).toContain('viewBox="0 0 80 80"')+ expect(svg).toContain('preserveAspectRatio="none"')+ expect(svg.match(/<path /g)).toHaveLength(2)+ expect(svg.match(/filter="url\(#/g)).toHaveLength(2)+ expect(svg).toContain('style="mix-blend-mode:overlay"')+ expect(svg).toContain('<feGaussianBlur stdDeviation="7"')+ expect(svg).not.toContain("fill-opacity")+ })++ it("is deterministic while keeping profile and icon geometry visually identical", () => {+ const icon = renderSeededBackdropSvg("stable-id", "icon")+ const profile = renderSeededBackdropSvg("stable-id", "profile")+ expect(renderSeededBackdropSvg("stable-id", "icon")).toBe(icon)+ expect(icon).not.toBe(profile)+ expect(icon.replace(/alook-marble-\d+/g, "id")).toBe(profile.replace(/alook-marble-\d+/g, "id"))+ })++ it("varies the upstream color and transform data across seeds", () => {+ const normalizeIds = (svg: string) => svg.replace(/alook-marble-\d+/g, "id")+ expect(normalizeIds(renderSeededBackdropSvg("server-a", "icon"))).not.toBe(+ normalizeIds(renderSeededBackdropSvg("server-b", "icon")),+ )+ })+})diff --git a/src/web/src/lib/avatar/backdrop.ts b/src/web/src/lib/avatar/backdrop.tsnew file mode 100644index 000000000..b74cf5780--- /dev/null+++ b/src/web/src/lib/avatar/backdrop.ts@@ -0,0 +1,44 @@+import { avatarHash, avatarThemeFromSeed } from "./theme"++export type SeededBackdropVariant = "profile" | "icon"++const MARBLE_SIZE = 80+const MARBLE_LAYERS = 3++function digit(value: number, position: number): number {+ return Math.floor((value / 10 ** position) % 10)+}++function signedModulo(value: number, maximum: number, signDigit?: number): number {+ const remainder = value % maximum+ return signDigit !== undefined && digit(value, signDigit) % 2 === 0 ? -remainder : remainder+}++/**+ * Faithful local port of [email protected]'s marble data function.+ * Keep the seemingly odd first-path `layers[2].scale` use below: the upstream+ * implementation does that too, and changing it would change existing visuals.+ */+function marbleLayersFromSeed(seed: string) {+ const hash = avatarHash(seed)+ const palette = avatarThemeFromSeed(seed).palette+ return Array.from({ length: MARBLE_LAYERS }, (_, index) => {+ const value = hash * (index + 1)+ return {+ color: palette[(hash + index) % palette.length],+ translateX: signedModulo(value, MARBLE_SIZE / 10, 1),+ translateY: signedModulo(value, MARBLE_SIZE / 10, 2),+ scale: 1.2 + signedModulo(value, MARBLE_SIZE / 20) / 10,+ rotate: signedModulo(value, 360, 1),+ }+ })+}++export function renderSeededBackdropSvg(seed: string, variant: SeededBackdropVariant): string {+ const layers = marbleLayersFromSeed(seed)+ const id = `alook-marble-${avatarHash(`${seed}:${variant}`)}`+ const maskId = `${id}-mask`+ const filterId = `${id}-filter`++ return `<svg viewBox="0 0 80 80" fill="none" width="100%" height="100%" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg"><mask id="${maskId}" maskUnits="userSpaceOnUse" x="0" y="0" width="80" height="80"><rect width="80" height="80" fill="#FFFFFF"/></mask><g mask="url(#${maskId})"><rect width="80" height="80" fill="${layers[0].color}"/><path filter="url(#${filterId})" d="M32.414 59.35L50.376 70.5H72.5v-71H33.728L26.5 13.381l19.057 27.08L32.414 59.35z" fill="${layers[1].color}" transform="translate(${layers[1].translateX} ${layers[1].translateY}) rotate(${layers[1].rotate} 40 40) scale(${layers[2].scale})"/><path filter="url(#${filterId})" style="mix-blend-mode:overlay" d="M22.216 24L0 46.75l14.108 38.129L78 86l-3.081-59.276-22.378 4.005 12.972 20.186-23.35 27.395L22.215 24z" fill="${layers[2].color}" transform="translate(${layers[2].translateX} ${layers[2].translateY}) rotate(${layers[2].rotate} 40 40) scale(${layers[2].scale})"/></g><defs><filter id="${filterId}" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="7" result="effect1_foregroundBlur"/></filter></defs></svg>`+}diff --git a/src/web/src/lib/avatar/boring-palettes.test.ts b/src/web/src/lib/avatar/boring-palettes.test.tsdeleted file mode 100644index b649461d4..000000000--- a/src/web/src/lib/avatar/boring-palettes.test.ts+++ /dev/null@@ -1,29 +0,0 @@-import { describe, it, expect } from "vitest"-import { PALETTES, paletteFromSeed } from "./boring-palettes"--describe("paletteFromSeed", () => {- it("is deterministic for the same seed", () => {- expect(paletteFromSeed("usr_1")).toBe(paletteFromSeed("usr_1"))- })-- it("returns a palette that is a member of PALETTES (reference equality)", () => {- const p = paletteFromSeed("usr_42")- expect(PALETTES).toContain(p)- })-- it("spreads across more than one palette over many seeds", () => {- const seen = new Set(- Array.from({ length: 60 }, (_, i) => paletteFromSeed(`seed_${i}`)),- )- expect(seen.size).toBeGreaterThan(1)- })-- it("first palette is the official boringavatars.com sample", () => {- expect(PALETTES[0]).toEqual(["#00686c", "#32c2b9", "#edecb3", "#fad928", "#ff9915"])- })-- it("ships the approved 25 color worlds", () => {- expect(PALETTES).toHaveLength(25)- for (const palette of PALETTES) expect(palette).toHaveLength(5)- })-})diff --git a/src/web/src/lib/avatar/boring-palettes.ts b/src/web/src/lib/avatar/boring-palettes.tsdeleted file mode 100644index 89fad2f3a..000000000--- a/src/web/src/lib/avatar/boring-palettes.ts+++ /dev/null@@ -1,65 +0,0 @@-/**- * Color palettes for boring-avatars, chosen deterministically per seed.- *- * Set 0 is the official boringavatars.com sample palette. Sets 1–12 began from- * opening entries of Matt DesLauriers' Nice Color Palettes (the same source the- * boringavatars.com playground samples from), with three muddy/clashing entries- * replaced by curated sets. Sets 13–24 are Alook's approved expansion: each has- * a deliberate dark anchor, bright body hues, and a light relief color so every- * generated wrapper can find a readable background. No global desaturation: it- * dropped contrast, so the vibrant hues stand.- *- * Selection reuses the same hash + mulberry32 PRNG as `gradient-from-seed.ts`- * so the "looks random, never flickers" behavior matches the rest of the app.- */--export const PALETTES: readonly (readonly string[])[] = [- ["#00686c", "#32c2b9", "#edecb3", "#fad928", "#ff9915"],- ["#69d2e7", "#a7dbd8", "#e0e4cc", "#f38630", "#fa6900"],- ["#fe4365", "#fc9d9a", "#f9cdad", "#c8c8a9", "#83af9b"],- ["#ffd166", "#f4845f", "#ef476f", "#c86b98", "#6a8caf"],- ["#556270", "#4ecdc4", "#c7f464", "#ff6b6b", "#c44d58"],- ["#774f38", "#e08e79", "#f1d4af", "#ece5ce", "#c5e0dc"],- ["#0b525b", "#06d6a0", "#8ac6d1", "#ffd166", "#ff9f68"],- ["#3a2e4d", "#8a5a9e", "#e0729a", "#ffb26b", "#ffe08a"],- ["#594f4f", "#547980", "#45ada8", "#9de0ad", "#e5fcc2"],- ["#00a0b0", "#6a4a3c", "#cc333f", "#eb6841", "#edc951"],- ["#e94e77", "#d68189", "#c6a49a", "#c6e5d9", "#f4ead5"],- ["#3fb8af", "#7fc7af", "#dad8a7", "#ff9e9d", "#ff3d7f"],- ["#00a8c6", "#40c0cb", "#f9f2e7", "#aee239", "#8fbe00"],- ["#23352f", "#7bc95a", "#dce95c", "#ffd65a", "#fff1b8"],- ["#17394a", "#35aeb4", "#77d9d5", "#b9eff0", "#f3d978"],- ["#3e233d", "#8b4771", "#dc6b9d", "#ff9fb3", "#ffe1dd"],- ["#4a2e25", "#d6664c", "#f58c64", "#ffc173", "#ffe2ad"],- ["#24372e", "#55744f", "#90aa62", "#c8d685", "#f0efc0"],- ["#25294f", "#4d5c9a", "#7587d6", "#a9b6ff", "#ebe9ff"],- ["#493044", "#eb7c8b", "#ffb46d", "#ffe08b", "#c8ecdc"],- ["#3c302b", "#8d5d4d", "#c27f65", "#e7ae85", "#f3dfc7"],- ["#16202a", "#32d48e", "#c4f342", "#ffdf3f", "#ff7597"],- ["#17192e", "#3f477f", "#7457a8", "#c47edb", "#f3c8ef"],- ["#362a52", "#7d60a9", "#b699dc", "#dfc7f0", "#fff0d9"],- ["#432526", "#c6403f", "#f0654b", "#ffab62", "#ffe0a6"],-] as const--function hashStr(s: string): number {- let h = 0- for (let i = 0; i < s.length; i++) h = ((h << 5) - h + s.charCodeAt(i)) | 0- return Math.abs(h)-}--function mulberry32(seed: number): () => number {- let a = seed- return () => {- a = (a + 0x6d2b79f5) | 0- let t = Math.imul(a ^ (a >>> 15), 1 | a)- t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t- return ((t ^ (t >>> 14)) >>> 0) / 4294967296- }-}--/** One palette from `PALETTES`, chosen deterministically by `seed`. */-export function paletteFromSeed(seed: string): string[] {- const rand = mulberry32(hashStr(seed))- const idx = Math.floor(rand() * PALETTES.length)- return PALETTES[idx] as string[]-}diff --git a/src/web/src/lib/avatar/face.test.ts b/src/web/src/lib/avatar/face.test.tsindex 49f4f5891..5b199269e 100644--- a/src/web/src/lib/avatar/face.test.ts+++ b/src/web/src/lib/avatar/face.test.ts@@ -1,8 +1,7 @@import { describe, it, expect } from "vitest"+import { createHash } from "node:crypto"import { FACE_HAT_LINE, FACE_SHAPE_PATHS, FACE_VOCABULARY, renderFaceSvg, ink } from "./face"-import { PALETTES } from "./boring-palettes"--const PALETTE = ["#00686c", "#32c2b9", "#edecb3", "#fad928", "#ff9915"]+import { AVATAR_PALETTES, avatarColorLuminance, avatarThemeFromSeed } from "./theme"describe("ink", () => {it("returns black ink on a light wrapper", () => {@@ -14,21 +13,34 @@ describe("ink", () => {})describe("renderFaceSvg", () => {+ it("matches the pre-theme-refactor SVG fixtures", () => {+ const fixtures = {+ Alice: "69613f62d983d4af75f7095f5aec1723338316f71e20f076a21005f0ae074b29",+ "Shelly#3863": "620de95400290665f45ee09c9e010cbf8225d725c0d01a28d911e75efc33564e",+ usr_42: "e119eb5fb0032a00514f0c2fdd135f33f5c0b6fbf11ca5f9e2ee7ca8fc69a363",+ "avatar:stable-seed": "810d929e00fc4ce739723d2aa5ac12f821800ee7b3bfb20f46d4b1e7c8a8fffb",+ }+ for (const [seed, expected] of Object.entries(fixtures)) {+ const svg = renderFaceSvg(seed)+ expect(createHash("sha256").update(svg).digest("hex")).toBe(expected)+ }+ })+it("is deterministic — same seed + palette → identical SVG", () => {- const a = renderFaceSvg("Shelly#3863", PALETTE)- const b = renderFaceSvg("Shelly#3863", PALETTE)+ const a = renderFaceSvg("Shelly#3863")+ const b = renderFaceSvg("Shelly#3863")expect(a).toBe(b)})it("emits a well-formed 36-unit SVG", () => {- const svg = renderFaceSvg("Alice", PALETTE)+ const svg = renderFaceSvg("Alice")expect(svg.startsWith("<svg")).toBe(true)expect(svg).toContain('viewBox="0 0 36 36"')expect(svg.trim().endsWith("</svg>")).toBe(true)})it("uses no <mask> id (would collide across many faces on one page)", () => {- const svg = renderFaceSvg("Alice", PALETTE)+ const svg = renderFaceSvg("Alice")expect(svg).not.toContain("<mask")expect(svg).not.toContain("url(#")})@@ -36,7 +48,7 @@ describe("renderFaceSvg", () => {it("draws two eyes and a mouth inside the face group", () => {// Every face renders a left+right eye and one mouth; the wrapper is a rect// or path. Assert the face has drawable children beyond the bg rect.- const svg = renderFaceSvg("Diego", PALETTE)+ const svg = renderFaceSvg("Diego")const inner = svg.slice(svg.indexOf('rotate'))expect(inner.length).toBeGreaterThan(0)// at least one stroke/fill primitive from the eye/mouth libraries@@ -45,15 +57,16 @@ describe("renderFaceSvg", () => {it("varies across seeds — different ids generally produce different faces", () => {const seeds = ["a", "b", "c", "d", "e", "f", "g", "h"]- const svgs = new Set(seeds.map((s) => renderFaceSvg(s, PALETTE)))+ const svgs = new Set(seeds.map((s) => renderFaceSvg(s)))// Not all identical — the richer vocabulary means low collision.expect(svgs.size).toBeGreaterThan(1)})it("only references colors from the given palette (plus contrast ink + white)", () => {- const svg = renderFaceSvg("Melisa#1043", PALETTE)+ const seed = "Melisa#1043"+ const svg = renderFaceSvg(seed)const hexes = svg.match(/#[0-9a-fA-F]{6}/g) ?? []- const allowed = new Set([...PALETTE, "#000000", "#ffffff"])+ const allowed = new Set([...avatarThemeFromSeed(seed).palette, "#000000", "#ffffff"])for (const h of hexes) expect(allowed.has(h)).toBe(true)})@@ -64,7 +77,7 @@ describe("renderFaceSvg", () => {// and shares its transform. Assert the SVG has exactly ONE transform group// and the eye/mouth nodes are inside it (after the wrapper fill).for (let n = 0; n < 60; n++) {- const svg = renderFaceSvg(`e-${n}`, PALETTE)+ const svg = renderFaceSvg(`e-${n}`)const groups = svg.match(/<g transform=/g) ?? []expect(groups.length).toBe(1) // single shared shape+face group// eyes/mouth (circle/path with the ink color) come AFTER the wrapper fill@@ -80,7 +93,7 @@ describe("renderFaceSvg", () => {// face anymore"). Rotation must stay within ±20° (rot = i%41 − 20). A wider// tilt would also eat the crown-reserve budget of the grounded paths.for (let n = 0; n < 80; n++) {- const svg = renderFaceSvg(`r-${n}`, PALETTE)+ const svg = renderFaceSvg(`r-${n}`)const rot = parseFloat((svg.match(/rotate\((-?\d+(?:\.\d+)?)/) ?? ["", "0"])[1])expect(Math.abs(rot)).toBeLessThanOrEqual(20)}@@ -93,7 +106,7 @@ describe("renderFaceSvg", () => {// |ty| ≤ ~2.6 → coverage radius (shape half-extent 12.2 − offset) > feature// extent 9.5, so the face is always inside the wrapper.for (let n = 0; n < 80; n++) {- const svg = renderFaceSvg(`t-${n}`, PALETTE)+ const svg = renderFaceSvg(`t-${n}`)const m = svg.match(/translate\((-?\d+(?:\.\d+)?) (-?\d+(?:\.\d+)?)\)/)!expect(Math.abs(parseFloat(m[1]))).toBeLessThanOrEqual(2.6)expect(Math.abs(parseFloat(m[2]))).toBeLessThanOrEqual(2.6)@@ -109,7 +122,7 @@ describe("renderFaceSvg", () => {// center (18,14 eye row / 18,~20 mouth), pre-transform (the shared transform// preserves relative position).for (let n = 0; n < 60; n++) {- const svg = renderFaceSvg(`s-${n}`, PALETTE)+ const svg = renderFaceSvg(`s-${n}`)// the face group is the LAST <g transform=...>; pull the coords inside itconst faceGroup = svg.slice(svg.lastIndexOf("<g transform"))const coords = [...faceGroup.matchAll(/(?:cx|x)="?(-?\d+(?:\.\d+)?)"?\s+(?:cy|y)="?(-?\d+(?:\.\d+)?)"?/g)]@@ -127,7 +140,7 @@ describe("renderFaceSvg", () => {const CX = 18const CYh = 23.5for (let n = 0; n < 400; n++) {- const svg = renderFaceSvg(`hat-${n}`, PALETTE)+ const svg = renderFaceSvg(`hat-${n}`)// Pull the wrapper path (first <path> after the shape group) and its transform.const xf = svg.match(/<g transform="([^"]+)"/)![1]const rot = parseFloat((xf.match(/rotate\((-?\d+(?:\.\d+)?)/) ?? ["", "0"])[1])@@ -189,7 +202,7 @@ describe("renderFaceSvg", () => {// outputs across many seeds to catch accidental vocabulary collapse.const shapes = new Set<string>()const svgs: string[] = []- for (let n = 0; n < 4000; n++) svgs.push(renderFaceSvg(`d-${n}`, PALETTE))+ for (let n = 0; n < 4000; n++) svgs.push(renderFaceSvg(`d-${n}`))for (const svg of svgs) shapes.add(svg.match(/<path d="([^"]+)"/)![1])expect(shapes.size).toBe(11)// The full head (shape+eye+mouth) space is large: expect many distinct faces.@@ -201,19 +214,16 @@ describe("renderFaceSvg", () => {// with a near-light background, melting the face into the bg. bg is now the// max-luminance-distance color, so the wrapper↔bg gap stays meaningful for// every palette + seed. Guard the worst case across many seeds per palette.- const lum = (hex: string) => {- const h = hex.replace("#", "")- return (parseInt(h.slice(0, 2), 16) * 299 + parseInt(h.slice(2, 4), 16) * 587 + parseInt(h.slice(4, 6), 16) * 114) / 1000+ const representatives = new Map<readonly string[], string>()+ for (let index = 0; representatives.size < AVATAR_PALETTES.length; index++) {+ const seed = `palette-${index}`+ representatives.set(avatarThemeFromSeed(seed).palette, seed)}- const seeds = Array.from({ length: 400 }, (_, n) => `seed-${n}`)- for (const palette of PALETTES) {- for (const seed of seeds) {- const svg = renderFaceSvg(seed, palette)- // first two fills are bg then wrapper; pull them in document order- const fills = [...svg.matchAll(/fill="(#[0-9a-fA-F]{6})"/g)].map((m) => m[1])- const [bg, wrapper] = fills- expect(Math.abs(lum(bg) - lum(wrapper))).toBeGreaterThan(40)- }+ for (const seed of representatives.values()) {+ const svg = renderFaceSvg(seed)+ const fills = [...svg.matchAll(/fill="(#[0-9a-fA-F]{6})"/g)].map((match) => match[1])+ const [bg, wrapper] = fills+ expect(Math.abs(avatarColorLuminance(bg) - avatarColorLuminance(wrapper))).toBeGreaterThan(40)}})})diff --git a/src/web/src/lib/avatar/face.ts b/src/web/src/lib/avatar/face.tsindex 48a7134b9..06d27fb75 100644--- a/src/web/src/lib/avatar/face.ts+++ b/src/web/src/lib/avatar/face.ts@@ -1,7 +1,6 @@-// Generated "beam" face renderer — the richer replacement for boring-avatars'-// fixed beam geometry. Ported from the approved design prototype (Alli). Same-// 36-unit canvas, same PRNG + auto-contrast ink as the lib's beam, so it reads-// as "more of the same face", not a new style. The feature vocabulary grew:+import { avatarHash, avatarThemeFromSeed } from "./theme"++// Generated face renderer from the approved design prototype. The feature vocabulary is:// 11 grounded shapes · 21 eyes · 22 mouths.// Each seed picks its shape/eye/mouth deterministically (INDEPENDENTLY), so a// given id always renders the same face and never flickers across renames.@@ -10,8 +9,6 @@// possible future hat. Hats do not exist in the product today, so this reserve// follows the QA-approved avatar geometry — the geometry must never be retuned// to satisfy a speculative accessory constraint (Gus, uiux#609–612).-//-// `beam` only. Marble (server/channel icons, banner) stays on the lib.const C = 36const CX = 18@@ -22,57 +19,12 @@ const CX = 18const CYh = 23.5export const FACE_HAT_LINE = 4-// boring-avatars PRNG helpers (verbatim from the lib bundle, so the base-// transform matches the lib's beam feel exactly).-function hashSeed(name: string): number {- let r = 0- for (let i = 0; i < name.length; i++) {- r = (r << 5) - r + name.charCodeAt(i)- r = r & r- }- return Math.abs(r)-}const digit = (n: number, p: number): number => Math.floor((n / Math.pow(10, p)) % 10)const unit = (n: number, m: number, p?: number): number => {const a = n % mreturn p && digit(n, p) % 2 === 0 ? -a : a}-const pick = (n: number, arr: readonly string[], off = 0): string => arr[(n + off) % arr.length]--// Perceived luminance (0–255), the same weighting the lib uses for faceColor.-function luminance(hex: string): number {- const h = hex.replace("#", "")- const r = parseInt(h.substr(0, 2), 16)- const g = parseInt(h.substr(2, 2), 16)- const b = parseInt(h.substr(4, 2), 16)- return (r * 299 + g * 587 + b * 114) / 1000-}--// Contrasting ink color — same luminance rule the lib uses for faceColor.-export function ink(hex: string): string {- return luminance(hex) >= 128 ? "#000000" : "#ffffff"-}--// Pick the palette color with the greatest luminance distance from `wrapper`,-// for use as the background. The lib's beam uses a fixed offset (bg =-// palette[(i+13)%len]) which can land wrapper + bg on two near-luminance-// colors — a face that melts into its background (the low-contrast bug Gus-// hit on the all-light idx-6 palette). Max-distance guarantees the face reads-// against the bg for every seed/palette. Deterministic: pure function of-// wrapper + palette, so faces stay stable and never flicker.-function farthestByLuminance(wrapper: string, palette: readonly string[]): string {- const wl = luminance(wrapper)- let best = palette[0]- let bestDist = -1- for (const c of palette) {- const d = Math.abs(luminance(c) - wl)- if (d > bestDist) {- bestDist = d- best = c- }- }- return best-}+export { avatarInk as ink } from "./theme"// Grounded wrapper shapes from the approved component review (uiux#591–593).// Their lower half shares a sturdy, almost-straight body and a broad rounded@@ -172,11 +124,12 @@ export const FACE_VOCABULARY = {// Render a generated beam face to an SVG string for the given seed + palette.// Feature choice is deterministic on the seed hash; the head is placed in the// lower band so the top ~20% stays clear for a hat.-export function renderFaceSvg(seed: string, palette: readonly string[]): string {- const i = hashSeed(seed)- const wrapper = pick(i, palette)- const bg = farthestByLuminance(wrapper, palette)- const c = ink(wrapper)+export function renderFaceSvg(seed: string): string {+ const i = avatarHash(seed)+ const theme = avatarThemeFromSeed(seed)+ const wrapper = theme.face+ const bg = theme.background+ const c = theme.ink// INDEPENDENT feature selection via radix slicing of the hash. The old code// used i%len for shape but digit(i,4)%6 / digit(i,5)%6 for eye/mouth — adiff --git a/src/web/src/lib/avatar/theme.test.ts b/src/web/src/lib/avatar/theme.test.tsnew file mode 100644index 000000000..5e1344cd5--- /dev/null+++ b/src/web/src/lib/avatar/theme.test.ts@@ -0,0 +1,34 @@+import { describe, expect, it } from "vitest"+import { AVATAR_PALETTES, avatarThemeFromSeed } from "./theme"++describe("avatarThemeFromSeed", () => {+ it("preserves the approved palette selection and face color roles", () => {+ expect(avatarThemeFromSeed("usr_42")).toEqual({+ palette: AVATAR_PALETTES[10],+ face: "#c6e5d9",+ background: "#e94e77",+ ink: "#000000",+ accents: ["#d68189", "#c6a49a", "#f4ead5"],+ darkest: "#e94e77",+ })+ })++ it("is deterministic and returns the selected palette by reference", () => {+ const first = avatarThemeFromSeed("stable-id")+ const second = avatarThemeFromSeed("stable-id")+ expect(first).toEqual(second)+ expect(AVATAR_PALETTES).toContain(first.palette)+ })++ it("ships all 25 approved five-color worlds", () => {+ expect(AVATAR_PALETTES).toHaveLength(25)+ for (const palette of AVATAR_PALETTES) expect(palette).toHaveLength(5)+ })++ it("spreads seeds across multiple themes", () => {+ const palettes = new Set(Array.from({ length: 60 }, (_, index) =>+ avatarThemeFromSeed(`seed_${index}`).palette,+ ))+ expect(palettes.size).toBeGreaterThan(1)+ })+})diff --git a/src/web/src/lib/avatar/theme.ts b/src/web/src/lib/avatar/theme.tsnew file mode 100644index 000000000..cd4b5a212--- /dev/null+++ b/src/web/src/lib/avatar/theme.ts@@ -0,0 +1,90 @@+export const AVATAR_PALETTES = [+ ["#00686c", "#32c2b9", "#edecb3", "#fad928", "#ff9915"],+ ["#69d2e7", "#a7dbd8", "#e0e4cc", "#f38630", "#fa6900"],+ ["#fe4365", "#fc9d9a", "#f9cdad", "#c8c8a9", "#83af9b"],+ ["#ffd166", "#f4845f", "#ef476f", "#c86b98", "#6a8caf"],+ ["#556270", "#4ecdc4", "#c7f464", "#ff6b6b", "#c44d58"],+ ["#774f38", "#e08e79", "#f1d4af", "#ece5ce", "#c5e0dc"],+ ["#0b525b", "#06d6a0", "#8ac6d1", "#ffd166", "#ff9f68"],+ ["#3a2e4d", "#8a5a9e", "#e0729a", "#ffb26b", "#ffe08a"],+ ["#594f4f", "#547980", "#45ada8", "#9de0ad", "#e5fcc2"],+ ["#00a0b0", "#6a4a3c", "#cc333f", "#eb6841", "#edc951"],+ ["#e94e77", "#d68189", "#c6a49a", "#c6e5d9", "#f4ead5"],+ ["#3fb8af", "#7fc7af", "#dad8a7", "#ff9e9d", "#ff3d7f"],+ ["#00a8c6", "#40c0cb", "#f9f2e7", "#aee239", "#8fbe00"],+ ["#23352f", "#7bc95a", "#dce95c", "#ffd65a", "#fff1b8"],+ ["#17394a", "#35aeb4", "#77d9d5", "#b9eff0", "#f3d978"],+ ["#3e233d", "#8b4771", "#dc6b9d", "#ff9fb3", "#ffe1dd"],+ ["#4a2e25", "#d6664c", "#f58c64", "#ffc173", "#ffe2ad"],+ ["#24372e", "#55744f", "#90aa62", "#c8d685", "#f0efc0"],+ ["#25294f", "#4d5c9a", "#7587d6", "#a9b6ff", "#ebe9ff"],+ ["#493044", "#eb7c8b", "#ffb46d", "#ffe08b", "#c8ecdc"],+ ["#3c302b", "#8d5d4d", "#c27f65", "#e7ae85", "#f3dfc7"],+ ["#16202a", "#32d48e", "#c4f342", "#ffdf3f", "#ff7597"],+ ["#17192e", "#3f477f", "#7457a8", "#c47edb", "#f3c8ef"],+ ["#362a52", "#7d60a9", "#b699dc", "#dfc7f0", "#fff0d9"],+ ["#432526", "#c6403f", "#f0654b", "#ffab62", "#ffe0a6"],+] as const++export interface AvatarTheme {+ palette: readonly string[]+ face: string+ background: string+ ink: "#000000" | "#ffffff"+ accents: readonly string[]+ darkest: string+}++export function avatarHash(seed: string): number {+ let hash = 0+ for (let index = 0; index < seed.length; index++) {+ hash = ((hash << 5) - hash + seed.charCodeAt(index)) | 0+ }+ return Math.abs(hash)+}++export function avatarColorLuminance(hex: string): number {+ const value = hex.replace("#", "")+ const red = Number.parseInt(value.slice(0, 2), 16)+ const green = Number.parseInt(value.slice(2, 4), 16)+ const blue = Number.parseInt(value.slice(4, 6), 16)+ return (red * 299 + green * 587 + blue * 114) / 1000+}++export function avatarInk(color: string): "#000000" | "#ffffff" {+ return avatarColorLuminance(color) >= 128 ? "#000000" : "#ffffff"+}++function seededRandom(seed: number): () => number {+ let state = seed+ return () => {+ state = (state + 0x6d2b79f5) | 0+ let value = Math.imul(state ^ (state >>> 15), 1 | state)+ value = (value + Math.imul(value ^ (value >>> 7), 61 | value)) ^ value+ return ((value ^ (value >>> 14)) >>> 0) / 4294967296+ }+}++export function avatarThemeFromSeed(seed: string): AvatarTheme {+ const hash = avatarHash(seed)+ const random = seededRandom(hash)+ const palette = AVATAR_PALETTES[Math.floor(random() * AVATAR_PALETTES.length)]+ const face = palette[hash % palette.length]+ const faceLuminance = avatarColorLuminance(face)+ const background = palette.reduce((best, color) =>+ Math.abs(avatarColorLuminance(color) - faceLuminance) > Math.abs(avatarColorLuminance(best) - faceLuminance)+ ? color+ : best,+ )+ const darkest = palette.reduce((best, color) =>+ avatarColorLuminance(color) < avatarColorLuminance(best) ? color : best,+ )+ return {+ palette,+ face,+ background,+ ink: avatarInk(face),+ accents: palette.filter((color) => color !== face && color !== background),+ darkest,+ }+}