From 1b2dccee6ea5f83a2591135c89d2ce221d6e18a8 Mon Sep 17 00:00:00 2001 From: Haze <709547807@qq.com> Date: Sun, 19 Apr 2026 19:36:33 +0800 Subject: [PATCH] refactor(chat): execution graph optimize (#873) Co-authored-by: Haze --- src/i18n/locales/en/chat.json | 15 +- src/i18n/locales/ja/chat.json | 15 +- src/i18n/locales/ru/chat.json | 15 +- src/i18n/locales/zh/chat.json | 15 +- src/pages/Chat/ChatInput.tsx | 73 ++-- src/pages/Chat/ChatMessage.tsx | 26 +- src/pages/Chat/ChatToolbar.tsx | 26 +- src/pages/Chat/ExecutionGraphCard.tsx | 309 +++++++++----- src/pages/Chat/index.tsx | 394 ++++++++++++++---- src/pages/Chat/message-utils.ts | 114 +++++ src/pages/Chat/task-visualization.ts | 184 +++++--- src/stores/chat.ts | 54 +-- src/stores/chat/helpers.ts | 39 +- src/stores/chat/internal.ts | 3 - src/stores/chat/runtime-ui-actions.ts | 4 +- src/stores/chat/store-api.ts | 2 +- src/stores/chat/types.ts | 2 - tests/e2e/chat-task-visualizer.spec.ts | 238 +++++++++-- tests/unit/chat-event-dedupe.test.ts | 140 +++++++ tests/unit/chat-message.test.tsx | 1 - tests/unit/chat-page-execution-graph.test.tsx | 180 ++++++++ tests/unit/chat-store-history-retry.test.ts | 4 - tests/unit/chat-target-routing.test.ts | 2 - tests/unit/task-visualization.test.ts | 125 ++++-- 24 files changed, 1444 insertions(+), 536 deletions(-) create mode 100644 tests/unit/chat-event-dedupe.test.ts create mode 100644 tests/unit/chat-page-execution-graph.test.tsx diff --git a/src/i18n/locales/en/chat.json b/src/i18n/locales/en/chat.json index b2b83f73d..437dc0d1d 100644 --- a/src/i18n/locales/en/chat.json +++ b/src/i18n/locales/en/chat.json @@ -13,8 +13,6 @@ "noLogs": "(No logs available yet)", "toolbar": { "refresh": "Refresh chat", - "showThinking": "Show thinking", - "hideThinking": "Hide thinking", "currentAgent": "Talking to {{agent}}" }, "taskPanel": { @@ -34,19 +32,12 @@ } }, "executionGraph": { - "eyebrow": "Conversation Run", "title": "Execution Graph", - "status": { - "active": "Active", - "latest": "Latest", - "previous": "Previous" - }, "branchLabel": "branch", - "userTrigger": "User Trigger", - "userTriggerHint": "Triggered by the user message above", + "thinkingLabel": "Thinking", "agentRun": "{{agent}} execution", - "agentReply": "Assistant Reply", - "agentReplyHint": "Resolved in the assistant reply below" + "collapsedSummary": "{{toolCount}} tool calls · {{processCount}} process messages", + "collapseAction": "Collapse execution graph" }, "composer": { "attachFiles": "Attach files", diff --git a/src/i18n/locales/ja/chat.json b/src/i18n/locales/ja/chat.json index 96584b225..d6f01557e 100644 --- a/src/i18n/locales/ja/chat.json +++ b/src/i18n/locales/ja/chat.json @@ -13,8 +13,6 @@ "noLogs": "(ログはまだありません)", "toolbar": { "refresh": "チャットを更新", - "showThinking": "思考を表示", - "hideThinking": "思考を非表示", "currentAgent": "現在の会話相手: {{agent}}" }, "taskPanel": { @@ -34,19 +32,12 @@ } }, "executionGraph": { - "eyebrow": "会話実行", "title": "実行グラフ", - "status": { - "active": "進行中", - "latest": "直近", - "previous": "履歴" - }, "branchLabel": "branch", - "userTrigger": "ユーザー入力", - "userTriggerHint": "上のユーザーメッセージがトリガーです", + "thinkingLabel": "考え中", "agentRun": "{{agent}} の実行", - "agentReply": "アシスタント返信", - "agentReplyHint": "結果は下のアシスタント返信に反映されます" + "collapsedSummary": "ツール呼び出し {{toolCount}} 件 · プロセスメッセージ {{processCount}} 件", + "collapseAction": "実行グラフを折りたたむ" }, "composer": { "attachFiles": "ファイルを添付", diff --git a/src/i18n/locales/ru/chat.json b/src/i18n/locales/ru/chat.json index 949d0c731..d964ece26 100644 --- a/src/i18n/locales/ru/chat.json +++ b/src/i18n/locales/ru/chat.json @@ -13,8 +13,6 @@ "noLogs": "(Журналы ещё недоступны)", "toolbar": { "refresh": "Обновить чат", - "showThinking": "Показать размышления", - "hideThinking": "Скрыть размышления", "currentAgent": "Общение с {{agent}}" }, "taskPanel": { @@ -34,19 +32,12 @@ } }, "executionGraph": { - "eyebrow": "Выполнение в чате", "title": "Граф выполнения", - "status": { - "active": "Активно", - "latest": "Последнее", - "previous": "Предыдущее" - }, "branchLabel": "ветвь", - "userTrigger": "Триггер пользователя", - "userTriggerHint": "Запущен пользовательским сообщением выше", + "thinkingLabel": "Думаю", "agentRun": "Выполнение {{agent}}", - "agentReply": "Ответ ассистента", - "agentReplyHint": "Разрешено в ответе ассистента ниже" + "collapsedSummary": "Вызовов инструментов: {{toolCount}} · Промежуточных сообщений: {{processCount}}", + "collapseAction": "Свернуть граф выполнения" }, "composer": { "attachFiles": "Прикрепить файлы", diff --git a/src/i18n/locales/zh/chat.json b/src/i18n/locales/zh/chat.json index 697c08df8..88ea7f963 100644 --- a/src/i18n/locales/zh/chat.json +++ b/src/i18n/locales/zh/chat.json @@ -13,8 +13,6 @@ "noLogs": "(暂无日志)", "toolbar": { "refresh": "刷新聊天", - "showThinking": "显示思考过程", - "hideThinking": "隐藏思考过程", "currentAgent": "当前对话对象:{{agent}}" }, "taskPanel": { @@ -34,19 +32,12 @@ } }, "executionGraph": { - "eyebrow": "对话执行", "title": "执行关系图", - "status": { - "active": "执行中", - "latest": "最近一次", - "previous": "历史" - }, "branchLabel": "分支", - "userTrigger": "用户触发", - "userTriggerHint": "对应上方这条用户消息", + "thinkingLabel": "思考中", "agentRun": "{{agent}} 执行", - "agentReply": "助手回复", - "agentReplyHint": "结果体现在下方这条助手回复里" + "collapsedSummary": "{{toolCount}} 个工具调用,{{processCount}} 条过程消息", + "collapseAction": "收起执行关系图" }, "composer": { "attachFiles": "添加文件", diff --git a/src/pages/Chat/ChatInput.tsx b/src/pages/Chat/ChatInput.tsx index dbe8307eb..c1a479d81 100644 --- a/src/pages/Chat/ChatInput.tsx +++ b/src/pages/Chat/ChatInput.tsx @@ -114,7 +114,7 @@ export function ChatInput({ onSend, onStop, disabled = false, sending = false, i useEffect(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; - textareaRef.current.style.height = `${Math.min(textareaRef.current.scrollHeight, 200)}px`; + textareaRef.current.style.height = `${Math.min(textareaRef.current.scrollHeight, 240)}px`; } }, [input]); @@ -407,33 +407,54 @@ export function ChatInput({ onSend, onStop, disabled = false, sending = false, i )} - {/* Input Row */} -
+ {/* Input Container */} +
{selectedTarget && ( -
+
)} -
+ {/* Text Row — flush-left */} +