Skip to content

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

fix(prompts): variables broken when copying prompt content (#8931)

Leo Weigand7b6b8b176b32
diff --git a/web/src/components/ui/CodeJsonViewer.tsx b/web/src/components/ui/CodeJsonViewer.tsx
index 245b4f6251..74bfad0d9a 100644
--- a/web/src/components/ui/CodeJsonViewer.tsx
+++ b/web/src/components/ui/CodeJsonViewer.tsx
@@ -196,6 +196,7 @@ export function JSONView(props: {
export function CodeView(props: {
content: string | React.ReactNode[] | undefined | null;
+ originalContent?: string;
className?: string;
defaultCollapsed?: boolean;
title?: string;
@@ -208,9 +209,10 @@ export function CodeView(props: {
event.preventDefault();
setIsCopied(true);
const content =
- typeof props.content === "string"
+ props.originalContent ??
+ (typeof props.content === "string"
? props.content
- : (props.content?.join("\n") ?? "");
+ : (props.content?.join("\n") ?? ""));
void copyTextToClipboard(content);
setTimeout(() => setIsCopied(false), 1000);
@@ -326,7 +328,7 @@ export function stringifyJsonNode(node: unknown) {
try {
return JSON.stringify(
node,
- (key, value) => {
+ (_key, value) => {
switch (typeof value) {
case "bigint":
return String(value) + "n";
diff --git a/web/src/features/prompts/components/prompt-detail.tsx b/web/src/features/prompts/components/prompt-detail.tsx
index e67db757ec..e954e16320 100644
--- a/web/src/features/prompts/components/prompt-detail.tsx
+++ b/web/src/features/prompts/components/prompt-detail.tsx
@@ -537,6 +537,7 @@ export const PromptDetail = ({
projectId as string,
prompt.prompt,
)}
+ originalContent={prompt.prompt}
title="Text Prompt"
/>
)