fix(ui): count dual-auth provider cards correctly

Share oauth+apikey/api_key stats for dual-auth providers (incl. kiro)
so card totals match the detail page.
This commit is contained in:
decolua 2026-07-29 19:27:31 +07:00
parent 15dfd86416
commit 44c7b34837

View file

@ -277,6 +277,16 @@ export default function ProvidersPage() {
})) }))
.filter((p) => matchSearch(p.name)); .filter((p) => matchSearch(p.name));
// Dual-auth providers (oauth + apikey) store API keys as authType "apikey"
// (and sometimes "api_key"). Card stats must count both so totals match detail.
// kiro has no authModes in registry but accepts both (headless uses "api_key").
const dualAuthTypes = (info, key) => {
if (key === "kiro") return ["oauth", "apikey", "api_key"];
const modes = info?.authModes;
if (!Array.isArray(modes) || !modes.includes("apikey")) return "oauth";
return ["oauth", "apikey", "api_key"];
};
const oauthEntries = sortByPriority( const oauthEntries = sortByPriority(
Object.entries(OAUTH_PROVIDERS).filter(([, info]) => !info.hidden && matchSearch(info.name)), Object.entries(OAUTH_PROVIDERS).filter(([, info]) => !info.hidden && matchSearch(info.name)),
"oauth", "oauth",
@ -424,16 +434,19 @@ export default function ProvidersPage() {
</div> </div>
</div> </div>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4"> <div className="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4">
{oauthEntries.map(([key, info]) => ( {oauthEntries.map(([key, info]) => {
<ProviderCard const authTypes = dualAuthTypes(info, key);
key={key} return (
providerId={key} <ProviderCard
provider={info} key={key}
stats={getProviderStats(key, "oauth")} providerId={key}
authType="oauth" provider={info}
onToggle={(active) => handleToggleProvider(key, "oauth", active)} stats={getProviderStats(key, authTypes)}
/> authType="oauth"
))} onToggle={(active) => handleToggleProvider(key, authTypes, active)}
/>
);
})}
</div> </div>
</div> </div>
)} )}
@ -466,12 +479,9 @@ export default function ProvidersPage() {
</div> </div>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4"> <div className="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4">
{freeEntries.map(([key, info]) => { {freeEntries.map(([key, info]) => {
// Kiro accepts both OAuth and api-key connections; count/toggle both // Dual-auth (e.g. kiro): count/toggle oauth + apikey/api_key so the
// so the card total matches the provider detail page (#kiro-apikey). // card total matches the provider detail page.
// Kiro's headless api-key flow persists authType "api_key" (underscore), const freeAuthTypes = dualAuthTypes(info, key);
// while generic apikey providers use "apikey" — include both spellings.
const freeAuthTypes =
key === "kiro" ? ["oauth", "apikey", "api_key"] : "oauth";
return ( return (
<ProviderCard <ProviderCard
key={key} key={key}