Skip to content

fix(tui): preserve fallback provider during refresh - #2501

Draft
xushun007 wants to merge 1 commit into
MoonshotAI:mainfrom
xushun007:agent/fix-provider-refresh-default
Draft

fix(tui): preserve fallback provider during refresh#2501
xushun007 wants to merge 1 commit into
MoonshotAI:mainfrom
xushun007:agent/fix-provider-refresh-default

Conversation

@xushun007

Copy link
Copy Markdown

Related Issue

None. This is a focused, reproducible bug fix found while reviewing the current main branch.

Problem

Provider model refreshes use a remove-then-set flow so stale model aliases can be deleted. Removing a provider also clears defaultProvider when it points to that provider.

The managed OAuth, open-platform, and custom-registry refresh branches rebuilt the provider successfully but omitted defaultProvider from the complete config patch. On the v2 atomic persistence path, that left the staged config without the configured fallback. A later provider refresh could then persist the missing value and silently remove a still-valid fallback provider.

What changed

  • Include the rebuilt defaultProvider value in every complete provider-refresh config patch.
  • Preserve the fallback when a provider is refreshed and re-added.
  • Continue clearing the fallback when a registry genuinely removes its provider, because the rebuilt config then explicitly carries undefined.
  • Update the refresh test host to model the real removal cascade and add a regression test for managed OAuth refresh.
  • Add a patch changeset for the CLI.

Validation

  • pnpm exec vitest run apps/kimi-code/test/tui/utils/refresh-providers.test.ts apps/kimi-code/test/tui/kimi-tui-startup.test.ts — 74 tests passed.
  • pnpm run typecheck — passed across all packages and applications.
  • pnpm run lint — passed with no errors (existing repository warnings remain).
  • git diff --check and changeset status validation — passed.
  • The full repository test suite was attempted, but the local environment hit unrelated image-compression/network timeouts and EMFILE: too many open files; the affected provider-refresh suites passed independently.

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.

@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 63677cd

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

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code 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.

1 participant