fix(mentions): fall back to user.image when principal avatar columns are empty#179
Merged
Merged
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
userand resolve avatars in the orderprincipal.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./api/v1/users/:id/cardand/api/v1/mentions/suggestso the picker thumbnail and the hover card always agree.Why
Spotted on prod: hovering an
@James Mortonchip showedJMinitials even though the same user's comment header rendered his avatar fine. The two reads hit different principal records (the deployment had twoJames Mortonrows; the picker selected the one with emptyavatar_*columns even though its linked user row hadimageKeypopulated). 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 stepstsc --noEmitcleaneslintclean (only pre-existing warnings)@-mention on a post whose target principal hasavatar_*null butuser.imageKeypopulated, confirm the photo renders