mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(usage): show edited connection names consistently across views
Prefer edited name over provider email/displayName in Providers and Quota Tracker; surface the provider-sourced email/display as secondary text. Keeps fallbacks for legacy or unnamed connections. Closes #1699 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
4078f36ced
commit
df37bb3468
@@ -71,10 +71,15 @@ export default function ConnectionRow({ connection, proxyPools, isOAuth, isFirst
|
||||
const isCookieConnection = rowAuthType === "cookie";
|
||||
const authIcon = isCookieConnection ? "cookie" : isOAuthConnection ? "lock" : "key";
|
||||
const authLabel = isOAuthConnection ? "OAuth" : isCookieConnection ? "Cookie" : "API Key";
|
||||
const isEmail = (v) => typeof v === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v);
|
||||
const displayName = isOAuthConnection
|
||||
? (isEmail(connection.email) ? connection.email : (isEmail(connection.name) ? connection.name : (connection.name || connection.email || connection.displayName || "OAuth Account")))
|
||||
: (connection.name || connection.email || connection.displayName || "API Key");
|
||||
const displayName = connection.name?.trim()
|
||||
|| connection.email?.trim()
|
||||
|| connection.displayName?.trim()
|
||||
|| (isOAuthConnection ? "OAuth Account" : isCookieConnection ? "Cookie Account" : "API Key");
|
||||
const secondaryDisplayName = connection.name?.trim() && connection.email?.trim() && connection.name.trim() !== connection.email.trim()
|
||||
? connection.email.trim()
|
||||
: connection.name?.trim() && connection.displayName?.trim() && connection.name.trim() !== connection.displayName.trim()
|
||||
? connection.displayName.trim()
|
||||
: null;
|
||||
|
||||
// Use useState + useEffect for impure Date.now() to avoid calling during render
|
||||
const [isCooldown, setIsCooldown] = useState(false);
|
||||
@@ -152,6 +157,9 @@ export default function ConnectionRow({ connection, proxyPools, isOAuth, isFirst
|
||||
</span>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium truncate">{displayName}</p>
|
||||
{secondaryDisplayName && (
|
||||
<p className="text-xs text-text-muted truncate">{secondaryDisplayName}</p>
|
||||
)}
|
||||
<div className="mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2">
|
||||
<Badge variant={getStatusVariant()} size="sm" dot>
|
||||
{connection.isActive === false ? "disabled" : (effectiveStatus || "Unknown")}
|
||||
|
||||
@@ -57,6 +57,18 @@ function kiroMethodLabel(conn) {
|
||||
return conn.authType === "api_key" ? "API Key" : "OAuth";
|
||||
}
|
||||
|
||||
function getConnectionSecondaryLabel(connection) {
|
||||
if (connection.name?.trim() && connection.email?.trim() && connection.name.trim() !== connection.email.trim()) {
|
||||
return connection.email.trim();
|
||||
}
|
||||
|
||||
if (connection.name?.trim() && connection.displayName?.trim() && connection.name.trim() !== connection.displayName.trim()) {
|
||||
return connection.displayName.trim();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Region is stored for builder-id/idc/api_key flows; social and imported flows
|
||||
// omit it, so fall back to the region segment of the profileArn
|
||||
// (arn:aws:codewhisperer:<region>:...).
|
||||
@@ -918,6 +930,11 @@ export default function ProviderLimits() {
|
||||
{getConnectionLabel(conn)}
|
||||
</p>
|
||||
) : null}
|
||||
{getConnectionSecondaryLabel(conn) ? (
|
||||
<p className="text-[11px] text-text-muted/80 truncate">
|
||||
{getConnectionSecondaryLabel(conn)}
|
||||
</p>
|
||||
) : null}
|
||||
{isCodex && (
|
||||
<p className="text-[11px] text-text-muted truncate">
|
||||
Reset eligible: {resetCreditCount}
|
||||
|
||||
@@ -21,11 +21,10 @@ export const QUOTA_SORT_OPTIONS = [
|
||||
|
||||
// ─── Pure helpers ─────────────────────────────────────────────────────────────
|
||||
export function getConnectionLabel(connection) {
|
||||
const isEmail = (value) =>
|
||||
typeof value === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
||||
if (isEmail(connection.email)) return connection.email;
|
||||
if (isEmail(connection.name)) return connection.name;
|
||||
return connection.name;
|
||||
return connection.name?.trim()
|
||||
|| connection.email?.trim()
|
||||
|| connection.displayName?.trim()
|
||||
|| null;
|
||||
}
|
||||
|
||||
export function getConnectionQuotaRemaining(connection, quotaData) {
|
||||
|
||||
Reference in New Issue
Block a user