Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(chat): retain account owner labels in direct rooms

shenjiacheng2421a5a6daa2
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
index a7a0fcb336..70a038eae7 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
@@ -190,6 +190,21 @@ describe('Chat Server result delivery and refresh', () => {
if (name !== null) expect(result.group.messages[1]).toMatchObject({ authorName: name, authorBotId: ownerId, authorKind: 'user' });
expect(bot).toMatchObject({ name: 'Companion X', ownerName: 'Account B', ownerActorId: ownerId });
});
+ // #6907: direct rooms share the adapter but must keep account owner labels, including empty legacy values.
+ it.each(['Account B', ''])('keeps direct owner labels from account %s', async ownerName => {
+ const bot = { id: botId, kind: 'bot', name: 'Companion X', state: 'joined', role: 'member', ownerActorId: selfId, ownerName };
+ const members = [bot, { id: selfId, kind: 'human', name: 'Nickname A', state: 'joined', role: 'member', ownerActorId: selfId }];
+ const messages = [{ id: execution.source_message_id, seq: '1', authorId: botId, author: { kind: 'bot', name: 'Companion X' },
+ content: [{ type: 'text', text: 'Example reply' }], createdAt: '2026-10-03T00:00:00Z', deleted: false, threadRootId: null }];
+ fixture.handle.mockImplementation(route => route.endsWith('/snapshot') ? { body: { room: { ...room(roomId), kind: 'direct' }, members, messages, cursor: '1' } }
+ : route.includes('/messages?') ? { body: messages } : response(route));
+ const result = await service.getGroup(roomId, { conversationKind: 'direct' });
+ if (!result.ok) throw new Error(result.errorCode);
+ const label = ownerName ? 'Companion X (Account B)' : 'Companion X';
+ expect(result.group).toMatchObject({ name: label, messages: [{ authorName: label }], lastMessage: { authorName: label } });
+ expect(result.group.members.find(m => m.actorId === botId)).toMatchObject({ name: label, ownerName });
+ expect(bot.ownerName).toBe(ownerName);
+ });
describe('分工 auto-continue on this computer (bot-group-chat.md §7.4)', () => {
const planId = '80000000-0000-4000-8000-000000000009';
const otherHuman = '30000000-0000-4000-8000-000000000002';
diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.ts
index 3fed9793b6..3651dea965 100644
--- a/apps/desktop/src/main/maker-ipc/chatServer.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts
@@ -505,7 +505,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
present: async (groupId, message) => {
const snapshot = await recentSnapshot(groupId);
const member = snapshot.members.find(member => member.id === message.authorId);
- const view = messageView(message, snapshot.members);
+ const view = messageView(message, snapshot.members, snapshot.room.kind === 'direct' ? [] : snapshot.members);
const words = (key: string) => t(`settings.notifications.chat.${key}`);
const name = notificationPreview(view.authorName) || words('sender');
const senderName = message.author.kind === 'bot' ? `${name} (${words('teammate')})` : name;
@@ -1077,7 +1077,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
const actor = actors.find(a => a.id === actorId && a.kind === 'bot');
return profiles.find(p => p.id === actor?.externalId);
}
- function messageView(m: Message, members: Member[]): BotGroupMessageView {
+ function messageView(m: Message, members: Member[], ownerMembers: readonly Member[] = members): BotGroupMessageView {
// Only the server-owned origin establishes a system event. A user-supplied
// card with the same namespace must remain an ordinary chat message.
if (m.origin === 'system') {
@@ -1110,7 +1110,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
const task = m.deleted || planCard ? null : taskCardOf(m);
return { id: m.id, sequence: Number(m.seq), serverSequence: m.seq, deleted: m.deleted, kind: planCard ? 'plan' : 'message', authorKind: legacy?.authorKind === 'system' ? 'system' : m.author.kind === 'human' ? 'user' : 'bot',
isSelf: m.authorId === selfId, threadRootId: m.threadRootId, replyCount: m.replyCount ?? 0, reactions: m.reactions ?? [], ...(quote ? { quote } : {}), ...(task ? { task } : {}),
- authorBotId: localBot(m.authorId)?.id ?? m.authorId, authorName: legacy?.authorKind === 'system' && typeof legacy.authorName === 'string' ? legacy.authorName : member ? memberName(member, members) : m.author.name, content: displayText(m),
+ authorBotId: localBot(m.authorId)?.id ?? m.authorId, authorName: legacy?.authorKind === 'system' && typeof legacy.authorName === 'string' ? legacy.authorName : member ? memberName(member, ownerMembers) : m.author.name, content: displayText(m),
mentions: { all: false, botIds: (m.mentions ?? []).map(actorId => localBot(actorId)?.id ?? actorId) }, noticeCode: null, planId: typeof planCard?.data?.planId === 'string' ? planCard.data.planId : null, files: [], attachments: [], createdAt: Date.parse(m.createdAt) };
}
/**
@@ -1179,7 +1179,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
* message can be quoted; the snapshot never comes from the controller's input. A thread
* share's own text is only its card's fallback, so a share is not quotable either.
*/
- async function quoteSnapshot(roomId: string, messageId: string, members: Promise<Member[]>): Promise<BotGroupQuoteView & { recipientActorId?: string }> {
+ async function quoteSnapshot(roomId: string, messageId: string, members: Promise<Member[]>, direct: boolean): Promise<BotGroupQuoteView & { recipientActorId?: string }> {
let quoted: Message;
try {
quoted = await api<Message>(`/conversations/${roomId}/messages/${messageId}`);
@@ -1187,7 +1187,8 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
if (error instanceof ChatResponseError && [403, 404].includes(error.status)) throw new Error('QUOTE_UNAVAILABLE');
throw error;
}
- const view = messageView(quoted, await members);
+ const resolvedMembers = await members;
+ const view = messageView(quoted, resolvedMembers, direct ? [] : resolvedMembers);
if (quoted.id !== messageId || quoted.deleted || quoted.threadRootId !== null || quoted.origin === 'system'
|| view.kind !== 'message' || view.authorKind === 'system' || readBotGroupThreadShareCard(quoted)) throw new Error('QUOTE_UNAVAILABLE');
return { ...botGroupQuoteFromMessage({ ...view, content: quotedText(quoted),
@@ -1209,9 +1210,9 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
changed(roomId);
}, ATTACHMENT_REFRESH_COALESCE_MS));
}
- async function messageViews(roomId: string, messages: Message[], members: Member[]) {
+ async function messageViews(roomId: string, messages: Message[], members: Member[], ownerMembers: readonly Member[] = members) {
return messages.map(message => {
- const view = messageView(message, members);
+ const view = messageView(message, members, ownerMembers);
for (const block of message.content) if (!message.deleted && block.type === 'media' && block.mediaId) {
const placeholder = (state: 'loading' | 'unavailable'): BotGroupAttachment => ({ id: block.mediaId!, name: attachmentName(block),
category: 'file', mimeType: '', size: 0, url: null, path: null, state });
@@ -1338,6 +1339,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
for (const read of [messagesRead, executionsRead]) read?.catch(() => undefined);
const s = await snapshotRead;
const page = (await messagesRead) ?? s.messages;
+ const ownerMembers = direct ? [] : s.members;
const executions = await executionsRead;
const ids = page.flatMap(m => m.content.flatMap(b => b.namespace === 'cindy.plan' && typeof b.data?.planId === 'string' ? [id.parse(b.data.planId)] : []));
const plansRead = direct ? Promise.resolve([] as ServerPlan[]) : api<ServerPlan[]>(`/conversations/${roomId}/plans${ids.length ? `?ids=${ids.join(',')}` : ''}`);
@@ -1361,7 +1363,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
const deciding = planning.get(roomId);
if (deciding) speakers.push({ botId: deciding.botId, sessionId: null, activity: 'planning' });
// Sidebar refresh must not download every attachment in every group's history.
- const messages = summaryOnly ? [] : await messageViews(roomId, page, s.members);
+ const messages = summaryOnly ? [] : await messageViews(roomId, page, s.members, ownerMembers);
const shares = summaryOnly || direct ? undefined : await decorateThreads(roomId, messages, page, s.messages, s.members, true, o.shownShares);
const threadShareUpdates = shares?.updates;
const reads = threadReads(s);
@@ -1372,20 +1374,20 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
const threadList = reads && !direct ? threadSummaries(roomId, s, page, reads) : undefined;
messages.sort((a, b) => a.sequence - b.sequence);
const last = s.messages[0];
- const lastView = last ? messageView(last, s.members) : null;
+ const lastView = last ? messageView(last, s.members, ownerMembers) : null;
// The sidebar never resolves shares: it names the sharer and never quotes the card's text.
const lastIsShare = !!last && !!readBotGroupThreadShareCard(last);
return { conversationKind: direct ? 'direct' : 'group', serverBacked: true, reactionRevision: reactionRevisions.get(roomId)?.room ?? runtimeReactionRevision, reactionRevisions: { ...reactionRevisions.get(roomId)?.messages }, supportsGroupLeave: !direct, supportsDissolve: !direct && supportsDissolve, supportsListRemoval, supportsMemberAvatar: !direct && supportsMemberAvatar, dissolvedAt: s.room.dissolved_at ?? null, migrationPending: [...upgradeErrors.keys()].some(source => upgradedGroups.get(source) === roomId), archived: s.room.archived, selfActorId: selfId, topic: s.room.topic, description: s.room.description, revision: s.room.revision, canInvite: !direct && !s.room.dissolved_at && s.members.some(m => m.ownerActorId === selfId && m.state === 'joined' && ['owner', 'admin'].includes(m.role)), canStopAll: !direct && singleSpeaker && !!managementActor(s), ...(!direct && singleSpeaker ? { singleSpeaker: true, supportsDivision: true } : {}), id: s.room.id, name: direct ? s.members.filter(m => m.state === 'joined' && m.id !== selfId).map(member => memberName(member, [])).join(', ') || s.room.name : s.room.name, replyMode: s.room.response_mode, speakingMode: s.room.speaking_mode,
members: s.members.filter(m => m.state === 'joined').map(m => {
const p = localBot(m.id);
return { botId: p?.id ?? m.id, actorId: m.id, actorKind: m.kind, isSelf: m.id === selfId,
- role: m.role, nickname: m.nickname, groupAvatar: m.groupAvatar ?? null, defaultAvatarUrl: m.defaultAvatarUrl ?? null, displayName: m.displayName, ownerActorId: m.ownerActorId, ownerName: m.kind === 'bot' ? chatGroupOwnerName(m, s.members) : m.ownerName,
+ role: m.role, nickname: m.nickname, groupAvatar: m.groupAvatar ?? null, defaultAvatarUrl: m.defaultAvatarUrl ?? null, displayName: m.displayName, ownerActorId: m.ownerActorId, ownerName: m.kind === 'bot' && !direct ? chatGroupOwnerName(m, ownerMembers) : m.ownerName,
isOwned: m.ownerActorId === selfId, guestAccess: m.guestAccess, accessRevision: m.accessRevision,
// Which computer runs my companion: a phone reaching this group through this computer
// reads the companion's tasks there, not here (bot-group-chat.md §10).
...(m.ownerActorId === selfId && m.kind === 'bot' ? { homeDeviceId: actors.find(a => a.id === m.id)?.homeDeviceId ?? null } : {}),
avatarUrl: m.avatar?.startsWith('https://') ? m.avatar : null,
- name: memberName(m, s.members), avatar: m.groupAvatar ? '' : p?.avatar ?? (m.avatar?.startsWith('https://') ? '' : m.avatar) ?? '', avatarColor: p?.avatarColor ?? 'violet', status: p?.status ?? 'active' };
+ name: memberName(m, ownerMembers), avatar: m.groupAvatar ? '' : p?.avatar ?? (m.avatar?.startsWith('https://') ? '' : m.avatar) ?? '', avatarColor: p?.avatarColor ?? 'violet', status: p?.status ?? 'active' };
}), organizerBotId: direct ? null : ((id?: string) => id ? localBot(id)?.id ?? id : null)(s.room.organizer_id ?? s.members.find(m => m.kind === 'bot' && m.state === 'joined')?.id), projectDir: workspace?.projectDir ?? null,
// Only servers that tell a 分工 from a queue (kind) can hand one on by itself.
...(singleSpeaker ? { autoContinue: workspace?.autoContinue === true } : {}), lastMessage: last && lastView ? {
@@ -2635,7 +2637,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
const quoteKey = i.quote ? JSON.stringify([i.groupId, i.clientId, i.quote.messageId, i.text, i.mentions, i.division]) : '';
const knownQuote = i.quote ? postedQuotes.get(quoteKey) : undefined;
const snapshotMembers = snapshotRead.then(value => value.members);
- const quoteRead = i.quote && !knownQuote ? quoteSnapshot(i.groupId, i.quote.messageId, snapshotMembers) : undefined;
+ const quoteRead = i.quote && !knownQuote ? quoteSnapshot(i.groupId, i.quote.messageId, snapshotMembers, direct) : undefined;
const plansRead = direct ? Promise.resolve([] as ServerPlan[]) : api<ServerPlan[]>(`/conversations/${i.groupId}/plans`);
const membersRead = namesNobody(i.mentions) && !i.quote ? undefined : api<Member[]>(`/conversations/${i.groupId}/members`);
for (const read of [snapshotMembers, quoteRead, plansRead, membersRead]) read?.catch(() => undefined);
diff --git a/apps/mobile/src/__tests__/chatServerClient.test.ts b/apps/mobile/src/__tests__/chatServerClient.test.ts
index d30499b007..aed21db3ec 100644
--- a/apps/mobile/src/__tests__/chatServerClient.test.ts
+++ b/apps/mobile/src/__tests__/chatServerClient.test.ts
@@ -34,6 +34,17 @@ describe('direct Chat Server client', () => {
expect(project(first).members.find(m => m.actorId === bot.id)).toMatchObject({ botId: bot.id, isOwned: false });
expect(bot).toMatchObject({ name: 'Companion X', ownerName: 'Account B', ownerActorId: human.id });
});
+ it.each(['Account B', ''])('keeps direct owner labels from account %s', ownerName => {
+ const human = { ...snapshot().members[0], name: 'Nickname A' };
+ const bot = { ...human, id: id(12), kind: 'bot' as const, name: 'Companion X', ownerName };
+ const source = { ...snapshot(), room: { ...room(), kind: 'direct' }, members: [human, bot] };
+ const messages = [{ ...message(20), authorId: bot.id, author: { kind: 'bot', name: bot.name } }];
+ const label = ownerName ? 'Companion X (Account B)' : 'Companion X';
+ const view = chatGroupView({ snapshot: source, messages, before: null }, human.id);
+ expect(view).toMatchObject({ name: label, messages: [{ authorName: label }] });
+ expect(view.members.find(m => m.actorId === bot.id)?.name).toBe(label);
+ expect(chatRoomRow(source.room, source).groupMembers?.find(m => m.botId === bot.id)?.name).toBe(label);
+ });
it('preserves thread identity through projection into the history new-message counter', () => {
const view = chatGroupView({ snapshot: snapshot(), before: null, messages: [message(20),
{ ...message(21), threadRootId: id(20) }, { ...message(22), threadRootId: id(99) }] }, id(11));
diff --git a/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx b/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx
index a7ab6f5e92..eec9f6a4d3 100644
--- a/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx
+++ b/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx
@@ -86,6 +86,27 @@ it('lists and opens an existing joined server group with all computers and the r
await act(async () => { await chat.act('send', { text: 'hello', clientId: 'fixture-operation', mentions: { all: false, botIds: [] } }); });
expect(h.auth.apiFetch).toHaveBeenCalledWith(`/v1/conversations/${id}/messages`, expect.objectContaining({ method: 'POST', body: { operationId: 'fixture-operation', content: [{ type: 'text', text: 'hello' }], mentions: [] } }));
});
+// #6907: the hook must pass direct-room scope to the real client's quote projection (unit tier).
+it('keeps the account owner label when quoting from a direct phone entry', async () => {
+ const botId = '00000000-0000-4000-8000-000000000003';
+ const owner = { id: self, kind: 'human', state: 'joined', name: 'Nickname A', ownerActorId: self, ownerName: '', role: 'member', avatar: null };
+ const bot = { ...owner, id: botId, kind: 'bot', name: 'Companion X', ownerName: 'Account B' };
+ const message = { id: self, seq: '1', authorId: botId, author: { kind: 'bot', name: bot.name }, content: [{ type: 'text', text: 'Example' }],
+ createdAt: '2026-10-09', deleted: false, threadRootId: null };
+ const original = h.auth.apiFetch.getMockImplementation()!;
+ h.auth.apiFetch.mockImplementation(async (path, options) => {
+ if (path.endsWith('/snapshot')) return { room: { ...room, kind: 'direct' }, members: [owner, bot], messages: [message], cursor: '1' };
+ if (path.endsWith('/members')) return [owner, bot];
+ if (path.endsWith('/messages/' + self)) return message;
+ return original(path, options);
+ });
+ showChat = true; await render();
+ expect(chat.state.kind).toBe('ready');
+ await act(async () => { await chat.act('send', { text: 'Agreed', clientId: 'direct-quote-scope', quote: { messageId: self }, mentions: { all: false, botIds: [] } }); });
+ expect(h.auth.apiFetch).toHaveBeenCalledWith('/v1/conversations/' + id + '/messages', expect.objectContaining({ method: 'POST', body: expect.objectContaining({
+ mentions: [botId], content: [expect.objectContaining({ data: expect.objectContaining({ authorName: 'Companion X (Account B)' }) }), { type: 'text', text: 'Agreed' }],
+ }) }));
+});
it('never includes the current human actor in explicit or everyone server mentions', async () => {
const other = '00000000-0000-4000-8000-000000000003';
const original = h.auth.apiFetch.getMockImplementation()!;
diff --git a/apps/mobile/src/chat/chatServerClient.ts b/apps/mobile/src/chat/chatServerClient.ts
index 7880f4acdb..235bd85183 100644
--- a/apps/mobile/src/chat/chatServerClient.ts
+++ b/apps/mobile/src/chat/chatServerClient.ts
@@ -88,17 +88,18 @@ export function chatRoomRow(room: ChatRoom, snapshot?: ChatSnapshot, selfId?: st
const members = snapshot?.members.filter(member => member.state === 'joined') ?? [];
const last = snapshot?.messages.filter(message => !message.threadRootId && !message.deleted)
.sort((a, b) => BigInt(chatCursor(a.seq)) < BigInt(chatCursor(b.seq)) ? 1 : -1)[0];
+ const ownerMembers = room.kind === 'direct' ? [] : members;
return { key: `chat:${room.id}`, host: { deviceId: '', deviceName: '' },
lastReplySequence: snapshot && selfId ? chatLastReplySequence(snapshot.messages, selfId) : undefined,
chatUnread: snapshot?.reads && selfId ? chatUnread(snapshot, selfId) : undefined,
- groupMembers: snapshot ? members.map(member => chatMemberIdentity(member, members)) : undefined, item: {
+ groupMembers: snapshot ? members.map(member => chatMemberIdentity(member, ownerMembers)) : undefined, item: {
ref: { collectionId: 'bot-groups', kind: 'bot-group', id: room.id },
revision: String(room.head ?? room.revision), display: { title: room.name,
- subtitle: members.map(member => memberName(member, members)).join(' · '),
- ...(snapshot ? { preview: last ? mobileMarkdownPreviewText(botGroupMessageSummaryText({ content: contentText(last), task: taskCardOf(last) ?? undefined, deleted: last.deleted }) || mediaNames(last)).slice(0, 160) || members.map(member => memberName(member, members)).join(' · ') : '' } : {}),
+ subtitle: members.map(member => memberName(member, ownerMembers)).join(' · '),
+ ...(snapshot ? { preview: last ? mobileMarkdownPreviewText(botGroupMessageSummaryText({ content: contentText(last), task: taskCardOf(last) ?? undefined, deleted: last.deleted }) || mediaNames(last)).slice(0, 160) || members.map(member => memberName(member, ownerMembers)).join(' · ') : '' } : {}),
timestamp: Date.parse(last?.createdAt ?? room.updated_at),
lastReplyAt: snapshot && selfId ? chatLastReplyAt(snapshot.messages, selfId) : undefined },
- links: members.map(member => ({ rel: 'member', label: memberName(member, members),
+ links: members.map(member => ({ rel: 'member', label: memberName(member, ownerMembers),
target: { kind: 'resource', ref: { collectionId: 'teammates', kind: 'bot', id: member.id } } })),
} };
}
@@ -162,9 +163,10 @@ function chatMemberIdentity(member: ChatMember, members: readonly ChatMember[])
*/
export function chatGroupView(page: ChatPage, selfId: string, actors: readonly ChatActor[] = []): BotGroupRemoteChatData {
const { room, members } = page.snapshot;
+ const ownerMembers = room.kind === 'direct' ? [] : members;
const active = members.filter(member => member.state === 'joined');
const memberViews: BotGroupMemberView[] = active.map(member => ({
- ...chatMemberIdentity(member, members), actorId: member.id, actorKind: member.kind, isSelf: member.id === selfId,
+ ...chatMemberIdentity(member, ownerMembers), actorId: member.id, actorKind: member.kind, isSelf: member.id === selfId,
isOwned: member.ownerActorId === selfId, role: member.role,
...(member.ownerActorId === selfId && member.kind === 'bot'
? { homeDeviceId: actors.find(actor => actor.id === member.id)?.homeDeviceId ?? null } : {}),
@@ -189,7 +191,7 @@ export function chatGroupView(page: ChatPage, selfId: string, actors: readonly C
...(task ? { task } : {}), threadRootId: message.threadRootId,
authorKind: message.origin === 'system' ? 'system' : message.author.kind === 'human' ? 'user' : 'bot',
authorBotId: message.authorId, authorName: joined && typeof joined.data?.displayName === 'string' ? joined.data.displayName
- : member ? memberName(member, members) : message.author.name,
+ : member ? memberName(member, ownerMembers) : message.author.name,
isSelf: message.authorId === selfId, content: contentText(message), mentions: { all: false, botIds: message.mentions ?? [] },
...(quote ? { quote: deletedIds.has(quote.messageId) ? { ...quote, originalDeleted: true } : quote } : {}),
noticeCode: joined ? 'member-joined' : null, planId: null, files: [],
@@ -200,7 +202,7 @@ export function chatGroupView(page: ChatPage, selfId: string, actors: readonly C
const failure = readBotGroupExecutionFailure(row, room.id);
if (!failure) return [];
const member = members.find(candidate => candidate.id === failure.botId);
- return [{ ...failure, botName: member ? memberName(member, members) : '' }];
+ return [{ ...failure, botName: member ? memberName(member, ownerMembers) : '' }];
});
return { id: room.id, conversationKind: room.kind === 'direct' ? 'direct' : 'group',
name: room.kind === 'direct' ? active.filter(member => member.id !== selfId).map(member => memberName(member, [])).join(', ') || room.name : room.name,
@@ -419,7 +421,7 @@ export function createChatServerClient(request: ChatRequest, personalList = crea
if (current) { if (BigInt(readSeq) > BigInt(current.read_seq)) current.read_seq = readSeq; }
else page.snapshot.reads.push({ thread_key: key, read_seq: readSeq });
},
- async send(roomId: string, input: { clientId: string; text: string; mentions: { all: boolean; botIds: string[] }; quote?: { messageId: string }; threadRootId?: string }) {
+ async send(roomId: string, input: { conversationKind?: 'direct'; clientId: string; text: string; mentions: { all: boolean; botIds: string[] }; quote?: { messageId: string }; threadRootId?: string }) {
const key = JSON.stringify([roomId, input.clientId, input.text, input.mentions, input.quote?.messageId, input.threadRootId]);
const known = input.quote ? postedQuotes.get(key) : undefined;
const content: ChatMessage['content'] = known?.content ?? [{ type: 'text', text: input.text }];
@@ -432,7 +434,7 @@ export function createChatServerClient(request: ChatRequest, personalList = crea
if (original.deleted || (original.threadRootId && original.threadRootId !== input.threadRootId) || original.origin === 'system') throw new Error('QUOTE_UNAVAILABLE');
const member = members.find(member => member.id === original.authorId);
const quote = botGroupQuoteFromMessage({ id: original.id, sequence: Number(original.seq), authorKind: original.author.kind === 'human' ? 'user' : 'bot',
- authorName: member ? memberName(member, members) : original.author.name, content: contentText(original), task: taskCardOf(original) ?? undefined,
+ authorName: member ? memberName(member, input.conversationKind === 'direct' ? [] : members) : original.author.name, content: contentText(original), task: taskCardOf(original) ?? undefined,
attachments: original.content.filter(block => block.type === 'media').map(block => ({ name: attachmentName(block) })) });
// Quote positions are only an optional UI hint; never round a server cursor into it.
if (!Number.isSafeInteger(quote.sequence)) quote.sequence = null;
diff --git a/apps/mobile/src/chat/useChatServer.ts b/apps/mobile/src/chat/useChatServer.ts
index 41aea2b605..60ce9ec3be 100644
--- a/apps/mobile/src/chat/useChatServer.ts
+++ b/apps/mobile/src/chat/useChatServer.ts
@@ -298,7 +298,7 @@ export function useChatServerGroup(groupId: string, enabled: boolean, threadRoot
: [...mentions.botIds];
const root = threadRootId ? latest.page.messages.find(message => message.id === threadRootId) : undefined;
if (root && joined.some(member => member.id === root.authorId && member.kind === 'bot')) recipients.push(root.authorId);
- await api.client.send(groupId, { clientId: String(input.clientId), text: String(input.text), threadRootId,
+ await api.client.send(groupId, { ...(latest.page.snapshot.room.kind === 'direct' ? { conversationKind: 'direct' as const } : {}), clientId: String(input.clientId), text: String(input.text), threadRootId,
...(input.quote && typeof input.quote === 'object' && 'messageId' in input.quote
? { quote: { messageId: String(input.quote.messageId) } } : {}),
mentions: { all: false, botIds: recipients.filter(id => id !== latest.self) } });
diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.md
index 6b966069cc..8fca5d7f91 100644
--- a/docs/product-rules/bot-group-chat.md
+++ b/docs/product-rules/bot-group-chat.md
@@ -543,7 +543,7 @@ Desktop 主群输入框发送即乐观显示:点发送后消息立即接在时
手机直连入口同样在发送前读取已加入成员、校验全部显式目标,再展开所有人。点名失效沿用本地化提示和草稿恢复,不把群页标为离线;重选当前成员后可以立即继续发送。回归见 `chatServerMobileEntry.test.tsx` 与 `BotGroupChatScreen.test.tsx`。
多人群里的伙伴统一显示为 `伙伴名 (主人昵称)`,例如 `Cindy (Chris)`,便于区分不同人带来的同名伙伴。消息、Thread、成员列表、侧栏摘要与 @ 候选使用同一显示名;后缀仅用于展示,身份、授权和 @ 路由仍依据唯一 ID。已有短名 @ 继续可用,选取完整名字时只点名对应伙伴。
-主人名称按 `ownerActorId` 关联当前群已加入的人类成员,复用其有效群名称(含群昵称),缺失或空白时回退到伙伴原有的 `ownerName`;均不可用时不加后缀。Desktop 与手机直连共用 `maker-shared/botGroupPresentation.ts` 的解析规则,手机经电脑读取沿用 Desktop 投影。昵称刷新沿既有成员资料读取与页面刷新规则生效,不重写历史消息、全局资料或归属字段。回归见 `chatServer.test.ts` 与 `chatServerClient.test.ts`。
+主人名称按 `ownerActorId` 关联当前群已加入的人类成员,复用其有效群名称(含群昵称),缺失或空白时回退到伙伴原有的 `ownerName`;均不可用时不加后缀。私聊继续使用原账号主人名,不解析群昵称。Desktop 与手机直连共用 `maker-shared/botGroupPresentation.ts` 的解析规则,手机经电脑读取沿用 Desktop 投影。昵称刷新沿既有成员资料读取与页面刷新规则生效,不重写历史消息、全局资料或归属字段。回归见 `chatServer.test.ts` 与 `chatServerClient.test.ts`。
Desktop 主群与 Thread 的表情回应徽标参考 Telegram:某个表情的回应者不超过 3 人时,徽标直接显示他们的头像
(替代数字,不需要悬停);超过 3 人时显示数字。头像按 Actor ID 从群成员投影取,同名伙伴各用自己的头像;