fix(desktop): scope agent cards and starts to community - #6547
fix(desktop): scope agent cards and starts to community#6547unclejobs-ai wants to merge 1 commit into
Conversation
Signed-off-by: EungjePark <patreot0312@gmail.com>
Chessing234
left a comment
There was a problem hiding this comment.
ranking the active community's identity above runtime status is the right call — a running sibling from another community is exactly the wrong thing to show on a profile.
the tiebreak is raw string equality on the relay URL though:
Number(right.relayUrl === preferredRelayUrl) - Number(left.relayUrl === preferredRelayUrl)
that only holds if both sides are already canonical. wss://current.example vs wss://current.example/, or a case difference in the host, compares false and the comparator silently falls through to status ordering — which is the pre-fix behaviour, so the bug comes back with no signal that the preference was ignored. this codebase has had that shape before with hex ids and repo owners.
is relayUrl guaranteed canonical from both sources here — the persisted agent record and whatever useCommunities hands you? if they come from different writers at different times, normalising both before comparing (or comparing parsed origins) would make the tiebreak actually hold.
the undefined case is fine, for what it's worth: with no preferredRelayUrl both terms are false and it falls through cleanly.
Summary
relayUrlmatches the active community before considering runtime status.A persona can have one identity-backed instance per community. The shared card selector previously preferred a running sibling even when it belonged to another relay. Clicking Start from community B could therefore target community A's pubkey, while the backend spawned it against the active workspace relay. The result was a wrong identity on the current relay or an agent with no resolvable channel subscriptions.
This change does not alter persisted records or relay routing. It selects the instance already belonging to the active relay and binds start side effects to the relay/signer scope captured by the UI.
Related issue
Testing
tsc --noEmitgit diff --checkManual macOS verification with two communities and duplicate persona instances:
No visual layout changes.