import clsx from "clsx"; import { AnimatePresence } from "framer-motion"; import { useTranslation } from "next-i18next"; import React from "react"; import { FaBars, FaTimesCircle } from "react-icons/fa"; import { v1 } from "uuid"; import Sidebar from "./Sidebar"; import { useAgentStore } from "../../stores"; import { useConfigStore } from "../../stores/configStore"; import { useTaskStore } from "../../stores/taskStore"; import type { Task as TaskType } from "../../types/task"; import { MESSAGE_TYPE_TASK, TASK_STATUS_STARTED } from "../../types/task"; import Button from "../Button"; import Input from "../Input"; import FadeIn from "../motions/FadeIn"; import { getMessageContainerStyle, getTaskStatusIcon } from "../utils/helpers"; const TaskSidebar = () => { const [customTask, setCustomTask] = React.useState(""); const agent = useAgentStore.use.agent(); const tasks = useTaskStore.use.tasks(); const addTask = useTaskStore.use.addTask(); const [t] = useTranslation(); const { layout, setLayout } = useConfigStore(); const setShow = (show: boolean) => { setLayout({ showRightSidebar: show }); }; const handleAddTask = () => { addTask({ id: v1().toString(), taskId: v1().toString(), value: customTask, status: TASK_STATUS_STARTED, type: MESSAGE_TYPE_TASK, }); setCustomTask(""); }; return ( setShow(!layout.showRightSidebar)} > {t("Current tasks")} {tasks.length == 0 && ( This window will display agent tasks as they are created. )} {tasks.map((task) => ( ))} setCustomTask(e.target.value)} placeholder={"Custom task"} small /> Add ); }; const Task = ({ task }: { task: TaskType }) => { const isAgentStopped = useAgentStore.use.lifecycle() === "stopped"; const deleteTask = useTaskStore.use.deleteTask(); const isTaskDeletable = task.taskId && !isAgentStopped && task.status === "started"; const handleDeleteTask = () => { if (isTaskDeletable) { deleteTask(task.taskId as string); } }; return ( {getTaskStatusIcon(task, { isAgentStopped })} {task.value} ); }; export default TaskSidebar;
This window will display agent tasks as they are created.