Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(local-agent): 保持发送结果校验与负载通知兼容
DavidShendc05a143bda1
diff --git a/apps/desktop/src/main/local-agent/__tests__/runtime.integration.test.ts b/apps/desktop/src/main/local-agent/__tests__/runtime.integration.test.tsindex bce9b9ff0f..c7d22d54f0 100644--- a/apps/desktop/src/main/local-agent/__tests__/runtime.integration.test.ts+++ b/apps/desktop/src/main/local-agent/__tests__/runtime.integration.test.ts@@ -351,10 +351,13 @@ describe('local client runtime lifecycle', () => {);expect(third.send).toHaveBeenCalledTimes(1);});- it('releases the execution when the engine declines a send before dispatch', async () => {- const f = await fixture();- f.first.send.mockResolvedValueOnce({ accepted: false });+ it.each(['declines', 'rejects'] as const)('releases execution and reports settled load when the engine %s a send', async (outcome) => {+ const changed = vi.fn();+ const f = await fixture({ trackLoad: () => changed });+ if (outcome === 'declines') f.first.send.mockResolvedValueOnce({ accepted: false });+ else f.first.send.mockRejectedValueOnce(new Error('fixture engine unavailable'));await f.runtime.call('send', message);+ await vi.waitFor(() => expect(changed).toHaveBeenCalledTimes(2));await vi.waitFor(() => expect(f.runtime.call('send', message)).resolves.toEqual({}));expect(f.first.send).toHaveBeenCalledTimes(2);});diff --git a/apps/desktop/src/main/local-agent/runtime.ts b/apps/desktop/src/main/local-agent/runtime.tsindex b90440cf27..5ebcacc2d5 100644--- a/apps/desktop/src/main/local-agent/runtime.ts+++ b/apps/desktop/src/main/local-agent/runtime.ts@@ -504,12 +504,13 @@ export async function openLocalAgentRuntime(releaseInputs();turnInputs.push(sending);void (async () => {- const sent = handle.send(sending);- // Session reserves the turn synchronously, even if the engine has no output yet.- notifyLoad();- const result = await sent.finally(() => notifyLoad());- if (!result.accepted) await discard(sending);- assertSendDispatched(result, 'local-agent/send');+ try {+ const result = await handle.send(sending);+ if (!result.accepted) await discard(sending);+ assertSendDispatched(result, 'local-agent/send');+ } finally {+ notifyLoad();+ }})().catch(() => {if (closed || turn !== generation) return;if (epoch === current) {@@ -520,6 +521,8 @@ export async function openLocalAgentRuntime(projection.fail('', 'interrupted');}});+ // send reserves the turn before its first await, even without engine output.+ notifyLoad();return {};} catch (error) {if (epoch === current) {