fix(desktop): publish new agent profiles to active relay (#1546)

Signed-off-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
Tyler
2026-07-06 14:36:53 -04:00
committed by GitHub
parent ccfdf45bc5
commit 346efe08b3
2 changed files with 17 additions and 6 deletions

View File

@@ -886,9 +886,13 @@ pub async fn create_managed_agent(
// ── Phase 4: sync agent profile on relay (async, outside lock) ───────────
// Use the avatar persisted on the record so the published profile and any
// later reconciliation agree on the same value.
let profile_relay_url = crate::relay::effective_agent_relay_url(
&resolved_relay_url,
&relay_ws_url_with_override(&state),
);
let profile_sync_error = (sync_managed_agent_profile(
&state,
&resolved_relay_url,
&profile_relay_url,
&agent_keys,
&name,
resolved_avatar_url.as_deref(),
@@ -1212,11 +1216,13 @@ pub(crate) async fn reconcile_agent_profile(
}
};
if expected_avatar.is_empty() {
return Ok(());
}
let expected_avatar = if expected_avatar.is_empty() {
None
} else {
Some(expected_avatar)
};
if !profile_needs_sync(existing.as_ref(), &data.name, Some(&expected_avatar)) {
if !profile_needs_sync(existing.as_ref(), &data.name, expected_avatar.as_deref()) {
return Ok(());
}
@@ -1228,7 +1234,7 @@ pub(crate) async fn reconcile_agent_profile(
&relay_url,
&agent_keys,
&data.name,
Some(&expected_avatar),
expected_avatar.as_deref(),
data.auth_tag.as_deref(),
)
.await

View File

@@ -82,6 +82,11 @@ fn profile_needs_sync_when_missing() {
assert!(profile_needs_sync(None, "Duncan", Some("https://x/a.png")));
}
#[test]
fn profile_needs_sync_when_missing_even_without_expected_avatar() {
assert!(profile_needs_sync(None, "Duncan", None));
}
#[test]
fn profile_needs_sync_when_name_diverges() {
let existing = profile(Some("Stilgar"), Some("https://x/a.png"));