From 64cdc74186c59fa0d5515f6320bb11018ec39e28 Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Thu, 4 Apr 2024 15:50:33 -0400 Subject: [PATCH] add a regenerate button to retry an iteration --- frontend/src/App.tsx | 94 ++++++++++++++++-------- frontend/src/components/core/TipLink.tsx | 16 ++++ 2 files changed, 78 insertions(+), 32 deletions(-) create mode 100644 frontend/src/components/core/TipLink.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 3b8f7da..5a51bc6 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -39,7 +39,7 @@ import { CodeGenerationModel } from "./lib/models"; import ModelSettingsSection from "./components/ModelSettingsSection"; import { extractHtml } from "./components/preview/extractHtml"; import useBrowserTabIndicator from "./hooks/useBrowserTabIndicator"; -import { URLS } from "./urls"; +import TipLink from "./components/core/TipLink"; const IS_OPENAI_DOWN = false; @@ -142,6 +142,25 @@ function App() { setShouldIncludeResultImage(false); }; + const regenerate = () => { + if (currentVersion === null) { + toast.error( + "No current version set. Please open a Github issue as this shouldn't happen." + ); + return; + } + + // Retrieve the previous command + const previousCommand = appHistory[currentVersion]; + if (previousCommand.type !== "ai_create") { + toast.error("Only the first version can be regenerated."); + return; + } + + // Re-run the create + doCreate(referenceImages, inputMode); + }; + const cancelCodeGeneration = () => { wsRef.current?.close?.(USER_CLOSE_WEB_SOCKET_CODE); // make sure stop can correct the state even if the websocket is already closed @@ -373,14 +392,7 @@ function App() { } /> - - Tips for better results - + {appState !== AppState.CODE_READY && } {IS_RUNNING_ON_CLOUD && !(settings.openAiApiKey || settings.accessCode) && ( @@ -454,21 +466,17 @@ function App() { Update -
+
-
+
+ +
)} @@ -556,19 +564,41 @@ function App() { {(appState === AppState.CODING || appState === AppState.CODE_READY) && (
-
- - - Desktop - - - Mobile - - - - Code - - +
+
+ {appState === AppState.CODE_READY && ( + <> + + + + )} +
+
+ + + Desktop + + + Mobile + + + + Code + + +
diff --git a/frontend/src/components/core/TipLink.tsx b/frontend/src/components/core/TipLink.tsx new file mode 100644 index 0000000..b54f83c --- /dev/null +++ b/frontend/src/components/core/TipLink.tsx @@ -0,0 +1,16 @@ +import { URLS } from "../../urls"; + +function TipLink() { + return ( + + Tips for better results + + ); +} + +export default TipLink;