Skip to content

[Bug] Agent avatar upload skips the crop/downscale that community icons already get #3662

Description

@w-y-a-t-t

Summary

When creating (or editing) an agent in Buzz Desktop, uploading a custom avatar image does not resize, downscale, or center-crop it. The raw uploaded file is sent as-is, so a large or non-square photo doesn't get shaped into a proper small square avatar the way it should.

Root cause (traced in code)

useAvatarUpload (desktop/src/features/profile/useAvatarUpload.ts:18,64-65) accepts an optional processImage(file): Promise<string> hook. When provided, it runs the file through that hook before upload; when omitted, it uploads the raw bytes untouched via uploadMediaBytes.

  • Community icons already solve this. CommunityIconSettingsCard.tsx:114 passes processImage={downscaleIconToDataUrl} (desktop/src/features/communities/lib/downscaleIcon.ts:11-37), which center-crops to a square and downscales to 128px before encoding to WebP/PNG.
  • Agent avatars do not. AgentDefinitionDialog.tsx:770 and AgentInstanceEditDialog.tsx:882 both render <AgentCreationPreview ... /> (which threads processImage down to useAvatarUpload) but neither passes a processImage prop — so agent avatar uploads skip cropping/downscaling entirely.

Expected

Agent avatar upload should reuse the same center-crop + downscale treatment community icons already get, so users can drop in any photo and have it become a properly framed square avatar without needing to pre-edit the image themselves.

Suggested fix

Generalize downscaleIconToDataUrl (it's not community-specific — just takes a File and returns a data URL) into a shared location, and pass it as processImage in AgentDefinitionDialog.tsx and AgentInstanceEditDialog.tsx, same pattern as CommunityIconSettingsCard.tsx.

Duplicate search

Searched open/closed issues for avatar resize, avatar crop, agent avatar, agent icon, resize image, downscale, square image, etc. — no existing issue describes this. Closest are #2366 (icon lost across communities — different bug) and #3089 (proposal for AI-generated avatars — unrelated to manual upload sizing).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions