Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bot): reconcile equal model chains after restoring defaults
xuzini-xzncfd292395d71
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.tsindex eb3426427a..eff6cb1d56 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts@@ -93,6 +93,26 @@ describe('permanent Bot model selection', () => {await reconcile('canonical');expect(h.apply).not.toHaveBeenCalled();});+ it.each([+ { followsCindyDefault: true, pending: false },+ { followsCindyDefault: true, pending: true },+ { followsCindyDefault: false, pending: false },+ { followsCindyDefault: false, pending: true },+ ])('applies an equal chain after changing its configuration source (default=$followsCindyDefault, pending=$pending)', async ({ followsCindyDefault, pending }) => {+ const h = harness();+ h.state.hasRuntimeOverride = true;+ h.state.followsCindyDefault = !followsCindyDefault;+ if (pending) h.state.next = { ...h.state.current, model: 'pending-fallback' };+ await h.reconcile('canonical');+ expect(h.apply).not.toHaveBeenCalled();+ // Global Restore defaults changes this flag even when the recommended chain+ // equals the saved custom chain; no per-profile invalidation is emitted.+ h.state.followsCindyDefault = followsCindyDefault;+ const expected = expect.objectContaining({ agentKind: 'codex', model: 'luna' });+ await expect(h.reconcile.preview('canonical')).resolves.toEqual(expected);+ await h.reconcile('canonical');+ expect(h.apply).toHaveBeenCalledExactlyOnceWith('canonical', expected, h.state.current);+ });it('reads a changed default after acquiring the ordinary send lock without deadlocking a lock holder', async () => {const h = harness();const reconcile = createBotModelRouteReconciler({ ownerEpoch: () => 'owner', read: h.read, apply: h.apply, withSessionLock: withSendToSessionLock });diff --git a/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts b/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.tsindex 32a8785d2e..6c16b83f00 100644--- a/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts+++ b/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts@@ -23,13 +23,18 @@ interface BotRouteState {next?: RuntimeRoute;}+function configuredKey(state: BotRouteState, chain = state.chain): string {+ // Restore defaults is a configuration change even when its routes are equal.+ return JSON.stringify([chain, state.followsCindyDefault === true]);+}+function configuredRoute(state: BotRouteState,previous: string | undefined,chain = state.chain,): RuntimeRoute | null {- const key = JSON.stringify(chain);- const isDraftChange = key !== JSON.stringify(state.chain);+ const key = configuredKey(state, chain);+ const isDraftChange = JSON.stringify(chain) !== JSON.stringify(state.chain);// An automation owns its temporary route until ordinary input restores it.// This also applies to companions following Cindy defaults and after restart.if (!isDraftChange && parseScheduledModelBaseline(state.scheduledModelBaseline) && (previous === undefined || previous === key)) return null;@@ -127,7 +132,7 @@ export function createBotModelRouteReconciler(deps: {// A temporary loss of model visibility must not erase that baseline.throwIpcError('PRECONDITION_FAILED', '请先选择已开启的伙伴模型');}- const key = JSON.stringify(state.chain);+ const key = configuredKey(state);const previous = parseScheduledModelBaseline(state.scheduledModelBaseline)?.pendingBotProfileVersion? '' : configured.get(sessionId);const route = configuredRoute(state, previous);