mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-07-09 16:08:31 +00:00
fix(frontend): Fix uploaded file metadata in message copy (#3944)
* fix uploaded file metadata copy * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
12eda6c701
commit
c05c1899b5
3 changed files with 25 additions and 7 deletions
|
|
@ -37,6 +37,7 @@ import { useI18n } from "@/core/i18n/hooks";
|
|||
import {
|
||||
extractContentFromMessage,
|
||||
extractReasoningContentFromMessage,
|
||||
getMessageCopyData,
|
||||
parseUploadedFiles,
|
||||
stripUploadedFilesTag,
|
||||
type FileInMessage,
|
||||
|
|
@ -162,13 +163,7 @@ export function MessageListItem({
|
|||
)}
|
||||
>
|
||||
<div className="pointer-events-auto flex gap-1">
|
||||
<CopyButton
|
||||
clipboardData={
|
||||
extractContentFromMessage(message) ??
|
||||
extractReasoningContentFromMessage(message) ??
|
||||
""
|
||||
}
|
||||
/>
|
||||
<CopyButton clipboardData={getMessageCopyData(message)} />
|
||||
{feedback !== undefined && runId && threadId && (
|
||||
<FeedbackButtons
|
||||
threadId={threadId}
|
||||
|
|
|
|||
|
|
@ -277,6 +277,17 @@ export function getAssistantTurnCopyData(
|
|||
);
|
||||
}
|
||||
|
||||
export function getMessageCopyData(message: Message) {
|
||||
const content = extractContentFromMessage(message);
|
||||
if (message.type === "human") {
|
||||
return stripUploadedFilesTag(content);
|
||||
}
|
||||
if (content.length > 0) {
|
||||
return content;
|
||||
}
|
||||
return extractReasoningContentFromMessage(message) ?? "";
|
||||
}
|
||||
|
||||
export function extractTextFromMessage(message: Message) {
|
||||
if (typeof message.content === "string") {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {
|
|||
extractContentFromMessage,
|
||||
extractTextFromMessage,
|
||||
extractReasoningContentFromMessage,
|
||||
getMessageCopyData,
|
||||
getAssistantTurnCopyData,
|
||||
getAssistantTurnUsageMessages,
|
||||
getMessageGroups,
|
||||
|
|
@ -246,6 +247,17 @@ describe("inline <think> tag splitting", () => {
|
|||
});
|
||||
|
||||
describe("human message internal context stripping", () => {
|
||||
test("strips uploaded file context from copy data", () => {
|
||||
const message = {
|
||||
id: "human-with-upload",
|
||||
type: "human",
|
||||
content:
|
||||
"<uploaded_files>\nThe following files were uploaded in this message:\n\n- paper.pdf (1.0 MB)\n Path: /mnt/user-data/uploads/paper.pdf\n</uploaded_files>\n\nSummarize this paper",
|
||||
} as Message;
|
||||
|
||||
expect(getMessageCopyData(message)).toBe("Summarize this paper");
|
||||
});
|
||||
|
||||
test("strips slash skill activation context from display content", () => {
|
||||
const content =
|
||||
"<slash_skill_activation>\n<skill_content># Secret SKILL.md</skill_content>\n</slash_skill_activation>\nreal user task";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue