Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(codex): preserve implicit OAuth thread identity

Cindydccb08ba922d
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts
index 3eaf82ab65..9d6738fb52 100644
--- a/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/codexCredentialSwitch.test.ts
@@ -195,6 +195,21 @@ describe('shouldCloseSessionForCredentialSwitch codex mode', () => {
expect(shouldCloseSessionForCredentialSwitch(input)).toBe(false);
});
+ it('keeps a raw OpenAI identity for the implicit OAuth route', () => {
+ const input = {
+ agentKind: 'codex',
+ currentProviderId: null,
+ nextProviderId: null,
+ currentModel: 'gpt-5.4',
+ nextModel: 'gpt-5.5',
+ currentCodexProxyActive: true,
+ currentCodexThreadModelProviderId: 'openai',
+ codexAuthInjection: 'oauth-bearer',
+ } as const;
+ expect(isCodexThreadModelProviderIdentityMismatch(input)).toBe(false);
+ expect(shouldCloseSessionForCredentialSwitch(input)).toBe(false);
+ });
+
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.ts
index 8e7429b852..b60dda16b9 100644
--- a/apps/desktop/src/main/maker-host/codex-credential-switch.ts
+++ b/apps/desktop/src/main/maker-host/codex-credential-switch.ts
@@ -222,7 +222,10 @@ export function isCodexThreadModelProviderIdentityMismatch(
const actualMatchesTargetLogicalProvider =
actualThreadModelProviderId !== null &&
(actualThreadModelProviderId === nextProviderId ||
- actualThreadModelProviderId === targetCatalogId);
+ actualThreadModelProviderId === targetCatalogId ||
+ (nextProviderId === null &&
+ effectiveNextMode === 'oauth-bearer' &&
+ actualThreadModelProviderId === 'openai'));
// 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