Skip to content

fix(mentions): fall back to user.image when principal avatar columns are empty#179

Merged
mortondev merged 1 commit into
mainfrom
fix/mention-card-user-image-fallback
May 16, 2026
Merged

fix(mentions): fall back to user.image when principal avatar columns are empty#179
mortondev merged 1 commit into
mainfrom
fix/mention-card-user-image-fallback

Conversation

@mortondev
Copy link
Copy Markdown
Member

@mortondev mortondev commented May 16, 2026

Summary

  • Mention hover-card and picker now LEFT JOIN user and resolve avatars in the order principal.avatarKey → principal.avatarUrl → user.imageKey → user.image, so principals whose own avatar columns drifted from the source-of-truth user record still render the right photo.
  • Same fallback applied to both /api/v1/users/:id/card and /api/v1/mentions/suggest so the picker thumbnail and the hover card always agree.

Why

Spotted on prod: hovering an @James Morton chip showed JM initials even though the same user's comment header rendered his avatar fine. The two reads hit different principal records (the deployment had two James Morton rows; the picker selected the one with empty avatar_* columns even though its linked user row had imageKey populated). This is a read-side safety net — the deeper question of how the second principal ended up without a synced avatar is worth a follow-up but doesn't block the user-visible fix.

Test plan

  • bun run test --run apps/web/src/routes/api/v1/users/__tests__/principal-card.test.ts apps/web/src/routes/api/v1/mentions/__tests__/suggest.test.ts — 25/25 pass, including new cases for both fallback steps
  • tsc --noEmit clean
  • eslint clean (only pre-existing warnings)
  • Manual: hover an @-mention on a post whose target principal has avatar_* null but user.imageKey populated, confirm the photo renders

…are empty

The hover card and picker rendered initials for principals whose own
avatar columns were null even when the linked user record had an image.
Both endpoints now LEFT JOIN user and resolve in the order:
principal.avatarKey -> principal.avatarUrl -> user.imageKey -> user.image.

Read-side safety net for principal rows that drifted from the source-of-
truth user record (e.g. created before syncPrincipalProfile was wired
into every upload path).
@mortondev mortondev merged commit fbaa0cf into main May 16, 2026
4 checks passed
@mortondev mortondev deleted the fix/mention-card-user-image-fallback branch May 16, 2026 16:04
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