Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

move commit code into one file

Abi Raja30d5cd2b65f4
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index f32b2848..4de93c00 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -22,7 +22,8 @@ import DeprecationMessage from "./components/messages/DeprecationMessage";
import { GenerationSettings } from "./components/settings/GenerationSettings";
import StartPane from "./components/start-pane/StartPane";
import { takeScreenshot } from "./lib/takeScreenshot";
-import { Commit, createCommit } from "./components/history/history_types";
+import { Commit } from "./components/commits/types";
+import { createCommit } from "./components/commits/utils";
function App() {
const {
diff --git a/frontend/src/components/history/history_types.ts b/frontend/src/components/commits/types.ts
similarity index 60%
rename from frontend/src/components/history/history_types.ts
rename to frontend/src/components/commits/types.ts
index e9171fc4..68c97ff0 100644
--- a/frontend/src/components/history/history_types.ts
+++ b/frontend/src/components/commits/types.ts
@@ -1,5 +1,3 @@
-export type CommitType = "ai_create" | "ai_edit" | "code_create";
-
export type CommitHash = string;
export type Variant = {
@@ -14,19 +12,7 @@ export type BaseCommit = {
selectedVariantIndex: number;
};
-import { nanoid } from "nanoid";
-
-// TODO: Move to a different file
-// TODO: Fix the type to be better
-export function createCommit(
- commit:
- | Omit<AiCreateCommit, "hash">
- | Omit<AiEditCommit, "hash">
- | Omit<CodeCreateCommit, "hash">
-): Commit {
- const hash = nanoid();
- return { ...commit, hash };
-}
+export type CommitType = "ai_create" | "ai_edit" | "code_create";
export type AiCreateCommit = BaseCommit & {
type: "ai_create";
@@ -48,10 +34,3 @@ export type CodeCreateCommit = BaseCommit & {
};
export type Commit = AiCreateCommit | AiEditCommit | CodeCreateCommit;
-
-export type RenderedHistoryItem = {
- type: string;
- summary: string;
- parentVersion: string | null;
- isActive: boolean;
-};
diff --git a/frontend/src/components/commits/utils.ts b/frontend/src/components/commits/utils.ts
new file mode 100644
index 00000000..9a208098
--- /dev/null
+++ b/frontend/src/components/commits/utils.ts
@@ -0,0 +1,17 @@
+import { nanoid } from "nanoid";
+import {
+ AiCreateCommit,
+ AiEditCommit,
+ CodeCreateCommit,
+ Commit,
+} from "./types";
+
+export function createCommit(
+ commit:
+ | Omit<AiCreateCommit, "hash">
+ | Omit<AiEditCommit, "hash">
+ | Omit<CodeCreateCommit, "hash">
+): Commit {
+ const hash = nanoid();
+ return { ...commit, hash };
+}
diff --git a/frontend/src/components/history/utils.ts b/frontend/src/components/history/utils.ts
index aa4f1833..b1e05526 100644
--- a/frontend/src/components/history/utils.ts
+++ b/frontend/src/components/history/utils.ts
@@ -1,4 +1,4 @@
-import { Commit, CommitHash, CommitType } from "./history_types";
+import { Commit, CommitHash, CommitType } from "../commits/types";
export function extractHistory(
hash: CommitHash,
diff --git a/frontend/src/store/project-store.ts b/frontend/src/store/project-store.ts
index 5304edd2..3830232d 100644
--- a/frontend/src/store/project-store.ts
+++ b/frontend/src/store/project-store.ts
@@ -1,5 +1,5 @@
import { create } from "zustand";
-import { Commit, CommitHash } from "../components/history/history_types";
+import { Commit, CommitHash } from "../components/commits/types";
// Store for app-wide state
interface ProjectStore {