From 447286730dc412afc2954c1d3d48c52c6f284f24 Mon Sep 17 00:00:00 2001 From: sasha Date: Thu, 7 Nov 2024 13:47:56 +0100 Subject: [PATCH] [OPIK-319]: prompt library improvements; (#579) * [OPIK-351]: use commit instead of id; * [OPIK-387]: add autorefresh to prompts; * [OPIK-351]: update the notification for copying a commit; * [OPIK-349]: add use this prompt code snippets; * [OPIK-349]: remove the autofocus for use this prompt modal; * [OPIK-351]: add a refetchInterval to commit history; --------- Co-authored-by: Sasha --- .../PromptPage/PromptTab/CommitHistory.tsx | 6 +-- .../pages/PromptPage/PromptTab/CommitsTab.tsx | 5 ++- .../pages/PromptPage/PromptTab/PromptTab.tsx | 11 +++--- .../PromptTab/UseThisPromptDialog.tsx | 38 ++++++++++++++++++- .../pages/PromptsPage/PromptsPage.tsx | 1 + apps/opik-frontend/src/types/prompts.ts | 1 + 6 files changed, 51 insertions(+), 11 deletions(-) diff --git a/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/CommitHistory.tsx b/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/CommitHistory.tsx index d0c2998d9e..1a2dd5f9b1 100644 --- a/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/CommitHistory.tsx +++ b/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/CommitHistory.tsx @@ -27,7 +27,7 @@ const CommitHistory = ({ await copy(versionId); toast({ - description: "ID successfully copied to clipboard", + description: "Commit successfully copied to clipboard", }); }; @@ -49,13 +49,13 @@ const CommitHistory = ({ >
- {version.id} + {version.commit} {hoveredVersionId == version.id && ( diff --git a/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/CommitsTab.tsx b/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/CommitsTab.tsx index 1a7b26fc7e..789db97a5e 100644 --- a/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/CommitsTab.tsx +++ b/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/CommitsTab.tsx @@ -15,6 +15,7 @@ import IdCell from "@/components/shared/DataTableCells/IdCell"; import { formatDate } from "@/lib/date"; import { convertColumnDataToColumn } from "@/lib/table"; import CodeCell from "@/components/shared/DataTableCells/CodeCell"; +import { keepPreviousData } from "@tanstack/react-query"; interface CommitsTabInterface { prompt?: PromptWithLatestVersion; @@ -26,7 +27,7 @@ export const COMMITS_DEFAULT_COLUMNS = convertColumnDataToColumn< >( [ { - id: "id", + id: "commit", label: "Prompt commit", type: COLUMN_TYPE.string, cell: IdCell as never, @@ -64,6 +65,8 @@ const CommitsTab = ({ prompt }: CommitsTabInterface) => { }, { enabled: !!prompt?.id, + placeholderData: keepPreviousData, + refetchInterval: 30000, }, ); diff --git a/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/PromptTab.tsx b/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/PromptTab.tsx index b6eb8bc192..712091d54d 100644 --- a/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/PromptTab.tsx +++ b/apps/opik-frontend/src/components/pages/PromptPage/PromptTab/PromptTab.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useRef, useState } from "react"; import { Button } from "@/components/ui/button"; -import { Pencil } from "lucide-react"; +import { Info, Pencil } from "lucide-react"; import { PromptWithLatestVersion } from "@/types/prompts"; import Loader from "@/components/shared/Loader/Loader"; import usePromptVersionsById from "@/api/prompts/usePromptVersionsById"; @@ -34,6 +34,7 @@ const PromptTab = ({ prompt }: PromptTabInterface) => { }, { enabled: !!prompt?.id, + refetchInterval: 30000, }, ); @@ -73,10 +74,10 @@ const PromptTab = ({ prompt }: PromptTabInterface) => { <>
- {/**/} +