From 7358c924adec0faa78aadfb9ba1e201a2603f7df Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 26 Aug 2025 03:06:47 +0200 Subject: [PATCH] upgraded codeblocks --- src/App.jsx | 21 +++++++++++++-------- src/styles.css | 6 ++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 91c4b10..4a6beba 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -112,14 +112,19 @@ export default function App() { const [editText, setEditText] = useState(''); // Helpers + handlers for message copy/edit/regenerate (must live inside App) function getVisibleTextForCopy(message) { - let raw = message.content || ''; - if (message.role === 'assistant') { - try { - const { think, answer } = splitThinkBlocks(raw); - raw = answer || raw; - } catch (_) {} + const raw = message.content || ''; + if (message.role !== 'assistant') { + // For user messages, copy exactly what they typed. + return raw; } - const html = markdownToHTML(raw); + // Assistant messages: strip think, render as HTML, then extract readable text. + let shown = raw; + try { + const { think, answer } = splitThinkBlocks(raw); + shown = answer || raw; + } catch (_) {} + + const html = markdownToHTML(shown); const tempDiv = document.createElement('div'); tempDiv.innerHTML = html; tempDiv.querySelectorAll('br').forEach(br => br.replaceWith('\n')); @@ -1167,7 +1172,7 @@ export default function App() { maxRows={13} /> ) : ( -
+
{m.content}
)} {!isSending && (
diff --git a/src/styles.css b/src/styles.css index 1c4e0b6..f1740c4 100644 --- a/src/styles.css +++ b/src/styles.css @@ -328,6 +328,12 @@ textarea.input { margin-right: 5px; margin-bottom: 15px; } +.msg.user .msg-content--user { + white-space: pre-wrap; /* keep newlines */ + overflow-wrap: anywhere; /* wrap long tokens/URLs */ + word-break: break-word; /* fallback */ +} + .msg.assistant { background: transparent; border: none;