8000 handle coding state correctly · ag-python/screenshot-to-code@8008513 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8008513

Browse files
committed
handle coding state correctly
1 parent 3d16d78 commit 8008513

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

frontend/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ function App() {
366366
return;
367367
setGeneratedCode(appHistory[index].code);
368368
}}
369+
shouldDisableReverts={appState === AppState.CODING}
369370
/>
370371
}
371372
</div>

frontend/src/components/HistoryDisplay.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { ScrollArea } from "@/components/ui/scroll-area";
22
import { History, HistoryItemType } from "../history_types";
3+
import toast from "react-hot-toast";
34

45
interface Props {
56
history: History;
67
revertToVersion: (version: number) => void;
8+
shouldDisableReverts: boolean;
79
}
810

911
function displayHistoryItemType(itemType: HistoryItemType) {
@@ -24,7 +26,11 @@ function displayHistoryItemType(itemType: HistoryItemType) {
2426
}
2527
}
2628

27-
export default function HistoryDisplay({ history, revertToVersion }: Props) {
29+
export default function HistoryDisplay({
30+
history,
31+
revertToVersion,
32+
shouldDisableReverts,
33+
}: Props) {
2834
return history.length === 0 ? null : (
2935
<div className="flex flex-col h-screen">
3036
<h1 className="font-bold mb-2">History</h1>
@@ -35,7 +41,13 @@ export default function HistoryDisplay({ history, revertToVersion }: Props) {
3541
key={index}
3642
className="flex items-center space-x-2 justify-between p-2
3743
border-b cursor-pointer hover:bg-black hover:text-white"
38-
onClick={() => revertToVersion(index)}
44+
onClick={() =>
45+
shouldDisableReverts
46+
? toast.error(
47+
"Please wait for code generation to complete before viewing an older version"
48+
)
49+
: revertToVersion(index)
50+
}
3951
>
4052
<h2 className="text-sm">{displayHistoryItemType(item.type)}</h2>
4153
<h2 className="text-sm">v{history.length - index}</h2>

0 commit comments

Comments
 (0)
0