Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): exclude own actor from group mentions
zqchrisa95144d4cb1c
diff --git a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsxindex 72c8309db6..a44d248a9b 100644--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx@@ -471,6 +471,19 @@ describe('group composer', () => {expect(h.row.value).toBe('');});+ it('keeps the current human in the group but excludes it from mention choices and typed mentions', async () => {+ h.chat.server = true;+ const data = group({ openPlan: null });+ data.members.unshift({ ...data.members[0]!, botId: 'self', name: 'Me', actorKind: 'human', isSelf: true });+ await render(data);+ await type('@');+ expect(byId('botGroup.mention.self')).toBeNull();+ expect(byId('botGroup.mention.mimi')).not.toBeNull();+ await type('@Me @阿布 hello');+ await click('botGroup.composer.send');+ expect(h.chat.act).toHaveBeenLastCalledWith('send', expect.objectContaining({ mentions: { all: false, botIds: ['abu'] } }));+ });+it('sends a 分工 message and keeps the clientId and tag for a retry', async () => {await render(group({ openPlan: null }));expect(byId('botGroup.divisionTag')).toBeNull();diff --git a/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx b/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsxindex d3a68cd6ef..9811912f96 100644--- a/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx+++ b/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx@@ -61,6 +61,19 @@ it('lists and opens an existing joined server group with all computers and the rawait 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: [] } }));});+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()!;+ h.auth.apiFetch.mockImplementation(async (path, options) => {+ const value = await original(path, options);+ return path.endsWith('/snapshot') ? { ...value, members: [...value.members, { ...value.members[0], id: other, name: 'Other', ownerActorId: other }] } : value;+ });+ showChat = true; await render();+ for (const all of [false, true]) {+ await act(async () => { await chat.act('send', { text: 'hello', clientId: `fixture-${all}`, mentions: { all, botIds: [self, other] } }); });+ expect(h.auth.apiFetch).toHaveBeenCalledWith(`/v1/conversations/${id}/messages`, expect.objectContaining({ method: 'POST', body: { operationId: `fixture-${all}`, content: [{ type: 'text', text: 'hello' }], mentions: [other] } }));+ }+});it('deduplicates server copies from multiple computers while retaining a local legacy group', async () => {h.legacy.items = ['mac', 'pc'].map(deviceId => ({ key: deviceId, host: { deviceId, deviceName: deviceId }, item: { ref: { collectionId: 'bot-groups', kind: 'bot-group', id }, revision: '1', display: { title: 'Discussion' }, links: [] } }));h.legacy.isOnline.mockReturnValue(true);diff --git a/apps/mobile/src/chat/useChatServer.ts b/apps/mobile/src/chat/useChatServer.tsindex 5a1d64b8e4..9f7db65a3b 100644--- a/apps/mobile/src/chat/useChatServer.ts+++ b/apps/mobile/src/chat/useChatServer.ts@@ -213,8 +213,11 @@ export function useChatServerGroup(groupId: string, enabled: boolean) {const latest = page.current;if (!latest || latest.identity !== identity) throw new Error('CHAT_READ_FAILED');const mentions = input.mentions as { all: boolean; botIds: string[] };+ const recipients = mentions.all+ ? latest.page.snapshot.members.filter(member => member.state === 'joined').map(member => member.id)+ : mentions.botIds;await api.client.send(groupId, { clientId: String(input.clientId), text: String(input.text),- mentions: { all: false, botIds: mentions.all ? latest.page.snapshot.members.filter(member => member.state === 'joined' && member.id !== latest.self).map(member => member.id) : mentions.botIds } });+ mentions: { all: false, botIds: recipients.filter(id => id !== latest.self) } });reload(); return { effects: [] };};const media = async (mediaId: string): Promise<BotGroupAttachment> => {diff --git a/apps/mobile/src/session/BotGroupComposer.tsx b/apps/mobile/src/session/BotGroupComposer.tsxindex a08a8eca2b..1334485ee6 100644--- a/apps/mobile/src/session/BotGroupComposer.tsx+++ b/apps/mobile/src/session/BotGroupComposer.tsx@@ -118,17 +118,19 @@ export function BotGroupComposer({const mediaLibraryEnabled = canBrowsePhotoLibraryDirectly(Platform.OS);const activeMembers = useMemo(() => members.filter(isActiveBotGroupMember), [members]);+ const mentionMembers = useMemo(() => members.filter(member => member.isSelf !== true), [members]);+ const mentionCandidates = useMemo(() => mentionMembers.filter(isActiveBotGroupMember), [mentionMembers]);const allLabel = t('groupChat.mention.all');const query = focused ? findBotGroupMentionQuery(text, caret) : null;const options = useMemo<MentionOption[]>(() => {- if (!query || activeMembers.length === 0) return [];+ if (!query || mentionCandidates.length === 0) return [];const everyone: MentionOption[] = filterBotGroupMentionCandidates(query.query, [{ name: allLabel }]).length > 0? [{ kind: 'all', label: allLabel }]: [];- const people = filterBotGroupMentionCandidates(query.query, activeMembers)+ const people = filterBotGroupMentionCandidates(query.query, mentionCandidates).map((member): MentionOption => ({ kind: 'member', label: member.name, member }));return [...everyone, ...people];- }, [activeMembers, allLabel, query]);+ }, [mentionCandidates, allLabel, query]);const pickerOpen = query !== null && options.length > 0;const trimmed = text.trim();@@ -193,7 +195,7 @@ export function BotGroupComposer({const attempt = nextBotGroupSendAttempt(attemptRef.current, draftText, draftDivision, randomUUID, attachmentIds);attemptRef.current = attempt;const mentions = resolveBotGroupMentions(draftText, {- members: members.map((member) => ({ botId: member.botId, name: member.name })),+ members: mentionMembers.map((member) => ({ botId: member.botId, name: member.name })),allLabels: [allLabel],tracked: draftTracked,});