diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d4b772e..cbefcfe 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -61,6 +61,7 @@ function App() { // App history const [appHistory, setAppHistory] = useState([]); + const [currentVersion, setCurrentVersion] = useState(null); const [shouldIncludeResultImage, setShouldIncludeResultImage] = useState(false); @@ -146,20 +147,25 @@ function App() { inputs: { image_url: referenceImages[0] }, }, ]); + setCurrentVersion(0); } else { - setAppHistory((prev) => [ - { - type: "ai_edit", - code, - // TODO: Doesn't typecheck correctly - inputs: { - // TODO: Fix this - previous_commands: [], - new_instruction: updateInstruction, + setAppHistory((prev) => { + const newHistory: History = [ + { + type: "ai_edit", + code, + // TODO: Doesn't typecheck correctly + inputs: { + // TODO: Fix this + previous_commands: [], + new_instruction: updateInstruction, + }, }, - }, - ...prev, - ]); + ...prev, + ]; + setCurrentVersion(0); + return newHistory; + }); } }, (line) => setExecutionConsole((prev) => [...prev, line]), @@ -357,6 +363,7 @@ function App() { { { if ( index < 0 || @@ -364,6 +371,7 @@ function App() { !appHistory[index] ) return; + setCurrentVersion(index); setGeneratedCode(appHistory[index].code); }} shouldDisableReverts={appState === AppState.CODING} diff --git a/frontend/src/components/HistoryDisplay.tsx b/frontend/src/components/HistoryDisplay.tsx index 3808b71..49a295d 100644 --- a/frontend/src/components/HistoryDisplay.tsx +++ b/frontend/src/components/HistoryDisplay.tsx @@ -1,9 +1,11 @@ import { ScrollArea } from "@/components/ui/scroll-area"; import { History, HistoryItemType } from "../history_types"; import toast from "react-hot-toast"; +import classNames from "classnames"; interface Props { history: History; + currentVersion: number | null; revertToVersion: (version: number) => void; shouldDisableReverts: boolean; } @@ -28,6 +30,7 @@ function displayHistoryItemType(itemType: HistoryItemType) { export default function HistoryDisplay({ history, + currentVersion, revertToVersion, shouldDisableReverts, }: Props) { @@ -39,8 +42,14 @@ export default function HistoryDisplay({ {history.map((item, index) => (
  • shouldDisableReverts ? toast.error(