Skip to content

fix: recover profile and avatar loading#13

Merged
Just-Insane merged 0 commit intointegrationfrom
fix/profile-avatar-loading
Mar 28, 2026
Merged

fix: recover profile and avatar loading#13
Just-Insane merged 0 commit intointegrationfrom
fix/profile-avatar-loading

Conversation

@Just-Insane
Copy link
Copy Markdown
Owner

Same fix as SableClient#566, but targeting the integration branch.

Description

Fixes profile and avatar loading regressions introduced around MSC4440 bio compatibility work:

  • defensive parsing for gay.fomx.biography
  • retry when profile cache is stuck in _fetched-only state
  • reset avatar error fallback state when image src changes

This branch is intended for integration testing/merge flow that targets integration.

Copilot AI review requested due to automatic review settings March 28, 2026 05:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes regressions in user profile/bio parsing and avatar rendering by making MSC4440 bio extraction defensive, recovering from certain broken profile-cache states, and resetting avatar error state when the image source changes.

Changes:

  • Make gay.fomx.biography parsing resilient to missing/malformed MSC4440 data.
  • Add a retry path when the global profile cache contains only an _fetched marker.
  • Reset avatar/room avatar error fallback state whenever src changes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/app/hooks/useUserProfile.ts Defensive MSC4440 bio parsing + retry logic for _fetched-only cache state
src/app/components/user-avatar/UserAvatar.tsx Reset error state when avatar src changes to recover after transient failures
src/app/components/room-avatar/RoomAvatar.tsx Same error reset behavior for room avatars when src changes
.changeset/fix-profile-avatar-loading.md Adds a patch changeset entry describing the fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +104 to +108
const hasOnlyFetchedMarker =
cached?._fetched === true && Object.keys(cached).every((key) => key === '_fetched');

const needsFetch =
!!userId && userId !== 'undefined' && (!cached?._fetched || hasOnlyFetchedMarker);
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasOnlyFetchedMarker makes needsFetch stay true when the cache contains only { _fetched: true }. Since the .catch() handler also writes exactly that shape when the first fetch fails (when prev[userId] is undefined), this can cause a tight refetch loop (re-render → fetch → catch → atom update → re-render …), spamming mx.getProfileInfo while offline or on persistent errors. Consider adding a separate cached error/timestamp/attempt marker (so this state doesn’t immediately qualify for retry), or throttling/backing off retries (e.g., only retry once per mount / after a delay / on focus) so persistent failures don’t DOS the homeserver/client.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

Status Preview URL Commit Alias Updated (UTC)
✅ Deployment successful! https://pr-13-sable.justin-tech.workers.dev e7fd523 pr-13 Sat, 28 Mar 2026 05:27:32 GMT

@Just-Insane Just-Insane force-pushed the fix/profile-avatar-loading branch from bf89a08 to 724b45f Compare March 28, 2026 15:09
@Just-Insane Just-Insane merged commit d9e2eff into integration Mar 28, 2026
@Just-Insane Just-Insane deleted the fix/profile-avatar-loading branch March 28, 2026 16:32
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.

2 participants