feat(chat): strip reasoning when copying

Remove internal reasoning from copied message text to avoidleaking implementation details or developer-only when a
user content from the chat- In chat_pagecopyMessage, cleaning steps to:
  - <details type="ing">...</details blocks
  - <think>think> and <ing>...</reason> tags
 - trim leftover whitespace before writing to the clipboard
- In assistant_message_widget._buildSegmentedContent, remove an
  unused hasMediaAbove calculation and a conditional spacer that added
  extra top padding before reasoning tiles. This simplifies rendering
  logic and avoids relying on removed spacing behavior.
This commit is contained in:
cogwheel0
2025-10-23 22:37:06 +05:30
parent e8f230ac4e
commit be62358270
2 changed files with 27 additions and 10 deletions

View File

@@ -969,7 +969,33 @@ class _ChatPageState extends ConsumerState<ChatPage> {
}
void _copyMessage(String content) {
Clipboard.setData(ClipboardData(text: content));
// Strip reasoning details from the copied content
String cleanedContent = content;
// Remove <details type="reasoning"> blocks
cleanedContent = cleanedContent.replaceAll(
RegExp(
r'<details\s+type="reasoning"[^>]*>[\s\S]*?<\/details>',
multiLine: true,
dotAll: true,
),
'',
);
// Remove raw reasoning tags
cleanedContent = cleanedContent.replaceAll(
RegExp(r'<think>[\s\S]*?<\/think>', multiLine: true, dotAll: true),
'',
);
cleanedContent = cleanedContent.replaceAll(
RegExp(r'<reasoning>[\s\S]*?<\/reasoning>', multiLine: true, dotAll: true),
'',
);
// Clean up any extra whitespace
cleanedContent = cleanedContent.trim();
Clipboard.setData(ClipboardData(text: cleanedContent));
}
void _regenerateMessage(dynamic message) async {