Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: prompt tag menu disappears when out of focus (#3394)

marliessophie0988635427e6
diff --git a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx
index 4d799c02c2..10ad1e138a 100644
--- a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx
+++ b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx
@@ -24,7 +24,15 @@ import { PRODUCTION_LABEL } from "@/src/features/prompts/constants";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { isReservedPromptLabel } from "@/src/features/prompts/utils";
-export function SetPromptVersionLabels({ prompt }: { prompt: Prompt }) {
+export function SetPromptVersionLabels({
+ prompt,
+ isOpen,
+ setIsOpen,
+}: {
+ prompt: Prompt;
+ isOpen: boolean;
+ setIsOpen: (isOpen: boolean) => void;
+}) {
const projectId = useProjectIdFromURL();
const utils = api.useUtils();
const capture = usePostHogClientCapture();
@@ -32,7 +40,6 @@ export function SetPromptVersionLabels({ prompt }: { prompt: Prompt }) {
const [selectedLabels, setSelectedLabels] = useState<string[]>([]);
const [labels, setLabels] = useState<string[]>([]);
- const [isOpen, setIsOpen] = useState(false);
const [isAddingLabel, setIsAddingLabel] = useState(false);
const customLabelScrollRef = useRef<HTMLDivElement | null>(null);
@@ -87,8 +94,8 @@ export function SetPromptVersionLabels({ prompt }: { prompt: Prompt }) {
<Popover
key={prompt.id}
open={isOpen}
- onOpenChange={() => {
- setIsOpen(!isOpen);
+ onOpenChange={(open) => {
+ setIsOpen(open);
setIsAddingLabel(false);
}}
>
diff --git a/web/src/features/prompts/components/prompt-history.tsx b/web/src/features/prompts/components/prompt-history.tsx
index c90ba76e2f..1547e4b3cd 100644
--- a/web/src/features/prompts/components/prompt-history.tsx
+++ b/web/src/features/prompts/components/prompt-history.tsx
@@ -22,6 +22,7 @@ const PromptHistoryTraceNode = (props: {
}) => {
const capture = usePostHogClientCapture();
const [isHovered, setIsHovered] = useState(false);
+ const [isLabelPopoverOpen, setIsLabelPopoverOpen] = useState(false);
const hasAccess = useHasProjectAccess({
projectId: props.projectId,
scope: "prompts:CUD",
@@ -45,7 +46,9 @@ const PromptHistoryTraceNode = (props: {
props.currentPromptVersion === prompt.version ? "bg-muted" : ""
}`}
onMouseEnter={() => setIsHovered(true)}
- onMouseLeave={() => setIsHovered(false)}
+ onMouseLeave={() => {
+ if (!isLabelPopoverOpen) setIsHovered(false);
+ }}
onClick={() => {
props.index === 0
? props.setCurrentPromptVersion(undefined)
@@ -67,7 +70,14 @@ const PromptHistoryTraceNode = (props: {
</div>
{isHovered && (
<div className="flex flex-row space-x-1">
- <SetPromptVersionLabels prompt={prompt} />
+ <SetPromptVersionLabels
+ prompt={prompt}
+ isOpen={isLabelPopoverOpen}
+ setIsOpen={(open) => {
+ setIsLabelPopoverOpen(open);
+ if (!open) setIsHovered(false);
+ }}
+ />
{hasAccess ? (
<Button
variant="outline"