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:
parent
4078f36ced
commit
df37bb3468
3 changed files with 33 additions and 9 deletions
|
|
@ -71,10 +71,15 @@ export default function ConnectionRow({ connection, proxyPools, isOAuth, isFirst
|
||||||
const isCookieConnection = rowAuthType === "cookie";
|
const isCookieConnection = rowAuthType === "cookie";
|
||||||
const authIcon = isCookieConnection ? "cookie" : isOAuthConnection ? "lock" : "key";
|
const authIcon = isCookieConnection ? "cookie" : isOAuthConnection ? "lock" : "key";
|
||||||
const authLabel = isOAuthConnection ? "OAuth" : isCookieConnection ? "Cookie" : "API Key";
|
const authLabel = isOAuthConnection ? "OAuth" : isCookieConnection ? "Cookie" : "API Key";
|
||||||
const isEmail = (v) => typeof v === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v);
|
const displayName = connection.name?.trim()
|
||||||
const displayName = isOAuthConnection
|
|| connection.email?.trim()
|
||||||
? (isEmail(connection.email) ? connection.email : (isEmail(connection.name) ? connection.name : (connection.name || connection.email || connection.displayName || "OAuth Account")))
|
|| connection.displayName?.trim()
|
||||||
: (connection.name || connection.email || connection.displayName || "API Key");
|
|| (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
|
// Use useState + useEffect for impure Date.now() to avoid calling during render
|
||||||
const [isCooldown, setIsCooldown] = useState(false);
|
const [isCooldown, setIsCooldown] = useState(false);
|
||||||
|
|
@ -152,6 +157,9 @@ export default function ConnectionRow({ connection, proxyPools, isOAuth, isFirst
|
||||||
</span>
|
</span>
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<p className="text-sm font-medium truncate">{displayName}</p>
|
<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">
|
<div className="mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2">
|
||||||
<Badge variant={getStatusVariant()} size="sm" dot>
|
<Badge variant={getStatusVariant()} size="sm" dot>
|
||||||
{connection.isActive === false ? "disabled" : (effectiveStatus || "Unknown")}
|
{connection.isActive === false ? "disabled" : (effectiveStatus || "Unknown")}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,18 @@ function kiroMethodLabel(conn) {
|
||||||
return conn.authType === "api_key" ? "API Key" : "OAuth";
|
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
|
// 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
|
// omit it, so fall back to the region segment of the profileArn
|
||||||
// (arn:aws:codewhisperer:<region>:...).
|
// (arn:aws:codewhisperer:<region>:...).
|
||||||
|
|
@ -918,6 +930,11 @@ export default function ProviderLimits() {
|
||||||
{getConnectionLabel(conn)}
|
{getConnectionLabel(conn)}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
|
{getConnectionSecondaryLabel(conn) ? (
|
||||||
|
<p className="text-[11px] text-text-muted/80 truncate">
|
||||||
|
{getConnectionSecondaryLabel(conn)}
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
{isCodex && (
|
{isCodex && (
|
||||||
<p className="text-[11px] text-text-muted truncate">
|
<p className="text-[11px] text-text-muted truncate">
|
||||||
Reset eligible: {resetCreditCount}
|
Reset eligible: {resetCreditCount}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,10 @@ export const QUOTA_SORT_OPTIONS = [
|
||||||
|
|
||||||
// ─── Pure helpers ─────────────────────────────────────────────────────────────
|
// ─── Pure helpers ─────────────────────────────────────────────────────────────
|
||||||
export function getConnectionLabel(connection) {
|
export function getConnectionLabel(connection) {
|
||||||
const isEmail = (value) =>
|
return connection.name?.trim()
|
||||||
typeof value === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|| connection.email?.trim()
|
||||||
if (isEmail(connection.email)) return connection.email;
|
|| connection.displayName?.trim()
|
||||||
if (isEmail(connection.name)) return connection.name;
|
|| null;
|
||||||
return connection.name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConnectionQuotaRemaining(connection, quotaData) {
|
export function getConnectionQuotaRemaining(connection, quotaData) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue