Skip to content

Commit ec11f8e

Browse files
tellahoCarlRizz
authored
fix(avatars): scale agent squircles from normalized paths (#7307)
## Overview **Category:** fix **User Impact:** Agent avatars and empty agent-team placeholders now keep the same intentional squircle silhouette at every size on desktop, while human avatars remain circular. **Problem:** Desktop agent avatars used percentage-rounded rectangles, which made the silhouette vary by surface and required each avatar implementation to recreate the shape. Empty team placeholders also drew a regular CSS border inside the clip, leaving straight inset edges that looked like a cropped square. **Solution:** Reuse one normalized SVG clip path across desktop artwork. Empty team placeholders use a separately clipped squircle outline behind the clipped surface, so both the fill and outline follow the canonical silhouette. > **Scope correction:** Mobile is deferred from this PR because a real Flutter capture could not be obtained reliably in the current build environment. Previously attached mobile images were hand-composed synthetic layouts, not captures from the running app; they have been removed and must not be treated as validation. The mobile implementation is being reverted in one follow-up commit so it can be reapplied and verified separately. ### Related issue Follow-up to #7106. ## Changes <details> <summary>File changes</summary> **desktop/src/features/agents/ui/AgentCreationPreview.tsx** Applies the shared squircle clip to agent creation preview images and fallbacks. **desktop/src/features/agents/ui/AgentSessionToolItem/CompactMessageSummary.tsx** Uses the shared agent-avatar silhouette in compact session summaries. **desktop/src/features/agents/ui/IdentityInitialsAvatar.tsx** Clips agent initials with the normalized squircle instead of a percentage radius. **desktop/src/features/agents/ui/TeamIdentityCard.tsx** Uses the shared squircle for agent identities and gives empty teams a separately clipped squircle outline instead of a regular inset border. **desktop/src/features/agents/ui/activityRenderClasses/UserMessageBubble.tsx** Keeps agent avatars in activity message bubbles on the canonical silhouette. **desktop/src/features/home/ui/InboxListPane.tsx** Applies the shared clip to agent avatars in the inbox list. **desktop/src/features/home/ui/InboxMessageRow.tsx** Applies the shared clip to agent avatars in inbox message rows. **desktop/src/features/huddle/components/ParticipantList.tsx** Uses the normalized squircle for agent participants while preserving circular human avatars. **desktop/src/features/messages/ui/MessageRow.tsx** Clips agent message avatars through the shared definition. **desktop/src/features/messages/ui/SystemMessageAvatars.tsx** Uses the canonical agent shape in system-message avatar groups. **desktop/src/features/messages/ui/TypingIndicatorRow.tsx** Uses the canonical agent shape in typing indicators. **desktop/src/features/profile/ui/ProfileAvatar.tsx** Scales the same squircle to the larger agent profile avatar. **desktop/src/features/profile/ui/SelectedRecipientChip.tsx** Uses the shared shape for selected agent recipients. **desktop/src/features/projects/ui/IssueAssigneesRow.tsx** Applies the agent squircle to issue assignees without changing human avatar geometry. **desktop/src/features/projects/ui/ProjectCards.tsx** Uses the canonical shape for agent avatars on project cards. **desktop/src/features/projects/ui/ProjectEntityListRow.tsx** Uses the canonical shape for agent identities in project entity lists. **desktop/src/features/projects/ui/ProjectsActivityFeed.tsx** Uses the shared clip for agent avatars in project activity. **desktop/src/features/projects/ui/ProjectsOverviewRail.tsx** Uses the shared clip for agent avatars in the project overview rail. **desktop/src/main.tsx** Mounts the single shared SVG clip-path definition once for the desktop application. **desktop/src/shared/lib/cn.ts** Registers `rounded-squircle` in the border-radius class group so shadcn-style `cn(...)` composition resolves it against `rounded-full` by normal last-class precedence. **desktop/src/shared/styles/globals/utilities.css** Registers the reusable Tailwind `rounded-squircle` utility and references the normalized SVG clip path without agent-specific CSS selectors. **desktop/src/shared/ui/AvatarClipPaths.tsx** Owns the reusable normalized object-bounding-box `rounded-squircle` path so all desktop sizes reuse one definition. **desktop/src/shared/ui/UserAvatar.tsx** Routes the existing squircle shape option through the shared SVG clip. **desktop/tests/e2e/agents.spec.ts** Verifies team facepile and empty-team placeholder surfaces/outlines use the canonical clip without a rectangular border. **desktop/tests/e2e/messaging.spec.ts** Verifies agent message and profile avatars reuse one clip definition and scale across rendered sizes. </details> ## Reproduction steps 1. Run the desktop app and open a channel containing both agent and human messages. 2. Compare agent avatars in the message list, inbox, huddle participants, projects, and profile panel. Agent images and fallbacks should share one smooth squircle silhouette at each size; human avatars should remain circular. 3. Open **Agents** and inspect an empty agent-team card. Its placeholder fill and outline should both be smooth squircles, with no straight inset cropped-square edges. 4. Open an agent profile from a message and confirm the larger profile avatar keeps the same proportions as the smaller message avatar. ## Testing - Desktop Biome check passed for the changed empty-team component and Agents E2E spec. - Desktop typecheck and differential file-size check passed. - Full desktop unit suite passed: 6,453 tests. - Full Agents integration spec passed: 37/37, including the empty-team outline regression. - Post-rebase pre-push gates passed at `304b159a2`: desktop checks, TypeScript typecheck, differential file-size gate, and all 6,453 desktop unit tests. - The shadcn-aligned `rounded-squircle` registration passed changed-file Biome, desktop TypeScript/build, and pre-push desktop checks at `27e0c12d3`; the full desktop unit suite passed 6,459/6,459. ## Screenshots Screenshots are temporarily omitted. The previous captures used the desktop E2E mock bridge and were not evidence from a live running app, so they were removed. --------- Signed-off-by: Taylor Ho <[email protected]> Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@buzz.block.builderlab.xyz> Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz>
1 parent d074576 commit ec11f8e

42 files changed

Lines changed: 1175 additions & 226 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎desktop/src-tauri/src/managed_agents/personas.rs‎

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

‎desktop/src-tauri/src/migration.rs‎

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ struct LegacyBuiltInAvatar<'a> {
525525
}
526526

