Skip to content

fix(cli): keep the saved default model across custom registry re-imports - #3746

Open
he-yufeng wants to merge 1 commit into
MoonshotAI:mainfrom
he-yufeng:fix/registry-reimport-keeps-default
Open

he-yufeng wants to merge 1 commit into
MoonshotAI:mainfrom
he-yufeng:fix/registry-reimport-keeps-default

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Fixes #3739.

What

Re-importing a custom registry (kimi provider add <registry-url>) replaces every stale provider through the removal cascade, which clears default_model when it dangles. The batch removal in handleProviderAdd never captured the previous value, and the final setConfig did not carry defaultModel either, so a refresh that still lists the model silently wiped the user's saved default.

How

  • Capture previousDefaultModel before the batch removal.
  • After the apply loop, restore it only when its alias still resolves (config.models?.[previousDefaultModel]), and pass defaultModel in the final setConfig. A registry that genuinely dropped the old model still leaves the default cleared — that is the loud failure the next session needs, and matches the catalog-import path's semantics.

Tests

Two regression tests against the disk-faithful fake harness (removeProvider re-reads from disk, setConfig deep-merges with undefined keys skipped):

  • re-import that still lists kohub/claude-opus-4-7 keeps default_model (fails without the fix);
  • re-import that dropped the model clears it (already the old behavior, pinned so the restore cannot overreach).

provider.test.ts 40/40 green, check-no-comments and oxlint clean.

Re-importing a custom registry dropped every stale provider through the
removal cascade, which clears default_model when it dangles. The batch
removal in handleProviderAdd never captured the previous value, and the
final setConfig did not even carry defaultModel, so a refresh that
still lists the model silently wiped the user's saved default (MoonshotAI#3739).

Capture the default before the batch removal and restore it when its
alias still resolves after the refresh; a registry that dropped the old
model still leaves it cleared, which is the loud failure the next
session needs. Regression tests pin both directions against the
disk-faithful fake harness.
@changeset-bot

changeset-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 58a05e0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-13T16:17:00.020546Z 58a05e0 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 13, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@58a05e0
npx https://pkg.pr.new/@moonshot-ai/kimi-code@58a05e0

commit: 58a05e0

@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: 58a05e025d

ℹ️ 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".

await harness.setConfig({
providers: config.providers,
models: config.models,
defaultModel: config.defaultModel,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add a CLI changeset for this user-visible fix

This changes user-visible kimi provider add behavior, but the commit contains no .changeset entry, so the fix will neither request the required CLI patch release nor appear in the generated changelog. Add a patch changeset for @moonshot-ai/kimi-code with a short user-facing sentence.

AGENTS.md reference: AGENTS.md:L86-L87

Useful? React with 👍 / 👎.

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.

[Bug]: 重新导入自定义 registry 后,仍有效的 default_model 被清空

1 participant