Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(chat): 远程外部指令离队后核对正式历史
Dashf8f0c2a2aa8c
diff --git a/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.ts b/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.tsindex d6776adcbf..308c904ce0 100644--- a/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.ts+++ b/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.ts@@ -408,7 +408,7 @@ describe('device-link controller mirror — end-to-end scenarios', () => {makerChatStore.purgeSession(s);});- it('does not turn an external queue departure into a local pending bubble', async () => {+ it.each([false, true])('reconciles an external queue departure without a local pending bubble (persisted=%s)', async (persisted) => {const s = sid();host.enableHistoryView();host.seedSession(s);@@ -424,15 +424,20 @@ describe('device-link controller mirror — end-to-end scenarios', () => {expect(makerChatStore.getSnapshot(s).pendingQueue).toHaveLength(1);// The queue may be cancelled or its DB push may be lost. Neither proves a// local send; only authoritative history may introduce the scheduled row.- host.push('maker:input:projection', emptyProjection(s));- expect(makerChatStore.getSnapshot(s).messages).toEqual([]);const origin = { kind: 'scheduler' as const, scheduleId: 'schedule', scheduleName: 'PR check', runId: 'run' };- host.hostMessage(s, {+ if (persisted) host.hostMessage(s, {...dbMessage(s, 'scheduled-db', 'Check the PR', '2026-09-17T00:00:00Z', 'user'),clientId: queued.clientId, agentMeta: { origin },}, { lossy: true });- await getRemoteHistoryView(s)!.refresh();+ host.push('maker:input:projection', emptyProjection(s));+ expect(makerChatStore.getSnapshot(s).messages).toEqual([]);+ await flush(); await flush();const rows = makerChatStore.getSnapshot(s).messages;+ if (!persisted) {+ expect(rows).toEqual([]);+ makerChatStore.purgeSession(s);+ return;+ }expect(rows).toHaveLength(1);expect(rows[0]).toMatchObject({ automationOrigin: origin });expect(rows[0].isPendingPersist).toBeUndefined();diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 13fe0e57e3..f64898cd7c 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -4502,6 +4502,7 @@ function applyInputProjection(}}let settlingClientIds: string[] = [];+ let externalQueueDeparted = false;let locallyDispatchedQueueItems: QueuedMessage[] = [];const deferredPersistFromProjection: {payload: {@@ -4532,6 +4533,11 @@ function applyInputProjection(// 队首连续出队 / steer 标记才进入 settling;中段删除不制造幽灵气泡。const currentQueueIds = new Set(pendingQueue.map((item) => item.clientId));+ externalQueueDeparted = remoteProjection && s.pendingQueue.some(+ (item) => !optimisticRecords?.has(item.clientId)+ && !currentQueueIds.has(item.clientId)+ && !persistedMessageIds.has(item.clientId),+ );let vanishedPrefixEnd = 0;while (vanishedPrefixEnd < s.pendingQueue.length &&@@ -4714,6 +4720,13 @@ function applyInputProjection(for (const clientId of settlingClientIds) {scheduleRemoteOptimisticSettlingRetirement(projection.sessionId, clientId);}+ if (externalQueueDeparted) {+ // A departure may be cancellation or a dispatch whose DB push was lost.+ // Reuse history reconciliation without inventing a local pending row.+ void reconcileRemoteMessages(projection.sessionId).catch((error) => {+ log.warn('remote queue departure reconciliation failed:', error);+ });+ }if (optimisticRecords) {const current = getOrCreateState(projection.sessionId);for (const [clientId, record] of optimisticRecords) {