feat: unify provider active logic and add env field support for kimi_code_io

This commit is contained in:
KimiSwitch Dev
2026-07-09 08:44:11 +08:00
parent 3b12844342
commit b01a5661b4
6 changed files with 44 additions and 25 deletions
+5 -6
View File
@@ -195,15 +195,14 @@ export default function App() {
const handleSwitchProvider = async (name: string) => {
updateConfig((cfg) => {
const target = cfg.providers[name];
if (!target || target.managed) return cfg;
if (!target) return cfg;
const isKimiNative = (p: Provider) => p.managed === true;
// Mark the selected provider as active and deactivate other custom providers.
// Kimi native providers are left untouched. No provider/model records are deleted.
// Only the selected provider is active. All other providers (including
// Kimi native/managed and custom) are deactivated so the target agent
// follows Pi Switch's choice exactly.
const providers: Record<string, Provider> = {};
for (const [key, p] of Object.entries(cfg.providers)) {
providers[key] = { ...p, active: isKimiNative(p) ? undefined : key === name };
providers[key] = { ...p, active: key === name };
}
// Set default model to the first model of the selected provider.
+1 -2
View File
@@ -94,8 +94,7 @@ export function ProviderList({
const defaultModelName = defaultModel
? models[defaultModel]?.display_name || defaultModel
: null;
const isKimiNative = provider.managed === true;
const isActive = !isKimiNative && provider.active === true;
const isActive = provider.active === true;
return (
<div