Skip to content

fix(desktop): sync agent relay profile when persona avatar changes#1512

Open
klopez4212 wants to merge 3 commits into
mainfrom
fix/persona-avatar-sync-to-agent-profile
Open

fix(desktop): sync agent relay profile when persona avatar changes#1512
klopez4212 wants to merge 3 commits into
mainfrom
fix/persona-avatar-sync-to-agent-profile

Conversation

@klopez4212

Copy link
Copy Markdown
Contributor

Problem

When editing a persona's avatar in the "Edit agent" dialog, the avatar change was saved to the persona record but the linked agent's relay profile (kind:0 event) was never re-synced. The agent card in the UI continued showing the old avatar because:

  1. Backend: update_persona saved the persona locally but never triggered sync_managed_agent_profile for linked agents, and never updated the agent record's avatar_url field.
  2. Frontend: The agent card prioritized the relay profile avatar (profileQuery.data?.avatarUrl) over the persona avatar (persona.avatarUrl), so the stale relay data won.

Fix

Backend (desktop/src-tauri/src/commands/personas/mod.rs)

  • After saving the persona, if the avatar changed, update all linked agent records' avatar_url field
  • Collect relay profile sync params and fire-and-forget re-publish their kind:0 profiles
  • Uses the same pattern as update_managed_agent (sync params collected under lock, async publish outside)

Frontend (desktop/src/features/agents/ui/UnifiedAgentsSection.tsx)

  • Flip avatar priority: firstAvatarUrl(persona.avatarUrl, profileQuery.data?.avatarUrl)
  • The persona avatar (local source of truth) now takes precedence over the relay profile avatar (which may be stale)

Frontend (desktop/src/features/agents/hooks.ts)

  • Invalidate all user-profile queries on persona update so the relay profile cache catches up after the backend sync

Testing

  • cargo check passes for the Tauri crate
  • Biome lint/format passes
  • All pre-push hooks pass (rust tests, desktop tests, mobile tests, desktop-tauri tests)

When editing a persona's avatar, the linked agents' relay profiles were
never re-synced — the kind:0 event still showed the old picture URL.

Backend: After saving the persona, if the avatar changed, update linked
agent records' avatar_url and fire-and-forget re-publish their kind:0
profiles to the relay.

Frontend: Flip avatar priority in the agent card to prefer the persona
avatar (local source of truth) over the relay profile avatar (which may
be stale after an edit). Also invalidate user-profile queries on persona
update so the relay cache catches up.

Fixes: avatar not updating when changing agent profile image

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7089313851

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread desktop/src-tauri/src/commands/personas/mod.rs Outdated
The fire-and-forget spawn allowed the command to return before the relay
profile was updated, causing the frontend cache invalidation to refetch
stale data. Await the sync inline (matching update_managed_agent's pattern)
so the mutation settlement sees the fresh relay profile.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91b3fdbb66

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread desktop/src/features/agents/hooks.ts Outdated
The useUpdatePersonaMutation already invalidated user-profile queries after
a persona avatar change, but channel timelines and member lists use
useUsersBatchQuery with a 60s staleTime. Without invalidating users-batch,
those surfaces show the stale avatar until the batch query naturally
refetches.

Addresses the outstanding Codex review comment on PR #1512.

Signed-off-by: Kenny Lopez <kenny@block.xyz>
@klopez4212 klopez4212 requested a review from wesbillman July 5, 2026 06:48
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