@tea-agent/loop-agent 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +157 -157
- package/CHANGELOG.md +116 -305
- package/README.md +357 -334
- package/bin/agent-worker.js +22 -22
- package/bin/loop-agent.js +21 -21
- package/dist/commands/cursor-prompt.js +6 -6
- package/dist/commands/init.js +505 -505
- package/dist/commands/loop-benchmark.js +11 -11
- package/dist/commands/pi-reuse-benchmark.js +16 -16
- package/dist/executors/pi-event-serializer.js +33 -11
- package/dist/sidecars/cursor-prompt/executor.js +1 -1
- package/dist/task/runtime.js +27 -27
- package/dist/worker/observe/spec-evidence.js +19 -10
- package/dist/worker/observe/static/api.js +46 -46
- package/dist/worker/observe/static/app.js +151 -150
- package/dist/worker/observe/static/constants.js +156 -148
- package/dist/worker/observe/static/copy.js +67 -67
- package/dist/worker/observe/static/dag-helpers.js +201 -172
- package/dist/worker/observe/static/dag-layout.d.ts +31 -31
- package/dist/worker/observe/static/dag-layout.js +83 -83
- package/dist/worker/observe/static/dag-model.js +72 -72
- package/dist/worker/observe/static/dom.js +122 -122
- package/dist/worker/observe/static/format-pool.d.ts +71 -0
- package/dist/worker/observe/static/format-pool.js +134 -67
- package/dist/worker/observe/static/format.js +317 -292
- package/dist/worker/observe/static/index.html +350 -308
- package/dist/worker/observe/static/kpi.js +100 -94
- package/dist/worker/observe/static/markdown-render.js +124 -0
- package/dist/worker/observe/static/relations.js +133 -133
- package/dist/worker/observe/static/router.js +93 -93
- package/dist/worker/observe/static/run-processing.js +148 -148
- package/dist/worker/observe/static/shell-chrome.js +74 -68
- package/dist/worker/observe/static/state.js +273 -267
- package/dist/worker/observe/static/styles.css +2504 -1902
- package/dist/worker/observe/static/views/batch.js +227 -227
- package/dist/worker/observe/static/views/dag-graph.js +172 -172
- package/dist/worker/observe/static/views/dag-inspector.js +530 -627
- package/dist/worker/observe/static/views/dag.js +371 -371
- package/dist/worker/observe/static/views/dashboard.js +86 -100
- package/dist/worker/observe/static/views/failures.js +143 -143
- package/dist/worker/observe/static/views/feature.js +492 -492
- package/dist/worker/observe/static/views/pool.js +708 -350
- package/dist/worker/observe/static/views/run.js +453 -453
- package/dist/worker/observe/static/views/session-timeline.js +771 -219
- package/dist/worker/observe/static/views/shell.js +7 -7
- package/dist/worker/observe/static/views/task.js +314 -314
- package/dist/worker/observe/static/views/timeline.js +163 -163
- package/dist/workflows/dag/canvas-observer.js +275 -275
- package/dist/workflows/dag/init-hybrid.js +27 -11
- package/docs/README.md +106 -104
- package/docs/architecture/README.md +26 -26
- package/docs/architecture/dag-execution.md +140 -140
- package/docs/architecture/evolution.md +54 -54
- package/docs/architecture/facts-and-state.md +71 -71
- package/docs/architecture/runtime-boundaries.md +191 -191
- package/docs/architecture/system-overview.md +93 -93
- package/docs/architecture/worker-and-feature.md +85 -85
- package/docs/harness-methodology-debugging.md +153 -153
- package/docs/harness-methodology-tdd.md +130 -130
- package/docs/harness-methodology-verification.md +27 -27
- package/docs/init-surface.manifest.json +304 -307
- package/docs/skills/README.md +7 -7
- package/docs/skills/vetted-skill-registry.md +29 -29
- package/docs/templates/adr.md +60 -60
- package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -94
- package/docs/templates/agent-dag-decision-envelope.schema.json +213 -213
- package/docs/templates/agent-dag-decision-gate-dogfood-report.md +117 -117
- package/docs/templates/agent-dag-decision-gate.prompt.md +246 -246
- package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -98
- package/docs/templates/agent-dag-report.schema.json +473 -473
- package/docs/templates/agent-dag-review-verdict.prompt.md +68 -68
- package/docs/templates/agent-dag.base.json +190 -190
- package/docs/templates/agent-dag.final-verification.json +185 -185
- package/docs/templates/agent-dag.schema.json +411 -411
- package/docs/templates/agent-dag.supervised-implementation.json +620 -620
- package/docs/templates/backend-test-analysis.schema.json +44 -44
- package/docs/templates/backend-test-case-manifest.schema.json +190 -190
- package/docs/templates/backend-test-dag.classify.prompt.md +75 -75
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +204 -204
- package/docs/templates/backend-test-dag.json +559 -559
- package/docs/templates/backend-test-dag.retrospect.prompt.md +139 -139
- package/docs/templates/backend-test-dag.review-cases.prompt.md +83 -83
- package/docs/templates/backend-test-execution.schema.json +133 -133
- package/docs/templates/backend-test-result.schema.json +99 -99
- package/docs/templates/branch-merge-report.md +0 -1
- package/docs/templates/exec-plan.md +64 -64
- package/docs/templates/feature-spec.md +53 -53
- package/docs/templates/frontend-design-contract.md +42 -42
- package/docs/templates/frontend-eval/fixtures/failures/01-type-build-error.md +17 -17
- package/docs/templates/frontend-eval/fixtures/failures/02-unit-component-test-fail.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/03-fixture-schema-drift.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/04-missing-loading-empty-error-state.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/05-forbidden-write-writeset-expansion.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/06-unapproved-dependency-add.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/07-mock-production-on.md +21 -21
- package/docs/templates/frontend-eval/fixtures/functional/01-simple-component-style.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/02-form-validation.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/03-list-detail-page.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/04-api-mock.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/05-permission-auth-gated-ui.md +27 -27
- package/docs/templates/frontend-eval/fixtures/functional/06-ssr-server-client-boundary.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/07-shared-public-component-api.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/08-pure-local-no-remote.md +27 -27
- package/docs/templates/frontend-eval/metrics.md +138 -138
- package/docs/templates/frontend-eval/smoke-targets.md +53 -53
- package/docs/templates/frontend-implementation-contract.schema.json +27 -27
- package/docs/templates/frontend-task-constraints.md +35 -35
- package/docs/templates/frontend-task-requirement.md +70 -70
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +5 -5
- package/docs/templates/frontend-test-dag.json +23 -23
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +3 -3
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +3 -3
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +3 -3
- package/docs/templates/frontend-test-dag.review-execution.prompt.md +3 -3
- package/docs/templates/harness.schema.json +221 -221
- package/docs/templates/hybrid-dag.json +188 -188
- package/docs/templates/init-evolution-review.md +35 -35
- package/docs/templates/interactive-ui-round2-experiment.md +66 -66
- package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -118
- package/docs/templates/knowledge-sync-dag.json +178 -178
- package/docs/templates/knowledge-sync-draft.schema.json +71 -71
- package/docs/templates/product-line/AGENTS.md +8 -8
- package/docs/templates/product-line/README.md +9 -9
- package/docs/templates/product-line/acceptance.yaml +14 -14
- package/docs/templates/product-line/closeout.yaml +9 -9
- package/docs/templates/product-line/design.md +13 -13
- package/docs/templates/product-line/links.md +10 -10
- package/docs/templates/product-line/requirement.md +17 -17
- package/docs/templates/product-line/task-graph.yaml +15 -15
- package/docs/templates/product-line/task.yaml +64 -64
- package/docs/templates/product-line/test-plan.md +7 -7
- package/docs/templates/production-readiness-checklist.md +57 -57
- package/docs/templates/progress-log.md +17 -17
- package/docs/templates/project-start-checklist.md +9 -9
- package/docs/templates/qa-report.md +48 -48
- package/docs/templates/sprint-contract.md +29 -29
- package/docs/templates/worker-dogfood-evidence.md +80 -80
- package/docs/templates/worker-dogfood-setup.md +68 -68
- package/examples/decision-gate-agent-dag.json +173 -173
- package/examples/example-dag.json +46 -46
- package/examples/hybrid-loop-agent-dag.json +188 -188
- package/harness.json +66 -66
- package/package.json +78 -52
- package/scripts/kb-bootstrap-init-skeleton.sh +240 -240
- package/scripts/kb-graph-incremental-prepare.mjs +386 -386
- package/scripts/kb-graph-materialize.mjs +105 -105
- package/scripts/kb-graph-promote.mjs +164 -164
- package/scripts/kb-query.mjs +554 -554
- package/skills/agent-worker/SKILL.md +39 -39
- package/skills/agent-worker/references/agent-worker-operator.md +60 -60
- package/skills/ai-engineering-context/SKILL.md +48 -48
- package/skills/analyze-product-dependencies/SKILL.md +67 -67
- package/skills/analyze-product-dependencies/agents/openai.yaml +4 -4
- package/skills/analyze-product-dependencies/references/api-documentation-schema.md +30 -30
- package/skills/analyze-product-dependencies/references/dependency-analysis-schema.md +28 -28
- package/skills/analyze-product-dependencies/references/example.md +76 -76
- package/skills/analyze-product-dependencies/references/forward-test-cases.md +35 -35
- package/skills/analyze-product-dependencies/references/input-contract.md +11 -11
- package/skills/analyze-product-dependencies/references/scouting-rules.md +61 -61
- package/skills/analyze-product-dependencies/scripts/test-validators.mjs +267 -267
- package/skills/analyze-product-dependencies/scripts/validate-api-documentation.mjs +101 -101
- package/skills/analyze-product-dependencies/scripts/validate-dependency-analysis.mjs +142 -142
- package/skills/analyze-product-dependencies/scripts/validate-product-requirement-input.mjs +76 -76
- package/skills/analyze-product-dependencies/scripts/validation-helpers.mjs +146 -146
- package/skills/analyze-product-requirements/SKILL.md +90 -90
- package/skills/analyze-product-requirements/agents/openai.yaml +4 -4
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +91 -91
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +56 -56
- package/skills/analyze-product-requirements/references/example.md +86 -86
- package/skills/analyze-product-requirements/references/forward-test-cases.md +66 -66
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +32 -32
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +33 -33
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +35 -35
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +193 -193
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +69 -69
- package/skills/analyze-product-requirements/scripts/validate-product-requirement.mjs +97 -97
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +98 -98
- package/skills/analyze-product-requirements/scripts/validation-helpers.mjs +156 -156
- package/skills/browser-tools/SKILL.md +196 -196
- package/skills/browser-tools/browser-content.js +103 -103
- package/skills/browser-tools/browser-cookies.js +35 -35
- package/skills/browser-tools/browser-eval.js +53 -53
- package/skills/browser-tools/browser-hn-scraper.js +108 -108
- package/skills/browser-tools/browser-nav.js +44 -44
- package/skills/browser-tools/browser-pick.js +162 -162
- package/skills/browser-tools/browser-screenshot.js +34 -34
- package/skills/browser-tools/browser-start.js +86 -86
- package/skills/browser-tools/package-lock.json +2556 -2556
- package/skills/browser-tools/package.json +19 -19
- package/skills/code-review-core/SKILL.md +20 -20
- package/skills/codebase-scout/SKILL.md +19 -19
- package/skills/frontend-design-review/SKILL.md +66 -66
- package/skills/frontend-design-review/references/review-checklist.md +40 -58
- package/skills/frontend-implementation/SKILL.md +49 -49
- package/skills/frontend-implementation/references/code-standards.md +32 -32
- package/skills/frontend-implementation/references/design-spec.md +46 -46
- package/skills/frontend-implementation/references/node-contracts.md +27 -27
- package/skills/frontend-review/SKILL.md +61 -59
- package/skills/frontend-review/references/review-findings.md +48 -47
- package/skills/frontend-verification/SKILL.md +55 -53
- package/skills/frontend-verification/references/verification-checklist.md +59 -68
- package/skills/grill-me/SKILL.md +10 -10
- package/skills/grill-with-docs/SKILL.md +88 -88
- package/skills/grill-with-docs/adr-format.md +47 -47
- package/skills/grill-with-docs/context-format.md +60 -60
- package/skills/init-capability-evolution/SKILL.md +70 -70
- package/skills/loop-agent/SKILL.md +151 -151
- package/skills/loop-agent/references/README.md +67 -67
- package/skills/loop-agent/references/command-reference.md +527 -527
- package/skills/loop-agent/references/docs-converge.md +126 -126
- package/skills/loop-agent/references/harness-policy.md +263 -263
- package/skills/loop-agent/references/hybrid-dag.md +243 -243
- package/skills/loop-agent/references/learned/README.md +21 -21
- package/skills/loop-agent/references/long-running-loop.md +57 -57
- package/skills/loop-agent/references/model-routing.md +36 -36
- package/skills/loop-agent/references/multi-worktree.md +54 -54
- package/skills/loop-agent/references/one-shot-runs.md +85 -85
- package/skills/loop-agent/references/orchestrator-and-interventions.md +169 -169
- package/skills/loop-agent/references/pi-prompt.md +23 -23
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +84 -84
- package/skills/loop-agent/references/post-implementation-and-patterns.md +44 -44
- package/skills/loop-agent/references/task-workflow.md +89 -89
- package/skills/loop-agent/references/verification-and-failure-handling.md +141 -141
- package/skills/playwright-cli/SKILL.md +420 -420
- package/skills/playwright-cli/references/element-attributes.md +23 -23
- package/skills/playwright-cli/references/playwright-tests.md +39 -39
- package/skills/playwright-cli/references/request-mocking.md +87 -87
- package/skills/playwright-cli/references/running-code.md +241 -241
- package/skills/playwright-cli/references/session-management.md +225 -225
- package/skills/playwright-cli/references/storage-state.md +275 -275
- package/skills/playwright-cli/references/test-generation.md +433 -433
- package/skills/playwright-cli/references/tracing.md +139 -139
- package/skills/playwright-cli/references/video-recording.md +143 -143
- package/skills/playwright-cli-case-generator/SKILL.md +74 -74
- package/skills/requesting-code-review/SKILL.md +101 -101
- package/skills/requesting-code-review/code-reviewer.md +168 -168
- package/skills/systematic-debugging/CREATION-LOG.md +119 -119
- package/skills/systematic-debugging/SKILL.md +296 -296
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
- package/skills/systematic-debugging/condition-based-waiting.md +115 -115
- package/skills/systematic-debugging/defense-in-depth.md +122 -122
- package/skills/systematic-debugging/find-polluter.sh +63 -63
- package/skills/systematic-debugging/root-cause-tracing.md +169 -169
- package/skills/systematic-debugging/test-academic.md +14 -14
- package/skills/systematic-debugging/test-pressure-1.md +58 -58
- package/skills/systematic-debugging/test-pressure-2.md +68 -68
- package/skills/systematic-debugging/test-pressure-3.md +69 -69
- package/skills/test-driven-development/SKILL.md +20 -20
- package/skills/using-git-worktrees/SKILL.md +215 -215
- package/skills/verification-before-completion/SKILL.md +154 -154
- package/skills/webapp-testing/SKILL.md +19 -19
- package/docs/agent-dag-recovery-playbook.md +0 -195
- package/docs/agent-dag-runner.md +0 -67
- package/docs/cursor-prompt-sidecar.md +0 -36
- package/docs/decisions/README.md +0 -18
- package/docs/design/README.md +0 -167
- package/docs/development-principles.md +0 -73
- package/docs/exec-plans/README.md +0 -6
- package/docs/exec-plans/active/README.md +0 -12
- package/docs/exec-plans/completed/README.md +0 -107
- package/docs/feature-workflow.md +0 -414
- package/docs/loop-agent-harness.md +0 -142
- package/docs/production-readiness.md +0 -96
- package/docs/progress/README.md +0 -80
- package/docs/reports/README.md +0 -159
- package/docs/verification-matrix.md +0 -70
- package/scripts/check-product-line-docs.sh +0 -29
- package/scripts/check-task-pool-root.sh +0 -32
- package/scripts/kb-graph-incremental-prepare.sh +0 -5
- package/scripts/kb-graph-materialize.sh +0 -4
- package/scripts/kb-graph-promote.sh +0 -4
- package/scripts/kb-query.sh +0 -5
|
@@ -1,350 +1,708 @@
|
|
|
1
|
-
/** Observe UI view module (R5). */
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
1
|
+
/** Observe UI view module — Task Pool ops surface (R5 + ops refresh). */
|
|
2
|
+
import { UI_TEXT, POOL_POLL_MS } from "../constants.js";
|
|
3
|
+
import { clearNode, el, reconcileKeyed } from "../dom.js";
|
|
4
|
+
import {
|
|
5
|
+
badge,
|
|
6
|
+
formatAgo,
|
|
7
|
+
formatTs,
|
|
8
|
+
livenessBadge,
|
|
9
|
+
truncateText,
|
|
10
|
+
} from "../format.js";
|
|
11
|
+
import { parseRoute, navigate, buildHashPath } from "../router.js";
|
|
12
|
+
import { fetchJson } from "../api.js";
|
|
13
|
+
import { objectRouteLink } from "../relations.js";
|
|
14
|
+
import {
|
|
15
|
+
isPageVisible,
|
|
16
|
+
dashboardPollDelay,
|
|
17
|
+
mountViewState,
|
|
18
|
+
renderViewState,
|
|
19
|
+
} from "../state.js";
|
|
20
|
+
import { uiState } from "../state.js";
|
|
21
|
+
import {
|
|
22
|
+
sortPoolTasks,
|
|
23
|
+
matchesPoolStatusFilter,
|
|
24
|
+
poolStatusCounts,
|
|
25
|
+
sortAttentionTasks,
|
|
26
|
+
collectPlannerReadyTasks,
|
|
27
|
+
taskIdentityKey,
|
|
28
|
+
} from "../format-pool.js";
|
|
29
|
+
import { showView, setBreadcrumb, updateHeaderRefresh } from "../shell-chrome.js";
|
|
30
|
+
import { renderProjectionFault } from "../kpi.js";
|
|
31
|
+
import { mountBoundedEventTimeline } from "./timeline.js";
|
|
32
|
+
|
|
33
|
+
let poolToolbarBound = false;
|
|
34
|
+
let poolEventsBound = false;
|
|
35
|
+
let poolHasRendered = false;
|
|
36
|
+
|
|
37
|
+
function poolAutoRefreshEnabled() {
|
|
38
|
+
return uiState.poolAutoRefresh === true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function syncPoolToolbar() {
|
|
42
|
+
const auto = document.getElementById("pool-auto-refresh");
|
|
43
|
+
const status = document.getElementById("pool-refresh-status");
|
|
44
|
+
if (auto) auto.checked = poolAutoRefreshEnabled();
|
|
45
|
+
if (status) {
|
|
46
|
+
status.textContent = poolAutoRefreshEnabled()
|
|
47
|
+
? `自动刷新约 ${Math.round(POOL_POLL_MS / 1000)}s`
|
|
48
|
+
: "已关闭自动刷新";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function bindPoolToolbar() {
|
|
53
|
+
if (poolToolbarBound) return;
|
|
54
|
+
const btn = document.getElementById("pool-refresh-btn");
|
|
55
|
+
const auto = document.getElementById("pool-auto-refresh");
|
|
56
|
+
if (!btn || !auto) return;
|
|
57
|
+
poolToolbarBound = true;
|
|
58
|
+
btn.addEventListener("click", () => {
|
|
59
|
+
void renderPool({ reason: "manual" });
|
|
60
|
+
});
|
|
61
|
+
auto.addEventListener("change", () => {
|
|
62
|
+
uiState.poolAutoRefresh = auto.checked;
|
|
63
|
+
syncPoolToolbar();
|
|
64
|
+
if (auto.checked) startPoolAutoPolling();
|
|
65
|
+
else stopPoolAutoPolling();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function bindPoolEventsDetails() {
|
|
70
|
+
if (poolEventsBound) return;
|
|
71
|
+
const details = document.getElementById("pool-events-details");
|
|
72
|
+
if (!details) return;
|
|
73
|
+
poolEventsBound = true;
|
|
74
|
+
details.addEventListener("toggle", () => {
|
|
75
|
+
if (details.open) void refreshPoolEvents();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function stopPoolAutoPolling() {
|
|
80
|
+
if (uiState.poolTimer) {
|
|
81
|
+
clearTimeout(uiState.poolTimer);
|
|
82
|
+
uiState.poolTimer = null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function startPoolAutoPolling() {
|
|
87
|
+
stopPoolAutoPolling();
|
|
88
|
+
if (!poolAutoRefreshEnabled()) return;
|
|
89
|
+
const generation = ++uiState.pollingGeneration;
|
|
90
|
+
const poll = async () => {
|
|
91
|
+
if (!poolAutoRefreshEnabled()) return;
|
|
92
|
+
await renderPool({ reason: "auto" });
|
|
93
|
+
if (generation !== uiState.pollingGeneration) return;
|
|
94
|
+
if (!poolAutoRefreshEnabled()) return;
|
|
95
|
+
const delay = isPageVisible() ? POOL_POLL_MS : dashboardPollDelay();
|
|
96
|
+
uiState.poolTimer = setTimeout(() => {
|
|
97
|
+
uiState.poolTimer = null;
|
|
98
|
+
void poll();
|
|
99
|
+
}, delay);
|
|
100
|
+
};
|
|
101
|
+
void poll();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function refreshPoolEvents() {
|
|
105
|
+
const eventsEl = document.getElementById("pool-events");
|
|
106
|
+
const details = document.getElementById("pool-events-details");
|
|
107
|
+
if (!eventsEl || !details?.open) return;
|
|
108
|
+
await mountBoundedEventTimeline(eventsEl, "/api/events", "最近事件");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function taskPath(task) {
|
|
112
|
+
if (task.featureId) {
|
|
113
|
+
return `/feature/${encodeURIComponent(task.featureId)}/task/${encodeURIComponent(task.taskId)}`;
|
|
114
|
+
}
|
|
115
|
+
return `/task/${encodeURIComponent(task.taskId)}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function linkTo(path, label, className) {
|
|
119
|
+
const a = el("a", className || "object-link", label);
|
|
120
|
+
a.href = `#${path}`;
|
|
121
|
+
a.addEventListener("click", (e) => {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
navigate(path);
|
|
125
|
+
});
|
|
126
|
+
return a;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function syncCell(row, index, content) {
|
|
130
|
+
let td = row.children[index];
|
|
131
|
+
if (!td) {
|
|
132
|
+
td = document.createElement("td");
|
|
133
|
+
row.appendChild(td);
|
|
134
|
+
}
|
|
135
|
+
while (td.firstChild) td.removeChild(td.firstChild);
|
|
136
|
+
if (content instanceof Node) td.appendChild(content);
|
|
137
|
+
else td.textContent = content ?? "—";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function ensureTable(parent, headers, scope) {
|
|
141
|
+
let table = parent.querySelector("table");
|
|
142
|
+
if (!table) {
|
|
143
|
+
table = document.createElement("table");
|
|
144
|
+
const thead = document.createElement("thead");
|
|
145
|
+
const headRow = document.createElement("tr");
|
|
146
|
+
for (const h of headers) {
|
|
147
|
+
const th = document.createElement("th");
|
|
148
|
+
th.textContent = h;
|
|
149
|
+
headRow.appendChild(th);
|
|
150
|
+
}
|
|
151
|
+
thead.appendChild(headRow);
|
|
152
|
+
table.appendChild(thead);
|
|
153
|
+
table.appendChild(document.createElement("tbody"));
|
|
154
|
+
parent.appendChild(table);
|
|
155
|
+
}
|
|
156
|
+
return table.querySelector("tbody");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function renderOpsCard(item, kind) {
|
|
160
|
+
const card = el("div", `pool-ops-card pool-ops-card-${kind}`);
|
|
161
|
+
const title = el("div", "pool-ops-card-title");
|
|
162
|
+
title.appendChild(linkTo(taskPath(item), item.taskId));
|
|
163
|
+
card.appendChild(title);
|
|
164
|
+
const meta = el("div", "pool-ops-card-meta");
|
|
165
|
+
meta.appendChild(
|
|
166
|
+
el("span", null, item.featureId ? `Feature ${item.featureId}` : "Feature —"),
|
|
167
|
+
);
|
|
168
|
+
if (item.priority) meta.appendChild(el("span", null, item.priority));
|
|
169
|
+
if (item.status) meta.appendChild(badge(item.status));
|
|
170
|
+
else if (item.liveness) meta.appendChild(livenessBadge(item.liveness));
|
|
171
|
+
card.appendChild(meta);
|
|
172
|
+
const detail = item.recommendedFollowUp || item.title || item.failureCategory;
|
|
173
|
+
if (detail) {
|
|
174
|
+
card.appendChild(
|
|
175
|
+
el("p", "pool-ops-card-detail", truncateText(String(detail), 96)),
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
card.classList.add("clickable");
|
|
179
|
+
card.addEventListener("click", () => navigate(taskPath(item)));
|
|
180
|
+
return card;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function updateOpsCard(card, item) {
|
|
184
|
+
const title = card.querySelector(".pool-ops-card-title");
|
|
185
|
+
if (title) {
|
|
186
|
+
while (title.firstChild) title.removeChild(title.firstChild);
|
|
187
|
+
title.appendChild(linkTo(taskPath(item), item.taskId));
|
|
188
|
+
}
|
|
189
|
+
const meta = card.querySelector(".pool-ops-card-meta");
|
|
190
|
+
if (meta) {
|
|
191
|
+
while (meta.firstChild) meta.removeChild(meta.firstChild);
|
|
192
|
+
meta.appendChild(
|
|
193
|
+
el("span", null, item.featureId ? `Feature ${item.featureId}` : "Feature —"),
|
|
194
|
+
);
|
|
195
|
+
if (item.priority) meta.appendChild(el("span", null, item.priority));
|
|
196
|
+
if (item.status) meta.appendChild(badge(item.status));
|
|
197
|
+
else if (item.liveness) meta.appendChild(livenessBadge(item.liveness));
|
|
198
|
+
}
|
|
199
|
+
let detail = card.querySelector(".pool-ops-card-detail");
|
|
200
|
+
const text = item.recommendedFollowUp || item.title || item.failureCategory;
|
|
201
|
+
if (text) {
|
|
202
|
+
if (!detail) {
|
|
203
|
+
detail = el("p", "pool-ops-card-detail");
|
|
204
|
+
card.appendChild(detail);
|
|
205
|
+
}
|
|
206
|
+
detail.textContent = truncateText(String(text), 96);
|
|
207
|
+
} else if (detail) {
|
|
208
|
+
detail.remove();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Mount or refresh the pool view. Default: no auto poll.
|
|
214
|
+
* @param {{ reason?: "route" | "manual" | "auto" }} [options]
|
|
215
|
+
*/
|
|
216
|
+
export async function renderPool(options = {}) {
|
|
217
|
+
showView("pool");
|
|
218
|
+
setBreadcrumb([
|
|
219
|
+
{ label: UI_TEXT.dashboard, href: "#/" },
|
|
220
|
+
{ label: "资源池" },
|
|
221
|
+
]);
|
|
222
|
+
bindPoolToolbar();
|
|
223
|
+
bindPoolEventsDetails();
|
|
224
|
+
syncPoolToolbar();
|
|
225
|
+
|
|
226
|
+
const faultEl = document.getElementById("pool-fault");
|
|
227
|
+
const updatedAtEl = document.getElementById("pool-updated-at");
|
|
228
|
+
const kpiEl = document.getElementById("pool-kpi");
|
|
229
|
+
const emptyEl = document.getElementById("pool-empty");
|
|
230
|
+
const attentionEl = document.getElementById("pool-attention");
|
|
231
|
+
const readyEl = document.getElementById("pool-ready");
|
|
232
|
+
const listEl = document.getElementById("pool-tasks");
|
|
233
|
+
const filtersEl = document.getElementById("pool-filters");
|
|
234
|
+
if (!faultEl || !kpiEl || !emptyEl || !listEl || !attentionEl || !readyEl) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const firstPaint = !poolHasRendered;
|
|
239
|
+
if (firstPaint) {
|
|
240
|
+
faultEl.hidden = false;
|
|
241
|
+
faultEl.classList.add("pool-fault-active");
|
|
242
|
+
mountViewState(faultEl, "loading", "加载资源池…");
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const snapshot = await fetchJson("/api/snapshot");
|
|
246
|
+
if (!snapshot) {
|
|
247
|
+
faultEl.hidden = false;
|
|
248
|
+
faultEl.classList.add("pool-fault-active");
|
|
249
|
+
mountViewState(faultEl, "error", "无法加载 snapshot。");
|
|
250
|
+
if (updatedAtEl) updatedAtEl.textContent = "";
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
uiState.lastSnapshot = snapshot;
|
|
254
|
+
updateHeaderRefresh(snapshot.generatedAt, {
|
|
255
|
+
mode: poolAutoRefreshEnabled() ? "auto" : "manual",
|
|
256
|
+
});
|
|
257
|
+
poolHasRendered = true;
|
|
258
|
+
|
|
259
|
+
if (updatedAtEl) {
|
|
260
|
+
updatedAtEl.textContent = snapshot.generatedAt
|
|
261
|
+
? `投影更新:${formatTs(snapshot.generatedAt)}(advisory)`
|
|
262
|
+
: "";
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
clearNode(faultEl);
|
|
266
|
+
let hasFaultContent = false;
|
|
267
|
+
if (snapshot.projectionError) {
|
|
268
|
+
hasFaultContent = true;
|
|
269
|
+
const degraded = renderViewState(
|
|
270
|
+
"degraded",
|
|
271
|
+
"投影降级:状态分布可能不完整。",
|
|
272
|
+
{ detail: snapshot.projectionError.message ?? null },
|
|
273
|
+
);
|
|
274
|
+
faultEl.appendChild(degraded);
|
|
275
|
+
faultEl.appendChild(renderProjectionFault(snapshot.projectionError));
|
|
276
|
+
}
|
|
277
|
+
if ((snapshot.projectionWarnings ?? []).length > 0) {
|
|
278
|
+
hasFaultContent = true;
|
|
279
|
+
const warn = el("div", "projection-fault");
|
|
280
|
+
const body = el("div", "projection-fault-body");
|
|
281
|
+
body.appendChild(el("p", "projection-fault-title", "投影警告"));
|
|
282
|
+
body.appendChild(
|
|
283
|
+
el(
|
|
284
|
+
"p",
|
|
285
|
+
"projection-fault-message",
|
|
286
|
+
snapshot.projectionWarnings.join(";"),
|
|
287
|
+
),
|
|
288
|
+
);
|
|
289
|
+
warn.appendChild(body);
|
|
290
|
+
faultEl.appendChild(warn);
|
|
291
|
+
}
|
|
292
|
+
faultEl.hidden = !hasFaultContent;
|
|
293
|
+
faultEl.classList.toggle("pool-fault-active", hasFaultContent);
|
|
294
|
+
|
|
295
|
+
const allTasks = sortPoolTasks(snapshot.tasks ?? []);
|
|
296
|
+
const routeFilters = parseRoute().filters ?? {};
|
|
297
|
+
const statusFilter = (routeFilters.status ?? "").toLowerCase();
|
|
298
|
+
const qFilter = (routeFilters.q ?? "").trim().toLowerCase();
|
|
299
|
+
const filteredTasks = allTasks.filter((task) => {
|
|
300
|
+
if (statusFilter && !matchesPoolStatusFilter(task.status, statusFilter)) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
if (qFilter) {
|
|
304
|
+
const hay =
|
|
305
|
+
`${task.taskId ?? ""} ${task.featureId ?? ""} ${task.workerRunId ?? ""} ${task.failureCategory ?? ""} ${task.recommendedFollowUp ?? ""}`.toLowerCase();
|
|
306
|
+
if (!hay.includes(qFilter)) return false;
|
|
307
|
+
}
|
|
308
|
+
return true;
|
|
309
|
+
});
|
|
310
|
+
const poolPresent = snapshot.taskPool?.present === true;
|
|
311
|
+
const projectionFailed = Boolean(snapshot.projectionError);
|
|
312
|
+
const readyItems = collectPlannerReadyTasks(snapshot.features);
|
|
313
|
+
const attentionTasks = sortAttentionTasks(allTasks);
|
|
314
|
+
const counts = poolStatusCounts(allTasks);
|
|
315
|
+
const health = snapshot.health ?? {};
|
|
316
|
+
|
|
317
|
+
// Filters (stable container in HTML)
|
|
318
|
+
if (filtersEl) {
|
|
319
|
+
reconcileKeyed(
|
|
320
|
+
filtersEl,
|
|
321
|
+
[{ key: "__filters__" }],
|
|
322
|
+
{
|
|
323
|
+
getKey: (item) => item.key,
|
|
324
|
+
create: () => {
|
|
325
|
+
const wrap = el("div", "pool-filters-inner");
|
|
326
|
+
const statusLabelEl = el("label", null);
|
|
327
|
+
statusLabelEl.appendChild(document.createTextNode("状态"));
|
|
328
|
+
const statusSelect = document.createElement("select");
|
|
329
|
+
statusSelect.setAttribute("aria-label", "按状态筛选 Task");
|
|
330
|
+
statusSelect.dataset.role = "status";
|
|
331
|
+
for (const [value, label] of [
|
|
332
|
+
["", "全部"],
|
|
333
|
+
["running", "运行中"],
|
|
334
|
+
["pending", "等待/排队"],
|
|
335
|
+
["blocked", "阻塞/失联"],
|
|
336
|
+
["failed", "失败"],
|
|
337
|
+
["succeeded", "成功/复用"],
|
|
338
|
+
]) {
|
|
339
|
+
const opt = document.createElement("option");
|
|
340
|
+
opt.value = value;
|
|
341
|
+
opt.textContent = label;
|
|
342
|
+
statusSelect.appendChild(opt);
|
|
343
|
+
}
|
|
344
|
+
statusLabelEl.appendChild(statusSelect);
|
|
345
|
+
const qLabel = el("label", null);
|
|
346
|
+
qLabel.appendChild(document.createTextNode("搜索"));
|
|
347
|
+
const qInput = document.createElement("input");
|
|
348
|
+
qInput.type = "search";
|
|
349
|
+
qInput.placeholder = "Task / Feature / run…";
|
|
350
|
+
qInput.setAttribute("aria-label", "搜索 Task");
|
|
351
|
+
qInput.dataset.role = "q";
|
|
352
|
+
qLabel.appendChild(qInput);
|
|
353
|
+
const count = el("span", "muted layer-raw");
|
|
354
|
+
count.dataset.role = "count";
|
|
355
|
+
statusSelect.addEventListener("change", () => {
|
|
356
|
+
navigate(
|
|
357
|
+
buildHashPath("/pool", {
|
|
358
|
+
status: statusSelect.value || undefined,
|
|
359
|
+
q: qInput.value.trim() || undefined,
|
|
360
|
+
}),
|
|
361
|
+
);
|
|
362
|
+
});
|
|
363
|
+
qInput.addEventListener("change", () => {
|
|
364
|
+
navigate(
|
|
365
|
+
buildHashPath("/pool", {
|
|
366
|
+
status: statusSelect.value || undefined,
|
|
367
|
+
q: qInput.value.trim() || undefined,
|
|
368
|
+
}),
|
|
369
|
+
);
|
|
370
|
+
});
|
|
371
|
+
wrap.appendChild(statusLabelEl);
|
|
372
|
+
wrap.appendChild(qLabel);
|
|
373
|
+
wrap.appendChild(count);
|
|
374
|
+
return wrap;
|
|
375
|
+
},
|
|
376
|
+
update: (wrap) => {
|
|
377
|
+
const statusSelect = wrap.querySelector('[data-role="status"]');
|
|
378
|
+
const qInput = wrap.querySelector('[data-role="q"]');
|
|
379
|
+
const count = wrap.querySelector('[data-role="count"]');
|
|
380
|
+
if (statusSelect && statusSelect.value !== statusFilter) {
|
|
381
|
+
statusSelect.value = statusFilter;
|
|
382
|
+
}
|
|
383
|
+
if (qInput && document.activeElement !== qInput) {
|
|
384
|
+
qInput.value = routeFilters.q ?? "";
|
|
385
|
+
}
|
|
386
|
+
if (count) {
|
|
387
|
+
count.textContent = `显示 ${filteredTasks.length}/${allTasks.length}`;
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (projectionFailed) {
|
|
395
|
+
clearNode(kpiEl);
|
|
396
|
+
kpiEl.appendChild(
|
|
397
|
+
el(
|
|
398
|
+
"p",
|
|
399
|
+
"empty",
|
|
400
|
+
"投影失败,状态分布与健康 KPI 不可用(避免将未知显示为健康 0)。",
|
|
401
|
+
),
|
|
402
|
+
);
|
|
403
|
+
clearNode(attentionEl);
|
|
404
|
+
clearNode(readyEl);
|
|
405
|
+
clearNode(listEl);
|
|
406
|
+
emptyEl.hidden = true;
|
|
407
|
+
await refreshPoolEvents();
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (!poolPresent && allTasks.length === 0) {
|
|
412
|
+
clearNode(kpiEl);
|
|
413
|
+
clearNode(attentionEl);
|
|
414
|
+
clearNode(readyEl);
|
|
415
|
+
clearNode(listEl);
|
|
416
|
+
emptyEl.hidden = false;
|
|
417
|
+
mountViewState(
|
|
418
|
+
emptyEl,
|
|
419
|
+
"empty",
|
|
420
|
+
"当前仓库未使用 Task Pool(未发现 .harness/task-pool)。",
|
|
421
|
+
);
|
|
422
|
+
await refreshPoolEvents();
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
emptyEl.hidden = !(poolPresent && allTasks.length === 0);
|
|
427
|
+
if (!emptyEl.hidden) {
|
|
428
|
+
mountViewState(emptyEl, "empty", "Task Pool 已存在,但当前没有 Task。");
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// L1 health — always from full pool, not filtered set
|
|
432
|
+
reconcileKeyed(kpiEl, [{ key: "__heading__" }], {
|
|
433
|
+
getKey: () => "__heading__",
|
|
434
|
+
scope: "heading",
|
|
435
|
+
create: () => el("h3", "section-heading", "池健康"),
|
|
436
|
+
update: () => {},
|
|
437
|
+
});
|
|
438
|
+
reconcileKeyed(kpiEl, [{ key: "__cards__" }], {
|
|
439
|
+
getKey: () => "__cards__",
|
|
440
|
+
scope: "cards",
|
|
441
|
+
create: () => el("div", "kpi-grid pool-health-grid"),
|
|
442
|
+
update: (cards) => {
|
|
443
|
+
const entries = [
|
|
444
|
+
["运行中", counts.running, counts.running > 0 ? "kpi-highlight" : ""],
|
|
445
|
+
[
|
|
446
|
+
"阻塞/失联",
|
|
447
|
+
counts.blocked,
|
|
448
|
+
counts.blocked > 0 ? "kpi-risk" : "",
|
|
449
|
+
],
|
|
450
|
+
["失败", counts.failed, counts.failed > 0 ? "kpi-danger" : ""],
|
|
451
|
+
[
|
|
452
|
+
"Ready",
|
|
453
|
+
readyItems.length,
|
|
454
|
+
readyItems.length > 0 ? "kpi-highlight" : "",
|
|
455
|
+
],
|
|
456
|
+
[
|
|
457
|
+
"无输出",
|
|
458
|
+
health.quietCount ?? 0,
|
|
459
|
+
(health.quietCount ?? 0) > 0 ? "kpi-muted" : "",
|
|
460
|
+
],
|
|
461
|
+
[
|
|
462
|
+
"即将超时",
|
|
463
|
+
health.timeoutRiskCount ?? 0,
|
|
464
|
+
(health.timeoutRiskCount ?? 0) > 0 ? "kpi-risk" : "",
|
|
465
|
+
],
|
|
466
|
+
["合计", allTasks.length, ""],
|
|
467
|
+
];
|
|
468
|
+
reconcileKeyed(cards, entries, {
|
|
469
|
+
getKey: ([label]) => label,
|
|
470
|
+
create: ([label, value, extra]) => {
|
|
471
|
+
const card = el("div", `kpi-card${extra ? ` ${extra}` : ""}`);
|
|
472
|
+
card.appendChild(el("div", "kpi-value", String(value)));
|
|
473
|
+
card.appendChild(el("div", "kpi-label", label));
|
|
474
|
+
return card;
|
|
475
|
+
},
|
|
476
|
+
update: (card, [label, value, extra]) => {
|
|
477
|
+
card.className = `kpi-card${extra ? ` ${extra}` : ""}`;
|
|
478
|
+
const valueEl = card.querySelector(".kpi-value");
|
|
479
|
+
const labelEl = card.querySelector(".kpi-label");
|
|
480
|
+
if (valueEl) valueEl.textContent = String(value);
|
|
481
|
+
if (labelEl) labelEl.textContent = label;
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
},
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
// L2 attention
|
|
488
|
+
reconcileKeyed(attentionEl, [{ key: "__heading__" }], {
|
|
489
|
+
getKey: () => "__heading__",
|
|
490
|
+
scope: "heading",
|
|
491
|
+
create: () => el("h3", "section-heading", "需处理"),
|
|
492
|
+
update: () => {},
|
|
493
|
+
});
|
|
494
|
+
reconcileKeyed(
|
|
495
|
+
attentionEl,
|
|
496
|
+
attentionTasks.length === 0
|
|
497
|
+
? [{ key: "__empty__", text: "当前没有需要处理的 Task。" }]
|
|
498
|
+
: [{ key: "__list__" }],
|
|
499
|
+
{
|
|
500
|
+
getKey: (item) => item.key,
|
|
501
|
+
scope: "body",
|
|
502
|
+
create: (item) => {
|
|
503
|
+
if (item.key === "__empty__") return el("p", "empty", item.text);
|
|
504
|
+
return el("div", "pool-ops-list");
|
|
505
|
+
},
|
|
506
|
+
update: (node, item) => {
|
|
507
|
+
if (item.key === "__empty__") {
|
|
508
|
+
node.textContent = item.text;
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
reconcileKeyed(node, attentionTasks, {
|
|
512
|
+
getKey: (task) => taskIdentityKey(task.featureId, task.taskId),
|
|
513
|
+
create: (task) => renderOpsCard(task, "attention"),
|
|
514
|
+
update: (card, task) => updateOpsCard(card, task),
|
|
515
|
+
});
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
// L2 Ready — planner selected only
|
|
521
|
+
reconcileKeyed(readyEl, [{ key: "__heading__" }], {
|
|
522
|
+
getKey: () => "__heading__",
|
|
523
|
+
scope: "heading",
|
|
524
|
+
create: () => el("h3", "section-heading", "Ready(Planner)"),
|
|
525
|
+
update: () => {},
|
|
526
|
+
});
|
|
527
|
+
reconcileKeyed(
|
|
528
|
+
readyEl,
|
|
529
|
+
readyItems.length === 0
|
|
530
|
+
? [{ key: "__empty__", text: "当前没有 Planner 选中的 Ready Task。" }]
|
|
531
|
+
: [{ key: "__list__" }],
|
|
532
|
+
{
|
|
533
|
+
getKey: (item) => item.key,
|
|
534
|
+
scope: "body",
|
|
535
|
+
create: (item) => {
|
|
536
|
+
if (item.key === "__empty__") return el("p", "empty", item.text);
|
|
537
|
+
return el("div", "pool-ops-list");
|
|
538
|
+
},
|
|
539
|
+
update: (node, item) => {
|
|
540
|
+
if (item.key === "__empty__") {
|
|
541
|
+
node.textContent = item.text;
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
const taskByKey = new Map(
|
|
545
|
+
allTasks.map((t) => [taskIdentityKey(t.featureId, t.taskId), t]),
|
|
546
|
+
);
|
|
547
|
+
reconcileKeyed(node, readyItems, {
|
|
548
|
+
getKey: (ready) => taskIdentityKey(ready.featureId, ready.taskId),
|
|
549
|
+
create: (ready) => {
|
|
550
|
+
const live = taskByKey.get(
|
|
551
|
+
taskIdentityKey(ready.featureId, ready.taskId),
|
|
552
|
+
);
|
|
553
|
+
return renderOpsCard(
|
|
554
|
+
{
|
|
555
|
+
...ready,
|
|
556
|
+
status: live?.status ?? "pending",
|
|
557
|
+
recommendedFollowUp: live?.recommendedFollowUp,
|
|
558
|
+
},
|
|
559
|
+
"ready",
|
|
560
|
+
);
|
|
561
|
+
},
|
|
562
|
+
update: (card, ready) => {
|
|
563
|
+
const live = taskByKey.get(
|
|
564
|
+
taskIdentityKey(ready.featureId, ready.taskId),
|
|
565
|
+
);
|
|
566
|
+
updateOpsCard(card, {
|
|
567
|
+
...ready,
|
|
568
|
+
status: live?.status ?? "pending",
|
|
569
|
+
recommendedFollowUp: live?.recommendedFollowUp,
|
|
570
|
+
});
|
|
571
|
+
},
|
|
572
|
+
});
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
// L3 inventory
|
|
578
|
+
reconcileKeyed(listEl, [{ key: "__heading__" }], {
|
|
579
|
+
getKey: () => "__heading__",
|
|
580
|
+
scope: "heading",
|
|
581
|
+
create: () => el("h3", "section-heading", "全部 Task"),
|
|
582
|
+
update: () => {},
|
|
583
|
+
});
|
|
584
|
+
if (filteredTasks.length === 0) {
|
|
585
|
+
reconcileKeyed(
|
|
586
|
+
listEl,
|
|
587
|
+
[{ key: "__empty__", text: "没有匹配筛选条件的 Task。" }],
|
|
588
|
+
{
|
|
589
|
+
getKey: (item) => item.key,
|
|
590
|
+
scope: "table",
|
|
591
|
+
create: (item) => el("p", "empty", item.text),
|
|
592
|
+
update: (node, item) => {
|
|
593
|
+
node.textContent = item.text;
|
|
594
|
+
},
|
|
595
|
+
},
|
|
596
|
+
);
|
|
597
|
+
} else {
|
|
598
|
+
reconcileKeyed(listEl, [{ key: "__table__" }], {
|
|
599
|
+
getKey: () => "__table__",
|
|
600
|
+
scope: "table",
|
|
601
|
+
create: () => el("div", "pool-table-wrap"),
|
|
602
|
+
update: (wrap) => {
|
|
603
|
+
const tbody = ensureTable(wrap, [
|
|
604
|
+
"Task",
|
|
605
|
+
"Feature",
|
|
606
|
+
"状态",
|
|
607
|
+
"存活",
|
|
608
|
+
"最新 run",
|
|
609
|
+
"Batch / DAG",
|
|
610
|
+
"跟进",
|
|
611
|
+
"更新",
|
|
612
|
+
]);
|
|
613
|
+
reconcileKeyed(tbody, filteredTasks, {
|
|
614
|
+
getKey: (task) => taskIdentityKey(task.featureId, task.taskId),
|
|
615
|
+
create: (task) => {
|
|
616
|
+
const tr = document.createElement("tr");
|
|
617
|
+
tr.classList.add("clickable");
|
|
618
|
+
tr.addEventListener("click", () => navigate(taskPath(task)));
|
|
619
|
+
for (let i = 0; i < 8; i++) tr.appendChild(document.createElement("td"));
|
|
620
|
+
return tr;
|
|
621
|
+
},
|
|
622
|
+
update: (tr, task) => {
|
|
623
|
+
syncCell(tr, 0, linkTo(taskPath(task), task.taskId));
|
|
624
|
+
syncCell(
|
|
625
|
+
tr,
|
|
626
|
+
1,
|
|
627
|
+
task.featureId
|
|
628
|
+
? objectRouteLink("feature", task.featureId, snapshot)
|
|
629
|
+
: "—",
|
|
630
|
+
);
|
|
631
|
+
syncCell(tr, 2, badge(task.status));
|
|
632
|
+
syncCell(
|
|
633
|
+
tr,
|
|
634
|
+
3,
|
|
635
|
+
task.liveness ? livenessBadge(task.liveness) : "—",
|
|
636
|
+
);
|
|
637
|
+
syncCell(
|
|
638
|
+
tr,
|
|
639
|
+
4,
|
|
640
|
+
task.workerRunId
|
|
641
|
+
? linkTo(
|
|
642
|
+
`/run/${encodeURIComponent(task.workerRunId)}`,
|
|
643
|
+
task.workerRunId,
|
|
644
|
+
)
|
|
645
|
+
: "—",
|
|
646
|
+
);
|
|
647
|
+
const links = el("span", "pool-ref-links");
|
|
648
|
+
if (task.batchRunId) {
|
|
649
|
+
links.appendChild(
|
|
650
|
+
linkTo(
|
|
651
|
+
`/batch/${encodeURIComponent(task.batchRunId)}`,
|
|
652
|
+
task.batchRunId,
|
|
653
|
+
),
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
if (task.dagRunId) {
|
|
657
|
+
if (links.childNodes.length) {
|
|
658
|
+
links.appendChild(document.createTextNode(" · "));
|
|
659
|
+
}
|
|
660
|
+
links.appendChild(
|
|
661
|
+
linkTo(
|
|
662
|
+
`/dag/${encodeURIComponent(task.dagRunId)}`,
|
|
663
|
+
task.dagRunId,
|
|
664
|
+
),
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
syncCell(
|
|
668
|
+
tr,
|
|
669
|
+
5,
|
|
670
|
+
links.childNodes.length ? links : "—",
|
|
671
|
+
);
|
|
672
|
+
syncCell(
|
|
673
|
+
tr,
|
|
674
|
+
6,
|
|
675
|
+
task.recommendedFollowUp || task.failureCategory || "—",
|
|
676
|
+
);
|
|
677
|
+
syncCell(
|
|
678
|
+
tr,
|
|
679
|
+
7,
|
|
680
|
+
formatAgo(task.updatedAt || task.finishedAt || task.startedAt),
|
|
681
|
+
);
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
},
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
if (options.reason === "manual" || options.reason === "auto") {
|
|
689
|
+
await refreshPoolEvents();
|
|
690
|
+
} else {
|
|
691
|
+
// Route entry: only load events if the operator already expanded them.
|
|
692
|
+
await refreshPoolEvents();
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** Enter pool view; auto-refresh stays off unless the user already enabled it. */
|
|
697
|
+
export function startPoolView() {
|
|
698
|
+
stopPoolAutoPolling();
|
|
699
|
+
syncPoolToolbar();
|
|
700
|
+
void renderPool({ reason: "route" }).then(() => {
|
|
701
|
+
if (poolAutoRefreshEnabled()) startPoolAutoPolling();
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/** @deprecated Use startPoolView — kept as alias for older call sites/tests. */
|
|
706
|
+
export function startPoolPolling() {
|
|
707
|
+
startPoolView();
|
|
708
|
+
}
|