527527
const LEGACY_BUILTIN_AVATARS: &[LegacyBuiltInAvatar<'static>] = &[
528+
// Original circular portraits replaced in #2215. Keep these entries so an
529+
// install that skips directly over that release still migrates cleanly.
528530
LegacyBuiltInAvatar {
529531
persona_id: "builtin:fizz",
530532
data_url_sha256: "2771b8c9c46aa3c8ac1c4d2acfa23fa9ba35b79c4b1694554e923081e3b8b4d0",
@@ -543,6 +545,25 @@ const LEGACY_BUILTIN_AVATARS: &[LegacyBuiltInAvatar<'static>] = &[
543545
sanitized_media_sha256: "9f798c61f8965b80beb808f505feb0a5b33726545188ea8212cc9ab22d05f0b6",
544546
persona_content_hash: "544a73f9106a3c8848b0f308b7a8b6f95077ac8deccdb9ed5552caa833d66c95",
545547
},
548+
// Circular 384px portraits replaced by the square 128px agent artwork.
549+
LegacyBuiltInAvatar {
550+
persona_id: "builtin:fizz",
551+
data_url_sha256: "6cdf8c338d27ef3c9dd68cf4839f3d62dec2298e2d4e07b851f26f8ba289b377",
552+
sanitized_media_sha256: "e6025a21c864750f4b3828c9035bafdbe68ec73bd247745c78309b82fedcbed5",
553+
persona_content_hash: "d30d9c7105be0765a2c5ebe89fdb67842201409e79a4b7937f46e2772411d925",
554+
},
555+
LegacyBuiltInAvatar {
556+
persona_id: "builtin:honey",
557+
data_url_sha256: "7b51bb3e353aed13b5d6a01d0ad9aa58d63b6bb347f2ed6ee891e7af6149febe",
558+
sanitized_media_sha256: "4a64f32d2375ccfe44c0880416bc72b809b055f0fb7d9dddeb8bb3dd6b80c297",
559+
persona_content_hash: "e0f88abf79d6826973cc99373ddd1f8350bed1df51064f7b1a0d7e3d7984c49e",
560+
},
561+
LegacyBuiltInAvatar {
562+
persona_id: "builtin:bumble",
563+
data_url_sha256: "9e1e841a76069202474393b786ada0628d90711703f8ba96c9ecee84a1c6a593",
564+
sanitized_media_sha256: "99d32de5791ec07db70c761db30fd145422e6c8200ba8d189363c3ce53273758",
565+
persona_content_hash: "783ee80629046d28f4f07095b1ceedab129661d40a2d5560806bc487a1a65a11",
566+
},
546567
];
547568

548569
struct LegacyAvatarMatch<'a> {
@@ -674,20 +695,21 @@ fn legacy_avatar_match<'a>(
674695
.get("persona_id")
675696
.and_then(serde_json::Value::as_str)
676697
.or_else(|| record.get("slug").and_then(serde_json::Value::as_str))?;
677-
let metadata = legacy_avatars
678-
.iter()
679-
.find(|legacy| legacy.persona_id == persona_id)?;
680698
let current_avatar = record
681699
.get("avatar_url")
682700
.and_then(serde_json::Value::as_str)?;
683-
let matches_data_url =
684-
hex::encode(Sha256::digest(current_avatar.as_bytes())) == metadata.data_url_sha256;
685-
let matches_uploaded_media = uploaded_media_sha256(current_avatar)
686-
.is_some_and(|sha256| sha256 == metadata.sanitized_media_sha256);
687-
(matches_data_url || matches_uploaded_media).then(|| LegacyAvatarMatch {
701+
let data_url_sha256 = hex::encode(Sha256::digest(current_avatar.as_bytes()));
702+
let uploaded_media_sha256 = uploaded_media_sha256(current_avatar);
703+
let metadata = legacy_avatars.iter().find(|legacy| {
704+
legacy.persona_id == persona_id
705+
&& (legacy.data_url_sha256 == data_url_sha256
706+
|| uploaded_media_sha256.as_deref() == Some(legacy.sanitized_media_sha256))
707+
})?;
708+
let was_uploaded = uploaded_media_sha256.as_deref() == Some(metadata.sanitized_media_sha256);
709+
Some(LegacyAvatarMatch {
688710
persona_id: persona_id.to_string(),
689711
metadata,
690-
was_uploaded: matches_uploaded_media,
712+
was_uploaded,
691713
})
692714
}
693715

‎desktop/src-tauri/src/migration_avatar_tests.rs‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,40 @@ fn current_builtin_agent_avatars_do_not_match_legacy_hashes() {
161161
}
162162
}
163163

164+
#[test]
165+
fn legacy_avatar_match_checks_every_known_generation_for_a_persona() {
166+
use sha2::{Digest as _, Sha256};
167+
168+
let prior_avatar = "data:image/png;base64,prior-fizz";
169+
let prior_hash = hex::encode(Sha256::digest(prior_avatar.as_bytes()));
170+
let legacy_avatars = [
171+
LegacyBuiltInAvatar {
172+
persona_id: "builtin:fizz",
173+
data_url_sha256: "older-fizz-hash",
174+
sanitized_media_sha256: "older-upload-hash",
175+
persona_content_hash: "older-persona-version",
176+
},
177+
LegacyBuiltInAvatar {
178+
persona_id: "builtin:fizz",
179+
data_url_sha256: prior_hash.as_str(),
180+
sanitized_media_sha256: "prior-upload-hash",
181+
persona_content_hash: "prior-persona-version",
182+
},
183+
];
184+
let record = serde_json::json!({
185+
"slug": "builtin:fizz",
186+
"avatar_url": prior_avatar,
187+
});
188+
189+
let matched = legacy_avatar_match(&record, &legacy_avatars).unwrap();
190+
191+
assert_eq!(
192+
matched.metadata.persona_content_hash,
193+
"prior-persona-version"
194+
);
195+
assert!(!matched.was_uploaded);
196+
}
197+
164198
#[test]
165199
fn refresh_builtin_agent_avatars_updates_versions_without_stored_definitions() {
166200
use sha2::{Digest as _, Sha256};

‎desktop/src/features/agents/ui/AgentCreationPreview.tsx‎

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { AvatarCustomColorPanel } from "@/features/profile/ui/AvatarCustomColorP
2828
import { useAvatarUpload } from "@/features/profile/useAvatarUpload";
2929
import { cn } from "@/shared/lib/cn";
3030
import { Button } from "@/shared/ui/button";
31+
import { ROUNDED_SQUIRCLE_PATH } from "@/shared/ui/AvatarClipPaths";
3132
import { useEmojiBurst } from "@/shared/ui/EmojiBurstProvider";
3233
import {
3334
Popover,
@@ -107,7 +108,6 @@ export function AgentCreationPreview({
107108
assetLabel.charAt(0).toUpperCase() + assetLabel.slice(1);
108109
const isRoundedSquare = shape === "rounded-square";
109110
const isCompact = variant === "compact";
110-
const emojiShape = isRoundedSquare ? "rounded-square" : "circle";
111111
const {
112112
inputRef: avatarUploadInputRef,
113113
isUploading,
@@ -197,11 +197,7 @@ export function AgentCreationPreview({
197197
if (!isCustomColorPickerOpen || !selectedEmoji) {
198198
return;
199199
}
200-
const nextAvatarUrl = emojiAvatarDataUrl(
201-
selectedEmoji,
202-
customColorDraft,
203-
emojiShape,
204-
);
200+
const nextAvatarUrl = emojiAvatarDataUrl(selectedEmoji, customColorDraft);
205201
if (avatarUrl === nextAvatarUrl) {
206202
return;
207203
}
@@ -212,7 +208,6 @@ export function AgentCreationPreview({
212208
isCustomColorPickerOpen,
213209
onSelectAvatar,
214210
selectedEmoji,
215-
emojiShape,
216211
]);
217212

218213
function applyAvatarUrl() {
@@ -227,7 +222,7 @@ export function AgentCreationPreview({
227222
}
228223

229224
function applyEmojiAvatar(emoji: string, color = selectedColor) {
230-
const nextAvatarUrl = emojiAvatarDataUrl(emoji, color, emojiShape);
225+
const nextAvatarUrl = emojiAvatarDataUrl(emoji, color);
231226
onSelectAvatar(nextAvatarUrl);
232227
onCommitAvatar?.(nextAvatarUrl);
233228
setSquishKey((key) => key + 1);
@@ -724,7 +719,7 @@ export function AgentCreationPreview({
724719
? isCompact
725720
? "rounded-2xl"
726721
: "rounded-[2rem]"
727-
: "rounded-[30%]",
722+
: "rounded-squircle",
728723
)}
729724
role="img"
730725
style={{ backgroundColor: emojiAvatarPreview.color }}
@@ -924,19 +919,19 @@ export function AgentCreationPreview({
924919
}
925920
className={isCompact ? "h-16 w-16" : "h-36 w-36"}
926921
clipTestId={`${testIdPrefix}-mask`}
927-
cornerRadius={(isCompact ? 64 : 144) * 0.3}
928922
cutout={
929923
isCompact
930924
? { cx: 58, cy: 58, r: 16.5 }
931925
: { cx: 123, cy: 123, r: 24 }
932926
}
933927
maskMode={isCompact ? "radial" : "clip-path"}
928+
shape="squircle"
934929
size={isCompact ? 64 : 144}
935930
>
936931
{emojiAvatarPreview ? (
937932
<div
938933
aria-label={`${label} ${assetLabel}`}
939-
className="relative flex h-full w-full shrink-0 items-center justify-center overflow-hidden rounded-[30%] shadow-xs transition-[background-color] duration-200 ease-out"
934+
className="relative flex h-full w-full shrink-0 items-center justify-center overflow-hidden rounded-squircle shadow-xs transition-[background-color] duration-200 ease-out"
940935
role="img"
941936
style={{
942937
backgroundColor: emojiAvatarPreview.color,
@@ -979,30 +974,54 @@ export function AgentCreationPreview({
979974
<button
980975
aria-label={`Add ${assetLabel}`}
981976
className={cn(
982-
"flex items-center justify-center border-2 border-dashed border-border bg-background text-primary shadow-xs transition-[background-color,border-color,color,box-shadow,scale] duration-150 ease-out hover:scale-[1.02] hover:border-primary/60 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-default disabled:opacity-60 disabled:hover:scale-100",
977+
"group/add-avatar relative flex items-center justify-center bg-transparent text-primary shadow-xs transition-[background-color,border-color,color,filter,scale] duration-150 ease-out hover:scale-[1.02] hover:brightness-110 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-default disabled:opacity-60 disabled:hover:scale-100",
983978
isCompact ? "h-16 w-16" : "h-36 w-36",
984979
isRoundedSquare
985-
? isCompact
986-
? "rounded-2xl"
987-
: "rounded-[2rem]"
988-
: "rounded-[30%]",
980+
? cn(
981+
"border-2 border-dashed border-border hover:border-primary/60 hover:bg-primary/5",
982+
isCompact ? "rounded-2xl" : "rounded-[2rem]",
983+
)
984+
: "border-0",
989985
isDragOverAvatar &&
990986
!isAvatarMenuOpen &&
991-
"border-primary/70 bg-primary/5 ring-2 ring-primary/15",
987+
(isRoundedSquare
988+
? "border-primary/70 bg-primary/5 ring-2 ring-primary/15"
989+
: "ring-2 ring-primary/30"),
992990
)}
993991
disabled={disabled || isUploading}
994992
title={`Add ${assetLabel}`}
995993
type="button"
996994
>
995+
{isRoundedSquare ? null : (
996+
<svg
997+
aria-hidden="true"
998+
className="pointer-events-none absolute inset-0 z-0 h-full w-full rounded-squircle bg-background text-border transition-colors duration-150 ease-out group-hover/add-avatar:bg-primary/5 group-hover/add-avatar:text-primary/60"
999+
data-testid={`${testIdPrefix}-empty-outline`}
1000+
preserveAspectRatio="none"
1001+
viewBox="0 0 1 1"
1002+
>
1003+
<path
1004+
d={ROUNDED_SQUIRCLE_PATH}
1005+
fill="none"
1006+
pathLength="1"
1007+
stroke="currentColor"
1008+
strokeDasharray="0.035 0.035"
1009+
strokeWidth="0.018"
1010+
/>
1011+
</svg>
1012+
)}
9971013
{isUploading ? (
9981014
<Spinner
9991015
aria-label={`Uploading ${assetLabel}`}
1000-
className="h-4 w-4 border-2"
1016+
className="relative z-10 h-4 w-4 border-2"
10011017
/>
10021018
) : (
10031019
<Plus
10041020
aria-hidden="true"
1005-
className={isCompact ? "h-6 w-6" : "h-14 w-14"}
1021+
className={cn(
1022+
"relative z-10",
1023+
isCompact ? "h-6 w-6" : "h-14 w-14",
1024+
)}
10061025
/>
10071026
)}
10081027
</button>

‎desktop/src/features/agents/ui/AgentRuntimeAvatarControl.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,12 @@ export function AgentRuntimeAvatarControl({
250250
: "bg-primary",
251251
)}
252252
className="h-24 w-24"
253-
cornerRadius={AGENT_AVATAR_SIZE * 0.3}
253+
clipTestId="agent-runtime-avatar-mask"
254+
shape="squircle"
254255
curve={showStatusDot ? STATUS_DOT_MASK_CURVE : ACTION_MASK_CURVE}
255256
cutout={badge.cutout}
256257
cutoutWidth={actionCutoutWidth}
258+
maskMode={showStatusDot ? "clip-path" : "none"}
257259
maskTransition={transition}
258260
size={AGENT_AVATAR_SIZE}
259261
>

‎desktop/src/features/agents/ui/IdentityInitialsAvatar.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function IdentityInitialsAvatar({
3939
return (
4040
<span
4141
className={cn(
42-
"flex h-full w-full items-center justify-center rounded-[30%] border-[3px] border-background font-semibold shadow-sm",
42+
"flex h-full w-full items-center justify-center rounded-squircle border-[3px] border-background font-semibold shadow-sm",
4343
colorClassName,
4444
textSizeClassName,
4545
className,

‎desktop/src/features/agents/ui/TeamIdentityCard.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ function TeamAvatarRow({
120120
if (visiblePersonas.length === 0 && overflowCount === 0) {
121121
return (
122122
<div className="absolute inset-x-4 top-0 bottom-12 flex items-center justify-center">
123-
<div className="flex h-24 w-24 items-center justify-center rounded-[30%] border border-border/65 bg-background/80 text-muted-foreground shadow-xs">
124-
<Users className="h-9 w-9" />
123+
<div className="relative h-24 w-24 before:rounded-squircle before:absolute before:-inset-px before:bg-border/65 before:content-['']">
124+
<div
125+
className="relative z-10 flex h-full w-full items-center justify-center rounded-squircle bg-background/80 text-muted-foreground shadow-xs"
126+
data-team-empty-avatar="avatar"
127+
>
128+
<Users className="h-9 w-9" />
129+
</div>
125130
</div>
126131
</div>
127132
);
@@ -142,7 +147,7 @@ function TeamAvatarRow({
142147
className={visiblePersonas.length > 0 ? "-ml-5" : ""}
143148
style={{ zIndex: stackItemCount }}
144149
>
145-
<span className="flex h-14 w-14 items-center justify-center rounded-[30%] bg-card text-sm font-semibold text-muted-foreground ring-2 ring-card">
150+
<span className="flex h-14 w-14 items-center justify-center rounded-squircle bg-card text-sm font-semibold text-muted-foreground ring-2 ring-card">
146151
+{overflowCount}
147152
</span>
148153
</div>
@@ -163,7 +168,7 @@ function TeamAvatarItem({
163168

164169
return (
165170
<div
166-
className={`relative h-14 w-14 before:absolute before:-inset-0.5 before:rounded-[calc(30%+2px)] before:bg-card before:content-[''] ${index > 0 ? "-ml-5" : ""}`}
171+
className={`relative h-14 w-14 before:rounded-squircle before:absolute before:-inset-0.5 before:bg-card before:content-[''] ${index > 0 ? "-ml-5" : ""}`}
167172
data-team-member-avatar="avatar"
168173
style={{
169174
zIndex: index + 1,

‎desktop/src/features/agents/ui/managedAgentAvatar.test.mjs‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@ test("resolveManagedAgentAvatarUrl uploads data image URIs", async () => {
2121
assert.equal(uploaded, "https://relay.example/avatar.png");
2222
});
2323

24-
test("resolveManagedAgentAvatarUrl passes emoji svg data URLs through", async () => {
25-
const emojiUrl =
26-
"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3C%2Fsvg%3E";
27-
const uploaded = await resolveManagedAgentAvatarUrl(emojiUrl, async () => {
24+
test("resolveManagedAgentAvatarUrl squares legacy emoji svg data URLs", async () => {
25+
const legacySvg =
26+
'<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><rect width="512" height="512" rx="256" fill="#ffcc00"/><text x="50%" y="56%" dominant-baseline="middle" text-anchor="middle" font-size="258">🐝</text></svg>';
27+
const emojiUrl = `data:image/svg+xml,${encodeURIComponent(legacySvg)}`;
28+
const resolved = await resolveManagedAgentAvatarUrl(emojiUrl, async () => {
2829
throw new Error("should not upload inline emoji svg data URLs");
2930
});
3031

31-
assert.equal(uploaded, emojiUrl);
32+
assert.ok(resolved);
33+
const normalizedSvg = decodeURIComponent(resolved.split(",", 2)[1]);
34+
assert.match(
35+
normalizedSvg,
36+
/<rect width="512" height="512" fill="#ffcc00"\/>/u,
37+
);
38+
assert.doesNotMatch(normalizedSvg, /\brx=/u);
39+
assert.match(normalizedSvg, />🐝<\/text>/u);
3240
});
3341

3442
test("resolveManagedAgentAvatarUrl passes non-data URLs through", async () => {

‎desktop/src/features/agents/ui/managedAgentAvatar.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { squareEmojiAvatarDataUrl } from "@/features/profile/ui/ProfileAvatarEditor.utils";
2+
13
type BlobDescriptor = {
24
url: string;
35
sha256: string;
@@ -23,10 +25,11 @@ export async function resolveManagedAgentAvatarUrl(
2325

2426
// Emoji avatars are stored as inline, percent-encoded SVG data URLs
2527
// (`data:image/svg+xml,%3C...`) — the same self-contained form profile
26-
// persists. They are not base64 and must not be run through `atob`/upload;
27-
// pass them through unchanged so the emoji survives agent creation.
28+
// persists. They are not base64 and must not be run through `atob`/upload.
29+
// Normalize legacy rounded source artwork to a square while creating or
30+
// editing an agent so the consuming squircle owns the complete silhouette.
2831
if (!isBase64DataUri(resolvedAvatarUrl)) {
29-
return resolvedAvatarUrl;
32+
return squareEmojiAvatarDataUrl(resolvedAvatarUrl);
3033
}
3134

3235
try {

‎desktop/src/features/agents/ui/snapshotAvatarPng.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test("resolveSnapshotAvatarPng: emoji SVG is rasterized onto a canvas", async ()
3838
};
3939

4040
const emojiSvg =
41-
'<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><rect width="512" height="512" rx="256" fill="#ffcc00"/><text>✨</text></svg>';
41+
'<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><rect width="512" height="512" rx="256" fill="#ffcc00"/><text x="50%" y="56%" dominant-baseline="middle" text-anchor="middle" font-size="258">✨</text></svg>';
4242
const result = await resolveSnapshotAvatarPng(
4343
`data:image/svg+xml,${encodeURIComponent(emojiSvg)}`,
4444
{

0 commit comments

Comments
 (0)