Skip to content

fix(oauth): switch default model on explicit login#2156

Open
simonhx6 wants to merge 2 commits into
MoonshotAI:mainfrom
simonhx6:fix/oauth-login-provider-switch
Open

fix(oauth): switch default model on explicit login#2156
simonhx6 wants to merge 2 commits into
MoonshotAI:mainfrom
simonhx6:fix/oauth-login-provider-switch

Conversation

@simonhx6

Copy link
Copy Markdown

Related Issue

Resolves #2151

Problem

After switching from Kimi Code OAuth to an API key, selecting Kimi Code OAuth from /login in a new session can leave the API key model as the default. The login appears successful, but requests continue to use the API key until the user logs out first.

What changed

  • Preserve the current default during an explicit OAuth login only when it is still a valid managed Kimi Code model.
  • Replace a non-managed API default when the user explicitly selects Kimi Code OAuth.
  • Keep background model refresh behavior unchanged so it does not replace defaults from other providers.
  • Add OAuth toolkit and SDK regression coverage for the persisted-token scenario while verifying that the existing API provider configuration is retained.
  • Add patch changesets for the CLI and SDK. No public API signatures were changed.

Verification

  • vitest run packages/oauth/test/toolkit.test.ts packages/oauth/test/managed-kimi-code.test.ts packages/node-sdk/test/auth-facade.test.ts — 84 tests passed.
  • pnpm run build
  • pnpm run lint
  • pnpm run sherif
  • CI-equivalent tsgo checks for the OAuth and SDK packages.

No documentation update is needed because this fix restores the existing provider-selection behavior and introduces no new command, option, or configuration.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43e4926b05

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/oauth/src/toolkit.ts Outdated
@changeset-bot

changeset-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 059cbe2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/kimi-code Patch
@moonshot-ai/kimi-code-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/login does not switch the default model back to Kimi Code OAuth when an API-key model is active

1 participant