Strip thinking from copy message outputs (#5179)

This commit is contained in:
Timothy Carambat 2026-03-09 11:10:17 -07:00 committed by GitHub
parent 563f95167d
commit bc58939843
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,11 +1,15 @@
import { THOUGHT_REGEX_COMPLETE } from "@/components/WorkspaceChat/ChatContainer/ChatHistory/ThoughtContainer";
import { useState } from "react";
export default function useCopyText(delay = 2500) {
const [copied, setCopied] = useState(false);
const copyText = async (content) => {
if (!content) return;
navigator?.clipboard?.writeText(content);
setCopied(content);
// Filter thinking blocks from the content if they exist
const nonThinkingContent = content.replace(THOUGHT_REGEX_COMPLETE, "");
navigator?.clipboard?.writeText(nonThinkingContent);
setCopied(nonThinkingContent);
setTimeout(() => {
setCopied(false);
}, delay);