fix(tasks): paginate compact task lists and preserve scroll on refresh
This commit is contained in:
parent
ed427505a8
commit
310007fab3
|
|
@ -1,9 +1,9 @@
|
|||
name: Task management UI
|
||||
on:
|
||||
push:
|
||||
paths: ['web/templates/index.html', 'web/static/js/tasks.js', 'web/static/js/long-tasks.js', 'web/static/js/router.js', 'web/static/js/auth.js', 'web/static/js/modal.js', 'web/static/js/rbac-guards.js', 'web/static/css/**', 'web/static/i18n/**', 'scripts/long-tasks-browser.test.cjs', 'scripts/task-controls-browser.test.cjs', 'scripts/helpers/task-ui-fixture.cjs', '.github/workflows/task-ui.yml']
|
||||
paths: ['web/templates/index.html', 'web/static/js/tasks.js', 'web/static/js/task-list-view.js', 'web/static/js/task-checklist-view.js', 'web/static/js/long-tasks.js', 'web/static/js/router.js', 'web/static/js/auth.js', 'web/static/js/modal.js', 'web/static/js/rbac-guards.js', 'web/static/css/**', 'web/static/i18n/**', 'scripts/long-tasks-browser.test.cjs', 'scripts/task-controls-browser.test.cjs', 'scripts/task-pagination-browser.test.cjs', 'scripts/helpers/task-ui-fixture.cjs', '.github/workflows/task-ui.yml']
|
||||
pull_request:
|
||||
paths: ['web/templates/index.html', 'web/static/js/tasks.js', 'web/static/js/long-tasks.js', 'web/static/js/router.js', 'web/static/js/auth.js', 'web/static/js/modal.js', 'web/static/js/rbac-guards.js', 'web/static/css/**', 'web/static/i18n/**', 'scripts/long-tasks-browser.test.cjs', 'scripts/task-controls-browser.test.cjs', 'scripts/helpers/task-ui-fixture.cjs', '.github/workflows/task-ui.yml']
|
||||
paths: ['web/templates/index.html', 'web/static/js/tasks.js', 'web/static/js/task-list-view.js', 'web/static/js/task-checklist-view.js', 'web/static/js/long-tasks.js', 'web/static/js/router.js', 'web/static/js/auth.js', 'web/static/js/modal.js', 'web/static/js/rbac-guards.js', 'web/static/css/**', 'web/static/i18n/**', 'scripts/long-tasks-browser.test.cjs', 'scripts/task-controls-browser.test.cjs', 'scripts/task-pagination-browser.test.cjs', 'scripts/helpers/task-ui-fixture.cjs', '.github/workflows/task-ui.yml']
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
|
|
@ -21,4 +21,4 @@ jobs:
|
|||
"$RUNNER_TEMP/task-ui-deps/node_modules/.bin/playwright" install --with-deps chromium
|
||||
- name: Test real task page entrypoints and controls
|
||||
run: |
|
||||
NODE_PATH="$RUNNER_TEMP/task-ui-deps/node_modules" node --test scripts/long-tasks-browser.test.cjs scripts/task-controls-browser.test.cjs
|
||||
NODE_PATH="$RUNNER_TEMP/task-ui-deps/node_modules" node --test scripts/long-tasks-browser.test.cjs scripts/task-controls-browser.test.cjs scripts/task-pagination-browser.test.cjs
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
例:目标为「整理已提供的本地安全测试材料,形成可交付报告」,范围列出允许读取的文件、输出目录以及“不访问新的目标”,验收条件列出需要包含的证据、覆盖缺口、文件格式及检查方式。不要把目标只写成“深度测评”,应描述希望交付什么。
|
||||
|
||||
旧任务、清单、Cron 和执行会话直接出现在统一列表中;清单详情嵌入同一工作区,保留单条执行、编辑、添加、重跑与定时设置。界面按状态和执行方式统一搜索、排序、分页。底层保留两种执行器及原 API,不重写已有数据。
|
||||
旧任务、清单、Cron 和执行会话直接出现在统一列表中;清单详情嵌入同一工作区,保留单条执行、编辑、添加、重跑与定时设置。界面按状态和执行方式统一搜索、排序、分页。左右列表均默认 20 条/页,采用与漏洞管理一致的紧凑行与详情抽屉;自动刷新保留页码、选中项和滚动位置。底层保留两种执行器及原 API,不重写已有数据。
|
||||
|
||||
## 执行机制
|
||||
|
||||
|
|
@ -62,7 +62,9 @@ flowchart TD
|
|||
|
||||
| 接口 | 用途 |
|
||||
| --- | --- |
|
||||
| `GET /api/tasks?mode=&status=&q=&limit=30&offset=0` | 统一列表;mode 可为 goal/list,包含旧任务及清单,摘要不包含执行轨迹 |
|
||||
| `GET /api/tasks?mode=&status=&q=&limit=20&offset=0` | 统一列表;mode 可为 goal/list,包含旧任务及清单,摘要不包含执行轨迹 |
|
||||
| `GET /api/batch-tasks/{queueId}?task_page=1&task_page_size=20` | 清单分页预览,附带全清单状态统计;不带分页参数时保留原完整响应 |
|
||||
| `GET /api/batch-tasks/{queueId}/tasks/{taskId}` | 读取所属清单内单条任务的完整内容与结果 |
|
||||
| `GET /api/long-tasks/options` | 可用项目、角色与模型渠道,不返回密钥 |
|
||||
| `GET /api/long-tasks?status=&q=&limit=30&offset=0` | 分页列表;摘要不携带完整目标材料或执行轨迹 |
|
||||
| `POST /api/long-tasks` | 保存草稿;字段见任务创建表单 |
|
||||
|
|
@ -88,3 +90,5 @@ flowchart TD
|
|||
- 新增任务控制器与 HTTP/真实 Pi Worker 集成回归:依赖链、慢规划/慢 Worker、失败路径替换、验收补做、时间/轮数预算、暂停恢复、事务失败不启动、权限/来源/版本冲突、任务记忆隔离与长输出尾部检索。
|
||||
- 真实 Pi SDK 对接本地模拟模型与工具,验证工具—检查点—记忆—结果—验收闭环,以及工具失败后模型虚报成功被拒绝。这里的“真实 Pi”不代表使用了真实供应商模型。
|
||||
- 真实前端的离线 Playwright 测试覆盖鉴权请求、草稿创建不执行、控制操作、报告下载、轮询保留输入、XSS 转义、明暗主题及 390/1440px 布局。夹具不操作任何现有任务或目标。
|
||||
|
||||
- 大清单浏览回归使用 365 条隔离样例,覆盖 20 条/页、19 页末页、双栏滚动、刷新期间手动滚动、详情读取完整结果,以及编辑草稿不被刷新覆盖。
|
||||
|
|
|
|||
|
|
@ -1130,6 +1130,7 @@ func setupRoutes(
|
|||
protected.PUT("/batch-tasks/:queueId/schedule", agentHandler.UpdateBatchQueueSchedule)
|
||||
protected.PUT("/batch-tasks/:queueId/schedule-enabled", agentHandler.SetBatchQueueScheduleEnabled)
|
||||
protected.DELETE("/batch-tasks/:queueId", agentHandler.DeleteBatchQueue)
|
||||
protected.GET("/batch-tasks/:queueId/tasks/:taskId", agentHandler.GetBatchTask)
|
||||
protected.PUT("/batch-tasks/:queueId/tasks/:taskId", agentHandler.UpdateBatchTask)
|
||||
protected.POST("/batch-tasks/:queueId/tasks/:taskId/run", agentHandler.RunSingleBatchTask)
|
||||
protected.POST("/batch-tasks/:queueId/tasks", agentHandler.AddBatchTask)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ type ManagedTaskRow struct {
|
|||
// ListManagedTasks merges before filtering/paging, avoiding gaps or duplicates
|
||||
// caused by paginating the two sources independently. No execution traces enter
|
||||
// the listing, and each source uses its own RBAC resource assignments.
|
||||
func (db *DB) ListManagedTasks(user, scope, mode, status, query string, limit, offset int) ([]ManagedTaskRow, error) {
|
||||
func managedTaskQuery(user, scope, mode, status, query string) (string, []any) {
|
||||
access := func(alias, resource string) (string, []any) {
|
||||
if scope == RBACScopeAll {
|
||||
return "1=1", nil
|
||||
|
|
@ -66,6 +66,18 @@ func (db *DB) ListManagedTasks(user, scope, mode, status, query string, limit, o
|
|||
sql += ` AND (instr(lower(name),lower(?))>0 OR instr(id,?)>0)`
|
||||
args = append(args, query, query)
|
||||
}
|
||||
return sql, args
|
||||
}
|
||||
|
||||
func (db *DB) CountManagedTasks(user, scope, mode, status, query string) (int, error) {
|
||||
querySQL, args := managedTaskQuery(user, scope, mode, status, query)
|
||||
var total int
|
||||
err := db.QueryRow(`SELECT COUNT(*) FROM (`+querySQL+`)`, args...).Scan(&total)
|
||||
return total, err
|
||||
}
|
||||
|
||||
func (db *DB) ListManagedTasks(user, scope, mode, status, query string, limit, offset int) ([]ManagedTaskRow, error) {
|
||||
sql, args := managedTaskQuery(user, scope, mode, status, query)
|
||||
sql += ` ORDER BY updated_at DESC,mode,id LIMIT ? OFFSET ?`
|
||||
args = append(args, limit, offset)
|
||||
rows, err := db.Query(sql, args...)
|
||||
|
|
|
|||
|
|
@ -1989,11 +1989,15 @@ func (h *AgentHandler) CreateBatchQueue(c *gin.Context) {
|
|||
// GetBatchQueue 获取批量任务队列
|
||||
func (h *AgentHandler) GetBatchQueue(c *gin.Context) {
|
||||
queueID := c.Param("queueId")
|
||||
queue, exists := h.batchTaskManager.GetBatchQueue(queueID)
|
||||
queue, exists := h.batchTaskManager.SnapshotBatchQueue(queueID)
|
||||
if !exists {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "队列不存在"})
|
||||
return
|
||||
}
|
||||
if c.Query("task_page") != "" || c.Query("task_page_size") != "" {
|
||||
h.writeBatchTaskPage(c, queue)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"queue": queue})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,118 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func copyBatchTime(value *time.Time) *time.Time {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
copy := *value
|
||||
return ©
|
||||
}
|
||||
|
||||
// SnapshotBatchQueue owns every mutable field before HTTP serialization. A
|
||||
// refresh must not race the worker updating status, result, or the task slice.
|
||||
func (m *BatchTaskManager) SnapshotBatchQueue(id string) (*BatchTaskQueue, bool) {
|
||||
if _, ok := m.GetBatchQueue(id); !ok {
|
||||
return nil, false
|
||||
}
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
source, ok := m.queues[id]
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
queue := *source
|
||||
queue.NextRunAt = copyBatchTime(source.NextRunAt)
|
||||
queue.LastScheduleTriggerAt = copyBatchTime(source.LastScheduleTriggerAt)
|
||||
queue.StartedAt = copyBatchTime(source.StartedAt)
|
||||
queue.CompletedAt = copyBatchTime(source.CompletedAt)
|
||||
queue.Tasks = make([]*BatchTask, 0, len(source.Tasks))
|
||||
for _, item := range source.Tasks {
|
||||
if item == nil {
|
||||
continue
|
||||
}
|
||||
task := *item
|
||||
task.StartedAt = copyBatchTime(item.StartedAt)
|
||||
task.CompletedAt = copyBatchTime(item.CompletedAt)
|
||||
queue.Tasks = append(queue.Tasks, &task)
|
||||
}
|
||||
return &queue, true
|
||||
}
|
||||
|
||||
func batchTaskCounts(queue *BatchTaskQueue) map[string]int {
|
||||
counts := map[string]int{"total": len(queue.Tasks), "pending": 0, "running": 0, "completed": 0, "failed": 0, "cancelled": 0}
|
||||
for _, task := range queue.Tasks {
|
||||
counts[task.Status]++
|
||||
}
|
||||
return counts
|
||||
}
|
||||
|
||||
func batchTaskPreview(value string, limit int) string {
|
||||
count := 0
|
||||
for offset := range value {
|
||||
if count == limit {
|
||||
return value[:offset] + "…"
|
||||
}
|
||||
count++
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func (h *AgentHandler) writeBatchTaskPage(c *gin.Context, queue *BatchTaskQueue) {
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("task_page", "1"))
|
||||
size, _ := strconv.Atoi(c.DefaultQuery("task_page_size", "20"))
|
||||
if size < 1 || size > 100 {
|
||||
size = 20
|
||||
}
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
total := len(queue.Tasks)
|
||||
pages := (total + size - 1) / size
|
||||
if pages < 1 {
|
||||
pages = 1
|
||||
}
|
||||
if page > pages {
|
||||
page = pages
|
||||
}
|
||||
start := (page - 1) * size
|
||||
end := start + size
|
||||
if end > total {
|
||||
end = total
|
||||
}
|
||||
stats := batchTaskCounts(queue)
|
||||
tasks := queue.Tasks[start:end]
|
||||
for _, task := range tasks {
|
||||
task.Message = batchTaskPreview(task.Message, 600)
|
||||
task.Result = batchTaskPreview(task.Result, 400)
|
||||
task.Error = batchTaskPreview(task.Error, 400)
|
||||
}
|
||||
queue.Tasks = tasks
|
||||
c.JSON(http.StatusOK, gin.H{"queue": queue, "task_stats": stats, "task_pagination": gin.H{"page": page, "page_size": size, "total": total, "total_pages": pages, "offset": start, "preview": true}})
|
||||
}
|
||||
|
||||
// GetBatchTask returns full evidence only for the selected task, within the
|
||||
// already-authorized queue. List previews never replace the persisted result.
|
||||
func (h *AgentHandler) GetBatchTask(c *gin.Context) {
|
||||
queue, ok := h.batchTaskManager.SnapshotBatchQueue(c.Param("queueId"))
|
||||
if !ok {
|
||||
c.JSON(404, gin.H{"error": "任务不存在"})
|
||||
return
|
||||
}
|
||||
for _, task := range queue.Tasks {
|
||||
if task.ID == c.Param("taskId") {
|
||||
stats := batchTaskCounts(queue)
|
||||
queue.Tasks = []*BatchTask{}
|
||||
c.JSON(200, gin.H{"task": task, "queue": queue, "task_stats": stats})
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(404, gin.H{"error": "子任务不存在"})
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"cyberstrike-ai/internal/database"
|
||||
"cyberstrike-ai/internal/security"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func TestBatchTaskPagesKeepTotalsAndFullEvidence(t *testing.T) {
|
||||
h, owner := longTaskFixture(t)
|
||||
h.batchTaskManager = NewBatchTaskManager(zap.NewNop())
|
||||
h.batchTaskManager.SetDB(h.db)
|
||||
messages := make([]string, 365)
|
||||
for i := range messages {
|
||||
messages[i] = fmt.Sprintf("Local fixture %d", i+1)
|
||||
}
|
||||
queue, err := h.batchTaskManager.CreateBatchQueue("365 fixtures", "", "single", "manual", "", "", nil, 2, messages)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h.db.SetResourceOwner("batch_task", queue.ID, owner.OwnerID)
|
||||
full := strings.Repeat("证据", 1000) + "FULL_EVIDENCE_TAIL"
|
||||
h.batchTaskManager.UpdateTaskStatus(queue.ID, queue.Tasks[0].ID, "completed", full, "")
|
||||
h.batchTaskManager.UpdateTaskStatus(queue.ID, queue.Tasks[25].ID, "running", "", "")
|
||||
h.batchTaskManager.UpdateQueueStatus(queue.ID, "paused")
|
||||
r := gin.New()
|
||||
r.Use(func(c *gin.Context) {
|
||||
c.Set(security.ContextSessionKey, security.Session{UserID: owner.OwnerID, Scope: database.RBACScopeOwn, Permissions: map[string]bool{"tasks:read": true}})
|
||||
})
|
||||
r.Use(security.RBACMiddleware(h.db))
|
||||
r.GET("/api/batch-tasks/:queueId", h.GetBatchQueue)
|
||||
r.GET("/api/batch-tasks/:queueId/tasks/:taskId", h.GetBatchTask)
|
||||
get := func(path string) *httptest.ResponseRecorder {
|
||||
t.Helper()
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, httptest.NewRequest("GET", path, nil))
|
||||
return w
|
||||
}
|
||||
first := get("/api/batch-tasks/" + queue.ID + "?task_page=1&task_page_size=20")
|
||||
if first.Code != 200 {
|
||||
t.Fatal(first.Code, first.Body.String())
|
||||
}
|
||||
var page struct {
|
||||
Queue BatchTaskQueue `json:"queue"`
|
||||
Stats map[string]int `json:"task_stats"`
|
||||
Pagination struct {
|
||||
Page, Total, Offset int
|
||||
Pages int `json:"total_pages"`
|
||||
} `json:"task_pagination"`
|
||||
}
|
||||
if err = json.Unmarshal(first.Body.Bytes(), &page); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(page.Queue.Tasks) != 20 || page.Pagination.Total != 365 || page.Pagination.Pages != 19 || page.Stats["running"] != 1 || page.Stats["completed"] != 1 || strings.Contains(first.Body.String(), "FULL_EVIDENCE_TAIL") {
|
||||
t.Fatalf("bad preview: %+v", page)
|
||||
}
|
||||
last := get("/api/batch-tasks/" + queue.ID + "?task_page=999&task_page_size=20")
|
||||
json.Unmarshal(last.Body.Bytes(), &page)
|
||||
if len(page.Queue.Tasks) != 5 || page.Pagination.Page != 19 || page.Pagination.Offset != 360 {
|
||||
t.Fatalf("bad last page: %+v", page)
|
||||
}
|
||||
detail := get("/api/batch-tasks/" + queue.ID + "/tasks/" + queue.Tasks[0].ID)
|
||||
if detail.Code != 200 || !strings.Contains(detail.Body.String(), "FULL_EVIDENCE_TAIL") {
|
||||
t.Fatal("full evidence lost", detail.Body.String())
|
||||
}
|
||||
legacy := get("/api/batch-tasks/" + queue.ID)
|
||||
json.Unmarshal(legacy.Body.Bytes(), &page)
|
||||
if len(page.Queue.Tasks) != 365 || page.Queue.Tasks[0].Result != full {
|
||||
t.Fatal("preview mutated live queue or legacy API")
|
||||
}
|
||||
other, err := h.db.CreateRBACUser("page-other", "Other", "hash", true, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
foreign, err := h.batchTaskManager.CreateBatchQueue("foreign", "", "single", "manual", "", "", nil, 1, []string{"private"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = h.db.SetResourceOwner("batch_task", foreign.ID, other.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
denied := get("/api/batch-tasks/" + foreign.ID + "/tasks/" + foreign.Tasks[0].ID)
|
||||
if denied.Code != 403 {
|
||||
t.Fatal("foreign evidence was accessible", denied.Code)
|
||||
}
|
||||
missing := get("/api/batch-tasks/" + queue.ID + "/tasks/not-in-this-queue")
|
||||
if missing.Code != 404 {
|
||||
t.Fatal(missing.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBatchQueueSnapshotWhileWorkersUpdate(t *testing.T) {
|
||||
manager := NewBatchTaskManager(zap.NewNop())
|
||||
queue, err := manager.CreateBatchQueue("snapshot", "", "single", "manual", "", "", nil, 1, []string{"test"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := queue.Tasks[0].ID
|
||||
var group sync.WaitGroup
|
||||
group.Add(2)
|
||||
go func() {
|
||||
defer group.Done()
|
||||
for i := 0; i < 100; i++ {
|
||||
manager.UpdateTaskStatus(queue.ID, id, "running", "", "")
|
||||
manager.UpdateTaskStatus(queue.ID, id, "completed", "evidence", "")
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
defer group.Done()
|
||||
for i := 0; i < 100; i++ {
|
||||
snapshot, ok := manager.SnapshotBatchQueue(queue.ID)
|
||||
if !ok {
|
||||
t.Error("snapshot missing")
|
||||
return
|
||||
}
|
||||
json.Marshal(snapshot)
|
||||
}
|
||||
}()
|
||||
group.Wait()
|
||||
}
|
||||
|
|
@ -24,6 +24,22 @@ func addLongTaskSpec(spec map[string]interface{}) {
|
|||
return op
|
||||
}
|
||||
id := map[string]interface{}{"name": "id", "in": "path", "required": true, "schema": stringSchema}
|
||||
queueID := map[string]interface{}{"name": "queueId", "in": "path", "required": true, "schema": stringSchema}
|
||||
taskID := map[string]interface{}{"name": "taskId", "in": "path", "required": true, "schema": stringSchema}
|
||||
taskPath := paths["/api/batch-tasks/{queueId}/tasks/{taskId}"]
|
||||
if taskPath == nil {
|
||||
taskPath = map[string]interface{}{}
|
||||
paths["/api/batch-tasks/{queueId}/tasks/{taskId}"] = taskPath
|
||||
}
|
||||
taskPath.(map[string]interface{})["get"] = operation("读取清单内单条任务的完整内容及结果", nil, []interface{}{queueID, taskID})
|
||||
|
||||
if path, ok := paths["/api/batch-tasks/{queueId}"].(map[string]interface{}); ok {
|
||||
if get, ok := path["get"].(map[string]interface{}); ok {
|
||||
params, _ := get["parameters"].([]map[string]interface{})
|
||||
get["parameters"] = append(params, map[string]interface{}{"name": "task_page", "in": "query", "schema": map[string]interface{}{"type": "integer", "minimum": 1}}, map[string]interface{}{"name": "task_page_size", "in": "query", "schema": map[string]interface{}{"type": "integer", "default": 20, "minimum": 1, "maximum": 100}})
|
||||
get["description"] = "不带分页参数时保留完整队列响应;带 task_page 时返回当前页预览、task_stats 全队列统计和 task_pagination。完整结果通过单条任务接口读取。"
|
||||
}
|
||||
}
|
||||
paths["/api/tasks"] = map[string]interface{}{"get": operation("统一任务列表:按 mode、status、q 筛选后统一分页", nil, nil)}
|
||||
paths["/api/long-tasks"] = map[string]interface{}{"get": operation("分页查询目标任务;支持 status、q、limit、offset", nil, nil), "post": operation("创建目标任务草稿,不自动执行", create, nil)}
|
||||
paths["/api/long-tasks"].(map[string]interface{})["post"].(map[string]interface{})["responses"].(map[string]interface{})["201"] = map[string]interface{}{"description": "草稿已保存"}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ func (h *AgentHandler) ListManagedTasks(c *gin.Context) {
|
|||
longTaskError(c, fmt.Errorf("无效的执行方式"))
|
||||
return
|
||||
}
|
||||
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "30"))
|
||||
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "20"))
|
||||
if limit < 1 || limit > 100 {
|
||||
limit = 30
|
||||
limit = 20
|
||||
}
|
||||
offset, _ := strconv.Atoi(c.DefaultQuery("offset", "0"))
|
||||
if offset < 0 {
|
||||
|
|
@ -34,15 +34,28 @@ func (h *AgentHandler) ListManagedTasks(c *gin.Context) {
|
|||
if offset > 100000 {
|
||||
offset = 100000
|
||||
}
|
||||
rows, err := h.db.ListManagedTasks(session.UserID, session.ScopeFor("tasks:read"), mode, c.Query("status"), strings.TrimSpace(c.Query("q")), limit+1, offset)
|
||||
total, err := h.db.CountManagedTasks(session.UserID, session.ScopeFor("tasks:read"), mode, c.Query("status"), strings.TrimSpace(c.Query("q")))
|
||||
if err != nil {
|
||||
h.logger.Error("统计任务列表失败", zap.Error(err))
|
||||
c.JSON(500, gin.H{"error": "查询任务列表失败"})
|
||||
return
|
||||
}
|
||||
if offset >= total {
|
||||
if total == 0 {
|
||||
offset = 0
|
||||
} else {
|
||||
offset = ((total - 1) / limit) * limit
|
||||
}
|
||||
}
|
||||
rows, err := h.db.ListManagedTasks(session.UserID, session.ScopeFor("tasks:read"), mode, c.Query("status"), strings.TrimSpace(c.Query("q")), limit, offset)
|
||||
if err != nil {
|
||||
h.logger.Error("查询任务列表失败", zap.Error(err))
|
||||
c.JSON(500, gin.H{"error": "查询任务列表失败"})
|
||||
return
|
||||
}
|
||||
more := len(rows) > limit
|
||||
if more {
|
||||
rows = rows[:limit]
|
||||
pages := (total + limit - 1) / limit
|
||||
if pages < 1 {
|
||||
pages = 1
|
||||
}
|
||||
c.JSON(200, gin.H{"tasks": rows, "has_more": more})
|
||||
c.JSON(200, gin.H{"tasks": rows, "has_more": offset+len(rows) < total, "total": total, "page": offset/limit + 1, "page_size": limit, "total_pages": pages, "offset": offset})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ function queue(id = 'q1') {
|
|||
async function fixture(t) {
|
||||
const a = goal('a', 'paused'); a.steps = [{ id: 's1', title: 'Local step', instruction: 'Read evidence', depends_on: [], status: 'failed', summary: 'Previous failure', conversation_id: 'conversation-a', attempts: 1 }];
|
||||
const state = { tasks: new Map([['a', a], ['b', goal('b')]]), queues: new Map([['q1', queue()]]), requests: [], hook: null, confirm: true, failResume: '', pageErrors: [] };
|
||||
const scripts = [...template.matchAll(/<script\b[^>]*\bsrc=["']([^"']+)["'][^>]*><\/script>/g)].filter(m => /^\/static\/js\/(router|auth|modal|tasks|long-tasks|rbac-guards)\.js(?:\?|$)/.test(m[1])).map(m => m[0]).join('');
|
||||
const scripts = [...template.matchAll(/<script\b[^>]*\bsrc=["']([^"']+)["'][^>]*><\/script>/g)].filter(m => /^\/static\/js\/(router|auth|modal|task-list-view|task-checklist-view|tasks|long-tasks|rbac-guards)\.js(?:\?|$)/.test(m[1])).map(m => m[0]).join('');
|
||||
const styles = [...template.matchAll(/<link\b[^>]*\bhref=["']([^"']+)["'][^>]*>/g)].filter(m => /^\/static\/css\/(style|mobile|long-tasks)\.css(?:\?|$)/.test(m[1])).map(m => m[0]).join('');
|
||||
const locale = JSON.stringify(JSON.parse(read('web/static/i18n/zh-CN.json'))).replaceAll('<', '\\u003c');
|
||||
const html = `<!doctype html><html><head><meta charset="UTF-8">${styles}</head><body><div class="container"><main class="main-layout"><section class="content-area">${div('page-tasks')}<div class="page" id="page-dashboard"><button onclick="switchPage('tasks')">Back to tasks</button></div><div class="page" id="page-chat"></div></section></main></div>${div('batch-import-modal')}${div('batch-queue-detail-modal')}${div('add-batch-task-modal')}<script>window.t=(key,opts={})=>{let v=key.split('.').reduce((o,k)=>o&&o[k],${locale});return String(v||key).replace(/{{(\\w+)}}/g,(_,k)=>String(opts[k]??''))};window.loadRoles=async()=>[];window.loadConversation=async id=>{window.visitedConversation=id};window.initializeChatUI=()=>{};window.refreshAppData=async()=>{};</script>${scripts}<script>document.removeEventListener('DOMContentLoaded',initializeApp);saveAuth('fixture-token',new Date(Date.now()+3600000),{user:{id:'fixture',username:'fixture'},permissions:['tasks:read','tasks:write','tasks:delete','agent:execute','chat:read','chat:write'],scope:'own'});</script></body></html>`;
|
||||
|
|
@ -45,7 +45,7 @@ async function fixture(t) {
|
|||
for (const q of state.queues.values()) rows.push({ id:q.id, mode:'list', name:q.title, status:q.status, summary:q.lastRunError || '', updated_at:q.createdAt, schedule_mode:q.scheduleMode, next_run_at:q.nextRunAt, completed_steps:q.tasks.filter(step => step.status==='completed').length, total_steps:q.tasks.length });
|
||||
const filtered=rows.filter(task => (!url.searchParams.get('mode') || task.mode===url.searchParams.get('mode')) && (!url.searchParams.get('status') || task.status===url.searchParams.get('status')) && (!url.searchParams.get('q') || task.name.includes(url.searchParams.get('q'))));
|
||||
const offset=Number(url.searchParams.get('offset')||0),limit=Number(url.searchParams.get('limit')||30);
|
||||
return send(200,{tasks:filtered.slice(offset,offset+limit),has_more:filtered.length>offset+limit});
|
||||
return send(200,{tasks:filtered.slice(offset,offset+limit),has_more:filtered.length>offset+limit,total:filtered.length,offset});
|
||||
}
|
||||
if (url.pathname === '/api/long-tasks') {
|
||||
if (req.method === 'POST') { const task = { ...goal('new-' + state.tasks.size), ...body }; state.tasks.set(task.id, task); return send(201, { task }); }
|
||||
|
|
@ -82,6 +82,16 @@ async function fixture(t) {
|
|||
const batch = url.pathname.match(/^\/api\/batch-tasks\/([^/]+)(?:\/(.*))?$/);
|
||||
if (batch) {
|
||||
const q = state.queues.get(batch[1]); if (!q) return send(404, { error: 'queue missing' }); const suffix = batch[2] || '';
|
||||
if(suffix.startsWith('tasks/') && req.method==='GET') {
|
||||
const item=q.tasks.find(item=>item.id===suffix.split('/')[1]);if(!item)return send(404,{error:'step missing'});
|
||||
const counts={total:q.tasks.length};for(const item of q.tasks)counts[item.status]=(counts[item.status]||0)+1;
|
||||
return send(200,{task:item,queue:{...q,tasks:[]},task_stats:counts});
|
||||
}
|
||||
if(!suffix && req.method==='GET' && url.searchParams.has('task_page')) {
|
||||
const size=Number(url.searchParams.get('task_page_size')||20),total=q.tasks.length,pages=Math.max(1,Math.ceil(total/size)),page=Math.min(pages,Math.max(1,Number(url.searchParams.get('task_page')||1))),offset=(page-1)*size;
|
||||
const counts={total,pending:0,running:0,completed:0,failed:0,cancelled:0};for(const item of q.tasks)counts[item.status]=(counts[item.status]||0)+1;
|
||||
return send(200,{queue:{...q,tasks:q.tasks.slice(offset,offset+size).map(item=>({...item,message:item.message.slice(0,600),result:(item.result||'').slice(0,400)}))},task_stats:counts,task_pagination:{page,page_size:size,total,total_pages:pages,offset,preview:true}});
|
||||
}
|
||||
if (suffix === 'start' || suffix === 'rerun') q.status = 'running';
|
||||
else if (suffix === 'pause') q.status = 'paused';
|
||||
else if (suffix === 'metadata' || suffix === 'schedule' || suffix === 'schedule-enabled') Object.assign(q, body);
|
||||
|
|
@ -101,9 +111,9 @@ async function fixture(t) {
|
|||
page.on('pageerror', error => state.pageErrors.push(error.message));
|
||||
page.on('dialog', dialog => (dialog.type() === 'confirm' && !state.confirm) ? dialog.dismiss() : dialog.accept());
|
||||
await page.goto(`http://127.0.0.1:${server.address().port}/#tasks`);
|
||||
await page.locator('[data-lt-action=select][data-id=a]').waitFor();
|
||||
await page.locator('[data-record-id="goal:a"] [data-record-open]').waitFor();
|
||||
await page.locator('#tasks-auto-refresh').uncheck();
|
||||
const select = async id => { await page.locator(`[data-lt-action=select][data-mode=goal][data-id="${id}"]`).click(); await page.waitForFunction(id => document.getElementById('lt-name').textContent === '目标 ' + id, id); };
|
||||
const select = async id => { await page.locator(`[data-record-id="goal:${id}"] [data-record-open]`).click(); await page.waitForFunction(id => document.getElementById('lt-name').textContent === '目标 ' + id, id); };
|
||||
const refresh = () => page.evaluate(() => refreshTaskWorkspace());
|
||||
return { page, state, select, refresh };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ test('goal task page: authenticated controls, stable polling, XSS, report and re
|
|||
// Load exactly the entrypoint's scripts in their original order. Do not inject
|
||||
// long-tasks.js independently: that hid a missing production script tag.
|
||||
const scriptTags = [...template.matchAll(/<script\b[^>]*\bsrc=["']([^"']+)["'][^>]*><\/script>/g)]
|
||||
.filter(match => /^\/static\/js\/(router|auth|tasks|long-tasks)\.js(?:\?|$)/.test(match[1]))
|
||||
.filter(match => /^\/static\/js\/(router|auth|task-list-view|task-checklist-view|tasks|long-tasks)\.js(?:\?|$)/.test(match[1]))
|
||||
.map(match => match[0]).join('');
|
||||
const styleTags = [...template.matchAll(/<link\b[^>]*\bhref=["']([^"']+)["'][^>]*>/g)]
|
||||
.filter(match => /^\/static\/css\/(style|mobile|long-tasks)\.css(?:\?|$)/.test(match[1]))
|
||||
|
|
@ -33,7 +33,7 @@ test('goal task page: authenticated controls, stable polling, XSS, report and re
|
|||
if (req.url === '/api/auth/validate') { res.setHeader('Content-Type','application/json'); return res.end('{}'); }
|
||||
if (req.url === '/favicon.ico') { res.statusCode=204; return res.end(); }
|
||||
if (req.url.startsWith('/api/batch-tasks')) { res.setHeader('Content-Type','application/json'); return res.end(JSON.stringify({queues:[],total:0,total_pages:1})); }
|
||||
if (req.url.startsWith('/api/tasks?')) { authenticated.push(req.headers.authorization); res.setHeader('Content-Type','application/json'); return res.end(JSON.stringify({tasks:[{...task,mode:'goal'}],has_more:false})); }
|
||||
if (req.url.startsWith('/api/tasks?')) { authenticated.push(req.headers.authorization); res.setHeader('Content-Type','application/json'); return res.end(JSON.stringify({tasks:[{...task,mode:'goal'}],has_more:false,total:1,offset:0})); }
|
||||
if (req.url.startsWith('/api/long-tasks')) {
|
||||
authenticated.push(req.headers.authorization);
|
||||
if (req.headers.authorization !== 'Bearer fixture-token') { res.statusCode = 401; return res.end('{}'); }
|
||||
|
|
@ -69,13 +69,14 @@ test('goal task page: authenticated controls, stable polling, XSS, report and re
|
|||
await page.evaluate(() => applyRBACToUI(document.getElementById('page-tasks')));
|
||||
assert.equal(await page.locator('#task-new-goal').isVisible(), true);
|
||||
assert.equal(await page.locator('#task-new-batch').count(), 0);
|
||||
await page.locator('[data-lt-action=select]').click();
|
||||
await page.locator('#lt-list [data-record-open]').click();
|
||||
await page.locator('#lt-name').waitFor();
|
||||
await page.waitForFunction(() => document.getElementById('lt-name').textContent.includes('本地材料'));
|
||||
assert.equal(await page.evaluate(() => window.bad), undefined);
|
||||
assert.equal(await page.locator('#lt-name img').count(), 0);
|
||||
await page.locator('[data-lt-action=start]').click();
|
||||
await page.locator('#lt-state .lt-status-running').waitFor();
|
||||
await page.locator('#lt-support > summary').click();
|
||||
await page.locator('#lt-guidance-input').fill('保留这个尚未提交的补充');
|
||||
await page.evaluate(() => refreshTaskWorkspace());
|
||||
assert.equal(await page.locator('#lt-guidance-input').inputValue(), '保留这个尚未提交的补充');
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ const { fixture, goal } = require('./helpers/task-ui-fixture.cjs');
|
|||
test('goal task actions: retry, budget, resume, pause, answer, report, cancel and delete', async t => {
|
||||
const { page, state, select, refresh } = await fixture(t);
|
||||
await select('a');
|
||||
await page.locator('[data-lt-action=retry]').click();
|
||||
await page.locator('.lt-step .lt-status-pending').waitFor();
|
||||
await page.locator('#lt-steps [data-record-open]').first().click(); await page.locator('[data-step-retry]').click();
|
||||
await page.locator('#lt-steps .lt-status-pending').waitFor();
|
||||
assert.equal(state.tasks.get('a').steps[0].status, 'pending');
|
||||
await page.locator('[data-lt-action=budget]').click();
|
||||
await page.locator('#lt-modal [name=max_rounds]').fill('60'); await page.locator('#lt-modal [name=minutes]').fill('90');
|
||||
|
|
@ -26,19 +26,21 @@ test('goal task actions: retry, budget, resume, pause, answer, report, cancel an
|
|||
assert.deepEqual(state.pageErrors, []);
|
||||
});
|
||||
|
||||
test('search responds while typing and expanded step instructions survive refresh', async t => {
|
||||
test('search responds while typing and the step inspector survives refresh', async t => {
|
||||
const { page, state, select, refresh } = await fixture(t);
|
||||
await select('a'); await page.locator('.lt-step details summary').click(); await refresh();
|
||||
assert.equal(await page.locator('.lt-step details').evaluate(e => e.open), true);
|
||||
await select('a'); await page.locator('#lt-steps [data-record-open]').first().click(); await refresh();
|
||||
assert.equal(await page.locator('#task-step-inspector').isVisible(), true);
|
||||
await page.locator('[data-inspector-close]').click();
|
||||
await page.locator('#lt-search').fill('目标 b');
|
||||
await page.waitForFunction(() => document.querySelectorAll('.lt-card').length === 1 && document.querySelector('.lt-card').dataset.id === 'b');
|
||||
await page.waitForFunction(() => document.querySelectorAll('#lt-list .task-record-row').length === 1 && document.querySelector('#lt-list .task-record-row').dataset.recordId === 'goal:b');
|
||||
assert.ok(state.requests.some(r => r.query.q === '目标 b'));
|
||||
});
|
||||
|
||||
test('cancelled tasks never offer a retry that the API rejects', async t => {
|
||||
const { page, state, select, refresh } = await fixture(t);
|
||||
await select('a'); state.tasks.get('a').status = 'cancelled'; await refresh();
|
||||
assert.equal(await page.locator('[data-lt-action=retry]').count(), 0);
|
||||
await page.locator('#lt-steps [data-record-open]').first().click();
|
||||
assert.equal(await page.locator('[data-step-retry]').count(), 0);
|
||||
});
|
||||
|
||||
test('a late creation-options response does not open a modal after leaving the page', async t => {
|
||||
|
|
@ -66,10 +68,10 @@ test('deleting A while selecting B preserves B and report filenames stay attache
|
|||
test('goal paging, filters, refresh toggle, modal close and execution links work', async t => {
|
||||
const { page, state, select, refresh } = await fixture(t);
|
||||
for (let i = 0; i < 34; i++) state.tasks.set('extra-' + i, goal('extra-' + i));
|
||||
await refresh(); await page.locator('#lt-next').click(); await page.waitForFunction(() => document.getElementById('lt-page').textContent === '2');
|
||||
await page.locator('#lt-prev').click(); await page.waitForFunction(() => document.getElementById('lt-page').textContent === '1');
|
||||
await page.locator('#lt-filter').selectOption('paused'); await page.waitForFunction(() => document.querySelectorAll('.lt-card').length === 1);
|
||||
await page.locator('#lt-filter').selectOption(''); await page.waitForFunction(() => document.querySelectorAll('.lt-card').length === 30);
|
||||
await refresh(); await page.locator('#lt-pagination [data-page-nav=next]').click(); await page.waitForFunction(() => document.querySelector('#lt-pagination .task-page-controls span').textContent.startsWith('2 /'));
|
||||
await page.locator('#lt-pagination [data-page-nav=previous]').click(); await page.waitForFunction(() => document.querySelector('#lt-pagination .task-page-controls span').textContent.startsWith('1 /'));
|
||||
await page.locator('#lt-filter').selectOption('paused'); await page.waitForFunction(() => document.querySelectorAll('#lt-list .task-record-row').length === 1);
|
||||
await page.locator('#lt-filter').selectOption(''); await page.waitForFunction(() => document.querySelectorAll('#lt-list .task-record-row').length === 20);
|
||||
await page.locator('#task-new-goal').click(); await page.locator('#lt-modal').waitFor(); await page.locator('#lt-modal [data-close]').last().click(); await page.waitForFunction(() => !document.getElementById('lt-modal'));
|
||||
await page.locator('#task-new-goal').click(); await page.locator('#lt-modal').waitFor(); await page.keyboard.press('Escape'); await page.waitForFunction(() => !document.getElementById('lt-modal'));
|
||||
assert.equal(state.requests.filter(r => r.method === 'POST').length, 0);
|
||||
|
|
@ -77,7 +79,7 @@ test('goal paging, filters, refresh toggle, modal close and execution links work
|
|||
await page.waitForTimeout(4200); assert.ok(state.requests.filter(r => r.path === '/api/tasks').length > count);
|
||||
await page.locator('#tasks-auto-refresh').uncheck(); await refresh(); const stopped = state.requests.length;
|
||||
await page.waitForTimeout(4200); assert.equal(state.requests.length, stopped);
|
||||
await select('a'); await page.locator('.lt-step a').click(); await page.waitForFunction(() => window.visitedConversation === 'conversation-a');
|
||||
await select('a'); await page.locator('#lt-steps [data-record-open]').first().click(); await page.locator('#task-step-inspector a').click(); await page.waitForFunction(() => window.visitedConversation === 'conversation-a');
|
||||
assert.deepEqual(state.pageErrors, []);
|
||||
});
|
||||
|
||||
|
|
@ -118,25 +120,28 @@ test('batch queue controls: create, close, metadata, add/edit/delete steps, sing
|
|||
await page.locator('[onclick="createBatchQueue()"]').click();
|
||||
await page.locator('[data-bq-detail-for="new-queue"]').waitFor();
|
||||
assert.equal(state.queues.get('new-queue').executeNow, false);
|
||||
await page.locator('[data-lt-action=select][data-id=a][data-mode=goal]').click();
|
||||
await page.locator('.lt-card[data-id=q1][data-mode=list]').click(); await page.locator('[data-bq-detail-for=q1]').waitFor();
|
||||
await page.locator('[data-record-id="goal:a"] [data-record-open]').click();
|
||||
await page.locator('[data-record-id="list:q1"] [data-record-open]').click(); await page.locator('[data-bq-detail-for=q1]').waitFor();
|
||||
await page.locator('#bq-settings > summary').click();
|
||||
await page.locator('#bq-title-val .bq-inline-editable').click(); await page.locator('#bq-edit-title').fill('Renamed queue'); await page.locator('#bq-edit-title').press('Enter');
|
||||
await page.waitForFunction(() => document.getElementById('bq-title-val').textContent === 'Renamed queue'); assert.equal(state.queues.get('q1').title, 'Renamed queue');
|
||||
await page.locator('#bq-concurrency-val .bq-inline-editable').click(); await page.locator('#bq-edit-concurrency').fill('2'); await page.locator('#bq-edit-concurrency').press('Enter');
|
||||
await page.waitForFunction(() => !document.getElementById('bq-edit-concurrency')); assert.equal(state.queues.get('q1').concurrency, 2);
|
||||
await page.locator('#batch-queue-add-task-btn').click(); await page.locator('#add-task-message').fill('Added fixture step'); await page.locator('[onclick="saveAddBatchTask()"]').click();
|
||||
await page.locator('.batch-task-item[data-task-id=added]').waitFor();
|
||||
await page.locator('.batch-task-item[data-task-id=added] .batch-task-edit-btn').click(); await page.locator('#bq-task-edit-added').fill('Edited fixture step'); await page.locator('#bq-task-edit-added').press('Tab');
|
||||
await page.waitForFunction(() => document.querySelector('[data-task-id=added] .batch-task-message').textContent === 'Edited fixture step');
|
||||
await page.locator('.batch-task-item[data-task-id=added] .batch-task-delete-btn').click(); await page.locator('.batch-task-item[data-task-id=added]').waitFor({ state: 'detached' });
|
||||
await page.locator('.batch-task-item[data-task-id=b1] .batch-task-run-btn').click(); await page.waitForFunction(() => document.querySelector('[data-task-id=b1] .batch-task-status').textContent === '已完成');
|
||||
await page.locator('#bq-task-rows [data-record-id=added]').waitFor();
|
||||
await page.locator('#bq-task-rows [data-record-id=added] [data-record-open]').first().click();
|
||||
await page.locator('[data-checklist-action=edit]').click();await page.locator('[data-task-editor] textarea').fill('Edited fixture step');await page.locator('[data-task-editor] [type=submit]').click();
|
||||
await page.waitForFunction(() => document.querySelector('[data-task-overview]').textContent.includes('Edited fixture step'));
|
||||
await page.locator('[data-checklist-action=delete]').click();await page.locator('#bq-task-rows [data-record-id=added]').waitFor({state:'detached'});
|
||||
await page.locator('#bq-task-rows [data-record-id=b1] [data-record-open]').first().click();await page.locator('[data-checklist-action=run]').click();
|
||||
await page.waitForFunction(() => document.querySelector('#bq-task-rows [data-record-id=b1] .lt-status').textContent === '已完成');await page.locator('[data-inspector-close]').click();
|
||||
await page.locator('#batch-queue-start-btn').click(); await page.locator('#batch-queue-pause-btn').waitFor({ state: 'visible' }); assert.equal(state.queues.get('q1').status, 'running');
|
||||
await page.locator('#batch-queue-pause-btn').click(); await page.locator('#batch-queue-start-btn').waitFor({ state: 'visible' }); assert.equal(state.queues.get('q1').status, 'paused');
|
||||
await page.locator('#batch-queue-start-btn').click(); await page.locator('#batch-queue-pause-btn').waitFor({ state: 'visible' });
|
||||
state.queues.get('q1').status = 'completed'; await page.evaluate(() => showBatchQueueDetail('q1')); await page.locator('#batch-queue-rerun-btn').click(); await page.locator('#batch-queue-pause-btn').waitFor({ state: 'visible' });
|
||||
await page.locator('#batch-queue-pause-btn').click(); await page.locator('#batch-queue-delete-btn').waitFor({ state: 'visible' }); await page.locator('#batch-queue-delete-btn').click();
|
||||
await page.locator('#batch-queue-detail-modal').waitFor({ state: 'hidden' }); assert.equal(state.queues.has('q1'), false);
|
||||
await page.locator('.lt-card[data-id=new-queue][data-mode=list]').click(); await page.locator('[data-bq-detail-for=new-queue]').waitFor(); await page.locator('#batch-queue-delete-btn').click(); await page.locator('.lt-card[data-id=new-queue][data-mode=list]').waitFor({ state: 'detached' });
|
||||
await page.locator('[data-record-id="list:new-queue"] [data-record-open]').click(); await page.locator('[data-bq-detail-for=new-queue]').waitFor(); await page.locator('#batch-queue-delete-btn').click(); await page.locator('[data-record-id="list:new-queue"] [data-record-open]').waitFor({ state: 'detached' });
|
||||
assert.deepEqual(state.pageErrors, []);
|
||||
});
|
||||
|
||||
|
|
@ -148,7 +153,7 @@ test('batch create and add-step clicks cannot submit twice on a slow connection'
|
|||
await page.locator('[data-bq-detail-for="new-queue"]').waitFor();
|
||||
assert.equal(state.requests.filter(r => r.method === 'POST' && r.path === '/api/batch-tasks').length, 1);
|
||||
await page.locator('#batch-queue-add-task-btn').click(); await page.locator('#add-task-message').fill('One new step');
|
||||
await page.locator('[onclick="saveAddBatchTask()"]').dblclick(); await page.locator('[data-task-id=added]').waitFor();
|
||||
await page.locator('[onclick="saveAddBatchTask()"]').dblclick(); await page.locator('#bq-task-rows [data-record-id=added]').waitFor();
|
||||
assert.equal(state.requests.filter(r => r.method === 'POST' && r.path.endsWith('/new-queue/tasks')).length, 1);
|
||||
});
|
||||
|
||||
|
|
@ -158,10 +163,10 @@ test('late batch detail and creation lookups do not take over a newer selection
|
|||
await page.evaluate(() => refreshBatchQueues());
|
||||
let release; const gate = new Promise(resolve => { release = resolve; });
|
||||
state.hook = async req => { if (req.path === '/api/batch-tasks/q1' && req.method === 'GET') await gate; };
|
||||
await page.locator('.lt-card[data-id=q1][data-mode=list]').click(); await page.locator('[data-lt-action=select][data-id=a][data-mode=goal]').click();
|
||||
await page.locator('.lt-card[data-id=q2][data-mode=list]').click(); await page.locator('[data-bq-detail-for=q2]').waitFor();
|
||||
await page.locator('[data-record-id="list:q1"] [data-record-open]').click(); await page.locator('[data-record-id="goal:a"] [data-record-open]').click();
|
||||
await page.locator('[data-record-id="list:q2"] [data-record-open]').click(); await page.locator('[data-bq-detail-for=q2]').waitFor();
|
||||
release(); await page.waitForTimeout(150); assert.equal(await page.locator('[data-bq-detail-for=q2]').count(), 1);
|
||||
await page.locator('[data-lt-action=select][data-id=a][data-mode=goal]').click();
|
||||
await page.locator('[data-record-id="goal:a"] [data-record-open]').click();
|
||||
const createGate = new Promise(resolve => { release = resolve; });
|
||||
state.hook = async req => { if (req.path === '/api/projects') await createGate; };
|
||||
await page.evaluate(() => { void showBatchImportModal(); }); await page.evaluate(() => switchPage('dashboard')); release(); await page.waitForTimeout(150);
|
||||
|
|
@ -172,11 +177,11 @@ test('one task list and one creation form support objectives, checklists and sch
|
|||
const { page, state } = await fixture(t);
|
||||
assert.equal(await page.locator('[data-task-tab]').count(), 0);
|
||||
assert.equal(await page.locator('#task-new-batch').count(), 0);
|
||||
assert.equal(await page.locator('#lt-list [data-mode=goal]').count(), 2);
|
||||
assert.equal(await page.locator('#lt-list [data-mode=list]').count(), 1);
|
||||
assert.equal(await page.locator('#lt-list [data-record-id^="goal:"]').count(), 2);
|
||||
assert.equal(await page.locator('#lt-list [data-record-id^="list:"]').count(), 1);
|
||||
await page.locator('#lt-mode-filter').selectOption('list');
|
||||
await page.waitForFunction(() => document.querySelectorAll('.lt-card').length === 1);
|
||||
await page.locator('.lt-card[data-mode=list][data-id=q1]').click();
|
||||
await page.waitForFunction(() => document.querySelectorAll('#lt-list .task-record-row').length === 1);
|
||||
await page.locator('[data-record-id="list:q1"] [data-record-open]').click();
|
||||
await page.locator('#lt-batch-detail [data-bq-detail-for=q1]').waitFor();
|
||||
assert.equal(await page.locator('#batch-queue-detail-modal').evaluate(node => node.classList.contains('modal')), false);
|
||||
await page.screenshot({path:'/tmp/csai-unified-task-list-preview.png'});
|
||||
|
|
@ -195,7 +200,7 @@ test('one task list and one creation form support objectives, checklists and sch
|
|||
assert.equal(state.queues.get('new-queue').cronExpr, '0 2 * * *');
|
||||
assert.equal(state.queues.get('new-queue').executeNow, false);
|
||||
assert.equal(state.queues.get('new-queue').tasks.length, 2);
|
||||
assert.equal(await page.locator('#lt-list [data-mode=list]').count(), 2);
|
||||
assert.equal(await page.locator('#lt-list [data-record-id^="list:"]').count(), 2);
|
||||
await page.locator('#task-new-goal').click();
|
||||
await page.locator('#lt-modal [name=name]').fill('Unified objective');
|
||||
await page.locator('#lt-modal [name=objective]').fill('Summarize the local report');
|
||||
|
|
@ -241,7 +246,7 @@ test('creation and budget dialogs stay centered with visible actions on desktop
|
|||
test('the unified empty state stays usable and checklist details fit narrow screens', async t => {
|
||||
const { page,state,refresh }=await fixture(t);
|
||||
await page.setViewportSize({width:390,height:844});
|
||||
await page.locator('.lt-card[data-mode=list][data-id=q1]').click();await page.locator('[data-bq-detail-for=q1]').waitFor();
|
||||
await page.locator('[data-record-id="list:q1"] [data-record-open]').click();await page.locator('[data-bq-detail-for=q1]').waitFor();
|
||||
assert.ok(await page.evaluate(()=>document.documentElement.scrollWidth<=window.innerWidth+1));
|
||||
await page.locator('#batch-queue-start-btn').scrollIntoViewIfNeeded();
|
||||
const button=await page.locator('#batch-queue-start-btn').boundingBox();assert.ok(button.x>=0 && button.x+button.width<=390);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,88 @@
|
|||
const {test}=require('node:test');
|
||||
const assert=require('node:assert/strict');
|
||||
const {fixture,goal}=require('./helpers/task-ui-fixture.cjs');
|
||||
|
||||
const queueRow=page=>page.locator('#lt-list [data-record-id="list:q1"] [data-record-open]');
|
||||
|
||||
test('365 tasks use stable 20-row pages; automatic refresh keeps both scroll positions and the selected task',async t=>{
|
||||
const {page,state,refresh}=await fixture(t);
|
||||
for(let i=0;i<36;i++)state.tasks.set('extra'+i,goal('extra'+i));
|
||||
const q=state.queues.get('q1');q.status='paused';q.tasks=Array.from({length:365},(_,i)=>({id:'step-'+i,message:`https://asset-${i}.example.test/`+'long-path/'.repeat(25),status:i<28?'completed':'pending',result:'Report preview '+i+' '+ 'evidence '.repeat(500)+'TAIL_EVIDENCE_'+i,conversationId:'conv-'+i}));
|
||||
await refresh();assert.equal(await page.locator('#lt-list .task-record-row').count(),20);
|
||||
await page.locator('#lt-pagination [data-page-nav=next]').click();await queueRow(page).click();
|
||||
await page.locator('#bq-task-rows [data-record-id=step-0]').waitFor();
|
||||
assert.equal(await page.locator('#bq-task-rows .task-record-row').count(),20);
|
||||
assert.match(await page.locator('#bq-task-pagination').textContent(),/365/);
|
||||
await page.locator('#bq-task-pagination [data-page-nav=next]').click();await page.locator('#bq-task-rows [data-record-id=step-20]').waitFor();
|
||||
await page.evaluate(()=>{document.getElementById('bq-task-rows').scrollTop=500;document.getElementById('lt-list').scrollTop=400;});
|
||||
const before=await page.evaluate(()=>({right:document.getElementById('bq-task-rows').scrollTop,left:document.getElementById('lt-list').scrollTop}));
|
||||
assert.ok(before.right>100&&before.left>100,JSON.stringify(before));
|
||||
q.tasks[21].status='completed';await refresh();
|
||||
const after=await page.evaluate(()=>({right:document.getElementById('bq-task-rows').scrollTop,left:document.getElementById('lt-list').scrollTop}));
|
||||
assert.deepEqual(after,before);
|
||||
let release;const gate=new Promise(resolve=>{release=resolve;});state.hook=async req=>{if(req.path==='/api/batch-tasks/q1'&&req.method==='GET')await gate;};
|
||||
await page.evaluate(()=>{window.pendingTaskRefresh=refreshTaskWorkspace();});await page.waitForTimeout(50);
|
||||
await page.evaluate(()=>{document.getElementById('bq-task-rows').scrollTop=600;});release();await page.evaluate(()=>window.pendingTaskRefresh);state.hook=null;
|
||||
assert.equal(await page.locator('#bq-task-rows').evaluate(node=>node.scrollTop),600,'scrolling while a refresh is in flight must keep the latest position');
|
||||
await page.evaluate(top=>{document.getElementById('bq-task-rows').scrollTop=top;},before.right);
|
||||
assert.match(await page.locator('#bq-task-pagination .task-page-controls span').textContent(),/^2 \/ 19/);
|
||||
assert.equal(await page.locator('#lt-list [data-record-id="list:q1"]').getAttribute('aria-current'),'true');
|
||||
await page.locator('#tasks-auto-refresh').check();await page.waitForTimeout(4300);await page.locator('#tasks-auto-refresh').uncheck();
|
||||
assert.equal(await page.locator('#bq-task-rows').evaluate(node=>node.scrollTop),before.right);
|
||||
assert.equal(await page.locator('#lt-list').evaluate(node=>node.scrollTop),before.left);
|
||||
// Exact same rows are retained, rather than replaced wholesale on an unchanged poll.
|
||||
await page.evaluate(()=>{window.savedTaskRow=document.querySelector('#bq-task-rows [data-record-id="step-20"]');});await refresh();
|
||||
assert.equal(await page.evaluate(()=>window.savedTaskRow===document.querySelector('#bq-task-rows [data-record-id="step-20"]')),true);
|
||||
await page.locator('#bq-task-pagination [data-page-nav=lastPage]').click();await page.locator('#bq-task-rows [data-record-id=step-360]').waitFor();
|
||||
assert.equal(await page.locator('#bq-task-rows .task-record-row').count(),5);
|
||||
assert.match(await page.locator('#bq-task-pagination').textContent(),/361.*365/);
|
||||
await page.screenshot({path:'/tmp/csai-task-rows-desktop.png'});
|
||||
await page.locator('#bq-task-rows [data-record-id=step-364] [data-record-open]').first().click();
|
||||
await page.waitForFunction(()=>document.getElementById('task-step-inspector').textContent.includes('TAIL_EVIDENCE_364'));
|
||||
assert.ok(state.requests.some(r=>r.path.endsWith('/tasks/step-364')&&r.method==='GET'));
|
||||
await page.locator('[data-inspector-close]').click();assert.match(await page.locator('#bq-task-pagination .task-page-controls span').textContent(),/^19 \/ 19/);
|
||||
assert.deepEqual(state.pageErrors,[]);
|
||||
});
|
||||
|
||||
test('autonomous steps share row pagination and keep drafts and scroll on refresh',async t=>{
|
||||
const {page,state,select,refresh}=await fixture(t);
|
||||
const task=state.tasks.get('a');task.steps=Array.from({length:45},(_,i)=>({id:'s'+i,title:'Local step '+i,instruction:'Inspect fixture '+i,status:'completed',summary:'Verified '+i,depends_on:[],conversation_id:'c'+i,attempts:1}));
|
||||
await select('a');assert.equal(await page.locator('#lt-steps .task-record-row').count(),20);
|
||||
await page.locator('#lt-step-pagination [data-page-nav=next]').click();await page.locator('#lt-steps [data-record-id=s20]').waitFor();
|
||||
await page.evaluate(()=>{document.getElementById('lt-steps').scrollTop=400;});const top=await page.locator('#lt-steps').evaluate(n=>n.scrollTop);assert.ok(top>0);
|
||||
task.steps[23].summary='New observation';await refresh();assert.equal(await page.locator('#lt-steps').evaluate(n=>n.scrollTop),top);
|
||||
await page.locator('#lt-support > summary').click();await page.locator('#lt-guidance-input').fill('Keep this unsent guidance');await refresh();assert.equal(await page.locator('#lt-guidance-input').inputValue(),'Keep this unsent guidance');
|
||||
await page.locator('#lt-support > summary').click();await page.locator('#lt-step-pagination [data-page-nav=lastPage]').click();assert.equal(await page.locator('#lt-steps .task-record-row').count(),5);
|
||||
await page.locator('#lt-steps [data-record-open=s44]').first().click();assert.match(await page.locator('.task-inspector-body').textContent(),/Verified 44/);
|
||||
await refresh();assert.equal(await page.locator('#task-step-inspector').isVisible(),true);await page.locator('[data-inspector-close]').click();
|
||||
assert.deepEqual(state.pageErrors,[]);
|
||||
});
|
||||
|
||||
|
||||
test('compact rows and fixed pagination remain usable in dark mode and narrow screens',async t=>{
|
||||
const {page,state,refresh}=await fixture(t);const q=state.queues.get('q1');q.status='paused';q.tasks=Array.from({length:35},(_,i)=>({id:'s'+i,message:'https://local.example.test/'+('long-path/'.repeat(30))+i,status:'completed',result:'<img src=x onerror="window.injected=1"> Full evidence '+i,conversationId:'c'+i}));
|
||||
await refresh();await queueRow(page).click();await page.locator('#bq-task-rows [data-record-id=s0]').waitFor();
|
||||
for(const width of [1440,390]){
|
||||
await page.setViewportSize({width,height:900});await page.evaluate(()=>document.documentElement.setAttribute('data-theme','dark'));
|
||||
assert.ok(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1));
|
||||
await page.locator('#bq-task-pagination').scrollIntoViewIfNeeded();
|
||||
const rect=await page.locator('#bq-task-pagination').boundingBox();assert.ok(rect.y+rect.height<=902);
|
||||
if(width===390){const controls=await page.locator('#bq-task-pagination .task-page-controls').boundingBox();assert.ok(controls.height<=50,'mobile paging controls must stay on one row');}
|
||||
await page.screenshot({path:`/tmp/csai-task-rows-dark-${width}.png`});
|
||||
}
|
||||
await page.setViewportSize({width:1440,height:900});await page.locator('#bq-task-rows [data-record-open=s0]').first().click();
|
||||
await page.locator('[data-checklist-action=edit]').waitFor();assert.equal(await page.evaluate(()=>window.injected),undefined);assert.equal(await page.locator('.task-inspector-body img').count(),0);
|
||||
await page.locator('[data-checklist-action=edit]').click();await page.locator('[data-task-editor] textarea').fill('Unsaved edit');await refresh();assert.equal(await page.locator('[data-task-editor] textarea').inputValue(),'Unsaved edit');
|
||||
await page.locator('[data-checklist-action=cancel-edit]').click();await page.locator('[data-checklist-action=edit]').click();assert.equal(await page.locator('[data-task-editor] textarea').inputValue(),q.tasks[0].message);
|
||||
assert.deepEqual(state.pageErrors,[]);
|
||||
});
|
||||
|
||||
|
||||
test('new parent rows above the viewport preserve the visible reading anchor',async t=>{
|
||||
const {page,state,refresh}=await fixture(t);for(let i=0;i<19;i++)state.tasks.set('p'+i,goal('p'+i));await refresh();
|
||||
await page.locator('#lt-list').evaluate(node=>{node.scrollTop=400;});
|
||||
const anchor=await page.locator('#lt-list').evaluate(root=>{const bounds=root.getBoundingClientRect();const row=[...root.children].find(row=>row.getBoundingClientRect().bottom>bounds.top);return {id:row.dataset.recordId,y:row.getBoundingClientRect().top};});
|
||||
state.tasks=new Map([['new-parent',goal('new-parent')],...state.tasks.entries()]);await refresh();
|
||||
const y=await page.locator('#lt-list').evaluate((root,id)=>[...root.children].find(row=>row.dataset.recordId===id).getBoundingClientRect().top,anchor.id);
|
||||
assert.ok(Math.abs(y-anchor.y)<2,`reading anchor moved from ${anchor.y} to ${y}`);
|
||||
});
|
||||
|
|
@ -175,3 +175,94 @@
|
|||
.lt-inline-queue .modal-header { background:transparent; box-shadow:none; }
|
||||
.lt-inline-queue .modal-header h2::before { display:none; }
|
||||
.lt-inline-queue .batch-queue-detail-hero { padding:0; border:0; background:transparent; min-height:0; }
|
||||
|
||||
/* The same compact-row grammar used by the vulnerability list. */
|
||||
#long-task-workspace { display:flex; flex-direction:column; min-height:0; overflow:hidden; }
|
||||
.lt-toolbar { flex:0 0 auto; }
|
||||
.lt-board { flex:1; min-height:0; grid-template-rows:minmax(0,1fr); align-items:stretch; overflow:hidden; }
|
||||
.lt-sidebar { position:static; min-height:0; display:flex; flex-direction:column; border:1px solid var(--border-color); border-radius:12px; background:var(--bg-primary); overflow:hidden; }
|
||||
.lt-sidebar-heading { padding:16px; border-bottom:1px solid var(--border-color); font-size:14px; font-weight:600; flex:0 0 auto; }
|
||||
#lt-list { flex:1; min-height:0; max-height:none; overflow:auto; display:flex; gap:8px; padding:10px; }
|
||||
.task-record-row { display:grid; grid-template-columns:32px 78px minmax(0,1fr) auto; align-items:center; gap:12px; flex:0 0 auto; min-height:72px; padding:12px 16px; margin:0; border:1px solid var(--border-color); border-radius:10px; background:var(--bg-primary); }
|
||||
.task-record-row:hover { border-color:color-mix(in srgb,var(--accent-color) 35%,var(--border-color)); }
|
||||
.task-record-row.is-selected { border-color:var(--accent-color); background:color-mix(in srgb,var(--accent-color) 5%,var(--bg-primary)); }
|
||||
.task-row-index { color:var(--text-secondary); font-size:12px; }
|
||||
.task-record-row .lt-status { align-self:center; justify-self:start; }
|
||||
.task-record-main { display:block; min-width:0; width:100%; padding:0; border:0; background:transparent; color:var(--text-primary); font:inherit; text-align:start; cursor:pointer; }
|
||||
.task-record-title,.task-record-summary { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; line-height:1.5; }
|
||||
.task-record-title { font-size:14px; font-weight:600; }
|
||||
.task-record-summary { margin-top:3px; color:var(--text-secondary); font-size:12px; }
|
||||
.task-record-view { border:0; background:transparent; padding:6px 0; color:var(--text-primary); font:inherit; font-size:13px; white-space:nowrap; cursor:pointer; }
|
||||
.task-record-main:hover .task-record-title,.task-record-view:hover { color:var(--accent-color); }
|
||||
.task-record-main:focus-visible,.task-record-view:focus-visible { outline:2px solid var(--accent-color); outline-offset:3px; }
|
||||
.task-record-row--nav { grid-template-columns:minmax(0,1fr) auto; gap:10px; padding:12px; }
|
||||
.task-record-row--nav .task-record-main { grid-column:1; grid-row:1; }
|
||||
.task-record-row--nav .lt-status { grid-column:2; grid-row:1; }
|
||||
.task-pagination { display:flex; flex:0 0 auto; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; border-top:1px solid var(--border-color); padding:12px 16px; background:var(--bg-primary); }
|
||||
.task-page-summary { color:var(--text-secondary); font-size:12px; }
|
||||
.task-page-controls { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:6px; font-size:12px; }
|
||||
.task-page-controls .btn-secondary { min-height:30px; padding:5px 8px; font-size:12px; border-radius:6px; }
|
||||
.lt-sidebar .task-pagination { justify-content:center; padding:12px 10px; }
|
||||
.lt-detail { display:flex; flex-direction:column; min-height:0; overflow:hidden; padding:18px; }
|
||||
.lt-detail-top { flex:0 0 auto; }
|
||||
.lt-detail-top h3 { font-size:18px; }
|
||||
.lt-detail-top #lt-progress { margin:6px 0 0; }
|
||||
.lt-detail-top .lt-actions { margin:12px 0; }
|
||||
.lt-context { flex:0 0 auto; margin:0 0 12px!important; border:1px solid var(--border-color); border-radius:8px; }
|
||||
.lt-context > summary { padding:10px 12px; font-size:13px; }
|
||||
.lt-context-body { padding:0 12px 12px; max-height:230px; overflow:auto; }
|
||||
.lt-context-body p { font-size:13px; }
|
||||
.lt-context-body h4 { font-size:13px; margin:12px 0 5px; }
|
||||
.task-items-panel { display:flex; flex-direction:column; flex:1; min-height:0; }
|
||||
.task-items-heading { flex:0 0 auto; display:flex; align-items:center; justify-content:space-between; padding:10px 0; }
|
||||
.task-items-heading h4 { margin:0; font-size:14px; }
|
||||
.task-record-list { flex:1; min-height:0; display:flex; flex-direction:column; gap:8px; overflow:auto; padding:0 2px 10px; }
|
||||
.task-items-panel > .task-pagination { margin-top:0; }
|
||||
.lt-inline-queue,.lt-inline-queue > .modal-content,.lt-inline-queue .modal-body,#batch-queue-detail-content { display:flex; flex-direction:column; min-height:0; flex:1; overflow:hidden; }
|
||||
.lt-inline-queue .modal-header { flex:0 0 auto; padding:0 0 12px; }
|
||||
.lt-inline-queue .modal-body { padding:12px 0 0; }
|
||||
.lt-inline-queue .batch-queue-detail-layout { flex:0 0 auto; }
|
||||
.lt-inline-queue .batch-queue-detail-hero { display:flex; align-items:center; flex-wrap:wrap; gap:12px; margin:0 0 12px; }
|
||||
.lt-inline-queue .batch-queue-detail-hero p { margin:0; font-size:12px; }
|
||||
.lt-inline-queue .batch-queue-detail-kv { margin:0; }
|
||||
.lt-inline-queue .lt-context { margin-bottom:12px!important; }
|
||||
.task-inspector { position:fixed; inset:0 0 0 auto; margin:0; width:min(620px,100vw); height:100vh; height:100dvh; max-width:none; max-height:none; padding:0; border:0; border-left:1px solid var(--border-color); background:var(--bg-primary); color:var(--text-primary); box-shadow:-12px 0 48px rgba(15,23,42,.18); }
|
||||
.task-inspector[open] { display:flex; flex-direction:column; }
|
||||
.task-inspector::backdrop { background:rgba(15,23,42,.35); }
|
||||
.task-inspector-header { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:20px 24px; border-bottom:1px solid var(--border-color); flex:0 0 auto; }
|
||||
.task-inspector-header h3 { font-size:18px; line-height:1.5; }
|
||||
.task-inspector-body { flex:1; min-height:0; overflow:auto; padding:20px 24px; }
|
||||
.task-inspector-body h4 { margin:20px 0 8px; font-size:13px; color:var(--text-secondary); }
|
||||
.task-inspector-body p,.task-inspector-body pre { font:inherit; font-size:14px; line-height:1.65; white-space:pre-wrap; overflow-wrap:anywhere; }
|
||||
.task-inspector-body textarea { width:100%; min-height:180px; padding:12px; font:inherit; border:1px solid var(--border-color); border-radius:8px; background:var(--bg-primary); color:var(--text-primary); resize:vertical; }
|
||||
.task-inspector-actions { flex:0 0 auto; display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:16px 24px; border-top:1px solid var(--border-color); }
|
||||
.task-inspector-actions .btn-delete { margin-left:auto; color:var(--error-color); }
|
||||
.task-inspector [hidden] { display:none!important; }
|
||||
@media(max-width:800px) {
|
||||
#long-task-workspace { overflow-y:auto; }
|
||||
.lt-board { display:block; flex:none; overflow:visible; }
|
||||
.lt-sidebar { height:300px; margin-bottom:16px; }
|
||||
#lt-list { max-height:none; }
|
||||
.lt-detail { height:min(760px,85vh); min-height:440px; padding:14px; }
|
||||
.task-record-row:not(.task-record-row--nav) { grid-template-columns:26px 70px minmax(0,1fr); gap:8px; padding:12px; }
|
||||
.task-record-row:not(.task-record-row--nav) .task-record-view { grid-column:2/-1; justify-self:end; }
|
||||
.task-record-main,.task-record-view { min-height:0!important; padding:0!important; }
|
||||
.task-pagination { padding:10px; justify-content:center; }
|
||||
.task-page-controls .btn-secondary { min-height:36px; }
|
||||
.task-inspector-header,.task-inspector-body,.task-inspector-actions { padding:16px; }
|
||||
}
|
||||
.task-record-row .lt-status { max-width:100%; overflow:hidden; text-overflow:ellipsis; }
|
||||
.task-meta-edit { padding:0; border:0; background:transparent; color:inherit; font:inherit; text-align:start; cursor:pointer; }
|
||||
.task-parent-summary { margin:8px 0; font-size:13px!important; color:var(--text-secondary); display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
|
||||
.lt-detail-top h3 { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
||||
|
||||
.lt-inline-queue .batch-queue-detail-layout { display:block; margin:0; padding:0; }
|
||||
.lt-inline-queue .batch-queue-detail-hero { flex-direction:row; justify-content:flex-start; }
|
||||
@media(max-width:800px) {
|
||||
#page-tasks .task-page-controls .btn-secondary { min-width:44px!important; min-height:44px!important; padding:6px 8px!important; font-size:12px!important; border-radius:6px!important; }
|
||||
.task-page-controls { gap:4px; }
|
||||
#page-tasks .task-page-controls [data-page-nav="firstPage"],#page-tasks .task-page-controls [data-page-nav="lastPage"] { font-size:0!important; }
|
||||
.task-page-controls [data-page-nav="firstPage"]::after { content:'«'; font-size:16px; }
|
||||
.task-page-controls [data-page-nav="lastPage"]::after { content:'»'; font-size:16px; }
|
||||
}
|
||||
#lt-list,.task-record-list { overflow-anchor:none; }
|
||||
|
|
|
|||
|
|
@ -5375,6 +5375,19 @@
|
|||
"defaultModel": "Default model",
|
||||
"untitled": "Untitled task",
|
||||
"addStep": "Add step",
|
||||
"rerunAll": "Rerun all"
|
||||
"rerunAll": "Rerun all",
|
||||
"viewDetail": "View details",
|
||||
"firstPage": "First",
|
||||
"lastPage": "Last",
|
||||
"pageSummary": "{{start}}–{{end}} of {{total}}",
|
||||
"perPage": "{{count}} per page",
|
||||
"pageNumber": "{{page}} / {{pages}}",
|
||||
"stepDetail": "Step details",
|
||||
"taskSettings": "Task settings",
|
||||
"stepList": "Steps",
|
||||
"guidanceAndEvents": "Guidance and activity",
|
||||
"loading": "Loading…",
|
||||
"result": "Execution result",
|
||||
"error": "Error"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5388,6 +5388,19 @@
|
|||
"defaultModel": "Модель по умолчанию",
|
||||
"untitled": "Задача без названия",
|
||||
"addStep": "Добавить шаг",
|
||||
"rerunAll": "Повторить всё"
|
||||
"rerunAll": "Повторить всё",
|
||||
"viewDetail": "Подробнее",
|
||||
"firstPage": "Первая",
|
||||
"lastPage": "Последняя",
|
||||
"pageSummary": "{{start}}–{{end}} из {{total}}",
|
||||
"perPage": "По {{count}} на странице",
|
||||
"pageNumber": "{{page}} / {{pages}}",
|
||||
"stepDetail": "Сведения о шаге",
|
||||
"taskSettings": "Настройки задачи",
|
||||
"stepList": "Шаги",
|
||||
"guidanceAndEvents": "Указания и события",
|
||||
"loading": "Загрузка…",
|
||||
"result": "Результат выполнения",
|
||||
"error": "Ошибка"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5363,6 +5363,19 @@
|
|||
"defaultModel": "默认模型",
|
||||
"untitled": "未命名任务",
|
||||
"addStep": "添加子任务",
|
||||
"rerunAll": "重跑全部"
|
||||
"rerunAll": "重跑全部",
|
||||
"viewDetail": "查看详情",
|
||||
"firstPage": "首页",
|
||||
"lastPage": "末页",
|
||||
"pageSummary": "{{start}}–{{end}} / {{total}} 条",
|
||||
"perPage": "每页 {{count}} 条",
|
||||
"pageNumber": "{{page}} / {{pages}}",
|
||||
"stepDetail": "子任务详情",
|
||||
"taskSettings": "任务设置",
|
||||
"stepList": "子任务列表",
|
||||
"guidanceAndEvents": "补充方向与任务动态",
|
||||
"loading": "正在加载…",
|
||||
"result": "执行结果",
|
||||
"error": "错误信息"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const taskSource = fs.readFileSync('web/static/js/tasks.js','utf8');
|
|||
function concurrencyHarness(value) {
|
||||
let calls = 0, message, focused = false;
|
||||
const input = {value, focus() { focused = true; }};
|
||||
const ctx = {_bqInlineSaving:false, batchQueuesState:{currentQueueId:'q'},
|
||||
const ctx = {window:{},_bqInlineSaving:false, batchQueuesState:{currentQueueId:'q'},
|
||||
document:{getElementById:() => input}, _t:x => x, alert:x => {message=x;},
|
||||
apiFetch:async () => {calls++;return {ok:true,json:async () => ({queue:{title:'title'}})};},
|
||||
showBatchQueueDetail() {},isAppModalOpen:() => true,refreshBatchQueues() {},console};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const template = fs.readFileSync(path.join(web, 'templates/index.html'), 'utf8')
|
|||
test('the production task page loads its goal-task controller and styles', () => {
|
||||
const scripts = [...template.matchAll(/<script\b[^>]*\bsrc=["']([^"']+)["'][^>]*>/g)]
|
||||
.map(match => new URL(match[1], 'http://fixture').pathname);
|
||||
for (const script of ['router', 'tasks', 'long-tasks']) {
|
||||
for (const script of ['router', 'task-list-view', 'tasks', 'task-checklist-view', 'long-tasks']) {
|
||||
const url = `/static/js/${script}.js`;
|
||||
assert.equal(scripts.filter(src => src === url).length, 1, `${url} must be included once by the real entrypoint`);
|
||||
assert.ok(fs.existsSync(path.join(web, url)), `${url} must exist`);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
/* Durable objectives in the existing task-management page. */
|
||||
(function () {
|
||||
'use strict';
|
||||
const state = { active: false, tasks: [], selected: null, selectedMode: 'goal', task: null, events: [], cursor: 0, offset: 0, more: false, epoch: 0, loading: false, timer: null, options: null, controller: null, optionsRequest: null, viewVersion: 0, searchTimer: null, mutating: new Set(), errorKind: null };
|
||||
const state = { active: false, tasks: [], selected: null, selectedMode: 'goal', task: null, events: [], cursor: 0, offset: 0, total: 0, stepPages: new Map(), more: false, epoch: 0, loading: false, timer: null, options: null, controller: null, optionsRequest: null, viewVersion: 0, searchTimer: null, mutating: new Set(), errorKind: null };
|
||||
const V = window.TaskListView;
|
||||
const el = id => document.getElementById(id);
|
||||
const tr = (key, args) => typeof window.t === 'function' ? window.t('longTasks.' + key, args) : key;
|
||||
const esc = value => String(value == null ? '' : value).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||
|
|
@ -19,19 +20,13 @@
|
|||
}
|
||||
function error(message, kind = 'action') { state.errorKind = message ? kind : null; const box = el('lt-error'); if (box) { box.textContent = message || ''; box.hidden = !message; } }
|
||||
function renderList() {
|
||||
el('lt-list').innerHTML = state.tasks.length ? state.tasks.map(task => {
|
||||
V.renderRows(el('lt-list'), state.tasks.map(task => {
|
||||
const mode = task.mode || 'goal';
|
||||
const selected = state.selected === task.id && state.selectedMode === mode;
|
||||
const progress = Number.isInteger(task.total_steps) ? tr('listProgress', { done: task.completed_steps, total: task.total_steps }) : '';
|
||||
const schedule = task.schedule_mode === 'cron' ? ' · ' + tr('scheduledLabel') : '';
|
||||
return `<button class="lt-card ${selected ? 'is-selected' : ''}" data-lt-action="select" data-id="${esc(task.id)}" data-mode="${mode}" aria-pressed="${selected}">
|
||||
<span class="lt-card-title">${esc(task.name)}</span>${badge(task.status)}
|
||||
<span class="lt-card-meta">${esc(tr(mode === 'list' ? 'modeList' : 'modeGoal'))}${esc(schedule)}${progress ? ' · ' + esc(progress) : ''}</span>
|
||||
${task.summary ? `<span class="lt-card-summary">${esc(task.summary)}</span>` : ''}
|
||||
<time>${esc(new Date(task.updated_at).toLocaleString())}</time></button>`;
|
||||
}).join('') : `<div class="lt-empty">${esc(tr('noMatches'))}</div>`;
|
||||
el('lt-page').textContent = String(state.offset / 30 + 1);
|
||||
el('lt-prev').disabled = state.offset === 0; el('lt-next').disabled = !state.more;
|
||||
return {id:mode+':'+task.id,title:task.name,status:task.status,summary:tr(mode==='list'?'modeList':'modeGoal')+schedule+(progress?' · '+progress:''),selected:state.selected===task.id&&state.selectedMode===mode};
|
||||
}), {navigation:true,key:'parents:'+state.offset,open:key=>{const i=key.indexOf(':');select(key.slice(i+1),key.slice(0,i));}});
|
||||
V.renderPager(el('lt-pagination'),{page:state.offset/V.pageSize+1,total:state.total,size:V.pageSize,change:page=>{state.offset=(page-1)*V.pageSize;invalidate();refresh();}});
|
||||
const empty = !state.tasks.length && !state.selected;
|
||||
el('lt-board').hidden = empty; el('lt-empty-state').hidden = !empty;
|
||||
const filtered = el('lt-search').value || el('lt-filter').value || el('lt-mode-filter').value;
|
||||
|
|
@ -39,13 +34,14 @@
|
|||
el('lt-empty-description').textContent = tr(filtered ? 'changeFilters' : 'empty');
|
||||
if (typeof window.applyRBACToUI === 'function') window.applyRBACToUI(el('lt-empty-state'));
|
||||
}
|
||||
function renderTask() {
|
||||
function renderTask(resetSteps = false) {
|
||||
const restore = V.captureScroll(el('lt-detail'));
|
||||
const t = state.selectedMode === 'goal' ? state.task : null;
|
||||
el('lt-empty-detail').hidden = !!state.selected; el('lt-detail').hidden = !t;
|
||||
el('lt-batch-detail').hidden = state.selectedMode !== 'list' || !state.selected;
|
||||
if (!t) { el('lt-steps').replaceChildren(); el('lt-steps').dataset.taskId = ''; return; }
|
||||
el('lt-name').textContent = t.name;
|
||||
el('lt-state').innerHTML = badge(t.status);
|
||||
el('lt-name').textContent = t.name; el('lt-name').title = t.name;
|
||||
V.setHTML(el('lt-state'), badge(t.status));
|
||||
const done = t.steps.filter(s => s.status === 'completed').length;
|
||||
const total = t.steps.filter(s => s.status !== 'retired').length;
|
||||
el('lt-progress').textContent = tr('progress', { done, total, rounds: t.rounds, max: t.max_rounds, minutes: Math.ceil(t.remaining_seconds / 60) });
|
||||
|
|
@ -67,19 +63,34 @@
|
|||
}
|
||||
actions.push(button('report', 'report'));
|
||||
if (writable('tasks:delete') && !active(t)) actions.push(button('delete', 'delete'));
|
||||
el('lt-actions').innerHTML = actions.join('');
|
||||
V.setHTML(el('lt-actions'), actions.join(''));
|
||||
el('lt-guidance-form').hidden = terminal || !writable();
|
||||
el('lt-guidance-send').textContent = tr(t.question ? 'answerResume' : 'sendGuidance');
|
||||
el('lt-guidance-send').disabled = state.mutating.has(t.id) || ['pausing', 'cancelling'].includes(t.status) || (!!t.question && (active(t) || !canExecute()));
|
||||
const stepsRoot = el('lt-steps');
|
||||
const expanded = new Set(stepsRoot.dataset.taskId === t.id ? [...stepsRoot.querySelectorAll('[data-step-id] details[open]')].map(detail => detail.closest('[data-step-id]').dataset.stepId) : []);
|
||||
stepsRoot.dataset.taskId = t.id;
|
||||
el('lt-steps').innerHTML = t.steps.length ? t.steps.map(s => `<article class="lt-step" data-step-id="${esc(s.id)}"><header><strong>${esc(s.id)} · ${esc(s.title)}</strong>${badge(s.status)}</header><p class="lt-dependencies">${esc(tr('depends'))}: ${(s.depends_on || []).length ? s.depends_on.map(esc).join(' → ') : esc(tr('independent'))}</p><details><summary>${esc(tr('instruction'))}</summary><p>${esc(s.instruction)}</p></details><p class="lt-step-result">${esc(s.summary || tr('noResult'))}</p><footer>${s.conversation_id ? `<a class="btn-secondary" href="#chat?conversation=${encodeURIComponent(s.conversation_id)}">${esc(tr('trace'))}</a>` : ''}${writable() && !terminal && !active(t) && ['failed', 'blocked', 'interrupted', 'cleanup_unconfirmed'].includes(s.status) ? button('retry', 'retry', `data-step="${esc(s.id)}"`) : ''}<small>${esc(tr('attempts', { count: s.attempts || 0 }))}</small></footer></article>`).join('') : `<div class="lt-empty">${esc(tr('noPlan'))}</div>`;
|
||||
stepsRoot.querySelectorAll('[data-step-id] details').forEach(detail => { detail.open = expanded.has(detail.closest('[data-step-id]').dataset.stepId); });
|
||||
if (t.question && el('lt-support').dataset.question !== t.question) el('lt-support').open = true;
|
||||
el('lt-support').dataset.question = t.question || '';
|
||||
const page=Math.min(state.stepPages.get(t.id)||1,Math.max(1,Math.ceil(t.steps.length/V.pageSize)));
|
||||
state.stepPages.set(t.id,page);
|
||||
const offset=(page-1)*V.pageSize;
|
||||
V.renderRows(el('lt-steps'),t.steps.slice(offset,offset+V.pageSize).map((step,index)=>({id:step.id,index:offset+index+1,title:step.title,status:step.status,summary:step.summary||step.instruction})),{key:t.id+':'+page,empty:tr('noPlan'),open:id=>openStep(t,id)});
|
||||
V.renderPager(el('lt-step-pagination'),{page,total:t.steps.length,size:V.pageSize,change:next=>{state.stepPages.set(t.id,next);renderTask(true);}});
|
||||
el('lt-guidance-history').textContent = (t.guidance || []).join('\n\n');
|
||||
restore(); if(resetSteps)el('lt-steps').scrollTop=0;
|
||||
}
|
||||
function openStep(task,id) {
|
||||
const step=task.steps.find(item=>item.id===id);if(!step)return;
|
||||
const terminal=['completed','cancelled'].includes(task.status);
|
||||
const retry=writable()&&!terminal&&!active(task)&&['failed','blocked','interrupted','cleanup_unconfirmed'].includes(step.status);
|
||||
const dialog=V.openDrawer(tr('stepDetail'),`${badge(step.status)}<h4>${esc(tr('taskContent'))}</h4><p>${esc(step.title)}</p><h4>${esc(tr('instruction'))}</h4><p>${esc(step.instruction)}</p><h4>${esc(tr('depends'))}</h4><p>${esc((step.depends_on||[]).join(', ')||tr('independent'))}</p><h4>${esc(tr('result'))}</h4><pre>${esc(step.summary||tr('noResult'))}</pre><p class="lt-form-error" data-step-error hidden></p>`,`${step.conversation_id?`<a class="btn-secondary" href="#chat?conversation=${encodeURIComponent(step.conversation_id)}">${esc(tr('trace'))}</a>`:''}${retry?`<button type="button" class="btn-primary" data-step-retry>${esc(tr('retry'))}</button>`:''}`);
|
||||
dialog.querySelector('[data-step-retry]')?.addEventListener('click',async event=>{
|
||||
if(!confirm(tr('retryConfirm')))return;event.target.disabled=true;
|
||||
try { const data=await control('retry',{step_id:id,cleanup_confirmed:true},task);if(data&&dialog.isConnected)V.closeDrawer(); }
|
||||
catch(error){if(dialog.isConnected){const box=dialog.querySelector('[data-step-error]');box.hidden=false;box.textContent=error.message;}}
|
||||
finally{if(event.target.isConnected)event.target.disabled=false;}
|
||||
});
|
||||
}
|
||||
function renderEvents() {
|
||||
el('lt-events').innerHTML = state.events.slice(-200).reverse().map(e => `<li><time>${esc(new Date(e.created_at).toLocaleTimeString())}</time><span>${esc(e.step_id ? '[' + e.step_id + '] ' : '')}${esc(e.message || e.kind)}</span></li>`).join('') || `<li>${esc(tr('noEvents'))}</li>`;
|
||||
V.setHTML(el('lt-events'), state.events.slice(-200).reverse().map(e => `<li><time>${esc(new Date(e.created_at).toLocaleTimeString())}</time><span>${esc(e.step_id ? '[' + e.step_id + '] ' : '')}${esc(e.message || e.kind)}</span></li>`).join('') || `<li>${esc(tr('noEvents'))}</li>`);
|
||||
}
|
||||
async function refresh() {
|
||||
if (!state.active || state.loading) return;
|
||||
|
|
@ -87,10 +98,10 @@
|
|||
const epoch = state.epoch, selected = state.selected, mode = state.selectedMode;
|
||||
const controller = new AbortController(); state.controller = controller;
|
||||
try {
|
||||
const params = new URLSearchParams({ limit: 30, offset: state.offset, mode: el('lt-mode-filter').value, status: el('lt-filter').value, q: el('lt-search').value });
|
||||
const params = new URLSearchParams({ limit: V.pageSize, offset: state.offset, mode: el('lt-mode-filter').value, status: el('lt-filter').value, q: el('lt-search').value });
|
||||
const list = await api('/api/tasks?' + params, { signal: controller.signal });
|
||||
if (epoch !== state.epoch || !state.active) return;
|
||||
state.tasks = list.tasks; state.more = list.has_more; renderList();
|
||||
state.tasks = list.tasks; state.more = list.has_more; state.total = list.total ?? list.tasks.length; state.offset = list.offset ?? state.offset; renderList();
|
||||
if (selected && mode === 'list') {
|
||||
if (typeof window.showBatchQueueDetail === 'function') await window.showBatchQueueDetail(selected, { inline: true });
|
||||
} else if (selected) {
|
||||
|
|
@ -107,7 +118,7 @@
|
|||
}
|
||||
function invalidate() { state.epoch++; if (state.controller) state.controller.abort(); state.controller = null; state.loading = false; }
|
||||
function select(id, mode = 'goal') {
|
||||
error(''); invalidate(); if (typeof window.closeBatchQueueDetailModal === 'function') window.closeBatchQueueDetailModal();
|
||||
V.closeDrawer(); error(''); invalidate(); if (typeof window.closeBatchQueueDetailModal === 'function') window.closeBatchQueueDetailModal();
|
||||
state.selectedMode = mode; state.selected = id; state.task = null; state.events = []; state.cursor = 0;
|
||||
el('lt-guidance-input').value = ''; renderTask(); renderEvents(); renderList(); refresh();
|
||||
}
|
||||
|
|
@ -129,7 +140,7 @@
|
|||
if (action === 'select') return select(target.dataset.id, target.dataset.mode || 'goal');
|
||||
if (action === 'refresh') { invalidate(); return refresh(); }
|
||||
if (action === 'new') return openCreate();
|
||||
if (action === 'previous' || action === 'next') { state.offset = Math.max(0, state.offset + (action === 'next' ? 30 : -30)); invalidate(); return refresh(); }
|
||||
if (action === 'guidance-panel') { el('lt-support').open=true;el('lt-guidance-input').focus({preventScroll:true});return; }
|
||||
if (!task || (mutationActions.has(action) && state.mutating.has(task.id))) return;
|
||||
if (action === 'delete') {
|
||||
if (!window.confirm(tr('deleteConfirm'))) return;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
/* Paged checklist rows use the same list and inspector as autonomous steps. */
|
||||
(function () {
|
||||
'use strict';
|
||||
const pages=new Map(), editorResets=new Set();
|
||||
const V=window.TaskListView;
|
||||
const allowed=permission=>typeof window.hasPermission!=='function'||window.hasPermission(permission);
|
||||
async function request(url, options={}) {
|
||||
const response=await window.apiFetch(url,options);
|
||||
const data=await response.json().catch(()=>({}));
|
||||
if(!response.ok)throw new Error(data.error||String(response.status));
|
||||
return data;
|
||||
}
|
||||
function render(queue,pagination) {
|
||||
const root=document.getElementById('batch-queue-detail-content');
|
||||
const restore=V.captureScroll(root);
|
||||
const size=V.pageSize;
|
||||
const page=pagination?.page||1,total=pagination?.total??queue.tasks.length,offset=(page-1)*size;
|
||||
const samePage=root.dataset.checklistID===queue.id && Number(root.dataset.renderedPage)===page;
|
||||
pages.set(queue.id,page);
|
||||
if(root.dataset.checklistID!==queue.id || !root.querySelector('#bq-task-rows')) {
|
||||
root.innerHTML=`<div class="batch-queue-detail-layout" data-bq-detail-for="${V.esc(queue.id)}"><div class="batch-queue-detail-hero" id="bq-inline-summary"></div><details class="lt-context" id="bq-settings"><summary>${V.esc(V.tr('taskSettings'))}</summary><div class="lt-context-body" id="bq-metadata" data-task-scroll></div></details></div><section class="task-items-panel"><div class="task-items-heading"><h4>${V.esc(V.tr('stepList'))}</h4></div><div id="bq-task-rows" class="task-record-list" data-task-scroll></div><div id="bq-task-pagination" class="task-pagination"></div></section>`;
|
||||
root.dataset.checklistID=queue.id;
|
||||
}
|
||||
const presentation=getBatchQueueStatusPresentation(queue);
|
||||
let displayStatus=queue.status;
|
||||
if(queue.status==='completed' && queue.taskStats?.failed>0) displayStatus=queue.taskStats.completed>0?'partial':'failed';
|
||||
else if(queue.status==='completed' && queue.scheduleMode==='cron' && queue.scheduleEnabled!==false) displayStatus='scheduled';
|
||||
V.setHTML(root.querySelector('#bq-inline-summary'),`<span class="lt-status lt-status-${V.esc(displayStatus)}">${V.esc(V.tr('status.'+displayStatus))}</span><p>${V.esc(V.tr('listProgress',{done:queue.taskStats?.completed||0,total}))}${presentation.sublabel?' · '+V.esc(presentation.sublabel):''}</p>`);
|
||||
const canEdit=batchQueueAllowsSubtaskMutation(queue)&&allowed('tasks:write');
|
||||
const row=(label,value,id,edit)=>`<div class="bq-kv"><span class="bq-kv__k">${V.esc(label)}</span><span class="bq-kv__v" id="${id}">${canEdit&&edit?`<button type="button" class="bq-inline-editable task-meta-edit" onclick="${edit}()">${V.esc(value)}</button>`:V.esc(value)}</span></div>`;
|
||||
const metadata=root.querySelector('#bq-metadata');
|
||||
if(editorResets.has(queue.id)||!metadata.querySelector('.bq-inline-edit-controls')) {
|
||||
const schedule=queue.scheduleMode==='cron'?queue.cronExpr:_t('batchImportModal.scheduleModeManual');
|
||||
const html=`<section class="batch-queue-detail-kv">${row(_t('batchQueueDetailModal.queueTitle'),queue.title||V.tr('untitled'),'bq-title-val','startInlineEditTitle')}${row(_t('batchQueueDetailModal.role'),queue.role||_t('batchQueueDetailModal.defaultRole'),'bq-role-val','startInlineEditRole')}${row(_t('batchImportModal.agentMode'),batchQueueAgentModeLabel(queue.agentMode),'bq-agentmode-val','startInlineEditAgentMode')}${row(_t('batchImportModal.hitlPolicy'),batchHITLPolicyLabel(queue.hitlPolicy),'bq-hitl-val','startInlineEditHITLPolicy')}${row(_t('batchImportModal.scheduleMode'),schedule,'bq-schedule-val','startInlineEditSchedule')}${row(_t('batchQueueDetailModal.concurrency'),queue.concurrency||1,'bq-concurrency-val','startInlineEditConcurrency')}</section>
|
||||
${queue.scheduleMode==='cron'?`<label class="bq-cron-toggle"><input type="checkbox" ${queue.scheduleEnabled!==false?'checked':''} ${!allowed('tasks:write')?'disabled':''} onchange="updateBatchQueueScheduleEnabled(this.checked)">${V.esc(_t('batchQueueDetailModal.scheduleCronAuto'))}</label>`:''}
|
||||
<details class="batch-queue-detail-tech"><summary>${V.esc(_t('batchQueueDetailModal.technicalDetails'))}</summary><p>${V.esc(queue.id)}\n${V.esc(_t('batchQueueDetailModal.createdAt'))}: ${V.esc(new Date(queue.createdAt).toLocaleString())}${queue.nextRunAt?'\n'+V.esc(_t('batchQueueDetailModal.nextRunAt'))+': '+V.esc(new Date(queue.nextRunAt).toLocaleString()):''}</p></details>
|
||||
${queue.lastRunError?`<p class="lt-form-error">${V.esc(queue.lastRunError)}</p>`:''}${queue.lastScheduleError?`<p class="lt-form-error">${V.esc(queue.lastScheduleError)}</p>`:''}`;
|
||||
V.setHTML(metadata,html,editorResets.has(queue.id));editorResets.delete(queue.id);
|
||||
}
|
||||
V.renderRows(root.querySelector('#bq-task-rows'),queue.tasks.map((task,index)=>({id:task.id,index:offset+index+1,status:task.status,title:task.message,summary:task.error||task.result||V.tr('noResult')})),{key:queue.id+':'+page,open:id=>open(queue.id,id)});
|
||||
V.renderPager(root.querySelector('#bq-task-pagination'),{page,total,size,change:next=>{
|
||||
pages.set(queue.id,next);showBatchQueueDetail(queue.id,{inline:true,taskPage:next});
|
||||
}});
|
||||
restore(); if(!samePage)root.querySelector('#bq-task-rows').scrollTop=0;root.dataset.renderedPage=String(page);
|
||||
}
|
||||
async function open(queueID,taskID) {
|
||||
const dialog=V.openDrawer(V.tr('stepDetail'),`<p>${V.esc(V.tr('loading'))}</p>`);
|
||||
const current=()=>dialog.isConnected&&dialog.open&&document.getElementById('task-step-inspector')===dialog;
|
||||
let task,queue,busy=false;
|
||||
const showError=error=>{if(current()){const box=dialog.querySelector('[data-inspector-error]');if(box){box.textContent=error.message||String(error);box.hidden=false;}}};
|
||||
async function load() {
|
||||
try {
|
||||
const data=await request(`/api/batch-tasks/${encodeURIComponent(queueID)}/tasks/${encodeURIComponent(taskID)}`);
|
||||
if(!current())return;
|
||||
task=data.task;queue=data.queue;queue.taskStats=data.task_stats;
|
||||
const editable=batchQueueAllowsSubtaskMutation(queue)&&task.status!=='running';
|
||||
dialog.querySelector('.task-inspector-body').innerHTML=`<div data-task-overview><span class="lt-status lt-status-${V.esc(task.status)}">${V.esc(V.tr('status.'+task.status))}</span><h4>${V.esc(V.tr('taskContent'))}</h4><p>${V.esc(task.message)}</p>${task.startedAt?`<h4>${V.esc(_t('batchQueueDetailModal.startLabel'))}</h4><p>${V.esc(new Date(task.startedAt).toLocaleString())}</p>`:''}${task.completedAt?`<h4>${V.esc(_t('batchQueueDetailModal.completeLabel'))}</h4><p>${V.esc(new Date(task.completedAt).toLocaleString())}</p>`:''}<h4>${V.esc(V.tr('result'))}</h4><pre>${V.esc(task.result||V.tr('noResult'))}</pre>${task.error?`<h4>${V.esc(V.tr('error'))}</h4><pre>${V.esc(task.error)}</pre>`:''}</div><form data-task-editor hidden><label>${V.esc(V.tr('taskContent'))}<textarea name="message" required>${V.esc(task.message)}</textarea></label><div class="lt-actions"><button class="btn-primary" type="submit">${V.esc(V.tr('save'))}</button><button type="button" class="btn-secondary" data-checklist-action="cancel-edit">${V.esc(V.tr('cancelEdit'))}</button></div></form><p class="lt-form-error" data-inspector-error role="alert" hidden></p>`;
|
||||
dialog.querySelector('.task-inspector-actions').hidden=false;
|
||||
dialog.querySelector('.task-inspector-actions').innerHTML=`${task.conversationId&&allowed('chat:read')?`<button type="button" class="btn-secondary" data-checklist-action="conversation">${V.esc(V.tr('trace'))}</button>`:''}${allowed('tasks:write')&&batchQueueCanRunSingleTask(queue,task)?`<button type="button" class="btn-primary" data-checklist-action="run">${V.esc(_t('tasks.runSingleTask'))}</button>`:''}${editable&&allowed('tasks:write')?`<button type="button" class="btn-secondary" data-checklist-action="edit">${V.esc(_t('common.edit'))}</button>`:''}${editable&&allowed('tasks:delete')?`<button type="button" class="btn-secondary btn-delete" data-checklist-action="delete">${V.esc(V.tr('delete'))}</button>`:''}`;
|
||||
}catch(error){if(current())dialog.querySelector('.task-inspector-body').innerHTML=`<p role="alert" class="lt-form-error">${V.esc(error.message)}</p>`;}
|
||||
}
|
||||
dialog.addEventListener('click',async event=>{
|
||||
const button=event.target.closest('[data-checklist-action]');if(!button||busy||!task)return;
|
||||
const action=button.dataset.checklistAction;
|
||||
if(action==='edit'||action==='cancel-edit'){
|
||||
dialog.querySelector('[data-task-overview]').hidden=action==='edit';dialog.querySelector('[data-task-editor]').hidden=action!=='edit';
|
||||
dialog.querySelector('.task-inspector-actions').hidden=action==='edit';
|
||||
if(action==='edit')dialog.querySelector('textarea').focus();else dialog.querySelector('textarea').value=task.message;return;
|
||||
}
|
||||
if(action==='conversation'){V.closeDrawer();viewBatchTaskConversation(task.conversationId);return;}
|
||||
if(action!=='run'&&action!=='delete')return;
|
||||
if(action==='run'&&!confirm(_t('tasks.confirmRunSingleTask')))return;
|
||||
if(action==='delete'&&!confirm(_t('tasks.confirmDeleteTask',{message:V.text(task.message).slice(0,50)})))return;
|
||||
busy=true;button.disabled=true;
|
||||
try{
|
||||
const base=`/api/batch-tasks/${encodeURIComponent(queueID)}/tasks/${encodeURIComponent(taskID)}`;
|
||||
const result=await request(action==='run'?base+'/run':base,{method:action==='run'?'POST':'DELETE'});
|
||||
if(action==='delete'&¤t())V.closeDrawer();
|
||||
await refreshBatchQueues();
|
||||
if(action==='run'&¤t()){await load();if(result.autoStarted===false&&result.message)showError(new Error(result.message));}
|
||||
}catch(error){showError(error);}finally{busy=false;if(button.isConnected)button.disabled=false;}
|
||||
});
|
||||
dialog.addEventListener('submit',async event=>{
|
||||
if(!event.target.matches('[data-task-editor]'))return;event.preventDefault();if(busy)return;
|
||||
const message=event.target.querySelector('textarea').value.trim();if(!message)return;
|
||||
busy=true;const save=event.target.querySelector('[type=submit]');save.disabled=true;
|
||||
try{await request(`/api/batch-tasks/${encodeURIComponent(queueID)}/tasks/${encodeURIComponent(taskID)}`,{method:'PUT',headers:{'Content-Type':'application/json'},body:JSON.stringify({message})});await refreshBatchQueues();if(current())await load();}
|
||||
catch(error){showError(error);}finally{busy=false;if(save.isConnected)save.disabled=false;}
|
||||
});
|
||||
await load();
|
||||
}
|
||||
window.TaskChecklistView={render,open,page:id=>pages.get(id)||1,resetEditor:id=>editorResets.add(id)};
|
||||
})();
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/* Shared row, pagination and scroll behavior for both sides of task management. */
|
||||
(function () {
|
||||
'use strict';
|
||||
const states = new WeakMap();
|
||||
const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({ '&':'&', '<':'<', '>':'>', '"':'"', "'":''' }[c]));
|
||||
const text = value => String(value || '').replace(/\s+/g, ' ').trim();
|
||||
const tr = (key, args) => typeof window.t === 'function' ? window.t('longTasks.' + key, { ...args, interpolation: { escapeValue:false } }) : key;
|
||||
function captureScroll(root) {
|
||||
const nodes = new Set(root ? [root, ...root.querySelectorAll('[data-task-scroll]')] : []);
|
||||
for (let node = root?.parentElement; node; node = node.parentElement) nodes.add(node);
|
||||
const saved = [...nodes].map(node => [node, node.scrollTop, node.scrollLeft]);
|
||||
return () => saved.forEach(([node, top, left]) => { if (node.isConnected) { node.scrollTop = top; node.scrollLeft = left; } });
|
||||
}
|
||||
function setHTML(node, html, force = false) {
|
||||
const state = states.get(node) || {};
|
||||
if (!force && state.html === html) return false;
|
||||
node.innerHTML = html; state.html = html; states.set(node, state); return true;
|
||||
}
|
||||
function renderRows(root, records, options = {}) {
|
||||
let state = states.get(root);
|
||||
if (!state) {
|
||||
state = {}; states.set(root, state);
|
||||
root.addEventListener('click', event => {
|
||||
const button = event.target.closest('[data-record-open]');
|
||||
if (button && root.contains(button)) state.open?.(button.dataset.recordOpen);
|
||||
});
|
||||
}
|
||||
state.open = options.open;
|
||||
const samePage = state.key === options.key;
|
||||
const top = root.scrollTop, bounds = root.getBoundingClientRect();
|
||||
const oldRows = new Map([...root.children].map(node => [node.dataset.recordId, node]));
|
||||
const anchor = samePage ? [...root.children].find(node => node.getBoundingClientRect().bottom > bounds.top) : null;
|
||||
const anchorOffset = anchor ? anchor.getBoundingClientRect().top - bounds.top : 0;
|
||||
const keep = new Set();
|
||||
records.forEach((record, index) => {
|
||||
const id = String(record.id); keep.add(id);
|
||||
const html = `<span class="task-row-index" ${record.index == null ? 'hidden' : ''}>${esc(record.index == null ? '' : '#' + record.index)}</span>
|
||||
<span class="lt-status lt-status-${esc(record.status)}" title="${esc(record.statusLabel || tr('status.' + record.status))}">${esc(record.statusLabel || tr('status.' + record.status))}</span>
|
||||
<button type="button" class="task-record-main" data-record-open="${esc(id)}" title="${esc(text(record.title).slice(0,1200))}">
|
||||
<span class="task-record-title">${esc(text(record.title))}</span>
|
||||
<span class="task-record-summary">${esc(text(record.summary).slice(0,240))}</span>
|
||||
</button>${options.navigation ? '' : `<button type="button" class="task-record-view" data-record-open="${esc(id)}">${esc(tr('viewDetail'))}</button>`}`;
|
||||
let row = oldRows.get(id);
|
||||
if (!row) { row = document.createElement('article'); row.dataset.recordId = id; }
|
||||
row.className = 'task-record-row' + (options.navigation ? ' task-record-row--nav' : '') + (record.selected ? ' is-selected' : '');
|
||||
row.setAttribute('aria-current', record.selected ? 'true' : 'false');
|
||||
if (states.get(row)?.html !== html) {
|
||||
const focused = row.contains(document.activeElement);
|
||||
setHTML(row, html);
|
||||
if (focused) row.querySelector('button')?.focus({preventScroll:true});
|
||||
}
|
||||
const at = root.children[index];
|
||||
if (at !== row) root.insertBefore(row, at || null);
|
||||
});
|
||||
oldRows.forEach((node, id) => { if (!keep.has(id)) node.remove(); });
|
||||
if (!records.length && !root.children.length) {
|
||||
const empty = document.createElement('div'); empty.className='lt-empty'; empty.textContent=options.empty || tr('noMatches'); root.append(empty);
|
||||
}
|
||||
if (samePage) {
|
||||
const retained = anchor && [...root.children].find(node => node.dataset.recordId === anchor.dataset.recordId);
|
||||
root.scrollTop = retained ? root.scrollTop + retained.getBoundingClientRect().top - root.getBoundingClientRect().top - anchorOffset : top;
|
||||
} else root.scrollTop = 0;
|
||||
state.key = options.key;
|
||||
}
|
||||
function renderPager(root, {page=1, total=0, size=20, change}) {
|
||||
const pages = Math.max(1, Math.ceil(total / size));
|
||||
let state = states.get(root);
|
||||
if (!state) {
|
||||
state = {}; states.set(root,state);
|
||||
root.addEventListener('click', event => { const button=event.target.closest('[data-task-page]'); if (button && !button.disabled) state.change?.(Number(button.dataset.taskPage)); });
|
||||
}
|
||||
state.change = change;
|
||||
const nav = (target,label,disabled) => `<button type="button" class="btn-secondary" data-task-page="${target}" data-page-nav="${label}" aria-label="${esc(tr(label))}" title="${esc(tr(label))}" ${disabled?'disabled':''}>${esc(tr(label))}</button>`;
|
||||
setHTML(root, `<span class="task-page-summary">${esc(tr('pageSummary',{start:total?(page-1)*size+1:0,end:Math.min(page*size,total),total}))} · ${esc(tr('perPage',{count:size}))}</span><div class="task-page-controls">
|
||||
${nav(1,'firstPage',page<=1)}${nav(page-1,'previous',page<=1)}<span>${esc(tr('pageNumber',{page,pages}))}</span>${nav(page+1,'next',page>=pages)}${nav(pages,'lastPage',page>=pages)}</div>`);
|
||||
}
|
||||
function closeDrawer() {
|
||||
const dialog=document.getElementById('task-step-inspector');
|
||||
if (!dialog) return;
|
||||
const restore=captureScroll(document.getElementById('long-task-workspace'));
|
||||
dialog.close(); restore();
|
||||
}
|
||||
function openDrawer(title, body, actions = '') {
|
||||
closeDrawer(); document.getElementById('task-step-inspector')?.remove();
|
||||
const dialog=document.createElement('dialog'); dialog.id='task-step-inspector'; dialog.className='task-inspector';
|
||||
dialog.setAttribute('aria-labelledby','task-inspector-title');
|
||||
dialog.innerHTML=`<div class="task-inspector-header"><h3 id="task-inspector-title">${esc(title)}</h3><button type="button" class="lt-dialog-close" data-inspector-close aria-label="${esc(tr('close'))}">×</button></div><div class="task-inspector-body" data-task-scroll>${body}</div><div class="task-inspector-actions">${actions}</div>`;
|
||||
document.body.append(dialog); dialog.querySelector('[data-inspector-close]').onclick=closeDrawer;
|
||||
dialog.addEventListener('close',()=>dialog.remove());
|
||||
dialog.addEventListener('click',event=>{if(event.target===dialog){const r=dialog.getBoundingClientRect();if(event.clientX<r.left||event.clientX>r.right||event.clientY<r.top||event.clientY>r.bottom)closeDrawer();}});
|
||||
dialog.showModal();return dialog;
|
||||
}
|
||||
window.TaskListView={pageSize:20,esc,text,tr,captureScroll,setHTML,renderRows,renderPager,openDrawer,closeDrawer};
|
||||
})();
|
||||
|
|
@ -45,9 +45,9 @@ function getBatchQueueStatusPresentation(queue) {
|
|||
const nextStr = queue.nextRunAt ? new Date(queue.nextRunAt).toLocaleString() : '';
|
||||
const empty = { sublabel: null, progressNote: null, callout: null };
|
||||
|
||||
const failedCount = (queue.tasks || []).filter(task => task.status === 'failed').length;
|
||||
const failedCount = queue.taskStats ? queue.taskStats.failed : (queue.tasks || []).filter(task => task.status === 'failed').length;
|
||||
if (queue.status === 'completed' && failedCount > 0) {
|
||||
const allFailed = failedCount === (queue.tasks || []).length;
|
||||
const allFailed = failedCount === (queue.taskStats ? queue.taskStats.total : (queue.tasks || []).length);
|
||||
return {
|
||||
text: allFailed ? _t('tasks.statusFailed') : _tPlain('tasks.statusEndedWithFailures', { count: failedCount }),
|
||||
class: 'batch-queue-status-failed',
|
||||
|
|
@ -90,7 +90,7 @@ function getBatchQueueStatusPresentation(queue) {
|
|||
function batchQueueAllowsSubtaskMutation(queue) {
|
||||
if (!queue) return false;
|
||||
if (queue.status === 'running') return false;
|
||||
const hasRunningSubtask = Array.isArray(queue.tasks) && queue.tasks.some(t => t && t.status === 'running');
|
||||
const hasRunningSubtask = queue.taskStats ? queue.taskStats.running > 0 : Array.isArray(queue.tasks) && queue.tasks.some(t => t && t.status === 'running');
|
||||
if (hasRunningSubtask) return false;
|
||||
return queue.status === 'pending' || queue.status === 'paused' || queue.status === 'completed' || queue.status === 'cancelled';
|
||||
}
|
||||
|
|
@ -98,6 +98,7 @@ function batchQueueAllowsSubtaskMutation(queue) {
|
|||
/** 是否允许对指定子任务发起单条执行(与后端 queueAllowsSingleTaskRunLocked 对齐) */
|
||||
function batchQueueCanRunSingleTask(queue, task) {
|
||||
if (!queue || !task) return false;
|
||||
if (queue.taskStats && queue.taskStats.running > 0) return false;
|
||||
if (task.status === 'running') return false;
|
||||
if (queue.status === 'running') return false;
|
||||
return queue.status === 'pending' || queue.status === 'paused' || queue.status === 'completed' || queue.status === 'cancelled';
|
||||
|
|
@ -812,6 +813,7 @@ function initTasksPage() {
|
|||
// 清理定时器(页面切换时调用)
|
||||
function cleanupTasksPage() {
|
||||
if (typeof cleanupLongTasks === 'function') cleanupLongTasks();
|
||||
if (window.TaskListView) window.TaskListView.closeDrawer();
|
||||
closeBatchImportModal();
|
||||
closeAddBatchTaskModal();
|
||||
closeBatchQueueDetailModal();
|
||||
|
|
@ -1799,7 +1801,7 @@ async function showBatchQueueDetail(queueId, options = {}) {
|
|||
if (!modal || !content) return;
|
||||
const holder = document.getElementById('lt-batch-detail');
|
||||
if (options.inline && holder) {
|
||||
holder.appendChild(modal); holder.hidden = false;
|
||||
if (modal.parentElement !== holder) holder.appendChild(modal); holder.hidden = false;
|
||||
modal.classList.remove('modal'); modal.classList.add('lt-inline-queue');
|
||||
}
|
||||
|
||||
|
|
@ -1814,11 +1816,12 @@ async function showBatchQueueDetail(queueId, options = {}) {
|
|||
if (content) content.innerHTML = '<p style="color:#64748b;margin:0;">…</p>';
|
||||
openAppModal('batch-queue-detail-modal', { focus: false });
|
||||
}
|
||||
if (options.inline) modal.style.display = 'flex';
|
||||
|
||||
try {
|
||||
// 加载角色列表(如果还未加载)
|
||||
let loadedRoles = [];
|
||||
if (typeof loadRoles === 'function') {
|
||||
if (!options.inline && typeof loadRoles === 'function') {
|
||||
try {
|
||||
loadedRoles = await loadRoles();
|
||||
} catch (error) {
|
||||
|
|
@ -1826,7 +1829,9 @@ async function showBatchQueueDetail(queueId, options = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
const response = await apiFetch(`/api/batch-tasks/${queueId}`);
|
||||
const paged = options.inline && window.TaskChecklistView;
|
||||
const page = options.taskPage || (paged ? window.TaskChecklistView.page(queueId) : 1);
|
||||
const response = await apiFetch(`/api/batch-tasks/${queueId}` + (paged ? `?task_page=${page}&task_page_size=20` : ''));
|
||||
if (!response.ok) {
|
||||
throw new Error(_t('tasks.getQueueDetailFailed'));
|
||||
}
|
||||
|
|
@ -1834,6 +1839,7 @@ async function showBatchQueueDetail(queueId, options = {}) {
|
|||
const result = await response.json();
|
||||
if (version !== batchDetailVersion || !isAppModalOpen('batch-queue-detail-modal')) return;
|
||||
const queue = result.queue;
|
||||
if (result.task_stats) queue.taskStats = result.task_stats;
|
||||
batchQueuesState.currentQueueId = queueId;
|
||||
const pres = getBatchQueueStatusPresentation(queue);
|
||||
const allowSubtaskMutation = batchQueueAllowsSubtaskMutation(queue);
|
||||
|
|
@ -1882,6 +1888,11 @@ async function showBatchQueueDetail(queueId, options = {}) {
|
|||
if (rerun) rerun.textContent = _t('longTasks.rerunAll');
|
||||
}
|
||||
|
||||
if (options.inline && window.TaskChecklistView) {
|
||||
window.TaskChecklistView.render(queue, result.task_pagination);
|
||||
stopBatchQueueRefresh(); return;
|
||||
}
|
||||
|
||||
// 任务状态映射
|
||||
const taskStatusMap = {
|
||||
'pending': { text: _t('tasks.statusPending'), class: 'batch-task-status-pending' },
|
||||
|
|
@ -2026,6 +2037,7 @@ async function showBatchQueueDetail(queueId, options = {}) {
|
|||
|
||||
function refreshBatchQueueDetailIfCurrent(queueId) {
|
||||
if (batchQueuesState.currentQueueId === queueId && isAppModalOpen('batch-queue-detail-modal')) {
|
||||
if (window.TaskChecklistView) window.TaskChecklistView.resetEditor(queueId);
|
||||
return showBatchQueueDetail(queueId, { inline: true });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
<link rel="stylesheet" href="/static/css/vulnerability-workspace.css?v=20261113-aligned-overview">
|
||||
<link rel="stylesheet" href="/static/css/vulnerability-list.css?v=20261113-compact-rows">
|
||||
<script src="/static/js/router.js?v=20261011-token-settings"></script>
|
||||
<link rel="stylesheet" href="/static/css/long-tasks.css?v=20261113-unified-tasks">
|
||||
<link rel="stylesheet" href="/static/css/long-tasks.css?v=20261113-task-rows">
|
||||
</head>
|
||||
<body>
|
||||
<div id="login-overlay" class="login-overlay" style="display: none;">
|
||||
|
|
@ -3022,25 +3022,25 @@
|
|||
<button type="button" class="btn-primary" data-lt-action="new" data-require-permission="tasks:write" data-i18n="longTasks.new">新建任务</button>
|
||||
</div>
|
||||
<div class="lt-board" id="lt-board">
|
||||
<aside class="lt-sidebar"><div id="lt-list"></div><div class="lt-pagination">
|
||||
<button id="lt-prev" class="btn-secondary" data-lt-action="previous" data-i18n="longTasks.previous">上一页</button><span id="lt-page">1</span><button id="lt-next" class="btn-secondary" data-lt-action="next" data-i18n="longTasks.next">下一页</button>
|
||||
</div></aside>
|
||||
<aside class="lt-sidebar"><div class="lt-sidebar-heading" data-i18n="longTasks.taskList">任务列表</div><div id="lt-list" data-task-scroll></div><div id="lt-pagination" class="task-pagination"></div></aside>
|
||||
<div id="lt-empty-detail" class="lt-empty" data-i18n="longTasks.choose">选择任务查看计划、进展和执行记录。</div>
|
||||
<section id="lt-detail" class="lt-detail" hidden>
|
||||
<header><h3 id="lt-name"></h3><div id="lt-state"></div></header>
|
||||
<p id="lt-progress"></p><div id="lt-actions" class="lt-actions"></div>
|
||||
<h4 data-i18n="longTasks.summary">当前进展</h4><p id="lt-summary"></p>
|
||||
<details><summary data-i18n="longTasks.contract">目标、范围与验收条件</summary>
|
||||
<div class="lt-detail-top"><header><h3 id="lt-name"></h3><div id="lt-state"></div></header>
|
||||
<p id="lt-progress"></p><p id="lt-summary" class="task-parent-summary"></p><div id="lt-actions" class="lt-actions"></div>
|
||||
<aside id="lt-question" hidden><strong data-i18n="longTasks.needsAnswer">需要你的答复</strong><p id="lt-question-text"></p><button type="button" class="btn-secondary" data-lt-action="guidance-panel" data-i18n="longTasks.answer">答复</button></aside>
|
||||
</div>
|
||||
<details class="lt-context"><summary data-i18n="longTasks.taskSettings">任务说明与设置</summary><div class="lt-context-body" data-task-scroll>
|
||||
<h4 data-i18n="longTasks.objective">目标</h4><p id="lt-objective"></p>
|
||||
<h4 data-i18n="longTasks.scope">范围与约束</h4><p id="lt-scope"></p>
|
||||
<h4 data-i18n="longTasks.criteria">验收条件</h4><p id="lt-criteria"></p>
|
||||
</details>
|
||||
<h4 data-i18n="longTasks.strategy">持续推进路线</h4><p id="lt-strategy"></p>
|
||||
<aside id="lt-question" hidden><strong data-i18n="longTasks.needsAnswer">需要你的答复</strong><p id="lt-question-text"></p></aside>
|
||||
<h4 data-i18n="longTasks.plan">执行计划与结果</h4><div id="lt-steps"></div>
|
||||
<form id="lt-guidance-form"><label id="lt-guidance-label" for="lt-guidance-input" data-i18n="longTasks.guidance">补充方向</label><textarea id="lt-guidance-input" rows="3" maxlength="8000" required></textarea><button id="lt-guidance-send" type="submit" class="btn-primary" data-i18n="longTasks.sendGuidance">提交补充</button></form>
|
||||
<details><summary data-i18n="longTasks.guidanceHistory">已提交的补充</summary><p id="lt-guidance-history"></p></details>
|
||||
<details open><summary data-i18n="longTasks.events">任务动态</summary><ol id="lt-events"></ol></details>
|
||||
<h4 data-i18n="longTasks.strategy">持续推进路线</h4><p id="lt-strategy"></p>
|
||||
</div></details>
|
||||
<details id="lt-support" class="lt-context"><summary data-i18n="longTasks.guidanceAndEvents">补充方向与任务动态</summary><div class="lt-context-body" data-task-scroll>
|
||||
<form id="lt-guidance-form"><label id="lt-guidance-label" for="lt-guidance-input" data-i18n="longTasks.guidance">补充方向</label><textarea id="lt-guidance-input" rows="3" maxlength="8000" required></textarea><button id="lt-guidance-send" type="submit" class="btn-primary" data-i18n="longTasks.sendGuidance">提交补充</button></form>
|
||||
<details><summary data-i18n="longTasks.guidanceHistory">已提交的补充</summary><p id="lt-guidance-history"></p></details>
|
||||
<details open><summary data-i18n="longTasks.events">任务动态</summary><ol id="lt-events"></ol></details>
|
||||
</div></details>
|
||||
<section class="task-items-panel"><div class="task-items-heading"><h4 data-i18n="longTasks.plan">执行计划与结果</h4></div><div id="lt-steps" class="task-record-list" data-task-scroll></div><div id="lt-step-pagination" class="task-pagination"></div></section>
|
||||
</section>
|
||||
<section id="lt-batch-detail" class="lt-detail" hidden></section>
|
||||
</div>
|
||||
|
|
@ -7158,8 +7158,10 @@
|
|||
<script src="/static/js/vulnerability-download.js?v=20261030-2"></script>
|
||||
<script src="/static/js/webshell.js?v=20261011-token-usage-tool-title"></script>
|
||||
<script src="/static/js/chat-files.js?v=20261103-personal-integration"></script>
|
||||
<script src="/static/js/tasks.js?v=20261113-unified-tasks"></script>
|
||||
<script src="/static/js/long-tasks.js?v=20261113-unified-tasks"></script>
|
||||
<script src="/static/js/task-list-view.js?v=20261113-task-rows"></script>
|
||||
<script src="/static/js/tasks.js?v=20261113-task-rows"></script>
|
||||
<script src="/static/js/task-checklist-view.js?v=20261113-task-rows"></script>
|
||||
<script src="/static/js/long-tasks.js?v=20261113-task-rows"></script>
|
||||
<script src="/static/js/workflow-package-client.js"></script>
|
||||
<script src="/static/js/workflows.js"></script>
|
||||
<script src="/static/js/update.js?v={{.Version}}-update-status"></script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue