From e65d3e5202a8a5f74c2ed80fd0694daf06cdfdf0 Mon Sep 17 00:00:00 2001
From: Autumn-27 <53844290+Autumn-27@users.noreply.github.com>
Date: Thu, 24 Sep 2026 13:26:22 -0400
Subject: [PATCH] =?UTF-8?q?feat(tasks):=20=E4=BB=BB=E5=8A=A1=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E6=96=B0=E5=A2=9E=E6=BC=8F=E6=B4=9E=E6=95=B0=E9=87=8F?=
=?UTF-8?q?=E5=88=97=EF=BC=8C=E6=8F=8F=E8=BF=B0/=E7=9B=AE=E6=A0=87?=
=?UTF-8?q?=E5=88=97=E6=94=B6=E7=AA=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 任务列表接口 TaskListMetricsAll 批量统计每任务的漏洞数(findings 表,
按 task_id),经 TaskDTO.findings 下发;列表页新增「漏洞」列,>0 高亮
- 描述/目标列宽 max-w-xs → max-w-40,目标列补 title 悬浮全文
- mock data/handler 同步补 findings 字段
---
db/exploration.go | 10 +++++++++-
server/dto.go | 1 +
server/server.go | 1 +
web/src/app/(main)/function/tasks/page.tsx | 14 ++++++++++++--
web/src/lib/mock/data.ts | 2 ++
web/src/lib/mock/handler.ts | 1 +
web/src/lib/types.ts | 1 +
7 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/db/exploration.go b/db/exploration.go
index 56a31d5..e5b0fd5 100644
--- a/db/exploration.go
+++ b/db/exploration.go
@@ -1299,6 +1299,7 @@ type TaskListMetrics struct {
LastActivity int64
Goals GoalCounts
RunningIntents int // kind='intent' 且 state='running' 的条数,即运行中 Worker 数
+ Findings int // findings 表里该任务的漏洞条数
}
// TaskListMetricsAll returns list aggregates for every live task in one query.
@@ -1314,7 +1315,8 @@ func (d *DB) TaskListMetricsAll() (map[int64]TaskListMetrics, error) {
COALESCE(latest_activity.created_at,0),
COALESCE(goal_metrics.total,0),
COALESCE(goal_metrics.met,0),
- COALESCE(intent_metrics.running,0)
+ COALESCE(intent_metrics.running,0),
+ COALESCE(finding_metrics.findings,0)
FROM tasks task
LEFT JOIN LATERAL (
SELECT SUM(input_tokens) AS input_tokens,
@@ -1342,6 +1344,11 @@ func (d *DB) TaskListMetricsAll() (map[int64]TaskListMetrics, error) {
FROM exploration_nodes
WHERE exploration_id=task.exploration_id AND kind='intent' AND state='running'
) intent_metrics ON true
+ LEFT JOIN LATERAL (
+ SELECT COUNT(*) AS findings
+ FROM findings
+ WHERE task_id=task.id
+ ) finding_metrics ON true
WHERE task.deleted_at IS NULL`)
if err != nil {
return nil, err
@@ -1361,6 +1368,7 @@ func (d *DB) TaskListMetricsAll() (map[int64]TaskListMetrics, error) {
&metrics.Goals.Total,
&metrics.Goals.Met,
&metrics.RunningIntents,
+ &metrics.Findings,
); err != nil {
return nil, err
}
diff --git a/server/dto.go b/server/dto.go
index 0e1ff46..de51334 100644
--- a/server/dto.go
+++ b/server/dto.go
@@ -51,6 +51,7 @@ type TaskDTO struct {
GoalsTotal int `json:"goals_total"`
GoalsMet int `json:"goals_met"`
InFlight int `json:"in_flight"` // 运行中 Worker 数(state=running 的意图)
+ Findings int `json:"findings"` // 该任务已登记的漏洞数(findings 表)
LLMProfileID *int64 `json:"llm_profile_id,omitempty"` // LLM profile used for this task; nil = default
LLMProfileIDs []int64 `json:"llm_profile_ids"`
ActiveLLMProfileID *int64 `json:"active_llm_profile_id,omitempty"`
diff --git a/server/server.go b/server/server.go
index 7f804f3..5e6d0d9 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1040,6 +1040,7 @@ func (s *Server) listTasks(w http.ResponseWriter, r *http.Request) {
dto.GoalsTotal = metric.Goals.Total
dto.GoalsMet = metric.Goals.Met
dto.InFlight = metric.RunningIntents
+ dto.Findings = metric.Findings
dtos = append(dtos, dto)
}
writeJSON(w, 200, map[string]any{"tasks": dtos, "active": active})
diff --git a/web/src/app/(main)/function/tasks/page.tsx b/web/src/app/(main)/function/tasks/page.tsx
index 1cd442d..89df25d 100644
--- a/web/src/app/(main)/function/tasks/page.tsx
+++ b/web/src/app/(main)/function/tasks/page.tsx
@@ -950,6 +950,7 @@ export default function TasksPage() {
onSort={sortTasksBy}
/>
目标进度
+ 漏洞
运行中 Worker
}
-
+
- {task.goal}
+
+ {task.goal}
+
@@ -1213,6 +1216,13 @@ const TaskRow = React.memo(function TaskRow({
—
)}
+
+ {task.findings && task.findings > 0 ? (
+ {task.findings}
+ ) : (
+ 0
+ )}
+
{task.in_flight && task.in_flight > 0 ? (
{task.in_flight}
diff --git a/web/src/lib/mock/data.ts b/web/src/lib/mock/data.ts
index 6eaa336..1ed2d77 100644
--- a/web/src/lib/mock/data.ts
+++ b/web/src/lib/mock/data.ts
@@ -65,6 +65,7 @@ export const tasks: Task[] = [
paused: false,
active: true,
in_flight: 3,
+ findings: 4,
stalled: false,
goals_total: 5,
goals_met: 2,
@@ -90,6 +91,7 @@ export const tasks: Task[] = [
paused: false,
active: false,
in_flight: 2,
+ findings: 2,
stalled: false,
goals_total: 4,
goals_met: 1,
diff --git a/web/src/lib/mock/handler.ts b/web/src/lib/mock/handler.ts
index d240c7a..da22153 100644
--- a/web/src/lib/mock/handler.ts
+++ b/web/src/lib/mock/handler.ts
@@ -1192,6 +1192,7 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
paused: false,
active: true,
in_flight: 0,
+ findings: 0,
stalled: false,
goals_total: 0,
goals_met: 0,
diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts
index 165dd52..7dc8e3f 100644
--- a/web/src/lib/types.ts
+++ b/web/src/lib/types.ts
@@ -23,6 +23,7 @@ export interface Task {
queued?: boolean;
active?: boolean;
in_flight?: number;
+ findings?: number; // 该任务已登记的漏洞数
last_activity?: string;
stalled?: boolean;
goals_total?: number;