diff --git a/src/common/TaskHistory.tsx b/src/common/TaskHistory.tsx index c93f2c9..1894143 100644 --- a/src/common/TaskHistory.tsx +++ b/src/common/TaskHistory.tsx @@ -1,3 +1,4 @@ +import { useState } from "react"; import { Alert, AlertIcon, @@ -11,11 +12,13 @@ import { AccordionButton, AccordionPanel, AccordionIcon, + Icon, Spacer, ColorProps, BackgroundProps, } from "@chakra-ui/react"; import { TaskHistoryEntry } from "../state/currentTask"; +import { BsSortNumericDown, BsSortNumericUp } from "react-icons/bs"; import { useAppState } from "../state/store"; import CopyButton from "./CopyButton"; import Notes from "./CustomKnowledgeBase/Notes"; @@ -155,8 +158,19 @@ export default function TaskHistory() { taskStatus: state.currentTask.status, taskHistory: state.currentTask.history, })); + const [sortNumericDown, setSortNumericDown] = useState(false); + const toggleSort = () => { + setSortNumericDown(!sortNumericDown); + }; if (taskHistory.length === 0 && taskStatus !== "running") return null; + const historyItems = taskHistory.map((entry, index) => ( + + )); + historyItems.unshift(); + if (!sortNumericDown) { + historyItems.reverse(); + } return ( @@ -165,13 +179,17 @@ export default function TaskHistory() { Action History + - - {taskHistory.map((entry, index) => ( - - ))} + {historyItems} );