import { useContext, useState } from "react"; import Button from "@moduletrace/twui/layout/Button"; import { Plus } from "lucide-react"; import { AppContext } from "@/src/pages/__root"; import { AddFlowContext } from "@/src/layouts/bots/(data)/add-flow-context"; import type { BotWithLastMessage } from "@/src/types"; import useSettingsList from "../../(hooks)/use-settings-list"; import SettingsGroup from "../../(partials)/settings-group"; import SettingsList from "../../(partials)/settings-list"; import SettingsStatus from "../../(partials)/settings-status"; import BotEditModal from "../(partials)/bot-edit-modal"; import BotSettingsRow from "../(partials)/bot-settings-row"; /** * The user's crew, coordinator first: chat with a bot, edit it, set its * models, add one or delete a worker. */ export default function BotsSettingsSection() { const { pageProps } = useContext(AppContext); const { openForm } = useContext(AddFlowContext); const { items, busy, status, remove } = useSettingsList({ items: pageProps?.bots || [] }); const [editing, setEditing] = useState(); return ( {items.map((bot) => ( setEditing(bot)} onDelete={() => remove({ id: bot.id, path: "bots/delete-bot", body: { bot_id: bot.id }, confirm: `Delete ${bot.name || "this bot"}? Its conversations, tasks and models go with it.`, }) } /> ))} setEditing(undefined)} /> ); }