From f22b81c2d2ddc5b0af0b511e5937c1608d175336 Mon Sep 17 00:00:00 2001 From: "Bob.Hou" Date: Fri, 7 Aug 2026 19:52:48 -0400 Subject: [PATCH] fix(sse): drop the localDb barrel imports from chat and auth (#9380) Merge-train validated (tip 6ce4effef8). Vitest failures confirmed as base-red (#9679). --- config/quality/eslint-suppressions.json | 13 ------------- src/sse/handlers/chat.ts | 9 ++++----- src/sse/services/auth.ts | 22 ++++++++-------------- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/config/quality/eslint-suppressions.json b/config/quality/eslint-suppressions.json index d2f8e946ec..4ac0c8ccb0 100644 --- a/config/quality/eslint-suppressions.json +++ b/config/quality/eslint-suppressions.json @@ -1356,24 +1356,11 @@ "count": 1 } }, - "src/sse/handlers/chat.ts": { - "no-restricted-imports": { - "count": 1 - } - }, "src/sse/handlers/chatHelpers.ts": { "no-restricted-imports": { "count": 1 } }, - "src/sse/services/auth.ts": { - "no-restricted-imports": { - "count": 1 - }, - "no-restricted-syntax": { - "count": 1 - } - }, "src/sse/services/model.ts": { "no-restricted-imports": { "count": 2 diff --git a/src/sse/handlers/chat.ts b/src/sse/handlers/chat.ts index 8ffba39d62..07e53b5c0f 100644 --- a/src/sse/handlers/chat.ts +++ b/src/sse/handlers/chat.ts @@ -54,11 +54,10 @@ import { promoteSuccessfulComboModel } from "@/lib/combos/autoPromote"; import { deleteSessionAccountAffinity, evictSessionAccountAffinityForConnection, - getCachedSettings, - getCombos, - getCombosCacheVersion, getSessionAccountAffinity, -} from "@/lib/localDb"; +} from "@/lib/db/sessionAccountAffinity"; +import { getCachedSettings, getCombosCacheVersion } from "@/lib/db/readCache"; +import { getCombos } from "@/lib/db/combos"; import { resolveModelLockoutSettings } from "@/lib/resilience/modelLockoutSettings"; import { ensureOpenAIStoreSessionFallback, @@ -956,7 +955,7 @@ async function handleChatImplementation( const providerPrefix = resolvedModelStr.split("/")[0]; if (providerPrefix) { try { - const { getComboByName } = await import("@/lib/localDb"); + const { getComboByName } = await import("@/lib/db/combos"); const routingCombo = await getComboByName(providerPrefix); if (routingCombo?.id) { routingComboId = routingCombo.id; diff --git a/src/sse/services/auth.ts b/src/sse/services/auth.ts index d206825a68..ce493195c5 100644 --- a/src/sse/services/auth.ts +++ b/src/sse/services/auth.ts @@ -2,16 +2,19 @@ import { randomUUID, createHash } from "crypto"; import { extractGoogApiKeyHeader } from "./googApiKeyAuth.ts"; import { getCachedRawProviderConnections, - getProviderConnections, getCachedProviderNodes, - validateApiKey, + getCachedSettings, +} from "@/lib/db/readCache"; +import { + getProviderConnections, updateProviderConnection, resetConnectionBackoff, - getSettings, - getCachedSettings, touchConnectionLastUsed, clearConnectionErrorIfUnchanged, -} from "@/lib/localDb"; +} from "@/lib/db/providers"; +import { validateApiKey } from "@/lib/db/apiKeys"; +import { getSettings } from "@/lib/db/settings"; +import { toNumber } from "@/shared/utils/numeric"; import { createLazyConnectionView, toProviderConnection, @@ -125,15 +128,6 @@ function toStringOrNull(value: unknown): string | null { return typeof value === "string" && value.trim().length > 0 ? value : null; } -function toNumber(value: unknown, fallback = 0): number { - if (typeof value === "number" && Number.isFinite(value)) return value; - if (typeof value === "string" && value.trim().length > 0) { - const parsed = Number(value); - return Number.isFinite(parsed) ? parsed : fallback; - } - return fallback; -} - function toNullableNumber(value: unknown): number | null { if (value === null || value === undefined) return null; const parsed = toNumber(value, Number.NaN);