block / block/buzz

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

Open
#3,662 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

## 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` 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 `` (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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.