Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix: replace sequential Account N with stable ID-based fallback for OAuth accounts

diegosouzapw26f927f79827
diff --git a/src/lib/db/providers.ts b/src/lib/db/providers.ts
index 40491b1e28..b5e7831a25 100644
--- a/src/lib/db/providers.ts
+++ b/src/lib/db/providers.ts
@@ -126,18 +126,16 @@ export async function createProviderConnection(data: JsonRecord) {
return cleanNulls(merged);
}
- // Generate name
+ // Generate name: prefer explicit name, then email, then a stable short-ID label.
+ // Avoid sequential "Account N" — it reassigns when accounts are deleted/reordered.
let connectionName = data.name || null;
if (!connectionName && data.authType === "oauth") {
if (data.email) {
- connectionName = data.email;
- } else {
- const count = db
- .prepare("SELECT COUNT(*) as cnt FROM provider_connections WHERE provider = ?")
- .get(data.provider) as JsonRecord | undefined;
- const cntValue = toNumberOrZero(toRecord(count).cnt);
- connectionName = `Account ${cntValue + 1}`;
+ connectionName = data.email as string;
+ } else if (data.displayName) {
+ connectionName = data.displayName as string;
}
+ // Otherwise leave null — UI will fall back to getAccountDisplayName() → "Account #<id>"
}
// Auto-increment priority