fix(ai): preserve references when copying failed messages

Closes #8552
This commit is contained in:
t8y2 committed 2026-09-09 13:13:09 +08:00
1 parent 3408ddbb65
commit c63d7927f9
2 files changed
+21 -6

No files matched your search

+8 -6
View File
@@ -1,14 +1,16 @@
export interface AiMessageCopyCandidate {
role: "user" | "assistant";
content: string;
mentions?: readonly AiMessageCopyMention[];
}
export interface AiMessageCopyMention {
kind: string;
raw: string;
}
/**
* Keeps message-level copy payloads scoped to the original message body.
* Reasoning, tool activity, mentions, and rendered HTML live outside this
* contract and must not be appended by the caller.
*/
export function resolveAiMessageCopyText(message: AiMessageCopyCandidate, streaming: boolean): string | null {
if (!message.content || streaming) return null;
return message.content;
const references = message.mentions?.filter((mention) => mention.kind === "table" || mention.kind === "sqlFile").map((mention) => mention.raw) ?? [];
return references.length > 0 ? `${references.join(" ")}\n\n${message.content}` : message.content;
}