Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(update): 复用已在进行的重启前也核对确认版本
Dash509962c4b129
diff --git a/apps/desktop/src/main/__tests__/updateService.test.ts b/apps/desktop/src/main/__tests__/updateService.test.tsindex aa0021ccc0..6507364762 100644--- a/apps/desktop/src/main/__tests__/updateService.test.ts+++ b/apps/desktop/src/main/__tests__/updateService.test.ts@@ -578,6 +578,32 @@ describe('agent-facing managed app update check', () => {}});+ it('treats a relaunch already under way as this install only for the confirmed version', async () => {+ // Idle auto-install is on and starts applying 0.0.65 as soon as it is staged.+ readAutoUpdateSettings.mockReturnValue({ autoRelaunchOnIdle: true });+ download.mockImplementation(async ({ targetPath }: { targetPath: string }) => {+ fs.mkdirSync(path.dirname(targetPath), { recursive: true });+ fs.writeFileSync(targetPath, 'update');+ return { path: targetPath, size: 123 };+ });+ const exitSpy = vi.spyOn(process, 'exit').mockImplementation((() => undefined) as never);+ const service = await freshUpdateService('darwin');+ try {+ expect(await service.checkForUpdate()).toBe('ready');+ await vi.waitFor(() => { expect(spawnProcess).toHaveBeenCalledOnce(); });+ const beforeRelaunch = vi.fn(async () => true);+ await expect(service.applyConfirmedAppUpdateForAgent({ expectedVersion: '0.0.66', beforeRelaunch }))+ .resolves.toMatchObject({ status: 'failed', errorCode: 'version_changed', stagedVersion: '0.0.65' });+ await expect(service.applyConfirmedAppUpdateForAgent({ expectedVersion: '0.0.65', beforeRelaunch }))+ .resolves.toEqual({ status: 'relaunching', targetVersion: '0.0.65' });+ expect(beforeRelaunch).not.toHaveBeenCalled();+ expect(spawnProcess).toHaveBeenCalledOnce();+ } finally {+ service.stopUpdateService();+ exitSpy.mockRestore();+ }+ });+it('does not relaunch when the download fails or the build is unsupported', async () => {download.mockRejectedValue(new Error('network'));const service = await freshUpdateService('darwin');diff --git a/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.tsindex 84ed0dfad7..03fdb3c8a2 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts@@ -1875,6 +1875,22 @@ describe('AgentInputCoordinator send transaction', () => {expect(h.coordinator.isActiveInputOwnerAuthored(sid)).toBe(false);});+ it('judges owner authority by the latest accepted steer, in both directions', async () => {+ const h = createHarness(), sid = 'owner-authority-steer';+ h.sendToAgent.mockImplementationOnce(async () => { h.setRunning(true); return sendSuccess(); });+ h.coordinator.enqueue(sid, { ...makeItem('typed', 'Update Cindy'), autoReviewUserText: 'Update Cindy' });+ await flush();+ expect(h.coordinator.isActiveInputOwnerAuthored(sid)).toBe(true);+ await h.coordinator.steer(sid, {+ ...makeItem('from-task', 'please update'),+ autoReviewUserText: 'please update',+ origin: { kind: 'session', senderSessionId: 'other', displayText: 'please update' },+ } as AgentInputQueuedMessage);+ expect(h.coordinator.isActiveInputOwnerAuthored(sid)).toBe(false);+ await h.coordinator.steer(sid, { ...makeItem('typed-again', 'Yes, update'), autoReviewUserText: 'Yes, update' });+ expect(h.coordinator.isActiveInputOwnerAuthored(sid)).toBe(true);+ });+it('keeps accepted plugin authority through pending and rejected human steering', async () => {const h = createHarness(), sid = 'accepted-plugin-authority';h.sendToAgent.mockImplementationOnce(async () => { h.setRunning(true); return sendSuccess(); });diff --git a/apps/desktop/src/main/updateService.ts b/apps/desktop/src/main/updateService.tsindex 6383f4b3c5..bc129ef759 100644--- a/apps/desktop/src/main/updateService.ts+++ b/apps/desktop/src/main/updateService.ts@@ -2208,7 +2208,11 @@ export async function applyConfirmedAppUpdateForAgent(options: {: null;const unsupported = agentUpdateUnsupportedReason();if (unsupported) return { status: 'failed', reason: unsupported, errorCode: 'unsupported' };- if (isRelaunching || autoRelaunchInProgress) return { status: 'relaunching', targetVersion: readyVersion };+ // A relaunch already under way (Settings banner or idle auto-install) only+ // counts as this install when it applies the confirmed version.+ if (isRelaunching || autoRelaunchInProgress) {+ return versionChanged() ?? { status: 'relaunching', targetVersion: readyVersion };+ }if (currentStatus !== 'ready') {const result = await checkForUpdate();if (result !== 'ready') {@@ -2220,7 +2224,10 @@ export async function applyConfirmedAppUpdateForAgent(options: {if (!await options.beforeRelaunch()) {return { status: 'failed', reason: '更新已下载,但本次没有重启。', errorCode: 'relaunch_cancelled' };}- if (isRelaunching || autoRelaunchInProgress) return { status: 'relaunching', targetVersion: readyVersion };+ // Same rule for a relaunch that started during the wait.+ if (isRelaunching || autoRelaunchInProgress) {+ return versionChanged() ?? { status: 'relaunching', targetVersion: readyVersion };+ }if (currentStatus !== 'ready' || !readyVersion) {return { status: 'failed', reason: '已下载的更新不再可用,请重新检查更新。', errorCode: 'not_ready' };}