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

2.6 KB
Raw Blame
"use client";

import { useTranslations } from "next-intl";
import { chaosText, type ChaosTranslator } from "../chaosI18n";

export interface ChaosModelResult {
  providerId: string;
  providerName: string;
  modelId: string;
  status: "success" | "error" | "skipped";
  content: string | null;
  error?: string;
  durationMs: number;
}

export interface ChaosTestResult {
  task: string;
  mode: string;
  startedAt: string;
  totalProviders: number;
  totalResults: number;
  models: ChaosModelResult[];
  summary?: string;
}

/**
 * Test-run results panel for the Chaos Mode config page. Extracted out of
 * ChaosConfigPageClient.tsx to keep the page component under the
 * complexity/size ratchet (config/quality/complexity-baseline.json).
 */
export function ChaosTestResultsPanel({ result }: { result: ChaosTestResult }) {
  const t = useTranslations("chaosConfig") as ChaosTranslator;
  const resultsTitle = chaosText(
    t,
    "testResults",
    `Test Results — ${result.mode} mode (${result.totalProviders} providers)`,
    { mode: result.mode, count: result.totalProviders }
  );
  const startedLabel = chaosText(
    t,
    "started",
    `Started: ${new Date(result.startedAt).toLocaleTimeString()}`,
    { time: new Date(result.startedAt).toLocaleTimeString() }
  );

  return (
    <div className="p-3 rounded-lg border border-border bg-surface/40 space-y-3">
      <h3 className="text-sm font-bold text-text-main">{resultsTitle}</h3>
      <div className="text-xs text-text-muted">{startedLabel}</div>
      {result.models.map((model, idx) => (
        <div
          key={idx}
          className={`p-2 rounded-md text-xs ${
            model.status === "success"
              ? "bg-green-500/5 border border-green-500/20"
              : "bg-red-500/5 border border-red-500/20"
          }`}
        >
          <div className="font-medium text-text-main">
            [{idx + 1}] {model.providerName} / {model.modelId}
            <span className="ml-2 text-text-muted">({model.durationMs}ms)</span>
            <span
              className={`ml-2 ${model.status === "success" ? "text-green-500" : "text-red-500"}`}
            >
              {model.status}
            </span>
          </div>
          {model.status === "success" && model.content && (
            <div className="mt-1 text-text-muted line-clamp-3 whitespace-pre-wrap">
              {model.content.slice(0, 300)}
              {model.content.length > 300 ? "..." : ""}
            </div>
          )}
          {model.error && <div className="mt-1 text-red-500">{model.error}</div>}
        </div>
      ))}
    </div>
  );
}