Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(codex): rebuild threads when switching into Cindy
Cindy9d66573a6572
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.tsindex 332757d27a..7d3ec852f1 100644--- a/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts@@ -137,6 +137,24 @@ describe('shouldCloseSessionForCredentialSwitch codex mode', () => {expect(shouldCloseSessionForCredentialSwitch(input)).toBe(false);});+ it('rebuilds when the live thread reports a non-Cindy provider before switching to Cindy', () => {+ // Older app-server/provider combinations report `openai` or a vendor id+ // instead of Cindy's cindy_* aliases. That is still a sticky thread+ // identity; hot-switching would reuse response items that the Cindy route+ // cannot resolve (`Item ... not found`, store=false).+ const input = {+ agentKind: 'codex',+ currentProviderId: 'openai',+ nextProviderId: 'xd',+ currentModel: 'gpt-5.4',+ nextModel: 'codex/gpt-5.5',+ currentCodexProxyActive: true,+ currentCodexThreadModelProviderId: 'openai',+ } as const;+ expect(isCodexThreadModelProviderIdentityMismatch(input)).toBe(true);+ expect(shouldCloseSessionForCredentialSwitch(input)).toBe(true);+ });+it('still closes a gateway Codex session when switching to OAuth on a proxy-active host', () => {expect(shouldCloseSessionForCredentialSwitch({agentKind: 'codex',diff --git a/apps/desktop/src/main/maker-host/codex-credential-switch.ts b/apps/desktop/src/main/maker-host/codex-credential-switch.tsindex c46f9c6af1..b3d988305b 100644--- a/apps/desktop/src/main/maker-host/codex-credential-switch.ts+++ b/apps/desktop/src/main/maker-host/codex-credential-switch.ts@@ -15,7 +15,10 @@ import {CODEX_GATEWAY_PROVIDER_ID,CODEX_OPENAI_COMPACT_PROVIDER_ID,} from './codex-gateway-config.js';-import { crossesCodexAppliedCustomProviderIdentity } from './codex-custom-provider-route.js';+import {+ crossesCodexAppliedCustomProviderIdentity,+ isAppliedCodexCustomProviderIdentity,+} from './codex-custom-provider-route.js';import type { CodexProxyAuthInjection } from './codex-proxy-host.js';import { withRehydrateCloseSuppressed } from './rehydrateCloseSuppression.js';import { getActiveCatalog } from './active-catalog.js';@@ -204,13 +207,18 @@ export function isCodexThreadModelProviderIdentityMismatch(? CODEX_GATEWAY_PROVIDER_ID: null;const actualThreadModelProviderId = normalizeProviderId(input.currentCodexThreadModelProviderId);- const actualThreadIdentityKnown =- actualThreadModelProviderId === CODEX_OPENAI_COMPACT_PROVIDER_ID ||- actualThreadModelProviderId === CODEX_CINDY_COMPACT_PROVIDER_ID ||- actualThreadModelProviderId === CODEX_GATEWAY_PROVIDER_ID;-+ const actualIsAppliedCustomProviderIdentity = isAppliedCodexCustomProviderIdentity(+ actualThreadModelProviderId,+ );+ // The app-server may report a provider id that is not one of Cindy's+ // materialized identities (for example `openai`, Azure, or a custom provider).+ // It is still a sticky thread identity. Treating those ids as unknown lets a+ // live thread cross into the Cindy gateway and keeps sending old response-item+ // ids to the new route, which fails with `Item ... not found` when `store=false`.+ // A missing id is the only case where there is no identity to compare.return (- actualThreadIdentityKnown &&+ !actualIsAppliedCustomProviderIdentity &&+ actualThreadModelProviderId !== null &&expectedThreadModelProviderId !== null &&actualThreadModelProviderId !== expectedThreadModelProviderId);diff --git a/apps/desktop/src/main/maker-host/codex-custom-provider-route.ts b/apps/desktop/src/main/maker-host/codex-custom-provider-route.tsindex d1159ac6b1..64a1dbfeaa 100644--- a/apps/desktop/src/main/maker-host/codex-custom-provider-route.ts+++ b/apps/desktop/src/main/maker-host/codex-custom-provider-route.ts@@ -265,6 +265,14 @@ export function crossesCodexAppliedCustomProviderIdentity(: actualIsAppliedCustomProviderIdentity || actualIsRetiredPrototypeIdentity;}+/** Whether a thread provider id belongs to the currently applied dynamic route set. */+export function isAppliedCodexCustomProviderIdentity(providerId: string | null | undefined): boolean {+ const actual = providerId?.trim() || null;+ return actual !== null && appliedCustomProviderRoutes.some(+ (route) => route.modelProviderId === actual,+ );+}+export function buildCodexCustomProviderArgs(proxyEndpoint: string,authMode: CodexProxySpawnAuthMode,