-
-

+ {referenceImages.length > 0 && (
+
+
+

+
+
+ Original Screenshot
+
-
- Original Screenshot
-
-
+ )}
Console
@@ -424,6 +447,7 @@ function App() {
doCreate={doCreate}
screenshotOneApiKey={settings.screenshotOneApiKey}
/>
+
)}
diff --git a/frontend/src/components/ImportCodeSection.tsx b/frontend/src/components/ImportCodeSection.tsx
new file mode 100644
index 0000000..0199413
--- /dev/null
+++ b/frontend/src/components/ImportCodeSection.tsx
@@ -0,0 +1,49 @@
+import { useState } from "react";
+import { Button } from "./ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "./ui/dialog";
+import { Textarea } from "./ui/textarea";
+
+interface Props {
+ importFromCode: (code: string) => void;
+}
+
+function ImportCodeSection({ importFromCode }: Props) {
+ const [code, setCode] = useState("");
+ return (
+
+ );
+}
+
+export default ImportCodeSection;
diff --git a/frontend/src/components/history/HistoryDisplay.tsx b/frontend/src/components/history/HistoryDisplay.tsx
index 9f4d8fc..db0b74b 100644
--- a/frontend/src/components/history/HistoryDisplay.tsx
+++ b/frontend/src/components/history/HistoryDisplay.tsx
@@ -21,6 +21,8 @@ function displayHistoryItemType(itemType: HistoryItemType) {
return "Create";
case "ai_edit":
return "Edit";
+ case "code_create":
+ return "Imported from code";
default: {
const exhaustiveCheck: never = itemType;
throw new Error(`Unhandled case: ${exhaustiveCheck}`);
@@ -62,7 +64,11 @@ export default function HistoryDisplay({
{" "}
- {item.type === "ai_edit" ? item.inputs.prompt : "Create"}
+ {item.type === "ai_edit"
+ ? item.inputs.prompt
+ : item.type === "ai_create"
+ ? "Create"
+ : "Imported from code"}
{/*
{displayHistoryItemType(item.type)}
*/}
{item.parentIndex !== null &&
@@ -76,7 +82,11 @@ export default function HistoryDisplay({
- {item.type === "ai_edit" ? item.inputs.prompt : "Create"}
+ {item.type === "ai_edit"
+ ? item.inputs.prompt
+ : item.type === "ai_create"
+ ? "Create"
+ : "Imported from code"}
{displayHistoryItemType(item.type)}
diff --git a/frontend/src/components/history/history_types.ts b/frontend/src/components/history/history_types.ts
index 55ca3f4..832e379 100644
--- a/frontend/src/components/history/history_types.ts
+++ b/frontend/src/components/history/history_types.ts
@@ -1,4 +1,4 @@
-export type HistoryItemType = "ai_create" | "ai_edit";
+export type HistoryItemType = "ai_create" | "ai_edit" | "code_create";
type CommonHistoryItem = {
parentIndex: null | number;
@@ -13,6 +13,10 @@ export type HistoryItem =
| ({
type: "ai_edit";
inputs: AiEditInputs;
+ } & CommonHistoryItem)
+ | ({
+ type: "code_create";
+ inputs: CodeCreateInputs;
} & CommonHistoryItem);
export type AiCreateInputs = {
@@ -23,4 +27,8 @@ export type AiEditInputs = {
prompt: string;
};
+export type CodeCreateInputs = {
+ code: string;
+};
+
export type History = HistoryItem[];
diff --git a/frontend/src/components/history/utils.ts b/frontend/src/components/history/utils.ts
index ce7bf3c..5e476af 100644
--- a/frontend/src/components/history/utils.ts
+++ b/frontend/src/components/history/utils.ts
@@ -14,9 +14,11 @@ export function extractHistoryTree(
if (item.type === "ai_create") {
// Don't include the image for ai_create
flatHistory.unshift(item.code);
- } else {
+ } else if (item.type === "ai_edit") {
flatHistory.unshift(item.code);
flatHistory.unshift(item.inputs.prompt);
+ } else if (item.type === "code_create") {
+ flatHistory.unshift(item.code);
}
// Move to the parent of the current item
diff --git a/frontend/src/generateCode.ts b/frontend/src/generateCode.ts
index 8a05fe7..5e826dd 100644
--- a/frontend/src/generateCode.ts
+++ b/frontend/src/generateCode.ts
@@ -12,6 +12,7 @@ export interface CodeGenerationParams {
image: string;
resultImage?: string;
history?: string[];
+ isImportedFromCode?: boolean;
// isImageGenerationEnabled: boolean; // TODO: Merge with Settings type in types.ts
}