diff --git a/db/exploration.go b/db/exploration.go index c90a290..a23792c 100644 --- a/db/exploration.go +++ b/db/exploration.go @@ -1064,9 +1064,10 @@ type GoalCounts struct{ Total, Met int } // TaskListMetrics contains the aggregates rendered in task lists. type TaskListMetrics struct { - Tokens TokenUsage - LastActivity int64 - Goals GoalCounts + Tokens TokenUsage + LastActivity int64 + Goals GoalCounts + RunningIntents int // kind='intent' 且 state='running' 的条数,即运行中 Worker 数 } // TaskListMetricsAll returns list aggregates for every live task in one query. @@ -1081,7 +1082,8 @@ func (d *DB) TaskListMetricsAll() (map[int64]TaskListMetrics, error) { COALESCE(token_metrics.cache_write_tokens,0), COALESCE(latest_activity.created_at,0), COALESCE(goal_metrics.total,0), - COALESCE(goal_metrics.met,0) + COALESCE(goal_metrics.met,0), + COALESCE(intent_metrics.running,0) FROM tasks task LEFT JOIN LATERAL ( SELECT SUM(input_tokens) AS input_tokens, @@ -1104,6 +1106,11 @@ func (d *DB) TaskListMetricsAll() (map[int64]TaskListMetrics, error) { FROM exploration_nodes WHERE exploration_id=task.exploration_id AND kind='goal' ) goal_metrics ON true + LEFT JOIN LATERAL ( + SELECT COUNT(*) AS running + FROM exploration_nodes + WHERE exploration_id=task.exploration_id AND kind='intent' AND state='running' + ) intent_metrics ON true WHERE task.deleted_at IS NULL`) if err != nil { return nil, err @@ -1122,6 +1129,7 @@ func (d *DB) TaskListMetricsAll() (map[int64]TaskListMetrics, error) { &metrics.LastActivity, &metrics.Goals.Total, &metrics.Goals.Met, + &metrics.RunningIntents, ); err != nil { return nil, err } diff --git a/server/dto.go b/server/dto.go index 596b808..2c77971 100644 --- a/server/dto.go +++ b/server/dto.go @@ -50,6 +50,7 @@ type TaskDTO struct { Tokens TokenTotalDTO `json:"tokens"` // whole-task token consumption GoalsTotal int `json:"goals_total"` GoalsMet int `json:"goals_met"` + InFlight int `json:"in_flight"` // 运行中 Worker 数(state=running 的意图) 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 6fc4354..7abf506 100644 --- a/server/server.go +++ b/server/server.go @@ -1064,6 +1064,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 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 3eaac38..a5637bf 100644 --- a/web/src/app/(main)/function/tasks/page.tsx +++ b/web/src/app/(main)/function/tasks/page.tsx @@ -948,6 +948,7 @@ export default function TasksPage() { onSort={sortTasksBy} /> 目标进度 + 运行中 Worker — )} + + {task.in_flight && task.in_flight > 0 ? ( + {task.in_flight} + ) : ( + 0 + )} + {fmtDateTime(task.created_unix)}