diff --git a/open-sse/services/autoCombo/virtualFactory.ts b/open-sse/services/autoCombo/virtualFactory.ts index dc6d0d7bc5..a38c45421a 100644 --- a/open-sse/services/autoCombo/virtualFactory.ts +++ b/open-sse/services/autoCombo/virtualFactory.ts @@ -34,7 +34,12 @@ export async function createVirtualAutoCombo( const validConnections = connections.filter((conn) => { const hasApiKey = !!conn.apiKey; - const expiresAt = Number(conn.oauthExpiresAt) || 0; + let expiresAt: number; + if (typeof conn.oauthExpiresAt === "string") { + expiresAt = new Date(conn.oauthExpiresAt).getTime(); + } else { + expiresAt = Number(conn.oauthExpiresAt) || 0; + } const hasOAuthToken = !!conn.oauthToken && new Date(expiresAt) > new Date(); return hasApiKey || hasOAuthToken; }); diff --git a/src/app/api/analytics/auto-routing/route.ts b/src/app/api/analytics/auto-routing/route.ts index aaac5c81a5..2026b62902 100644 --- a/src/app/api/analytics/auto-routing/route.ts +++ b/src/app/api/analytics/auto-routing/route.ts @@ -59,22 +59,14 @@ export async function GET(request: Request) { GROUP BY provider ORDER BY count DESC LIMIT 10 - ` + ` ) .all() as Array<{ provider: string; count: number }>; - // Mock metrics (would need actual scoring data from auto-combo engine) - const mockMetrics = { - avgSelectionScore: 0.85, - explorationRate: 0.05, - lkgpHitRate: 0.72, - }; - return NextResponse.json({ totalRequests: totalRequests.count, variantBreakdown, topProviders, - ...mockMetrics, }); } catch (error) { console.error("Auto-routing analytics error:", error); @@ -82,9 +74,6 @@ export async function GET(request: Request) { totalRequests: 0, variantBreakdown: {}, topProviders: [], - avgSelectionScore: 0, - explorationRate: 0.05, - lkgpHitRate: 0, }); } } diff --git a/src/sse/handlers/chat.ts b/src/sse/handlers/chat.ts index 3e1ef03a35..377f808449 100644 --- a/src/sse/handlers/chat.ts +++ b/src/sse/handlers/chat.ts @@ -352,7 +352,7 @@ export async function handleChat(request: any, clientRawRequest: any = null) { } // Auto-prefix short-circuit: if auto/ prefix was detected, replace combo with virtual one - if (autoVariant !== undefined && combo === null) { + if (isAutoRouting && combo === null) { try { const { createVirtualAutoCombo } = await import("@omniroute/open-sse/services/autoCombo/virtualFactory.ts"); diff --git a/src/shared/components/AutoRoutingBanner.test.tsx b/tests/unit/shared/components/AutoRoutingBanner.test.tsx similarity index 85% rename from src/shared/components/AutoRoutingBanner.test.tsx rename to tests/unit/shared/components/AutoRoutingBanner.test.tsx index 2249ef566e..d7a8153812 100644 --- a/src/shared/components/AutoRoutingBanner.test.tsx +++ b/tests/unit/shared/components/AutoRoutingBanner.test.tsx @@ -32,7 +32,7 @@ describe("AutoRoutingBanner", () => { }); it("renders banner on first mount", async () => { - const { default: AutoRoutingBanner } = await import("./AutoRoutingBanner"); + const { default: AutoRoutingBanner } = await import("@/shared/components/AutoRoutingBanner"); const container = makeContainer(); const root = createRoot(container); await act(async () => { @@ -43,7 +43,7 @@ describe("AutoRoutingBanner", () => { }); it("includes link to Combos page", async () => { - const { default: AutoRoutingBanner } = await import("./AutoRoutingBanner"); + const { default: AutoRoutingBanner } = await import("@/shared/components/AutoRoutingBanner"); const container = makeContainer(); const root = createRoot(container); await act(async () => { @@ -54,7 +54,7 @@ describe("AutoRoutingBanner", () => { }); it("can be dismissed by clicking close button", async () => { - const { default: AutoRoutingBanner } = await import("./AutoRoutingBanner"); + const { default: AutoRoutingBanner } = await import("@/shared/components/AutoRoutingBanner"); const container = makeContainer(); const root = createRoot(container); await act(async () => { @@ -70,7 +70,7 @@ describe("AutoRoutingBanner", () => { }); it("persists dismissal to localStorage", async () => { - const { default: AutoRoutingBanner } = await import("./AutoRoutingBanner"); + const { default: AutoRoutingBanner } = await import("@/shared/components/AutoRoutingBanner"); const container = makeContainer(); const root = createRoot(container); await act(async () => { @@ -85,7 +85,7 @@ describe("AutoRoutingBanner", () => { it("remains hidden after dismissal on remount", async () => { localStorage.setItem("auto-routing-banner-dismissed", "true"); - const { default: AutoRoutingBanner } = await import("./AutoRoutingBanner"); + const { default: AutoRoutingBanner } = await import("@/shared/components/AutoRoutingBanner"); const container = makeContainer(); const root = createRoot(container); await act(async () => { diff --git a/vitest.config.ts b/vitest.config.ts index 8fb8eb8c6e..95d3dc286f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -13,6 +13,7 @@ export default defineConfig({ "src/lib/memory/__tests__/**/*.test.ts", "src/lib/skills/__tests__/**/*.test.ts", "tests/unit/encryption.test.ts", + "tests/unit/**/*.test.tsx", "open-sse/**/__tests__/**/*.test.ts", "open-sse/services/**/__tests__/**/*.test.ts", "tests/e2e/ecosystem.test.ts",