The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): roster avatar sync no longer dials a backend per registered profile at launch
Tekniume4080b381b5d
diff --git a/apps/desktop/src/plugins/hermes-bots/profile-ops.test.ts b/apps/desktop/src/plugins/hermes-bots/profile-ops.test.tsindex 6b794421fd1..067e273423b 100644--- a/apps/desktop/src/plugins/hermes-bots/profile-ops.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/profile-ops.test.ts@@ -153,3 +153,60 @@ describe('duplicating a bot', () => {expect(await duplicateBot(bot, [bot, elsewhere])).toBe('ops-2')})})++/**+ * Roster avatar sync must stay on the ACTIVE gateway (#102978). Every row of+ * a local-primary roster is source-scoped, so routing `profiles.get_asset` /+ * `set_asset` per row through the (connectionId, profile) secondary dialed a+ * pooled backend for every registered profile on the first paint after+ * launch — 60 profiles against 3 slots, a queue that never drained. The+ * active gateway's `profiles.list` already read those directories; the asset+ * RPCs are the same reads, addressed by the row's backend name.+ */+describe('roster avatar sync (#102978)', () => {+ it('fetches has_avatar art through the active gateway, never a per-row secondary dial', async () => {+ const { pullServerAvatars } = await import('./profile-ops')+ hostMock.request.mockResolvedValue({ found: false })++ const roster = ['alpha', 'beta', 'gamma'].map(+ name =>+ ({+ connectionId: 'local',+ connectionKind: 'local',+ has_avatar: true,+ name,+ route: { connectionId: 'local', mode: 'local', profile: name, targetProfile: name },+ sourceScoped: true+ }) as RosterRow+ )++ pullServerAvatars(roster)+ await Promise.resolve()++ expect(hostMock.requestProfile).not.toHaveBeenCalled()+ expect(hostMock.request.mock.calls.map(([method, params]) => [method, params.name])).toEqual([+ ['profiles.get_asset', 'alpha'],+ ['profiles.get_asset', 'beta'],+ ['profiles.get_asset', 'gamma']+ ])+ })++ it('addresses an aliased row by its backend profile name', async () => {+ const { pullServerAvatars } = await import('./profile-ops')+ hostMock.request.mockResolvedValue({ found: false })++ pullServerAvatars([+ {+ connectionId: 'local',+ has_avatar: true,+ name: 'mara',+ route: { connectionId: 'local', mode: 'local', profile: 'mara', targetProfile: 'default' },+ sourceScoped: true+ } as RosterRow+ ])+ await Promise.resolve()++ expect(hostMock.requestProfile).not.toHaveBeenCalled()+ expect(hostMock.request).toHaveBeenCalledWith('profiles.get_asset', { asset: 'avatar', name: 'default' })+ })+})diff --git a/apps/desktop/src/plugins/hermes-bots/profile-ops.ts b/apps/desktop/src/plugins/hermes-bots/profile-ops.tsindex 033548f6b79..518977c8ca9 100644--- a/apps/desktop/src/plugins/hermes-bots/profile-ops.ts+++ b/apps/desktop/src/plugins/hermes-bots/profile-ops.ts@@ -40,6 +40,21 @@ import type { RosterRow } from './types'const avatarFetchInflight = new Set<string>()const avatarPushInflight = new Set<string>()+/** Asset RPC for a row of the ACTIVE source's roster (#102978). These rows+ * came back from the active gateway's own `profiles.list`, which reads every+ * local profile's directory — `profiles.get_asset` / `set_asset` are the+ * same directory reads, so the active gateway answers them with the row's+ * backend name. Routing them through requestForBot instead dials the row's+ * own (connectionId, profile) secondary, and on a local-primary desktop+ * every roster row is source-scoped: the first roster paint after launch+ * queued one pooled backend spawn per registered profile (60 profiles, 3+ * slots → a queue that never drained). */+function requestAssetOnActiveSource<T>(bot: RosterRow, method: string, params: Record<string, unknown>) {+ const route = botConnectionRoute(bot)++ return host.request<T>(method, { ...params, name: route ? route.targetProfile || route.profile : bot.name })+}+/** Backfill: local meta has art the server lacks -> profiles.set_asset.* Server-side avatars power the inter-agent notice pfp (core #85855) and* cross-machine roster art, so local-only images are a bug, not a state. */@@ -56,17 +71,11 @@ function pushLocalAvatars(roster: RosterRow[]) {if (image && typeof image === 'string' && image.startsWith('data:')) {avatarPushInflight.add(key)- const request = bot.sourceScoped- ? requestForBot(bot, 'profiles.set_asset', {- name: bot.name,- asset: 'avatar',- data: image- })- : host.request('profiles.set_asset', {- name: bot.name,- asset: 'avatar',- data: image- })+ const request = requestAssetOnActiveSource(bot, 'profiles.set_asset', {+ name: bot.name,+ asset: 'avatar',+ data: image+ })Promise.resolve(request).then(() =>@@ -92,18 +101,11 @@ function pushLocalAvatars(roster: RosterRow[]) {rasterizeSvgToPng(svg, 160).then(png =>png- ? (bot.sourceScoped- ? requestForBot(bot, 'profiles.set_asset', {- name: bot.name,- asset: 'avatar',- data: png- })- : host.request('profiles.set_asset', {- name: bot.name,- asset: 'avatar',- data: png- })- ).then(() =>+ ? requestAssetOnActiveSource(bot, 'profiles.set_asset', {+ name: bot.name,+ asset: 'avatar',+ data: png+ }).then(() =>queryClient.invalidateQueries({queryKey: ['hermes-bots', 'roster']})@@ -175,17 +177,12 @@ export function pullServerAvatars(roster: RosterRow[]) {avatarFetchInflight.add(key)- const assetRequest = bot.sourceScoped- ? requestForBot(bot, 'profiles.get_asset', {- name: bot.name,- asset: 'avatar'- })- : host.request('profiles.get_asset', {- name: bot.name,- asset: 'avatar'- })-- Promise.resolve(assetRequest as Promise<ProfilesGetAssetResult>)+ const assetRequest = requestAssetOnActiveSource<ProfilesGetAssetResult>(bot, 'profiles.get_asset', {+ name: bot.name,+ asset: 'avatar'+ })++ assetRequest.then(res => {if (res?.found && res.data) {const current = $botMeta.get()