feat: narrow polled servers to the current session's provider

This commit is contained in:
Troed Sångberg committed 2026-08-21 13:38:27 +02:00
1 parent cad446da2b
commit ce2f7d5baf
2 files changed
+82 -1

No files matched your search

+25
View File
@@ -276,3 +276,28 @@ export function resolveServerUrls(options: unknown, providers: unknown, config:
const legacy = extractProviderUrls(config)
return legacy.length > 0 ? legacy : ["http://localhost:8080"]
}
export function selectSessionUrls(
candidates: string[],
providers: unknown,
providerID: string | undefined,
): string[] {
if (!providerID || providerID.trim() === "" || candidates.length === 0) return candidates
if (!Array.isArray(providers)) return candidates
for (const entry of providers) {
if (!entry || typeof entry !== "object") continue
const provider = entry as Record<string, unknown>
if (provider.id !== providerID) continue
const opts = provider.options
if (opts && typeof opts === "object") {
const baseURL =
(opts as Record<string, unknown>).baseURL || (opts as Record<string, unknown>).base_url
if (typeof baseURL === "string") {
const normalized = stripBaseUrlPath(baseURL)
if (candidates.includes(normalized)) return [normalized]
}
}
break
}
return candidates
}