From d5fdbb0cb38fa193227b2bb4d1babfb434184939 Mon Sep 17 00:00:00 2001
From: ViperEkura <3081035982@qq.com>
Date: Thu, 26 Mar 2026 14:43:23 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E7=B2=BE?=
=?UTF-8?q?=E7=AE=80=E4=B8=8EUI=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/services/chat.py | 10 +
docs/Design.md | 9 +-
frontend/package-lock.json | 11 +
frontend/package.json | 1 +
frontend/src/App.vue | 163 ++----
frontend/src/api/index.js | 16 -
frontend/src/components/ChatView.vue | 114 ++--
frontend/src/components/MessageBubble.vue | 83 ++-
frontend/src/components/MessageInput.vue | 2 +-
frontend/src/components/ProcessBlock.vue | 601 +++++++++------------
frontend/src/components/ProjectManager.vue | 63 ++-
frontend/src/components/SettingsPanel.vue | 68 +--
frontend/src/components/Sidebar.vue | 15 +-
frontend/src/components/StatsPanel.vue | 564 ++++++++++++++-----
frontend/src/composables/useTheme.js | 17 +-
frontend/src/styles/global.css | 330 ++++++++---
frontend/src/styles/highlight.css | 72 ++-
frontend/src/utils/markdown.js | 88 ++-
18 files changed, 1345 insertions(+), 882 deletions(-)
diff --git a/backend/services/chat.py b/backend/services/chat.py
index 7ce3943..efd8c13 100644
--- a/backend/services/chat.py
+++ b/backend/services/chat.py
@@ -127,6 +127,11 @@ class ChatService:
yield f"event: process_step\ndata: {json.dumps({'index': step_index, 'type': 'thinking', 'content': full_thinking}, ensure_ascii=False)}\n\n"
step_index += 1
+ # Send text as a step if exists (text before tool calls)
+ if full_content:
+ yield f"event: process_step\ndata: {json.dumps({'index': step_index, 'type': 'text', 'content': full_content}, ensure_ascii=False)}\n\n"
+ step_index += 1
+
# Also send legacy tool_calls event for backward compatibility
yield f"event: tool_calls\ndata: {json.dumps({'calls': tool_calls_list}, ensure_ascii=False)}\n\n"
@@ -169,6 +174,11 @@ class ChatService:
yield f"event: process_step\ndata: {json.dumps({'index': step_index, 'type': 'thinking', 'content': full_thinking}, ensure_ascii=False)}\n\n"
step_index += 1
+ # Send text as a step if exists
+ if full_content:
+ yield f"event: process_step\ndata: {json.dumps({'index': step_index, 'type': 'text', 'content': full_content}, ensure_ascii=False)}\n\n"
+ step_index += 1
+
suggested_title = None
with app.app_context():
# Build content JSON
diff --git a/docs/Design.md b/docs/Design.md
index afe7f93..2289f0c 100644
--- a/docs/Design.md
+++ b/docs/Design.md
@@ -402,7 +402,7 @@ def process_tool_calls(self, tool_calls, context=None):
| `message` | 回复内容的增量片段 |
| `tool_calls` | 工具调用信息 |
| `tool_result` | 工具执行结果 |
-| `process_step` | 处理步骤(按顺序:thinking/tool_call/tool_result),支持交替显示 |
+| `process_step` | 处理步骤(按顺序:thinking/text/tool_call/tool_result),支持穿插显示 |
| `error` | 错误信息 |
| `done` | 回复结束,携带 message_id 和 token_count |
@@ -412,11 +412,14 @@ def process_tool_calls(self, tool_calls, context=None):
// 思考过程
{"index": 0, "type": "thinking", "content": "完整思考内容..."}
+// 回复文本(可穿插在任意步骤之间)
+{"index": 1, "type": "text", "content": "回复文本内容..."}
+
// 工具调用
-{"index": 1, "type": "tool_call", "id": "call_abc123", "name": "web_search", "arguments": "{\"query\": \"...\"}"}
+{"index": 2, "type": "tool_call", "id": "call_abc123", "name": "web_search", "arguments": "{\"query\": \"...\"}"}
// 工具返回
-{"index": 2, "type": "tool_result", "id": "call_abc123", "name": "web_search", "content": "{\"success\": true, ...}", "skipped": false}
+{"index": 3, "type": "tool_result", "id": "call_abc123", "name": "web_search", "content": "{\"success\": true, ...}", "skipped": false}
```
字段说明:
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index ceef20e..2b6fc93 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -11,6 +11,7 @@
"highlight.js": "^11.10.0",
"katex": "^0.16.40",
"marked": "^15.0.0",
+ "marked-highlight": "^2.2.3",
"vue": "^3.4.0"
},
"devDependencies": {
@@ -1151,6 +1152,7 @@
"resolved": "https://registry.npmmirror.com/marked/-/marked-15.0.12.tgz",
"integrity": "sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==",
"license": "MIT",
+ "peer": true,
"bin": {
"marked": "bin/marked.js"
},
@@ -1158,6 +1160,15 @@
"node": ">= 18"
}
},
+ "node_modules/marked-highlight": {
+ "version": "2.2.3",
+ "resolved": "https://registry.npmmirror.com/marked-highlight/-/marked-highlight-2.2.3.tgz",
+ "integrity": "sha512-FCfZRxW/msZAiasCML4isYpxyQWKEEx44vOgdn5Kloae+Qc3q4XR7WjpKKf8oMLk7JP9ZCRd2vhtclJFdwxlWQ==",
+ "license": "MIT",
+ "peerDependencies": {
+ "marked": ">=4 <18"
+ }
+ },
"node_modules/nanoid": {
"version": "3.3.11",
"resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.11.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 176b2ef..e368977 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -12,6 +12,7 @@
"highlight.js": "^11.10.0",
"katex": "^0.16.40",
"marked": "^15.0.0",
+ "marked-highlight": "^2.2.3",
"vue": "^3.4.0"
},
"devDependencies": {
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 5e74dd1..41d151a 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -14,7 +14,6 @@
/>