Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): retain paused bot model saves until resume
ylliuuu6604858b0c81f9
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.tsindex e415a2d2c1..82d6a40e03 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts@@ -12,7 +12,7 @@ function harness() {current: { agentKind: 'pi' as const, model: 'glm', providerId: 'xd', effort: 'high', fastMode: false },hasRuntimeOverride: false,};- const read = vi.fn(async () => state);+ const read = vi.fn<Parameters<typeof createBotModelRouteReconciler>[0]['read']>(async () => state);const apply = vi.fn<Parameters<typeof createBotModelRouteReconciler>[0]['apply']>(async () => undefined);const onSelectionAccepted = vi.fn(async (_id: string) => {});const reconcile = createBotModelRouteReconciler({ ownerEpoch: () => owner, read, apply, onSelectionAccepted });@@ -352,3 +352,46 @@ it('keeps the baseline when a newer explicit save fails after an ordinary reconcawait h.scope.restore('canonical', 'automation');expect(h.state.current.model).toBe('new-permanent');});++// A paused Bot is absent from the production apply reader, but its settings+// can still save a permanent selection. Resume must accept that selection+// before the next IM restores a surviving automation baseline.+it.each([true, false])('retains a paused save until resume (already current: %s)', async alreadyCurrent => {+ const h = automationHarness();+ let paused = true;+ h.read.mockImplementation(async (_id, purpose) => paused && purpose === 'apply' ? null : h.state);+ h.state.hasRuntimeOverride = true;+ if (alreadyCurrent) {+ h.state.current = { agentKind: 'codex', model: 'luna', providerId: 'xd', effort: 'medium', fastMode: false };+ }+ const baseline = h.baseline();+ await h.reconcile.profileChanged('canonical');+ await h.reconcile('canonical');+ await h.reconcile.preview('canonical');+ expect(h.apply).not.toHaveBeenCalled();+ expect(h.onSelectionAccepted).not.toHaveBeenCalled();+ expect(h.baseline()).toBe(baseline);+ paused = false;+ await h.reconcile('canonical');+ await h.scope.restore('canonical', 'automation');+ expect(h.state.current.model).toBe('luna');+ expect(h.baseline()).toBeNull();+ expect(h.onSelectionAccepted).toHaveBeenCalledOnce();+ expect(h.apply).toHaveBeenCalledTimes(alreadyCurrent ? 0 : 1);+});++it('retries a paused save after its first resumed route fails without losing the baseline', async () => {+ const h = automationHarness();+ h.state.hasRuntimeOverride = true;+ h.read.mockResolvedValueOnce(null);+ const baseline = h.baseline();+ await h.reconcile.profileChanged('canonical');+ h.apply.mockRejectedValueOnce(new Error('provider unavailable'));+ await expect(h.reconcile('canonical')).rejects.toThrow('provider unavailable');+ expect(h.baseline()).toBe(baseline);+ expect(h.onSelectionAccepted).not.toHaveBeenCalled();+ await h.reconcile('canonical');+ await h.scope.restore('canonical', 'automation');+ expect(h.state.current.model).toBe('luna');+ expect(h.baseline()).toBeNull();+});diff --git a/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts b/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.tsindex 70006a8ffc..70cf904e60 100644--- a/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts+++ b/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts@@ -81,7 +81,9 @@ export function createBotModelRouteReconciler(deps: {if (deps.ownerEpoch() !== epoch) throw new Error('Bot model route owner changed');if ((revisions.get(sessionId) ?? 0) !== revision) continue;if (!state) {- configured.delete(sessionId);+ // Paused profiles are absent from the apply reader. Keep an explicit+ // save pending until resume can accept it and invalidate the scope.+ if (configured.get(sessionId) !== '') configured.delete(sessionId);return;}if (!state.chain.length) {