From e395c82a9f031d0ca94155e07dc1ef79bf1071c9 Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Mon, 9 Mar 2026 17:59:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E5=92=8C=E5=A4=8D=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 隐藏前端系统消息块显示 - 修复压缩对话后自动跳转到新对话 - 压缩对话标题改为"原标题 压缩后" - 复制对话标题改为"原标题 的副本" Co-Authored-By: Claude Sonnet 4.5 --- static/src/app/methods/message.ts | 6 +++++- static/src/components/chat/ChatArea.vue | 2 +- utils/context_manager.py | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/static/src/app/methods/message.ts b/static/src/app/methods/message.ts index a0a4ee1..6b6b7c6 100644 --- a/static/src/app/methods/message.ts +++ b/static/src/app/methods/message.ts @@ -238,8 +238,12 @@ export const messageMethods = { if (response.ok && result.success) { const newId = result.compressed_conversation_id; if (newId) { - this.currentConversationId = newId; + await this.loadConversation(newId, { force: true }); } + + this.conversationsOffset = 0; + await this.loadConversationsList(); + debugLog('对话压缩完成:', result); } else { const message = result.message || result.error || '压缩失败'; diff --git a/static/src/components/chat/ChatArea.vue b/static/src/components/chat/ChatArea.vue index 73be804..cb95b6d 100644 --- a/static/src/components/chat/ChatArea.vue +++ b/static/src/components/chat/ChatArea.vue @@ -387,7 +387,7 @@ const stackedBlocksEnabled = computed(() => { return enabled !== false; }); const filteredMessages = computed(() => - (props.messages || []).filter(m => !(m && m.metadata && m.metadata.system_injected_image)) + (props.messages || []).filter(m => !(m && m.metadata && m.metadata.system_injected_image) && m.role !== 'system') ); const DEFAULT_GENERATING_TEXT = '生成中…'; diff --git a/utils/context_manager.py b/utils/context_manager.py index 6f236c4..b78e738 100644 --- a/utils/context_manager.py +++ b/utils/context_manager.py @@ -946,10 +946,11 @@ class ContextManager: has_images=has_images ) - # 复制原对话标题(若存在) + # 设置压缩后的对话标题 if original_title: try: - self.conversation_manager.update_conversation_title(compressed_conversation_id, original_title) + new_title = f"{original_title} 压缩后" + self.conversation_manager.update_conversation_title(compressed_conversation_id, new_title) except Exception: pass @@ -970,6 +971,7 @@ class ContextManager: } original_messages = deepcopy(conversation_data.get("messages", []) or []) + original_title = conversation_data.get("title") metadata = conversation_data.get("metadata", {}) resolved_project_path = self._resolve_project_path_from_metadata(metadata) @@ -1002,6 +1004,14 @@ class ContextManager: self.conversation_manager._save_conversation_file(duplicate_conversation_id, new_data) self.conversation_manager._update_index(duplicate_conversation_id, new_data) + # 设置复制后的对话标题 + if original_title: + try: + new_title = f"{original_title} 的副本" + self.conversation_manager.update_conversation_title(duplicate_conversation_id, new_title) + except Exception: + pass + return { "success": True, "duplicate_conversation_id": duplicate_conversation_id