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

feat(phase4): focus indicators, session management, k6 load tests, remove @ts-check

diegosouzapw0279341221c9
diff --git a/src/app/(dashboard)/dashboard/settings/components/SecurityTab.tsx b/src/app/(dashboard)/dashboard/settings/components/SecurityTab.tsx
index 112fb57ff6..7ecfa8d1d2 100644
--- a/src/app/(dashboard)/dashboard/settings/components/SecurityTab.tsx
+++ b/src/app/(dashboard)/dashboard/settings/components/SecurityTab.tsx
@@ -3,6 +3,7 @@
import { useState, useEffect } from "react";
import { Card, Button, Input, Toggle } from "@/shared/components";
import IPFilterSection from "./IPFilterSection";
+import SessionInfoCard from "./SessionInfoCard";
export default function SecurityTab() {
const [settings, setSettings] = useState({ requireLogin: false, hasPassword: false });
@@ -145,6 +146,7 @@ export default function SecurityTab() {
)}
</div>
</Card>
+ <SessionInfoCard />
<IPFilterSection />
</div>
);
diff --git a/src/app/(dashboard)/dashboard/settings/components/SessionInfoCard.tsx b/src/app/(dashboard)/dashboard/settings/components/SessionInfoCard.tsx
new file mode 100644
index 0000000000..22d71089f4
--- /dev/null
+++ b/src/app/(dashboard)/dashboard/settings/components/SessionInfoCard.tsx
@@ -0,0 +1,127 @@
+"use client";
+
+/**
+ * Session Info Card — P-3
+ *
+ * Displays current session details and provides session management
+ * controls (logout, clear sessions) within the Security settings tab.
+ */
+
+import { useState, useEffect } from "react";
+import { Card, Button } from "@/shared/components";
+
+interface SessionInfo {
+ authenticated: boolean;
+ loginTime: string | null;
+ sessionAge: string;
+ ipAddress: string;
+ userAgent: string;
+}
+
+export default function SessionInfoCard() {
+ const [session, setSession] = useState<SessionInfo | null>(null);
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ // Build session info from client-side data
+ const loginTime = sessionStorage.getItem("omniroute_login_time");
+ const now = Date.now();
+
+ let sessionAge = "Unknown";
+ if (loginTime) {
+ const elapsed = now - parseInt(loginTime, 10);
+ const hours = Math.floor(elapsed / 3600000);
+ const minutes = Math.floor((elapsed % 3600000) / 60000);
+ sessionAge = hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
+ }
+
+ setSession({
+ authenticated: !!document.cookie.includes("omniroute"),
+ loginTime: loginTime ? new Date(parseInt(loginTime, 10)).toLocaleString() : null,
+ sessionAge,
+ ipAddress: "—", // Server-side only
+ userAgent: navigator.userAgent.split(" ").slice(-2).join(" ") || "Unknown",
+ });
+ setLoading(false);
+ }, []);
+
+ const handleLogout = async () => {
+ try {
+ await fetch("/api/auth/logout", { method: "POST" });
+ sessionStorage.removeItem("omniroute_login_time");
+ window.location.href = "/";
+ } catch {
+ window.location.href = "/";
+ }
+ };
+
+ const handleClearStorage = () => {
+ if (confirm("Clear all local data? This will reset your preferences.")) {
+ localStorage.clear();
+ sessionStorage.clear();
+ window.location.reload();
+ }
+ };
+
+ if (loading) {
+ return (
+ <Card>
+ <div className="animate-pulse h-32 bg-black/5 dark:bg-white/5 rounded-lg" />
+ </Card>
+ );
+ }
+
+ return (
+ <Card>
+ <div className="flex items-center gap-3 mb-4">
+ <div className="p-2 rounded-lg bg-blue-500/10 text-blue-500">
+ <span className="material-symbols-outlined text-[20px]" aria-hidden="true">
+ person
+ </span>
+ </div>
+ <h3 className="text-lg font-semibold">Session</h3>
+ </div>
+
+ <div className="flex flex-col gap-3" role="list" aria-label="Session details">
+ <div className="flex justify-between items-center text-sm" role="listitem">
+ <span className="text-text-muted">Status</span>
+ <span className="flex items-center gap-1.5">
+ <span
+ className={`w-2 h-2 rounded-full ${session?.authenticated ? "bg-green-500" : "bg-yellow-500"}`}
+ aria-hidden="true"
+ />
+ {session?.authenticated ? "Authenticated" : "Guest"}
+ </span>
+ </div>
+
+ {session?.loginTime && (
+ <div className="flex justify-between items-center text-sm" role="listitem">
+ <span className="text-text-muted">Login Time</span>
+ <span className="font-mono text-xs">{session.loginTime}</span>
+ </div>
+ )}
+
+ <div className="flex justify-between items-center text-sm" role="listitem">
+ <span className="text-text-muted">Session Age</span>
+ <span className="font-mono text-xs">{session?.sessionAge}</span>
+ </div>
+
+ <div className="flex justify-between items-center text-sm" role="listitem">
+ <span className="text-text-muted">Browser</span>
+ <span className="font-mono text-xs truncate max-w-[200px]">{session?.userAgent}</span>
+ </div>
+ </div>
+
+ <div className="flex gap-3 mt-4 pt-4 border-t border-border/50">
+ <Button variant="secondary" onClick={handleClearStorage}>
+ Clear Local Data
+ </Button>
+ {session?.authenticated && (
+ <Button variant="danger" onClick={handleLogout}>
+ Logout
+ </Button>
+ )}
+ </div>
+ </Card>
+ );
+}
diff --git a/src/app/globals.css b/src/app/globals.css
index 8a3a3c8ac2..0d4480a029 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -102,6 +102,30 @@
-apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
}
+/* ── Focus Indicators (U-3) ── */
+:root {
+ --focus-ring: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-accent);
+}
+
+/* Visible focus ring on keyboard navigation only */
+:focus-visible {
+ outline: none;
+ box-shadow: var(--focus-ring);
+ border-radius: 4px;
+}
+
+/* Utility class for custom focus ring */
+.focus-ring:focus-visible {
+ outline: none;
+ box-shadow: var(--focus-ring);
+}
+
+/* Remove focus ring from mouse clicks */
+:focus:not(:focus-visible) {
+ outline: none;
+ box-shadow: none;
+}
+
/* Base styles */
body {
background-color: var(--color-bg);
diff --git a/src/domain/comboResolver.ts b/src/domain/comboResolver.ts
index 25b9d28c8d..d57e57d7b3 100644
--- a/src/domain/comboResolver.ts
+++ b/src/domain/comboResolver.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Combo Resolver — FASE-09 Domain Extraction (T-46)
*
diff --git a/src/domain/costRules.ts b/src/domain/costRules.ts
index 08714002d2..01f3cad2da 100644
--- a/src/domain/costRules.ts
+++ b/src/domain/costRules.ts
@@ -9,7 +9,6 @@
* @module domain/costRules
*/
-// @ts-check
import {
saveBudget,
diff --git a/src/domain/fallbackPolicy.ts b/src/domain/fallbackPolicy.ts
index 215162da9f..860d2316aa 100644
--- a/src/domain/fallbackPolicy.ts
+++ b/src/domain/fallbackPolicy.ts
@@ -10,7 +10,6 @@
* @module domain/fallbackPolicy
*/
-// @ts-check
import {
saveFallbackChain,
diff --git a/src/domain/lockoutPolicy.ts b/src/domain/lockoutPolicy.ts
index 558d85c275..752f9e4f45 100644
--- a/src/domain/lockoutPolicy.ts
+++ b/src/domain/lockoutPolicy.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Lockout Policy — FASE-09 Domain Extraction (T-46)
*
diff --git a/src/domain/modelAvailability.ts b/src/domain/modelAvailability.ts
index a735d9e906..a21a69b693 100644
--- a/src/domain/modelAvailability.ts
+++ b/src/domain/modelAvailability.ts
@@ -9,7 +9,6 @@
* @module domain/modelAvailability
*/
-// @ts-check
/**
* @typedef {Object} UnavailableEntry
diff --git a/src/lib/compliance/index.ts b/src/lib/compliance/index.ts
index a6c8ec1d28..f3f7013a8f 100644
--- a/src/lib/compliance/index.ts
+++ b/src/lib/compliance/index.ts
@@ -9,7 +9,6 @@
* @module lib/compliance
*/
-// @ts-check
import { getDbInstance } from "../db/core";
diff --git a/src/lib/evals/evalRunner.ts b/src/lib/evals/evalRunner.ts
index bf8bba4975..9e61c3a0b8 100644
--- a/src/lib/evals/evalRunner.ts
+++ b/src/lib/evals/evalRunner.ts
@@ -8,7 +8,6 @@
* @module lib/evals/evalRunner
*/
-// @ts-check
/**
* @typedef {Object} EvalCase
diff --git a/src/lib/usage/callLogs.ts b/src/lib/usage/callLogs.ts
index 4c87229378..500dbb5013 100644
--- a/src/lib/usage/callLogs.ts
+++ b/src/lib/usage/callLogs.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Call Logs — extracted from usageDb.js (T-15)
*
diff --git a/src/lib/usage/costCalculator.ts b/src/lib/usage/costCalculator.ts
index 76892e341a..ffa94301f6 100644
--- a/src/lib/usage/costCalculator.ts
+++ b/src/lib/usage/costCalculator.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Cost Calculator — extracted from usageDb.js (T-15)
*
diff --git a/src/lib/usage/usageHistory.ts b/src/lib/usage/usageHistory.ts
index 5457c7ebee..8e25baf9cc 100644
--- a/src/lib/usage/usageHistory.ts
+++ b/src/lib/usage/usageHistory.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Usage History — extracted from usageDb.js (T-15)
*
diff --git a/src/shared/schemas/validation.ts b/src/shared/schemas/validation.ts
index cac82da2d0..447fbd83a0 100644
--- a/src/shared/schemas/validation.ts
+++ b/src/shared/schemas/validation.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Zod Validation Schemas — Shared request schemas for API routes
*
diff --git a/src/shared/utils/a11yAudit.ts b/src/shared/utils/a11yAudit.ts
index a3d44ba615..6f8738066e 100644
--- a/src/shared/utils/a11yAudit.ts
+++ b/src/shared/utils/a11yAudit.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* a11y Audit — Basic WCAG Accessibility Checker
*
diff --git a/src/shared/utils/circuitBreaker.ts b/src/shared/utils/circuitBreaker.ts
index 7dac3f133e..daa917f4a6 100644
--- a/src/shared/utils/circuitBreaker.ts
+++ b/src/shared/utils/circuitBreaker.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Circuit Breaker — FASE-04 Observability & Resilience
*
diff --git a/src/shared/utils/costEstimator.ts b/src/shared/utils/costEstimator.ts
index 3aaefb65aa..dfc56e4ef7 100644
--- a/src/shared/utils/costEstimator.ts
+++ b/src/shared/utils/costEstimator.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Cost Estimator — Pre-flight cost estimation for LLM requests
*
diff --git a/src/shared/utils/fetchTimeout.ts b/src/shared/utils/fetchTimeout.ts
index e13752ef2f..f48e76be9b 100644
--- a/src/shared/utils/fetchTimeout.ts
+++ b/src/shared/utils/fetchTimeout.ts
@@ -7,7 +7,6 @@
* @module shared/utils/fetchTimeout
*/
-// @ts-check
const DEFAULT_TIMEOUT_MS = 120000; // 2 minutes
const FETCH_TIMEOUT_MS = parseInt(process.env.FETCH_TIMEOUT_MS || "", 10) || DEFAULT_TIMEOUT_MS;
diff --git a/src/shared/utils/inputSanitizer.ts b/src/shared/utils/inputSanitizer.ts
index a1638b5772..d98ae9a313 100644
--- a/src/shared/utils/inputSanitizer.ts
+++ b/src/shared/utils/inputSanitizer.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Input Sanitizer — FASE-01 Security Hardening
*
diff --git a/src/shared/utils/requestId.ts b/src/shared/utils/requestId.ts
index abf7d9b285..db99bbb619 100644
--- a/src/shared/utils/requestId.ts
+++ b/src/shared/utils/requestId.ts
@@ -10,7 +10,6 @@
* @module shared/utils/requestId
*/
-// @ts-check
import { AsyncLocalStorage } from "node:async_hooks";
import { randomUUID } from "node:crypto";
diff --git a/src/shared/utils/streamTracker.ts b/src/shared/utils/streamTracker.ts
index f0c68568a8..6f055bad00 100644
--- a/src/shared/utils/streamTracker.ts
+++ b/src/shared/utils/streamTracker.ts
@@ -1,4 +1,3 @@
-// @ts-check
/**
* Stream Tracker — Unified SSE stream monitoring
*
diff --git a/tests/load/proxy-load.js b/tests/load/proxy-load.js
new file mode 100644
index 0000000000..c5391106d8
--- /dev/null
+++ b/tests/load/proxy-load.js
@@ -0,0 +1,151 @@
+/**
+ * OmniRoute — k6 Load / Performance Test (T-5)
+ *
+ * Tests the proxy endpoint under sustained load to measure:
+ * - Request throughput (RPS)
+ * - Response latency (p50, p95, p99)
+ * - Error rate
+ * - Concurrent connection handling
+ *
+ * Usage:
+ * k6 run tests/load/proxy-load.js
+ * k6 run tests/load/proxy-load.js --env BASE_URL=https://llms.omniroute.online
+ * k6 run tests/load/proxy-load.js --env VUS=50 --env DURATION=120s
+ *
+ * Prerequisites:
+ * - k6 installed: https://grafana.com/docs/k6/latest/set-up/install-k6/
+ * - OMNIROUTE_API_KEY env var or --env API_KEY=... set
+ */
+
+import http from "k6/http";
+import { check, sleep } from "k6";
+import { Rate, Trend } from "k6/metrics";
+
+// ── Custom metrics ──
+const errorRate = new Rate("errors");
+const chatLatency = new Trend("chat_latency", true); // in ms
+const healthLatency = new Trend("health_latency", true);
+
+// ── Configuration ──
+const BASE_URL = __ENV.BASE_URL || "http://localhost:3000";
+const API_KEY = __ENV.API_KEY || __ENV.OMNIROUTE_API_KEY || "test-key";
+const VUS = parseInt(__ENV.VUS || "10", 10);
+const DURATION = __ENV.DURATION || "60s";
+
+export const options = {
+ scenarios: {
+ // Ramp-up scenario for stress testing
+ chat_stress: {
+ executor: "ramping-vus",
+ startVUs: 1,
+ stages: [
+ { duration: "10s", target: VUS }, // Ramp up
+ { duration: DURATION, target: VUS }, // Sustained load
+ { duration: "10s", target: 0 }, // Ramp down
+ ],
+ exec: "chatCompletions",
+ },
+ // Constant rate for health checks
+ health_check: {
+ executor: "constant-vus",
+ vus: 2,
+ duration: DURATION,
+ exec: "healthCheck",
+ },
+ },
+ thresholds: {
+ http_req_duration: ["p(95)<5000"], // 95% of requests < 5s
+ errors: ["rate<0.1"], // Error rate < 10%
+ chat_latency: ["p(50)<3000", "p(95)<8000"],
+ health_latency: ["p(95)<500"],
+ },
+};
+
+// ── Headers ──
+const headers = {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${API_KEY}`,
+};
+
+// ── Scenarios ──
+
+/**
+ * Chat Completions — main proxy endpoint
+ * Sends a simple non-streaming chat request.
+ */
+export function chatCompletions() {
+ const payload = JSON.stringify({
+ model: "gpt-4o-mini",
+ messages: [
+ { role: "user", content: "Say hello in one word." },
+ ],
+ temperature: 0,
+ max_tokens: 10,
+ stream: false,
+ });
+
+ const res = http.post(`${BASE_URL}/v1/chat/completions`, payload, {
+ headers,
+ timeout: "15s",
+ });
+
+ chatLatency.add(res.timings.duration);
+
+ const passed = check(res, {
+ "status is 200": (r) => r.status === 200,
+ "has choices": (r) => {
+ try {
+ const body = JSON.parse(r.body);
+ return body.choices && body.choices.length > 0;
+ } catch {
+ return false;
+ }
+ },
+ "response time < 10s": (r) => r.timings.duration < 10000,
+ });
+
+ errorRate.add(!passed);
+ sleep(0.5);
+}
+
+/**
+ * Health Check — lightweight endpoint to measure base latency.
+ */
+export function healthCheck() {
+ const res = http.get(`${BASE_URL}/api/health`, {
+ headers: { Authorization: `Bearer ${API_KEY}` },
+ timeout: "5s",
+ });
+
+ healthLatency.add(res.timings.duration);
+
+ const passed = check(res, {
+ "health status 200": (r) => r.status === 200,
+ "response time < 1s": (r) => r.timings.duration < 1000,
+ });
+
+ errorRate.add(!passed);
+ sleep(2);
+}
+
+/**
+ * Summary handler — outputs a custom summary.
+ */
+export function handleSummary(data) {
+ const summary = {
+ timestamp: new Date().toISOString(),
+ scenarios: Object.keys(options.scenarios),
+ metrics: {
+ http_reqs: data.metrics.http_reqs?.values?.count || 0,
+ avg_duration_ms: Math.round(data.metrics.http_req_duration?.values?.avg || 0),
+ p95_duration_ms: Math.round(data.metrics.http_req_duration?.values?.["p(95)"] || 0),
+ p99_duration_ms: Math.round(data.metrics.http_req_duration?.values?.["p(99)"] || 0),
+ error_rate: (data.metrics.errors?.values?.rate || 0).toFixed(4),
+ },
+ };
+
+ return {
+ stdout: `\n📊 Load Test Summary\n${JSON.stringify(summary, null, 2)}\n`,
+ "tests/load/results.json": JSON.stringify(summary, null, 2),
+ };
+}