"use client"; import { useState } from "react"; import { useTranslations } from "next-intl"; import { ModelSelectorModal } from "./ModelSelectorModal"; export interface MappingRow { source: string; target: string; } interface ModelMappingTableProps { agentId: string; mappings: MappingRow[]; onSave: (agentId: string, mappings: MappingRow[]) => Promise; } /** * Editable table: source model → target OmniRoute model. */ export function ModelMappingTable({ agentId, mappings, onSave }: ModelMappingTableProps) { const t = useTranslations("agentBridge"); const [rows, setRows] = useState(mappings); const [selectorOpen, setSelectorOpen] = useState(null); const [saving, setSaving] = useState(false); const updateTarget = (index: number, target: string) => { setRows((prev) => prev.map((r, i) => (i === index ? { ...r, target } : r))); setSelectorOpen(null); }; const handleSave = async () => { setSaving(true); try { await onSave(agentId, rows); } finally { setSaving(false); } }; if (rows.length === 0) { return (

{t("noMappings") || "No model mappings configured. Run setup wizard to auto-detect models."}

); } return (
{rows.map((row, i) => ( ))}
{t("sourceModel") || "Source model (agent native)"} {t("targetModel") || "Target model (OmniRoute)"}
{row.source}
{selectorOpen !== null && ( updateTarget(selectorOpen, model)} onClose={() => setSelectorOpen(null)} /> )}
); }