Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 回复数不变时话题预览仍先取窗口里的新回复
Dashdf712c49e005
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerThreads.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerThreads.test.tsindex 22330610c9..59a66e85cb 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerThreads.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerThreads.test.ts@@ -98,6 +98,18 @@ describe('thread previews', () => {expect(io.threadPage).toHaveBeenCalledTimes(3);});+ it('shows a new reply in the window even when a deletion keeps the reply count unchanged', async () => {+ const root = message({ id: rootB, replyCount: 3 });+ io.threadPage.mockResolvedValue([reply('b3', rootB), reply('b2', rootB), reply('b1', rootB)]);+ projection.previews(room, [root], fullWindow([]));+ await projection.settled();+ // An older reply is deleted while b4 arrives: still three replies.+ const newest = reply('b4', rootB);+ const previews = projection.previews(room, [root], fullWindow([newest]));+ expect(previews.get(rootB)!.map(m => m.id)).toEqual(['b3', 'b4']);+ expect(io.threadPage).toHaveBeenCalledTimes(1);+ });+it('bounds concurrent reads and backs off a failed thread instead of failing the room', async () => {vi.useFakeTimers({ toFake: ['Date'] });let active = 0, peak = 0;diff --git a/apps/desktop/src/main/maker-ipc/chatServerThreads.ts b/apps/desktop/src/main/maker-ipc/chatServerThreads.tsindex 9ab2cf27fc..81a46bbc93 100644--- a/apps/desktop/src/main/maker-ipc/chatServerThreads.ts+++ b/apps/desktop/src/main/maker-ipc/chatServerThreads.ts@@ -145,6 +145,7 @@ export function createThreadProjection<M extends ThreadMessage>(io: {}const result = new Map<string, M[]>();const missing: Array<{ cacheKey: string; item: M }> = [];+ const windowStart = snapshot.reduce<bigint | null>((min, message) => min === null || BigInt(message.seq) < min ? BigInt(message.seq) : min, null);for (const root of page) {const count = root.replyCount ?? 0;if (root.threadRootId || count <= 0) continue;@@ -153,7 +154,10 @@ export function createThreadProjection<M extends ThreadMessage>(io: {const cached = previews.get(cacheKey);// The window is a suffix of the room's sequence, so what it holds is the newest.if (complete || found.length >= Math.min(count, BOT_GROUP_THREAD_PREVIEW_REPLIES)) result.set(root.id, found);- else if (cached?.replyCount === count) result.set(root.id, cached.replies);+ // A same count can hide a new reply beside a deleted old one: what the window holds+ // comes first, and the cached page only fills in below it.+ else if (cached?.replyCount === count) result.set(root.id, [...found,+ ...cached.replies.filter(reply => windowStart === null || BigInt(reply.seq) < windowStart)]);else if (!waiting(cacheKey)) missing.push({ cacheKey, item: root });}fill(roomId, missing, async root => {