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。

fix(history): 按原始读取上限继续扫描子任务详情

Dash4734e3aec2dd
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/historyViewReader.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/historyViewReader.test.ts
index 27a6bf25b6..cd29d9306c 100644
--- a/apps/desktop/src/main/localDb/ipc/__tests__/historyViewReader.test.ts
+++ b/apps/desktop/src/main/localDb/ipc/__tests__/historyViewReader.test.ts
@@ -365,7 +365,7 @@ describe('outline history reads', () => {
const source = [row(n++, 'user'),
{ ...row(n++, 'tool_use'), toolUseId: 'a', content: { toolName: 'Agent', input: { description: 'Full agent description' } } }];
if (resultOnly) source.push({ ...row(n++, 'tool_use'), toolUseId: 'child-call', content: { toolName: 'Bash', input: {} }, agentMeta: { parentUuid: 'a' } });
- for (let i = 0; i < (large ? 6 : 30); i++) {
+ for (let i = 0; i < (large ? 6 : 75); i++) {
source.push(resultOnly || liveTail ? row(n++) : { ...row(n++), agentMeta: { parentUuid: 'a' } });
source.push({ ...row(n++, 'assistant'), content: '# Result\n' + 'x'.repeat(large ? 200000 : 10), agentMeta: { turnCompleted: true } });
}
@@ -375,7 +375,8 @@ describe('outline history reads', () => {
if (!liveTail) source.push(tail);
if (newerTail) source.push(row(n++, 'user'));
const base = reader(source);
- const api = createHistoryViewReader({ list: base.list,
+ // readMessagesList clamps raw reads to 100 even when more rows are requested.
+ const api = createHistoryViewReader({ list: (sid, opts) => base.list(sid, { ...opts, limit: Math.min(opts.limit, 100) }),
...(outlined ? {
outline: async (sid: string, opts: { before?: string; after?: string; limit: number }) =>
(await base.list(sid, opts)).map((message) => message.role === 'tool_use'
diff --git a/apps/desktop/src/main/localDb/ipc/historyViewReader.ts b/apps/desktop/src/main/localDb/ipc/historyViewReader.ts
index 9e4fc15971..8508e30b03 100644
--- a/apps/desktop/src/main/localDb/ipc/historyViewReader.ts
+++ b/apps/desktop/src/main/localDb/ipc/historyViewReader.ts
@@ -330,15 +330,16 @@ export function createHistoryViewReader<T extends HistoryMessageSource>(deps: Hi
if (!first.id.startsWith('history-live:')) {
append([first]);
let cursor = first.id;
+ const limit = outlined ? 1000 : 100;
while (cursor !== (ref.lastStoredMessageId ?? last.id)) {
- const batch = (await read(sessionId, { limit: 1000, after: cursor }, true)).slice().reverse();
+ const batch = (await read(sessionId, { limit, after: cursor }, true)).slice().reverse();
if (!batch.length) break;
const bounded = batch.filter((row) => compareRows(row, last) <= 0);
append(bounded);
const next = batch.at(-1)!.id;
if (next === cursor) throwIpcError('INTERNAL', 'History detail cursor did not advance');
cursor = next;
- if (bounded.length < batch.length || batch.length < 1000) break;
+ if (bounded.length < batch.length || batch.length < limit) break;
}
}
for (const id of ref.liveMessageIds ?? []) {