"use client";
import { useTranslation } from "react-i18next";
import { ServiceConfigEditor } from "./ServiceConfigEditor";
import { ModelTestPanel } from "./ModelTestPanel";
import { useSettings } from "@/features/settings/store/SettingsStore";
import { selectClass } from "./shared";
/** Optional task references leave every legacy profile and credential intact. */
export function TaskModelsEditor() {
const { t } = useTranslation();
const { draft, catalogEditable, mutateCatalog } =
useSettings();
const task = draft.services.task;
const mode = task.mode ?? (task.profiles.length ? "profiles" : "inherit");
const options = draft.services.llm.profiles.flatMap((profile) =>
profile.models
.filter((model) => model.model)
.map((model) => ({
profile,
model,
value: JSON.stringify([profile.id, model.id]),
})),
);
const selected = options.find(
(item) =>
item.profile.id === task.selection?.profile_id &&
item.model.id === task.selection?.model_id,
);
const value =
mode === "reference" ? (selected?.value ?? "missing") : mode;
if (!catalogEditable) return
{t( "Conversation titles and starting suggestions can use a smaller model from a provider you already configured.", )}
{mode !== "profiles" && ( <> {mode === "reference" && selected && ({t( "Provider credentials are reused. Your previously configured task providers are kept when switching modes.", )}
> )} {mode === "profiles" &&