Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(chat): 修复自动任务重复回复与远程残留气泡
Dash8f17cd43c172
diff --git a/apps/desktop/src/main/scheduler-host/__tests__/runnerSilentNotify.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/runnerSilentNotify.test.tsindex 52259b951d..5196fc3bfa 100644--- a/apps/desktop/src/main/scheduler-host/__tests__/runnerSilentNotify.test.ts+++ b/apps/desktop/src/main/scheduler-host/__tests__/runnerSilentNotify.test.ts@@ -254,6 +254,24 @@ describe('MakerScheduleRunner silent-run notification skip', () => {},);+ it.each(['', ' \n'])(+ 'does not replay commentary after an empty final message (%j)',+ async (emptyFinal) => {+ const h = createSessionHarness(acceptingSend());+ const { runner, notifier } = createRunnerHarness(h.session, { silenced: true });+ const pending = runner.fire(baseSchedule({ silentWhenIdle: true }), createFireContext());+ await vi.waitFor(() => expect(mocks.createMessage).toHaveBeenCalled());+ h.emit({ type: 'text', data: { text: 'Checking the PR.', isFinal: true, phase: 'commentary' } });+ // Codex emits the empty final item, then done falls back to its last+ // nonempty assistant item. That commentary already belongs to the transcript.+ h.emit({ type: 'text', data: { text: emptyFinal, isFinal: true, phase: 'final_answer' } });+ h.emit({ type: 'done', data: { result: 'Checking the PR.' } });+ await expect(pending).resolves.toMatchObject({ resultText: 'Checking the PR.' });+ expect(mocks.createMessage.mock.calls.filter(([, body]) => body.role === 'assistant')).toHaveLength(0);+ expect(notifier.notify).not.toHaveBeenCalled();+ },+ );+it.each([true, false].flatMap((silenced) =>['result', 'finalText'].map((field) => ({ silenced, field })),diff --git a/apps/desktop/src/main/scheduler-host/runner.ts b/apps/desktop/src/main/scheduler-host/runner.tsindex 31f52c1a4d..6d75265f2b 100644--- a/apps/desktop/src/main/scheduler-host/runner.ts+++ b/apps/desktop/src/main/scheduler-host/runner.ts@@ -3104,6 +3104,10 @@ export class MakerScheduleRunner implements ScheduleRunner {if (ev.type === 'text') {const data = ev.data as { text?: string; isFinal?: boolean } | null;if (data && typeof data.text === 'string') {+ // Empty final items do not replace a visible transcript message.+ // Codex's done may fall back to its last nonempty commentary; keep+ // that streamed text so finalizeRun does not persist it a second time.+ if (data.isFinal && !data.text.trim()) return;if (data.text.trim()) finalTextMatchesStream = true;if (data.isFinal) assistantText = data.text;else assistantText += data.text;diff --git a/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.ts b/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.tsindex 905dd1e760..d6776adcbf 100644--- a/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.ts+++ b/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.ts@@ -408,6 +408,38 @@ 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 () => {+ const s = sid();+ host.enableHistoryView();+ host.seedSession(s);+ remoteProjectsStore.setDeviceSessions(DEVICE_ID, 'Mac A', [{ id: s } as Session]);+ makerChatStore.enterView(s);+ makerChatStore.ensureInitialMessages(s);+ await flush(); await flush();+ const queued = {+ clientId: 'scheduled-input', text: 'Check the PR', persistedContent: 'Check the PR',+ chatMessage: { clientId: 'scheduled-input', role: 'user', content: 'Check the PR', createdAt: '2026-09-17T00:00:00Z' },+ };+ host.push('maker:input:projection', { ...emptyProjection(s), pendingQueue: [queued] });+ 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, {+ ...dbMessage(s, 'scheduled-db', 'Check the PR', '2026-09-17T00:00:00Z', 'user'),+ clientId: queued.clientId, agentMeta: { origin },+ }, { lossy: true });+ await getRemoteHistoryView(s)!.refresh();+ const rows = makerChatStore.getSnapshot(s).messages;+ expect(rows).toHaveLength(1);+ expect(rows[0]).toMatchObject({ automationOrigin: origin });+ expect(rows[0].isPendingPersist).toBeUndefined();+ expect(rows[0].localSendPrecedingClientIds).toBeUndefined();+ makerChatStore.purgeSession(s);+ });+it('reserves a queued send whose DB echo beats the dispatch projection', async () => {const s = sid();host.enableHistoryView();diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 53ab032664..13fe0e57e3 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -4544,6 +4544,10 @@ function applyInputProjection(const currentSteeringIds = new Set(projection.steeringQueueClientIds);const settlingQueueItems = s.pendingQueue.filter((item, index) => {if (!remoteProjection) return false;+ // Only this controller's sends have an outbox record that can reconcile a+ // missing DB echo. Scheduler/IM/other-device queue entries may disappear+ // through cancellation too; let durable history introduce those messages.+ if (!optimisticRecords?.has(item.clientId)) return false;if (persistedMessageIds.has(item.clientId)) return false;if (currentQueueIds.has(item.clientId)) return false;if (locallyRemoved?.has(item.clientId)) return false;