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。

test(mobile): preserve live execution reads in topic cache regression

ylliuuu662d102e15fb0e
diff --git a/apps/mobile/src/__tests__/chatServerClient.test.ts b/apps/mobile/src/__tests__/chatServerClient.test.ts
index 4b1b6b300c..be3ec75bc9 100644
--- a/apps/mobile/src/__tests__/chatServerClient.test.ts
+++ b/apps/mobile/src/__tests__/chatServerClient.test.ts
@@ -39,11 +39,13 @@ it('retains fresh executions when cached history changes during load', async ()
});
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 () => {
+ // Unit: reuse cached topic history, but refresh live execution state on every open.
+ it('reuses the durable root and reply page while refreshing executions when reopening a topic', async () => {
+ let executionStatus = 'running';
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('/executions')) return [{ id: id(30), bot_id: id(12), status: executionStatus, epoch: 1, source_message_id: id(20) }];
if (path.endsWith(`/messages/${id(20)}`)) return message(20);
if (path.includes('/messages?')) return [{ ...message(21), threadRootId: id(20) }];
return [];
@@ -53,10 +55,18 @@ describe('direct Chat Server client', () => {
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));
+ expect(chatGroupView(first, id(10)).round.speakers).toMatchObject([{ executionId: id(30), executionStatus: 'running' }]);
+ executionStatus = 'stopping';
request.mockClear();
- expect((await client.load(id(1), undefined, id(20))).messages).toEqual(first.messages);
+ const reopened = await client.load(id(1), undefined, id(20));
+ expect(reopened.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);
+ expect(chatGroupView(reopened, id(10)).round.speakers).toMatchObject([{ executionId: id(30), executionStatus: 'stopping' }]);
+ // Exactly the two live-state reads: no repeated snapshot, root or reply-page download.
+ expect(request.mock.calls.map(([path]) => path)).toEqual([
+ `/conversations/${id(1)}/executions`,
+ expect.stringContaining(`/conversations/${id(1)}/execution-failures?`),
+ ]);
});
// #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', () => {