Add missing message actions to archive messages

- Archive messages (loadLatestArchive) now render reply, delete, mark
  and share buttons, matching the behavior of _renderMessagesIntoFragment
- Add review-bubble and preparer-bubble detection for archive messages
- Add data-role, data-timestamp attributes for proper reply quoting
- Add isMarked/deletedOn CSS class handling for archive messages
- Also add [Preparer:] to isReviewMsg check in _renderMessagesIntoFragment
  for consistency
This commit is contained in:
Meleki committed 2026-03-07 18:53:45 +01:00
1 parent f4dc5fd812
commit a82d8cfb05
1 file changed
+36 -6
+36 -6
View File
@@ -180,7 +180,7 @@ function _renderMessagesIntoFragment(fragment, msgs, imageMessageIds) {
const div = document.createElement('div'); const div = document.createElement('div');
switch (msg.type) { switch (msg.type) {
case 'text': { case 'text': {
const isReviewMsg = msg.content && (msg.content.startsWith('[Review:') || msg.content.startsWith('[Review-Feedback') || msg.content.startsWith('[Finalizer:')); const isReviewMsg = msg.content && (msg.content.startsWith('[Review:') || msg.content.startsWith('[Review-Feedback') || msg.content.startsWith('[Finalizer:') || msg.content.startsWith('[Preparer:'));
if (msg.role === 'user' && !isReviewMsg) { if (msg.role === 'user' && !isReviewMsg) {
div.className = 'msg user markdown' + (msg.isMarked ? ' marked' : ''); div.className = 'msg user markdown' + (msg.isMarked ? ' marked' : '');
if (msg.deletedOn) div.classList.add(isDeletedVisible() ? 'msg-deleted' : 'msg-deleted-hidden'); if (msg.deletedOn) div.classList.add(isDeletedVisible() ? 'msg-deleted' : 'msg-deleted-hidden');
@@ -472,17 +472,46 @@ async function loadLatestArchive() {
for (const msg of mergedMsgs) { for (const msg of mergedMsgs) {
const div = document.createElement('div'); const div = document.createElement('div');
switch (msg.type) { switch (msg.type) {
case 'text': case 'text': {
if (msg.role === 'user') { const isReviewMsg = msg.content && (msg.content.startsWith('[Review:') || msg.content.startsWith('[Review-Feedback') || msg.content.startsWith('[Finalizer:') || msg.content.startsWith('[Preparer:'));
div.className = 'msg user markdown archived'; if (msg.role === 'user' && !isReviewMsg) {
div.className = 'msg user markdown archived' + (msg.isMarked ? ' marked' : '');
if (msg.deletedOn) div.classList.add(isDeletedVisible() ? 'msg-deleted' : 'msg-deleted-hidden');
div.dataset.role = 'user';
div.dataset.timestamp = msg.createdAt || '';
if (msg.id) div.dataset.messageId = msg.id; if (msg.id) div.dataset.messageId = msg.id;
renderUserContent(div, msg.content); renderUserContent(div, msg.content);
_addTimestamp(div, msg.createdAt); _addTimestamp(div, msg.createdAt);
} else { _addReplyButton(div);
div.className = 'msg assistant markdown archived'; _addDeleteButton(div, msg.id, msg.deletedOn);
_addMarkButton(div, msg.id, msg.isMarked);
_addShareButton(div, msg.id);
} else if (isReviewMsg) {
div.className = 'msg review-bubble markdown archived' + (msg.isMarked ? ' marked' : '');
if (msg.deletedOn) div.classList.add(isDeletedVisible() ? 'msg-deleted' : 'msg-deleted-hidden');
div.dataset.role = msg.role;
div.dataset.timestamp = msg.createdAt || '';
if (msg.id) div.dataset.messageId = msg.id;
div.innerHTML = renderMarkdown(msg.content); div.innerHTML = renderMarkdown(msg.content);
parseFluentEmojis(div); parseFluentEmojis(div);
_addTimestamp(div, msg.createdAt); _addTimestamp(div, msg.createdAt);
_addReplyButton(div);
_addDeleteButton(div, msg.id, msg.deletedOn);
_addMarkButton(div, msg.id, msg.isMarked);
_addShareButton(div, msg.id);
} else if (msg.role === 'assistant') {
div.className = 'msg assistant markdown archived' + (msg.isMarked ? ' marked' : '');
if (msg.deletedOn) div.classList.add(isDeletedVisible() ? 'msg-deleted' : 'msg-deleted-hidden');
div.dataset.role = 'assistant';
div.dataset.timestamp = msg.createdAt || '';
if (msg.id) div.dataset.messageId = msg.id;
div.innerHTML = renderMarkdown(msg.content);
parseFluentEmojis(div);
_addTimestamp(div, msg.createdAt);
_addReplyButton(div);
_addDeleteButton(div, msg.id, msg.deletedOn);
_addMarkButton(div, msg.id, msg.isMarked);
_addShareButton(div, msg.id);
} }
if (msg.role === 'user' && msg.attachmentCount > 0) { if (msg.role === 'user' && msg.attachmentCount > 0) {
if (/\[Bild: [^\]]+\]/.test(msg.content)) archiveImageIds.push(msg.id); if (/\[Bild: [^\]]+\]/.test(msg.content)) archiveImageIds.push(msg.id);
@@ -498,6 +527,7 @@ async function loadLatestArchive() {
div.appendChild(ind); div.appendChild(ind);
} }
break; break;
}
case 'tool_use': case 'tool_use':
if (!isToolVisible(msg.toolName)) continue; if (!isToolVisible(msg.toolName)) continue;
div.className = 'tool-box archived'; div.className = 'tool-box archived';