Skip to content

Fix repo avatars falling back to initials when icon can't load - #919

Merged
natllian merged 1 commit into
mainfrom
nathan/retail-api-icon-fallback
Jul 3, 2026
Merged

natllian merged 1 commit into
mainfrom
nathan/retail-api-icon-fallback

Conversation

@natllian

@natllian natllian commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes repo avatars rendering blank instead of falling back to the name initials when a repository's icon file can't be displayed (e.g. an empty favicon.ico placeholder or an undecodable .ico file).

What changed

Backend (helpers.rs):

  • Added check to treat empty icon files as "no icon" to avoid creating invalid data: URIs that render as blank
  • Added test coverage for the empty icon file scenario

Frontend (avatar.tsx):

  • Replaced naive onError/onLoad handlers with proper onLoadingStatusChange tracking from Radix Avatar
  • Radix's Avatar.Image never mounts the underlying <img> on error, so native onError never fires
  • Now explicitly track the loading status and fall back to initials only when the status is "error"
  • Added detailed comments explaining the fix

Tests (avatar.test.tsx):

  • Added test that stubs window.Image to simulate broken icons and verifies the fallback renders
  • Existing tests still pass and verify the fallback shows immediately when switching from an icon repo

Misc (row-item.tsx, workspace-hover-card.tsx):

  • Fixed nullish coalescing operators (??) to logical OR (||) for consistency with repoInitials

Test plan

  • ✅ Frontend tests pass (new test for fallback behavior)
  • ✅ Rust tests pass (new test for empty icon files)
  • ✅ Manual testing: navigate to a workspace with a broken or empty icon file — the avatar should display initials instead of rendering blank
  • ✅ Pre-commit hooks passed (biome, cargo clippy)

- Handle empty/undecodable icon files (e.g. 0-byte favicon.ico) in backend
- Track Radix Avatar's `onLoadingStatusChange` instead of img events
- Fix avatar showing blank instead of initials when icon fails
- Add test coverage for fallback behavior and empty icon files
@vercel

vercel Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
helmor-marketing Ignored Ignored Jul 3, 2026 6:13am

Request Review

@natllian
natllian merged commit 205da66 into main Jul 3, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant