Update ChatMessage.svelte

This commit is contained in:
rankaiyx 2026-03-08 22:08:22 +08:00 committed by GitHub
parent 3dd083dce9
commit 14a2ca7a21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 0 deletions

View File

@ -6,6 +6,9 @@
import { conversationsStore } from '$lib/stores/conversations.svelte';
import { DatabaseService } from '$lib/services';
import { SYSTEM_MESSAGE_PLACEHOLDER } from '$lib/constants';
import { AGENTIC_REGEX, TRIM_NEWLINES_REGEX } from '$lib/constants/agentic';
import { copyToClipboard } from '$lib/utils/clipboard';
import { config } from '$lib/stores/settings.svelte';
import { MessageRole, AttachmentType } from '$lib/enums';
import {
ChatMessageAssistant,
@ -128,6 +131,18 @@
}
function handleCopy() {
if (
config().copyWithoutThinking &&
message.role === MessageRole.ASSISTANT &&
message.content
) {
const stripped = message.content
.replace(AGENTIC_REGEX.REASONING_BLOCK, '')
.replace(AGENTIC_REGEX.REASONING_OPEN, '')
.replace(TRIM_NEWLINES_REGEX, '');
void copyToClipboard(stripped);
return;
}
chatActions.copy(message);
}