The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): qualify group (you) by connection, not bare profile name
KoNit-K3b45681c25a8
diff --git a/apps/desktop/src/plugins/hermes-bots/cross-connection-bots.test.ts b/apps/desktop/src/plugins/hermes-bots/cross-connection-bots.test.tsindex b241c223a4d..e767812a612 100644--- a/apps/desktop/src/plugins/hermes-bots/cross-connection-bots.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/cross-connection-bots.test.ts@@ -175,4 +175,48 @@ describe('a group room seats members from several machines', () => {})).toMatch(/@dixie \[on Mac Mini\]/)})++ it('does not self-attribute a same-named default on another connection (#106851)', () => {+ // Cross-connection same profile name must not self-attribute in model prompt lines.+ const line = formatGroupChatLine(+ { at: 1, from: { kind: 'member', name: 'default', source: 'Connection B' }, text: 'Remote reply' },+ { name: 'default' }+ )++ expect(line).not.toContain('(you)')+ expect(line).toMatch(/Remote reply/)++ // CONTROL: same-connection self still gets (you)+ expect(+ formatGroupChatLine(+ { at: 2, from: { kind: 'member', name: 'default' }, text: 'Mine' },+ { name: 'default' }+ )+ ).toContain('(you)')++ // CONTROL: remote viewer seeing own remote line still gets (you)+ expect(+ formatGroupChatLine(+ { at: 3, from: { kind: 'member', name: 'default', source: 'Connection B' }, text: 'Mine remote' },+ { name: 'default', remoteSource: true, connectionLabel: 'Connection B', connectionId: 'conn-b' }+ )+ ).toContain('(you)')++ // String viewer API is local / unsourced — a sourced peer of the same+ // name must not pick up (you) just because the names match.+ expect(+ formatGroupChatLine(+ { at: 4, from: { kind: 'member', name: 'default', source: 'Connection B' }, text: 'Still remote' },+ 'default'+ )+ ).not.toContain('(you)')++ // User lines stay on the (user) path even when the display name collides.+ expect(+ formatGroupChatLine({ at: 5, from: { kind: 'user', name: 'default' }, text: 'human' }, { name: 'default' })+ ).toContain('(user)')+ expect(+ formatGroupChatLine({ at: 5, from: { kind: 'user', name: 'default' }, text: 'human' }, { name: 'default' })+ ).not.toContain('(you)')+ })})diff --git a/apps/desktop/src/plugins/hermes-bots/group-round-members.ts b/apps/desktop/src/plugins/hermes-bots/group-round-members.tsindex ad62d8ec05a..51037b227fc 100644--- a/apps/desktop/src/plugins/hermes-bots/group-round-members.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-round-members.ts@@ -93,7 +93,7 @@ function prepareGroupRoundMember(context: GroupRoundMemberContext, member: GroupgroupName: context.group,members,viewer: member,- deltaLines: delta.slice(-GROUP_CHAT_HISTORY_LIMIT).map((e: GroupMessage) => formatGroupChatLine(e, member.name))+ deltaLines: delta.slice(-GROUP_CHAT_HISTORY_LIMIT).map((e: GroupMessage) => formatGroupChatLine(e, member))})// Images riding this delta (user attachments — member entries don't@@ -279,7 +279,7 @@ async function runGroupContinuationMember(// The continuation prompt centers on what the member missed:// everything since its watermark, which includes the reply// that cites it.- deltaLines: delta.slice(-GROUP_CHAT_HISTORY_LIMIT).map((e: GroupMessage) => formatGroupChatLine(e, member.name))+ deltaLines: delta.slice(-GROUP_CHAT_HISTORY_LIMIT).map((e: GroupMessage) => formatGroupChatLine(e, member))})let continuationReply: null | string = nulldiff --git a/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts b/apps/desktop/src/plugins/hermes-bots/group-round-prompt.tsindex 1ee31a6fa18..eaa03c16657 100644--- a/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts@@ -1,11 +1,17 @@import { botHandle } from './data'import { groupSpeakerLabel } from './group-chat'import { groupMemberKey } from './group-membership'-import type { GroupMember, GroupMessage } from './types'+import type { GroupMember, GroupMessage, GroupMessageAuthor } from './types'++/** Viewer identity for a room-log line. A bare string is the local, unsourced+ * profile name (legacy call sites and single-connection jobs). */+export type GroupChatLineViewer =+ | string+ | (Pick<GroupMember, 'name'> & Partial<Pick<GroupMember, 'connectionId' | 'connectionLabel' | 'remoteSource'>>)/** Room-log line as a member sees it: `Name (user): …` / `Name: …` /* `Name (you): …`. */-export function formatGroupChatLine(entry: GroupMessage, viewerName: string) {+export function formatGroupChatLine(entry: GroupMessage, viewer: GroupChatLineViewer) {// Attachments are staged into each member's session as real payloads; the// transcript line names them so the delta text and the bytes line up.const attached =@@ -23,7 +29,7 @@ export function formatGroupChatLine(entry: GroupMessage, viewerName: string) {return `${entry.from.name || 'User'} (user): ${entry.text}${attached}`}- const suffix = entry.from.name === viewerName ? ' (you)' : ''+ const suffix = isGroupChatSelf(entry.from, viewer) ? ' (you)' : ''// Cross-connection speakers carry their device so same-named agents on// two machines stay tellable apart in every member's transcript.const source = entry.from.source ? ` [${entry.from.source}]` : ''@@ -31,6 +37,36 @@ export function formatGroupChatLine(entry: GroupMessage, viewerName: string) {return `${groupSpeakerLabel(entry.from.name)}${suffix}${source}: ${entry.text}${attached}`}+function viewerNameOf(viewer: GroupChatLineViewer): string {+ return typeof viewer === 'string' ? viewer : viewer?.name || ''+}++/** Remote members stamp `from.source` as `connectionLabel || connectionId`.+ * Only a remoteSource viewer exposes those tokens; a string or local member+ * is unsourced so same-name remote lines fail open (no `(you)`). */+function viewerConnectionSources(viewer: GroupChatLineViewer): string[] {+ if (typeof viewer === 'string' || !viewer?.remoteSource) {+ return []+ }++ return [viewer.connectionLabel, viewer.connectionId].filter((token): token is string => Boolean(token))+}++function isGroupChatSelf(from: GroupMessageAuthor, viewer: GroupChatLineViewer): boolean {+ if (!from.name || from.name !== viewerNameOf(viewer)) {+ return false+ }++ const speakerSource = from.source || ''+ const viewerSources = viewerConnectionSources(viewer)++ if (!speakerSource && viewerSources.length === 0) {+ return true+ }++ return Boolean(speakerSource) && viewerSources.includes(speakerSource)+}+interface GroupChatTurnPromptInput {deltaLines: string[]groupName: string