Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge pull request #7233 from zqchris/cindy/thoughtful-feynman
Lizi9648c6c2e82c
diff --cc apps/mobile/src/__tests__/chatServerClient.test.tsindex 52ec68e9da,deff8cbfc4..4b1b6b300c--- a/apps/mobile/src/__tests__/chatServerClient.test.ts+++ b/apps/mobile/src/__tests__/chatServerClient.test.ts@@@ -1,8 -1,8 +1,9 @@@import { describe, expect, it, vi } from 'vitest';import { i18n } from '@/i18n';import { botGroupNewMessageCount } from '@cindy/maker-shared/botGroupPresentation';+import { createChatHistory, type ChatHistoryState } from '@cindy/maker-shared/chat-history';import { chatGroupView, chatRoomRow, chatReadAt, createChatServerClient, type ChatMessage, type ChatPage, type ChatRoom, type ChatSnapshot } from '@/chat/chatServerClient';+ import type { ChatHistory } from '@cindy/maker-shared/chat-history';import { botGroupQuoteFromMessage, resolveBotGroupQuote, buildBotGroupQuoteCard, buildBotGroupTaskCard } from '@cindy/maker-shared/botGroupChat';const id = (n: number) => `00000000-0000-4000-8000-${String(n).padStart(12, '0')}`;const room = (n = 1, state = 'joined'): ChatRoom => ({ id: id(n), name: 'Discussion', kind: 'group', state, archived: false,@@@ -14,26 -14,30 +15,49 @@@ const snapshot = (): ChatSnapshot => ({ id: id(10), kind: 'human', name: 'Other member', state: 'joined', ownerActorId: id(10), ownerName: '', avatar: null, role: 'member' },] });+ // Merge regression: history generation changes while execution state is read.+ // Production load must retry, retaining both the new revision and fresh work.+ it('retains fresh executions when cached history changes during load', async () => {+ const stored = {+ snapshot: vi.fn().mockResolvedValueOnce({ ...snapshot(), cacheGeneration: 'old' })+ .mockResolvedValue({ ...snapshot(), cacheGeneration: 'current' }),+ page: vi.fn(async () => [message(20)]),+ projection: vi.fn(async () => ({ generation: 'current', messages: [] })),+ };+ let reads = 0;+ const request = vi.fn(async (path: string) => {+ if (path === '/me') return { actor: { id: id(11), kind: 'human' } };+ if (path.endsWith('/executions')) return [{ id: id(++reads === 1 ? 30 : 31), bot_id: id(12), status: 'stopping', epoch: 1, source_message_id: id(20) }];+ if (path.includes('/execution-failures?')) return [];+ throw new Error(path);+ });+ const client = createChatServerClient(request as any, undefined, async () => stored as unknown as ChatHistory);+ const page = await client.load(id(1));+ expect(stored.snapshot).toHaveBeenCalledTimes(2);+ expect(page.historyRevision).toBe('current');+ expect(chatGroupView(page, id(11)).round.speakers.map(speaker => [speaker.executionId, speaker.executionStatus])).toEqual([[id(31), 'stopping']]);+ });+describe('direct Chat Server client', () => {+ // Unit: topic loads already cached replies but still fetched the root on every open.+ it('reuses the durable root and reply page when reopening a topic', async () => {+ const request = vi.fn().mockImplementation(async (path: string) => {+ if (path === '/me') return { actor: { id: id(10), kind: 'human' } };+ if (path.endsWith('/snapshot')) return snapshot();+ if (path.endsWith(`/messages/${id(20)}`)) return message(20);+ if (path.includes('/messages?')) return [{ ...message(21), threadRootId: id(20) }];+ return [];+ });+ let saved: ChatHistoryState | undefined;+ const history = createChatHistory({ api: request, current: () => true, newGeneration: () => 'topic',+ store: { read: async () => saved, write: async (_, state) => { saved = state ?? undefined; } } });+ const client = createChatServerClient(request, undefined, async () => history);+ const first = await client.load(id(1), undefined, id(20));+ request.mockClear();+ expect((await client.load(id(1), undefined, id(20))).messages).toEqual(first.messages);+ expect(first.messages.map(m => m.id)).toEqual([id(21), id(20)]);+ expect(request.mock.calls.every(([path]) => path.includes('/execution-failures?'))).toBe(true);+ });// #6907: existing fixtures never pair a human's group name A with account ownerName B (unit tier).it('keeps owner labels scoped to each group and follows refreshed names without changing identities', () => {const human = { ...snapshot().members[0], name: 'Nickname A' };diff --cc apps/mobile/src/chat/chatServerClient.tsindex 693964618c,f89f5c4b68..0f5cf701d3--- a/apps/mobile/src/chat/chatServerClient.ts+++ b/apps/mobile/src/chat/chatServerClient.ts@@@ -450,10 -456,11 +456,12 @@@ export function createChatServerClient(messages.push(...batch); before = next;}if (threadRootId) {- const root = await request<ChatMessage>(`/conversations/${room}/messages/${chatId(threadRootId)}`);+ const root = stored ? await stored.message<ChatMessage>(room, chatId(threadRootId))+ : await request<ChatMessage>(`/conversations/${room}/messages/${chatId(threadRootId)}`);messages.push(root);}+ // Use the same execution snapshot for running status and stop controls.+ const executions = await request<ChatExecution[]>(`/conversations/${room}/executions`);const executionFailures = await failures(room, messages);const projection = await stored?.projection<ChatMessage>(room, []);if (projection && snapshot.cacheGeneration !== projection.generation) {