From f20d94b08fb2cbdcbeeb040141fd20ba49bddc06 Mon Sep 17 00:00:00 2001 From: Meleki Date: Sat, 28 Feb 2026 21:48:15 +0100 Subject: [PATCH] Streaming-Cursor: Block-Cursor-Stil, schnelleres Blinken, korrekte Inline-Positionierung --- wwwroot/css/chat.css | 17 ++++++----------- wwwroot/js/ui.js | 10 ++++++++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/wwwroot/css/chat.css b/wwwroot/css/chat.css index dcb8d18..c81a6e1 100644 --- a/wwwroot/css/chat.css +++ b/wwwroot/css/chat.css @@ -122,17 +122,18 @@ .msg .cursor { display: inline-block; - width: .125em; - height: 1em; + width: .55em; + height: 1.15em; background: var(--text); - animation: blink 0.8s infinite; + animation: blink .2s step-end infinite; vertical-align: text-bottom; - margin-left: .125em; + margin-left: .15em; + border-radius: 1px; } @keyframes blink { 0%, 50% { opacity: 1; } - 51%, 100% { opacity: 0; } + 50.1%, 100% { opacity: 0; } } .tool-box { @@ -502,9 +503,3 @@ max-height: 60vh; overflow: auto; } - -/* Message-Typ Button */ - -.cmd-type-message { - font-style: italic; -} diff --git a/wwwroot/js/ui.js b/wwwroot/js/ui.js index 87d8c3a..9c854d1 100644 --- a/wwwroot/js/ui.js +++ b/wwwroot/js/ui.js @@ -121,7 +121,7 @@ let _streamText = ''; function startStreamBubble() { _streamDiv = document.createElement('div'); _streamDiv.className = 'msg assistant markdown streamed'; - _streamDiv.innerHTML = ''; + _streamDiv.innerHTML = '

'; _streamText = ''; chatEl().appendChild(_streamDiv); scrollDown(); @@ -131,9 +131,15 @@ function appendToStream(text) { if (!_streamDiv) startStreamBubble(); _streamText += text; _streamDiv.innerHTML = renderMarkdown(_streamText); + // Cursor ins letzte Inline/Text-Element einfügen, damit er nicht auf eine neue Zeile rutscht const cursor = document.createElement('span'); cursor.className = 'cursor'; - _streamDiv.appendChild(cursor); + const lastBlock = _streamDiv.lastElementChild; + if (lastBlock) { + lastBlock.appendChild(cursor); + } else { + _streamDiv.appendChild(cursor); + } scrollDown(); }