|
1 | 1 | import React from "react"; |
2 | 2 | import FadeIn from "./motions/FadeIn"; |
3 | 3 | import Expand from "./motions/expand"; |
4 | | -import { Task } from "../types/agentTypes"; |
| 4 | +import { |
| 5 | + Task, |
| 6 | + MESSAGE_TYPE_TASK, |
| 7 | + TASK_STATUS_STARTED, |
| 8 | +} from "../types/agentTypes"; |
5 | 9 | import { getMessageContainerStyle, getTaskStatusIcon } from "./utils/helpers"; |
6 | 10 | import { useMessageStore } from "./stores"; |
7 | 11 | import { FaListAlt, FaTimesCircle } from "react-icons/fa"; |
8 | 12 | import { useAgentStore } from "./stores"; |
9 | 13 | import clsx from "clsx"; |
| 14 | +import Input from "./Input"; |
| 15 | +import Button from "./Button"; |
| 16 | +import { v1 } from "uuid"; |
10 | 17 | import { useTranslation } from "next-i18next"; |
11 | 18 |
|
12 | 19 | export const TaskWindow = () => { |
| 20 | + const [customTask, setCustomTask] = React.useState(""); |
13 | 21 | const tasks = useMessageStore.use.tasks(); |
| 22 | + const addMessage = useMessageStore.use.addMessage(); |
14 | 23 | const { t } = useTranslation(); |
15 | 24 |
|
| 25 | + const handleAddTask = () => { |
| 26 | + addMessage({ |
| 27 | + taskId: v1().toString(), |
| 28 | + value: customTask, |
| 29 | + status: TASK_STATUS_STARTED, |
| 30 | + type: MESSAGE_TYPE_TASK, |
| 31 | + }); |
| 32 | + setCustomTask(""); |
| 33 | + }; |
| 34 | + |
16 | 35 | return ( |
17 | 36 | <Expand className="xl mx-2 mt-4 hidden w-[20rem] flex-col items-center rounded-2xl border-2 border-white/20 bg-zinc-900 px-1 font-mono shadow-2xl xl:flex"> |
18 | 37 | <div className="sticky top-0 my-2 flex items-center justify-center gap-2 bg-zinc-900 p-2 text-gray-300 "> |
19 | 38 | <FaListAlt /> <span>{t("current-tasks")}</span> |
20 | 39 | </div> |
21 | | - <div className="window-heights mb-2 w-full px-1 "> |
22 | | - <div className="flex flex-col gap-2 overflow-y-auto overflow-x-hidden"> |
| 40 | + <div className="flex h-full w-full flex-col gap-2 px-1 py-1"> |
| 41 | + <div className="window-heights flex w-full flex-col gap-2 overflow-y-auto overflow-x-hidden pr-1"> |
23 | 42 | {tasks.map((task, i) => ( |
24 | 43 | <Task key={i} task={task} /> |
25 | 44 | ))} |
26 | 45 | </div> |
| 46 | + <div className="flex flex-row gap-1"> |
| 47 | + <Input |
| 48 | + value={customTask} |
| 49 | + onChange={(e) => setCustomTask(e.target.value)} |
| 50 | + placeholder={t("custom-task") as string} |
| 51 | + small |
| 52 | + /> |
| 53 | + <Button |
| 54 | + className="font-sm px-2 py-[0] text-sm sm:px-2 sm:py-[0]" |
| 55 | + onClick={handleAddTask} |
| 56 | + disabled={!customTask} |
| 57 | + > |
| 58 | + {t("add-task")} |
| 59 | + </Button> |
| 60 | + </div> |
27 | 61 | </div> |
28 | 62 | </Expand> |
29 | 63 | ); |
|
0 commit comments