From 7362db549b1c420e29d2426d00757aeae708b838 Mon Sep 17 00:00:00 2001
From: "andrii.dudar"
Date: Tue, 17 Dec 2024 17:17:41 +0100
Subject: [PATCH] [OPIK-578] [FR]: Prompt diff
---
.../PromptPage/PromptTab/EditPromptDialog.tsx | 62 ++++++++++++++++---
1 file changed, 52 insertions(+), 10 deletions(-)
diff --git a/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/EditPromptDialog.tsx b/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/EditPromptDialog.tsx
index 4ba38a3828..9f2befdda9 100644
--- a/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/EditPromptDialog.tsx
+++ b/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/EditPromptDialog.tsx
@@ -11,7 +11,14 @@ import {
import { Textarea } from "@/components/ui/textarea";
import { Label } from "@/components/ui/label";
import { Button } from "@/components/ui/button";
+import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
import useCreatePromptVersionMutation from "@/api/prompts/useCreatePromptVersionMutation";
+import TextDiff from "@/components/shared/CodeDiff/TextDiff";
+
+enum PROMPT_PREVIEW_MODE {
+ write = "write",
+ diff = "diff",
+}
type EditPromptDialogProps = {
open: boolean;
@@ -29,6 +36,9 @@ const EditPromptDialog: React.FunctionComponent = ({
promptName,
onSetActiveVersionId,
}) => {
+ const [previewMode, setPreviewMode] = useState(
+ PROMPT_PREVIEW_MODE.write,
+ );
const [promptTemplate, setPromptTemplate] = useState(parentPromptTemplate);
const createPromptVersionMutation = useCreatePromptVersionMutation();
@@ -41,8 +51,8 @@ const EditPromptDialog: React.FunctionComponent = ({
});
};
- const isValid =
- promptTemplate?.length && promptTemplate !== parentPromptTemplate;
+ const templateHasChanges = promptTemplate !== parentPromptTemplate;
+ const isValid = promptTemplate?.length && templateHasChanges;
return (