Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 已归档群不再回到伙伴列表 (#6481)
Chris Zhangab2c837cda77
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botGroupRemoteResourceProvider.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botGroupRemoteResourceProvider.test.tsindex 340898aef8..56865f1109 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botGroupRemoteResourceProvider.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botGroupRemoteResourceProvider.test.ts@@ -122,6 +122,18 @@ describe('bot group remote resources', () => {afterEach(() => h.sqlite?.close());+ it('omits archived groups from phone lists while keeping authorized history readable', async () => {+ const archived = detail({ serverBacked: true, archived: true });+ service.listGroups.mockResolvedValue({ ok: true, groups: [archived, summary({ id: 'active' })] });+ const result = await remoteResourceRegistry.list(context, { client: client(), collectionId: BOT_GROUP_REMOTE_COLLECTION_ID });+ expect(result.items.map(item => item.ref.id)).toEqual(['active']);+ service.getGroup.mockResolvedValue({ ok: true, group: archived });+ const history = await remoteResourceRegistry.get(context, { client: client([BOT_GROUP_CHAT_PRIMITIVE]), ref: ref('g1') });+ expect(history.blocks?.[0]).toMatchObject({ data: { archived: true, messages: archived.messages } });+ expect(service.deleteGroup).not.toHaveBeenCalled();+ expect(service.chatServer.manage).not.toHaveBeenCalled();+ });+it('advertises revision-checked settings only for server groups', () => {expect(botGroupRemoteChatData(detail()).supportsSettingsManagement).toBe(false);expect(botGroupRemoteChatData(detail({ serverBacked: true, revision: 3 })).supportsSettingsManagement).toBe(true);diff --git a/apps/desktop/src/main/maker-ipc/botGroupRemoteResourceProvider.ts b/apps/desktop/src/main/maker-ipc/botGroupRemoteResourceProvider.tsindex 1ac3af430d..539d06a8f2 100644--- a/apps/desktop/src/main/maker-ipc/botGroupRemoteResourceProvider.ts+++ b/apps/desktop/src/main/maker-ipc/botGroupRemoteResourceProvider.ts@@ -319,7 +319,7 @@ export function registerBotGroupRemoteResourceProvider(service: () => BotGroupChconst scope = captureDataOwnerBroadcastScope();const result = await requireService().listGroups();if (!result.ok) refuse(result);- const groups = await visibleGroups(result.groups);+ const groups = await visibleGroups(result.groups.filter(group => !group.archived));if (!isDataOwnerBroadcastScopeCurrent(scope)) throw new RemoteResourceRegistryError('NOT_FOUND', 'Account changed');const query = request.query?.trim().toLocaleLowerCase() ?? '';const matched = querydiff --git a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsxindex 06cb321f32..3f518acb5c 100644--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx@@ -960,6 +960,16 @@ describe('group settings', () => {expect(byId('botGroup.settings')).not.toBeNull();}+ it('allows personal removal from an archived read-only group without management rights', async () => {+ h.chat.server = true;+ await openSettings(group({ serverBacked: true, archived: true, supportsListRemoval: true, supportsSettingsManagement: false,+ members: [{ botId: 'self', actorId: 'self', name: 'Me', avatar: '', avatarColor: '', status: 'active', isSelf: true, role: 'member' }] }));+ expect(byId('botGroup.settings.delete')).toBeNull();+ expect(byId('botGroup.settings.hide')?.disabled).toBe(false);+ await click('botGroup.settings.hide');+ expect(h.chat.act).toHaveBeenCalledExactlyOnceWith('hide', undefined);+ });+it.each([true, false])('leaves after confirmed personal hide even when settings unmounts before the reply (direct=%s)', async direct => {h.chat.server = direct;let finish!: () => void;diff --git a/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx b/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsxindex a7748b4328..77d5c62415 100644--- a/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx+++ b/apps/mobile/src/__tests__/chatServerMobileEntry.test.tsx@@ -257,6 +257,36 @@ it('deduplicates server copies from multiple computers while retaining a local lawait act(async () => { await roster.refresh(); });expect(roster.items.map(row => row.item.ref.id)).toEqual(['old-local-group']);});+// Regression: desktop archive was honored by neither mobile list path. Keep the+// server ID for deduplication even when the room must not become a visible row.+it.each(['list', 'snapshot'] as const)('keeps an archived %s out on cold load, refresh and foreground, including old computer copies', async source => {+ const allowed = h.auth.apiFetch.getMockImplementation()!;+ const legacyHost = { deviceId: 'old-computer', deviceName: 'Old' };+ h.targets = [legacyHost]; h.legacy.isOnline.mockReturnValue(true);+ h.legacy.items = [{ host: legacyHost, item: { ref: { id, kind: 'bot-group', collectionId: 'bot-groups' } } }];+ let archived = true;+ h.auth.apiFetch.mockImplementation(async (path, options) => {+ if (path.startsWith('/v1/conversations?')) return [{ ...room, archived: source === 'list' && archived }];+ const value = await allowed(path, options);+ return path.endsWith('/snapshot') ? { ...value, room: { ...room, archived } } : value;+ });+ await render();+ expect(roster.items).toEqual([]);+ if (source === 'list') expect(h.auth.apiFetch.mock.calls.some(([path]) => path.endsWith('/snapshot'))).toBe(false);+ await act(async () => { await roster.refresh(); });+ await act(async () => h.foreground.forEach(fn => fn('active')));+ expect(roster.items).toEqual([]);+ archived = false;+ await act(async () => { await roster.refresh(); });+ expect(roster.items).toHaveLength(1);+ expect(roster.items[0].host.deviceId).toBe('');+ archived = true;+ await act(async () => { await roster.refresh(); });+ expect(roster.items).toEqual([]);+ h.auth.apiFetch.mockRejectedValue(new Error('offline'));+ await act(async () => { await roster.refresh(); });+ expect(roster.items).toEqual([]);+});it('clears removed membership, exposes first-read failures and recovers on foreground', async () => {showChat = true; h.auth.apiFetch.mockRejectedValue(new Error('offline'));await render(); expect(chat.state.kind).toBe('error');@@ -380,6 +410,9 @@ it('keeps a hidden room out of the roster even if an old server list and computeexpect(roster.items).toEqual([]);expect(h.auth.apiFetch.mock.calls.some(([path]) => path.endsWith('/snapshot'))).toBe(false);expect(roster.error).toBeNull();+ await act(async () => { await roster.refresh(); });+ await act(async () => h.foreground.forEach(fn => fn('active')));+ expect(roster.items).toEqual([]);});it('merges a computer-confirmed personal removal without requiring direct server access or trusting stale room data', async () => {diff --git a/apps/mobile/src/chat/useChatServer.ts b/apps/mobile/src/chat/useChatServer.tsindex bd5519973b..72d0afad3a 100644--- a/apps/mobile/src/chat/useChatServer.ts+++ b/apps/mobile/src/chat/useChatServer.ts@@ -76,17 +76,21 @@ export function useChatServerRoster(enabled: boolean) {const [rooms, self] = await Promise.all([api.client.list(), api.client.me()]);const rows: ReturnType<typeof chatRoomRow>[] = [];const fresh = new Map<string, { owner: string; head: string | undefined; value: ChatSnapshot }>();+ // Keep archived IDs in `rooms` for computer-copy deduplication, but do not+ // download their histories or project them into the default teammate list.+ const visibleRooms = rooms.filter(room => !room.archived);let partial = false;// List provides room heads, so unchanged rooms need no history download on polling.- for (let offset = 0; offset < rooms.length; offset += 4) {- await Promise.all(rooms.slice(offset, offset + 4).map(async room => {+ for (let offset = 0; offset < visibleRooms.length; offset += 4) {+ await Promise.all(visibleRooms.slice(offset, offset + 4).map(async room => {try {const cached = snapshots.current.get(room.id);const value = cached?.owner === api.owner && room.head !== undefined && cached.head === room.head&& !run.reasons.some(reason => ['changed', 'connected', 'visible'].includes(reason))? cached.value : await api.client.snapshot(room.id);fresh.set(room.id, { owner: api.owner, head: room.head, value });- rows.push(chatRoomRow(room, value, self));+ // An archive can land between the list and the newer snapshot.+ if (!value.room.archived) rows.push(chatRoomRow(room, value, self));} catch (error) {if (!chatAccessLost(error)) { partial = true; rows.push(chatRoomRow(room)); }}diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.mdindex f0b686e9ad..160cd0c4dc 100644--- a/docs/product-rules/bot-group-chat.md+++ b/docs/product-rules/bot-group-chat.md@@ -367,6 +367,9 @@`check:endpoints` 对两份生产正本检查群聊地址非空 HTTPS,并阻止直连代码硬编码生产地址。- 手机列表以服务器群 ID 去重,优先直连;电脑声明的 `bot-groups` 继续提供本地旧群和旧入口兼容。旧缓存无法区分服务器群与本地群,因此兼容群行须有电脑当前连接代次的成功列群回包,断线缓存不能作为成员权限依据。+ 直连列表和电脑 `bot-groups` 列表均排除已归档群;直连仍保留其服务器 ID 用于去重,防止旧电脑回包重新带回同一群。+ 列群后取得的较新快照已归档时也不显示该行。过滤只影响列表,既有历史访问和群管理权限保持不变;个人移除仍走账号的 list-state。+ 回归见 `chatServerMobileEntry.test.tsx`、`BotGroupChatScreen.test.tsx` 与 `botGroupRemoteResourceProvider.test.ts`。无电脑参数的群路由直连,带电脑参数的既有推送/创建路由仍走原资源协议。- 列表在前台订阅账号成员事件,每 30 秒核对群 head,仅重读变化群的快照;打开群后订阅该群事件,用字符串游标 ack,断线/前后台切换重连并重读授权快照。离开页面或切换账号即停止订阅。