Skip to content

Commit 847b9f3

Browse files
chitalianJustin Torreclaude
authored
fix: Use CSS truncation instead of string modification in prompt editor (#5528)
Replace string truncation (appending "...") with CSS line-clamp for visual truncation. This prevents the truncation marker from being treated as actual content when editing or saving prompts. Fixes issue where long prompts would have content deleted below the truncation point when editing. Co-authored-by: Justin Torre <justin@Justins-MacBook-Pro.local> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9dadb24 commit 847b9f3

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

web/components/templates/prompts/id/promptChatRow.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -376,23 +376,24 @@ const PromptChatRow = (props: PromptChatRowProps) => {
376376
);
377377
const text = textMessage?.text || "";
378378
const isMinimized = minimize && text.length > 100;
379-
const displayText = isMinimized ? `${text.substring(0, 100)}...` : text;
380379
const isStatic = text.includes("<helicone-prompt-static>");
380+
// Always use full text to avoid truncation bugs - use CSS for visual truncation
381+
const displayText = isStatic
382+
? text.replace(
383+
/<helicone-prompt-static>(.*?)<\/helicone-prompt-static>/g,
384+
"$1",
385+
)
386+
: text;
381387

382388
return (
383389
<div className="flex flex-col space-y-4 whitespace-pre-wrap">
384-
<RenderWithPrettyInputKeys
385-
text={removeLeadingWhitespace(
386-
isStatic
387-
? displayText.replace(
388-
/<helicone-prompt-static>(.*?)<\/helicone-prompt-static>/g,
389-
"$1",
390-
)
391-
: displayText,
392-
)}
393-
selectedProperties={selectedProperties}
394-
playgroundMode={playgroundMode}
395-
/>
390+
<div className={isMinimized ? "line-clamp-3" : ""}>
391+
<RenderWithPrettyInputKeys
392+
text={removeLeadingWhitespace(displayText)}
393+
selectedProperties={selectedProperties}
394+
playgroundMode={playgroundMode}
395+
/>
396+
</div>
396397
{hasImage(content) && (
397398
<div className="flex flex-wrap items-center border-t border-slate-300 pt-4 dark:border-slate-700">
398399
{content
@@ -480,17 +481,16 @@ const PromptChatRow = (props: PromptChatRowProps) => {
480481
} else {
481482
const contentString = enforceString(content) || "";
482483
const isMinimized = minimize && contentString.length > 100;
483-
const displayText = isMinimized
484-
? `${contentString.substring(0, 100)}...`
485-
: contentString;
486484

487485
return (
488486
<div className="flex flex-col space-y-4 whitespace-pre-wrap">
489-
<RenderWithPrettyInputKeys
490-
text={displayText}
491-
selectedProperties={selectedProperties}
492-
playgroundMode={playgroundMode}
493-
/>
487+
<div className={isMinimized ? "line-clamp-3" : ""}>
488+
<RenderWithPrettyInputKeys
489+
text={contentString}
490+
selectedProperties={selectedProperties}
491+
playgroundMode={playgroundMode}
492+
/>
493+
</div>
494494
</div>
495495
);
496496
}

0 commit comments

Comments
 (0)