fix(desktop): sync agent relay profile when persona avatar changes#1512
fix(desktop): sync agent relay profile when persona avatar changes#1512klopez4212 wants to merge 3 commits into
Conversation
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
There was a problem hiding this comment.
💡 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".
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.
There was a problem hiding this comment.
💡 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".
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>
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:
update_personasaved the persona locally but never triggeredsync_managed_agent_profilefor linked agents, and never updated the agent record'savatar_urlfield.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)avatar_urlfieldupdate_managed_agent(sync params collected under lock, async publish outside)Frontend (
desktop/src/features/agents/ui/UnifiedAgentsSection.tsx)firstAvatarUrl(persona.avatarUrl, profileQuery.data?.avatarUrl)Frontend (
desktop/src/features/agents/hooks.ts)user-profilequeries on persona update so the relay profile cache catches up after the backend syncTesting
cargo checkpasses for the Tauri crate