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(desktop): guard search context prefetch budget

ficowang01117ac670fa
diff --git a/apps/desktop/src/main/localDb/__tests__/remoteHistoryPagination.test.ts b/apps/desktop/src/main/localDb/__tests__/remoteHistoryPagination.test.ts
index e5b7155cec..8d48cc9fb0 100644
--- a/apps/desktop/src/main/localDb/__tests__/remoteHistoryPagination.test.ts
+++ b/apps/desktop/src/main/localDb/__tests__/remoteHistoryPagination.test.ts
@@ -230,11 +230,21 @@ describe.each(modes)('%s remote history visibility', (mode) => {
} });
let cursor: string | undefined;
for (let i = 0; i < 3; i++) {
+ const queries = vi.spyOn(state.client, 'query');
const page = historyPayload(await registry.call('search_chat_history', {
query: 'budgetneedle', limit: 10, context_radius: radius, ...(cursor ? { cursor } : {}),
})) as any;
+ const contextQueries = queries.mock.calls.filter(([sql]) => String(sql).includes('_anchorOrder'));
+ queries.mockRestore();
expect(page.hits).toHaveLength(1);
expect(page.hits[0].context.find((row: any) => row.isHit).content).toBe(text);
+ if (radius === 2) {
+ expect(contextQueries).toHaveLength(1);
+ const contextParams = (contextQueries[0][1] ?? []) as unknown[];
+ expect(new Set(contextParams.filter((value): value is string =>
+ typeof value === 'string' && ids.includes(value),
+ )).size).toBe(1);
+ }
found.push(page.hits[0].messageId);
expect(page.hasMore).toBe(i < 2);
if (page.nextCursor !== null) { expect(page.nextCursor).not.toBe(cursor); cursor = page.nextCursor; }