Frontend: Aufeinanderfolgende Assistant-Text-Messages gleicher Iteration mergen
- Neue Hilfsfunktion _mergeConsecutiveAssistantTexts() in history.js - Nahtloses Zusammenfügen (Whitespace-Trenner) bei gleicher Iteration - Angewandt in renderMessages(), _renderMessagesIntoFragment() und loadLatestArchive() - Behebt fragmentierte Darstellung bei Web-Search-Antworten
This commit is contained in:
1 parent
8039b47dec
commit
f49c526384
2 files changed
+26
-2
No files matched your search
+25
-1
@@ -117,7 +117,29 @@ function _findOldestMessageId(entries) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function _mergeConsecutiveAssistantTexts(msgs) {
|
||||
const result = [];
|
||||
for (const msg of msgs) {
|
||||
if (msg.type === 'text' && msg.role === 'assistant') {
|
||||
const prev = result[result.length - 1];
|
||||
if (prev && prev.type === 'text' && prev.role === 'assistant'
|
||||
&& prev.iteration === msg.iteration) {
|
||||
// Gleiche Iteration: nahtlos zusammenfügen (Web-Search-Fragmente etc.)
|
||||
prev.content = (prev.content || '') + ' ' + (msg.content || '');
|
||||
// IDs/Timestamps: letztes behalten (für Mark-Button etc.)
|
||||
if (msg.id) prev.id = msg.id;
|
||||
if (msg.createdAt) prev.createdAt = msg.createdAt;
|
||||
if (msg.isMarked) prev.isMarked = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result.push(Object.assign({}, msg));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function _renderMessagesIntoFragment(fragment, msgs) {
|
||||
msgs = _mergeConsecutiveAssistantTexts(msgs);
|
||||
for (const msg of msgs) {
|
||||
const div = document.createElement('div');
|
||||
switch (msg.type) {
|
||||
@@ -185,6 +207,7 @@ function _renderMessagesIntoFragment(fragment, msgs) {
|
||||
}
|
||||
|
||||
function renderMessages(msgs, addToConversation) {
|
||||
msgs = _mergeConsecutiveAssistantTexts(msgs);
|
||||
for (const msg of msgs) {
|
||||
if (msg.id > lastKnownMessageId) lastKnownMessageId = msg.id;
|
||||
|
||||
@@ -266,7 +289,8 @@ async function loadLatestArchive() {
|
||||
fragment.appendChild(sep);
|
||||
|
||||
for (const entry of data) {
|
||||
for (const msg of entry.messages) {
|
||||
const mergedMsgs = _mergeConsecutiveAssistantTexts(entry.messages);
|
||||
for (const msg of mergedMsgs) {
|
||||
const div = document.createElement('div');
|
||||
switch (msg.type) {
|
||||
case 'text':
|
||||
|
||||
@@ -151,7 +151,7 @@ registerPage('dashboard', {
|
||||
if (a.useSoul) badges.push('<span class="badge badge-feature" title="Hat eine Seele (SOUL.md)"><i class="fa fa-heart"></i> Seele</span>');
|
||||
if (a.useIdentity) badges.push('<span class="badge badge-feature" title="Hat eine Identität (IDENTITY.md)"><i class="fa fa-id-badge"></i> Ich</span>');
|
||||
if (a.useUserInfo) badges.push('<span class="badge badge-feature" title="Kennt sein Gegenüber (USER.md)"><i class="fa fa-user"></i> Du</span>');
|
||||
if (a.useMemory) badges.push('<span class="badge badge-feature" title="Auf Erinnerungen zugreifen (Memory-Tools)"><i class="fa fa-database"></i> Erinnerungen</span>');
|
||||
if (a.useMemory) badges.push('<span class="badge badge-feature" title="Zugriff auf Erinnerungen (Memory-Tools)"><i class="fa fa-database"></i> Erinnerungen</span>');
|
||||
if (a.webSearchVersion) {
|
||||
const wsYear = a.webSearchVersion.includes('2025') ? '2025' : '2026';
|
||||
badges.push(`<span class="badge badge-feature" title="Web-Suche (${wsYear})"><i class="fa fa-search"></i> Web-Suche</span>`);
|
||||
|
||||
Reference in new issue
Block a user