From 91685ebfddff04dcd8f654e84f9beb2b6190aa91 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sun, 14 Jun 2026 17:12:11 +0800 Subject: [PATCH] =?UTF-8?q?[moz]=20feat(frontend):=20=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E9=93=BE=E9=9D=A2=E6=9D=BF=E5=8A=A0=20from/to=20=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=20+=20=E7=AD=9B=E9=80=89=20+=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=B1=BB=E5=9E=8B=E6=9C=AA=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 前端:列表项加 from → to 标签(Agent 中文名) - 前端:加「全部 / 未处理」筛选按钮 - 前端:详情区也显示 from → to - 后端:ToolchainContextSection 修复事件类型 fallback 为中文标签 - 后端:加来源/指派信息到 prompt 消息体 --- src/daemon/toolchain_handler.py | 26 +++++++++- .../src/components/ToolchainPanel.tsx | 49 ++++++++++++++++++- 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/daemon/toolchain_handler.py b/src/daemon/toolchain_handler.py index bcde084..55b9b11 100644 --- a/src/daemon/toolchain_handler.py +++ b/src/daemon/toolchain_handler.py @@ -51,17 +51,41 @@ class ToolchainContextSection: name: str = "toolchain_context" priority: int = 10 + EVENT_LABELS_ZH: Dict[str, str] = { + "review_request": "Review 请求", + "review_result": "Review 结果", + "review_merged": "PR 合并", + "review_comment": "Review 评论", + "review_updated": "Review 更新", + "ci_failure": "CI 失败", + "deploy_failure": "部署失败", + "issue_assigned": "Issue 指派", + "mention": "@提及", + } + def render(self, context: PromptContext) -> str: event_type = context.event_type event_data: Dict = context.event_data or {} + # 事件类型中文标签 + event_label = self.EVENT_LABELS_ZH.get(event_type, event_type or '未知') + + # from / to 信息 + to_agent = context.agent_id or '' + from_agent = 'system' + # Part 1: 事件信息(现有模板引擎) if event_type in _TEMPLATE_MAP: variables = {k: str(v) for k, v in event_data.items()} event_text = render_template(event_type, variables) + # 补充事件类型中文标签 + from/to + header = f"- **事件类型**: {event_label}\n- **来源**: {from_agent}\n- **指派**: {to_agent}\n" + event_text = header + "\n" + event_text else: lines = ["## 工具链事件", ""] - lines.append(f"- **事件类型**: {event_type or '未知'}") + lines.append(f"- **事件类型**: {event_label}") + lines.append(f"- **来源**: {from_agent}") + lines.append(f"- **指派**: {to_agent}") if event_data: lines.append("- **事件详情**:") for key, value in event_data.items(): diff --git a/src/frontend/src/components/ToolchainPanel.tsx b/src/frontend/src/components/ToolchainPanel.tsx index 37c421d..c5e465f 100644 --- a/src/frontend/src/components/ToolchainPanel.tsx +++ b/src/frontend/src/components/ToolchainPanel.tsx @@ -4,6 +4,28 @@ */ import { useEffect, useState } from 'react'; +const AGENT_NAMES: Record = { + 'pangtong-fujunshi': '庞统', + 'simayi-challenger': '司马懿', + 'zhangfei-dev': '张飞', + 'guanyu-dev': '关羽', + 'zhaoyun-data': '赵云', + 'jiangwei-infra': '姜维', + 'system': '系统', +}; + +const EVENT_LABELS: Record = { + 'review_request': 'Review 请求', + 'review_result': 'Review 结果', + 'review_merged': 'PR 合并', + 'review_comment': 'Review 评论', + 'review_updated': 'Review 更新', + 'ci_failure': 'CI 失败', + 'deploy_failure': '部署失败', + 'issue_assigned': 'Issue 指派', + 'mention': '@提及', +}; + const STATUS_COLORS: Record = { pending: '#f59e0b22', claimed: '#6a9eff22', working: '#6a9eff22', review: '#818cf822', done: '#2ecc8a22', failed: '#ef444422', @@ -36,6 +58,7 @@ export default function ToolchainPanel() { const [detail, setDetail] = useState(null); const [searchQuery, setSearchQuery] = useState(''); const [loading, setLoading] = useState(false); + const [filterMode, setFilterMode] = useState<'all' | 'pending'>('all'); const loadTasks = async (q?: string) => { setLoading(true); @@ -52,6 +75,10 @@ export default function ToolchainPanel() { setLoading(false); }; + const displayed = filterMode === 'pending' + ? tasks.filter(t => !['done', 'failed', 'cancelled'].includes(t.status)) + : tasks; + useEffect(() => { loadTasks(); }, []); // 搜索防抖 300ms @@ -120,7 +147,19 @@ export default function ToolchainPanel() { padding: '3px 8px', borderRadius: 4, fontSize: 10, border: '1px solid #2a3550', background: '#161b2e', color: '#8899aa', cursor: 'pointer', }}>🔄 - {tasks.length} 条 + + + {filterMode === 'pending' ? displayed.length : tasks.length} 条 {/* 事件列表 */} @@ -130,7 +169,7 @@ export default function ToolchainPanel() { {loading ? '加载中...' : '暂无工具链事件'} )} - {tasks.map((t: any) => ( + {displayed.map((t: any) => (
setSelectedId(t.id)} style={{ padding: '10px 14px', borderBottom: '1px solid var(--line)', cursor: 'pointer', transition: 'background .15s', @@ -151,6 +190,9 @@ export default function ToolchainPanel() { fontSize: 12, fontWeight: 500, color: '#dde4f8', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', }}>{t.title}
+
+ {AGENT_NAMES['system'] || '系统'} → {AGENT_NAMES[t.assignee] || t.assignee || '?'} +
))} @@ -174,6 +216,9 @@ export default function ToolchainPanel() { {detail.id}
{detail.title}
+
+ {AGENT_NAMES['system'] || '系统'} → {AGENT_NAMES[detail.assignee] || detail.assignee || '?'} +
{fmtTime(detail.created_at)}