opencastle 0.28.0 → 0.29.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.
Files changed (85) hide show
  1. package/README.md +12 -3
  2. package/dist/cli/convoy/engine.d.ts.map +1 -1
  3. package/dist/cli/convoy/engine.js +0 -9
  4. package/dist/cli/convoy/engine.js.map +1 -1
  5. package/dist/cli/convoy/engine.test.js +1 -0
  6. package/dist/cli/convoy/engine.test.js.map +1 -1
  7. package/dist/cli/convoy/export.d.ts +1 -3
  8. package/dist/cli/convoy/export.d.ts.map +1 -1
  9. package/dist/cli/convoy/export.js +9 -88
  10. package/dist/cli/convoy/export.js.map +1 -1
  11. package/dist/cli/convoy/export.test.js +7 -186
  12. package/dist/cli/convoy/export.test.js.map +1 -1
  13. package/dist/cli/convoy/pipeline.d.ts.map +1 -1
  14. package/dist/cli/convoy/pipeline.js +0 -21
  15. package/dist/cli/convoy/pipeline.js.map +1 -1
  16. package/dist/cli/convoy/pipeline.test.js +0 -21
  17. package/dist/cli/convoy/pipeline.test.js.map +1 -1
  18. package/dist/cli/dashboard.d.ts.map +1 -1
  19. package/dist/cli/dashboard.js +32 -8
  20. package/dist/cli/dashboard.js.map +1 -1
  21. package/dist/cli/destroy.d.ts.map +1 -1
  22. package/dist/cli/destroy.js +13 -0
  23. package/dist/cli/destroy.js.map +1 -1
  24. package/dist/cli/dispute.d.ts +3 -0
  25. package/dist/cli/dispute.d.ts.map +1 -0
  26. package/dist/cli/dispute.js +25 -0
  27. package/dist/cli/dispute.js.map +1 -0
  28. package/dist/cli/doctor.d.ts +1 -1
  29. package/dist/cli/doctor.d.ts.map +1 -1
  30. package/dist/cli/doctor.js +14 -1
  31. package/dist/cli/doctor.js.map +1 -1
  32. package/dist/cli/eject.d.ts.map +1 -1
  33. package/dist/cli/eject.js +14 -0
  34. package/dist/cli/eject.js.map +1 -1
  35. package/dist/cli/init.d.ts.map +1 -1
  36. package/dist/cli/init.js +14 -0
  37. package/dist/cli/init.js.map +1 -1
  38. package/dist/cli/log.d.ts +0 -11
  39. package/dist/cli/log.d.ts.map +1 -1
  40. package/dist/cli/log.js +2 -114
  41. package/dist/cli/log.js.map +1 -1
  42. package/dist/cli/pipeline.js +21 -5
  43. package/dist/cli/pipeline.js.map +1 -1
  44. package/dist/cli/run.js +2 -2
  45. package/dist/cli/run.js.map +1 -1
  46. package/dist/cli/update.d.ts.map +1 -1
  47. package/dist/cli/update.js +16 -0
  48. package/dist/cli/update.js.map +1 -1
  49. package/dist/cli/watch.d.ts.map +1 -1
  50. package/dist/cli/watch.js +1 -3
  51. package/dist/cli/watch.js.map +1 -1
  52. package/package.json +1 -1
  53. package/src/cli/convoy/engine.test.ts +1 -0
  54. package/src/cli/convoy/engine.ts +0 -3
  55. package/src/cli/convoy/export.test.ts +7 -224
  56. package/src/cli/convoy/export.ts +10 -106
  57. package/src/cli/convoy/pipeline.test.ts +0 -25
  58. package/src/cli/convoy/pipeline.ts +0 -19
  59. package/src/cli/dashboard.ts +33 -8
  60. package/src/cli/destroy.ts +15 -0
  61. package/src/cli/dispute.ts +28 -0
  62. package/src/cli/doctor.ts +16 -1
  63. package/src/cli/eject.ts +16 -0
  64. package/src/cli/init.ts +16 -0
  65. package/src/cli/log.ts +2 -120
  66. package/src/cli/pipeline.ts +24 -5
  67. package/src/cli/run.ts +2 -2
  68. package/src/cli/update.ts +18 -0
  69. package/src/cli/watch.ts +1 -3
  70. package/src/dashboard/dist/_astro/index.Je1YjU_y.css +1 -0
  71. package/src/dashboard/dist/index.html +141 -1391
  72. package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
  73. package/src/dashboard/scripts/etl.test.ts +4 -62
  74. package/src/dashboard/scripts/etl.ts +13 -33
  75. package/src/dashboard/src/pages/index.astro +204 -1630
  76. package/src/dashboard/src/styles/dashboard.css +473 -7
  77. package/src/orchestrator/prompts/brainstorm.prompt.md +1 -0
  78. package/src/orchestrator/prompts/generate-convoy.prompt.md +7 -0
  79. package/src/orchestrator/prompts/generate-prd.prompt.md +6 -0
  80. package/dist/cli/convoy/log-merge.test.d.ts +0 -2
  81. package/dist/cli/convoy/log-merge.test.d.ts.map +0 -1
  82. package/dist/cli/convoy/log-merge.test.js +0 -147
  83. package/dist/cli/convoy/log-merge.test.js.map +0 -1
  84. package/src/cli/convoy/log-merge.test.ts +0 -179
  85. package/src/dashboard/dist/_astro/index.6L3_HsPT.css +0 -1
@@ -25,12 +25,6 @@ try {
25
25
  <h1 class="dash-header__title">Observability Dashboard</h1>
26
26
  </div>
27
27
  <div class="dash-header__actions">
28
- <div class="convoy-selector">
29
- <label class="convoy-selector__label" for="convoy-select">Convoy</label>
30
- <select class="convoy-selector__select" id="convoy-select" aria-label="Select a convoy to view its details">
31
- <option value="">Select convoy…</option>
32
- </select>
33
- </div>
34
28
  <button class="dash-btn dash-btn--ghost" id="export-btn" type="button" title="Export data as JSON" aria-label="Export dashboard data as JSON">
35
29
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
36
30
  Export
@@ -43,18 +37,24 @@ try {
43
37
  <!-- Sidebar Navigation -->
44
38
  <nav class="dash-sidebar" id="dash-sidebar">
45
39
  <ul class="dash-sidebar__list">
46
- <li><a class="dash-sidebar__link dash-sidebar__link--active" href="#overall-section" data-section="overall-section" aria-label="Overview section">Overview</a></li>
47
- <li><a class="dash-sidebar__link" href="#tasks-section" data-section="tasks-section" aria-label="Tasks section">Tasks</a></li>
48
- <li><a class="dash-sidebar__link" href="#quality-section" data-section="quality-section" aria-label="Quality section">Quality</a></li>
49
- <li><a class="dash-sidebar__link" href="#reliability-section" data-section="reliability-section" aria-label="Reliability section">Reliability</a></li>
50
- <li><a class="dash-sidebar__link" href="#drift-section" data-section="drift-section" aria-label="Drift section">Drift</a></li>
51
- <li><a class="dash-sidebar__link" href="#outputs-section" data-section="outputs-section" aria-label="Outputs section">Outputs</a></li>
52
- <li><a class="dash-sidebar__link" href="#event-timeline-section" data-section="event-timeline-section" aria-label="Event Log section">Event Log</a></li>
53
- <li><a class="dash-sidebar__link" href="#convoy-section" data-section="convoy-section" aria-label="Convoy section">Convoy</a></li>
40
+ <li><a class="dash-sidebar__link dash-sidebar__link--active" href="#overall-section" data-section="overall-section" data-view="home" aria-label="Overview section">Overview</a></li>
41
+ <li><a class="dash-sidebar__link" href="#convoy-list-section" data-section="convoy-list-section" data-view="home" aria-label="Convoys section">Convoys</a></li>
42
+ <li><a class="dash-sidebar__link" href="#tasks-section" data-section="tasks-section" data-view="detail" aria-label="Tasks section">Tasks</a></li>
43
+ <li><a class="dash-sidebar__link" href="#quality-section" data-section="quality-section" data-view="detail" aria-label="Quality section">Quality</a></li>
44
+ <li><a class="dash-sidebar__link" href="#reliability-section" data-section="reliability-section" data-view="detail" aria-label="Reliability section">Reliability</a></li>
45
+ <li><a class="dash-sidebar__link" href="#drift-section" data-section="drift-section" data-view="detail" aria-label="Drift section">Drift</a></li>
46
+ <li><a class="dash-sidebar__link" href="#outputs-section" data-section="outputs-section" data-view="detail" aria-label="Outputs section">Outputs</a></li>
47
+ <li><a class="dash-sidebar__link" href="#event-timeline-section" data-section="event-timeline-section" data-view="detail" aria-label="Event Log section">Event Log</a></li>
54
48
  </ul>
55
49
  </nav>
56
50
 
57
51
  <main class="dash-main">
52
+ <nav class="breadcrumbs" id="breadcrumbs" data-view-hidden>
53
+ <a class="breadcrumbs__link" href="#" id="breadcrumbs-home">Observability</a>
54
+ <span class="breadcrumbs__separator">/</span>
55
+ <span class="breadcrumbs__current" id="breadcrumbs-convoy"></span>
56
+ </nav>
57
+ <div class="view-home" id="view-home">
58
58
  <!-- Overall Stats Section -->
59
59
  <section class="overall-stats" id="overall-section" data-nav-section>
60
60
  <div class="overall-stats__header">
@@ -89,21 +89,57 @@ try {
89
89
  </div>
90
90
  </section>
91
91
 
92
- <!-- Selected Convoy Header -->
93
- <section class="convoy-detail-header" id="convoy-detail-header">
94
- <div class="convoy-detail-header__top">
95
- <h2 class="convoy-detail-header__name" id="selected-convoy-name">No convoy selected</h2>
96
- <span class="status-badge" id="selected-convoy-status" role="status"></span>
97
- <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: A convoy is a set of AI tasks working together on one goal." data-tooltip="A convoy is a set of AI tasks working together on one goal."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg></span>
92
+ <!-- Convoy List Section -->
93
+ <section class="convoy-list-section" id="convoy-list-section">
94
+ <div class="convoy-list-section__header">
95
+ <h2>Convoys</h2>
96
+ <p class="convoy-list-section__desc">All convoy runs across your project</p>
98
97
  </div>
99
- <p class="convoy-status-explanation" id="convoy-status-explanation" role="status" aria-live="polite"></p>
100
- <div class="convoy-detail-header__meta" id="selected-convoy-meta">
101
- <!-- Populated by JS: branch, timestamps, duration, tokens, cost -->
98
+ <div class="convoy-list-filters" id="convoy-list-filters">
99
+ <div class="convoy-list-filters__group">
100
+ <label for="cl-filter-search">Search</label>
101
+ <input class="convoy-list-filters__input" type="text" id="cl-filter-search" placeholder="Convoy name…" />
102
+ </div>
103
+ <div class="convoy-list-filters__group">
104
+ <label for="cl-filter-status">Status</label>
105
+ <select class="convoy-list-filters__select" id="cl-filter-status">
106
+ <option value="">All</option>
107
+ <option value="done">Done</option>
108
+ <option value="running">Running</option>
109
+ <option value="failed">Failed</option>
110
+ <option value="gate-failed">Gate Failed</option>
111
+ <option value="pending">Pending</option>
112
+ </select>
113
+ </div>
114
+ <div class="convoy-list-filters__group">
115
+ <label for="cl-filter-from">From</label>
116
+ <input class="convoy-list-filters__date" type="date" id="cl-filter-from" />
117
+ </div>
118
+ <div class="convoy-list-filters__group">
119
+ <label for="cl-filter-to">To</label>
120
+ <input class="convoy-list-filters__date" type="date" id="cl-filter-to" />
121
+ </div>
122
+ <button class="convoy-list-filters__reset" type="button" id="cl-filter-reset">Reset</button>
102
123
  </div>
124
+ <div id="convoy-list-table-wrap"></div>
125
+ <div class="convoy-list-empty" id="convoy-list-empty" style="display:none">
126
+ <div class="convoy-list-empty__icon">
127
+ <svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="6" y="6" width="28" height="28" rx="4"/><line x1="14" y1="20" x2="26" y2="20" opacity="0.5"/></svg>
128
+ </div>
129
+ <p class="convoy-list-empty__text">No convoys match your filters</p>
130
+ </div>
131
+ </section>
132
+ </div><!-- .view-home -->
133
+
134
+ <div class="view-convoy-detail" id="view-convoy-detail" data-view-hidden>
135
+ <section class="convoy-detail-hero" id="convoy-detail-hero">
136
+ <div class="convoy-detail-hero__title" id="detail-hero-title"></div>
137
+ <span class="convoy-detail-hero__status" id="detail-hero-status"></span>
138
+ <div class="convoy-detail-hero__meta" id="detail-hero-meta"></div>
103
139
  </section>
104
140
 
105
141
  <!-- Tasks Section -->
106
- <section class="chart-card" id="tasks-section" data-nav-section style="display:none">
142
+ <section class="chart-card" id="tasks-section" data-nav-section>
107
143
  <div class="chart-card__header">
108
144
  <h2 class="chart-card__title">Tasks</h2>
109
145
  <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Individual units of work in this convoy." data-tooltip="Individual units of work in this convoy."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg></span>
@@ -117,7 +153,7 @@ try {
117
153
  </section>
118
154
 
119
155
  <!-- Quality Section -->
120
- <section class="chart-card" id="quality-section" data-nav-section style="display:none">
156
+ <section class="chart-card" id="quality-section" data-nav-section>
121
157
  <div class="chart-card__header">
122
158
  <h2 class="chart-card__title">Quality / Review</h2>
123
159
  <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Code review results and dispute resolution." data-tooltip="Code review results and dispute resolution."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg></span>
@@ -130,7 +166,7 @@ try {
130
166
  </section>
131
167
 
132
168
  <!-- Reliability Section -->
133
- <section class="chart-card" id="reliability-section" data-nav-section style="display:none">
169
+ <section class="chart-card" id="reliability-section" data-nav-section>
134
170
  <div class="chart-card__header">
135
171
  <h2 class="chart-card__title">Reliability</h2>
136
172
  <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Errors, retry attempts, and safety mechanisms." data-tooltip="Errors, retry attempts, and safety mechanisms."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg></span>
@@ -147,7 +183,7 @@ try {
147
183
  </section>
148
184
 
149
185
  <!-- Drift Section -->
150
- <section class="chart-card" id="drift-section" data-nav-section style="display:none">
186
+ <section class="chart-card" id="drift-section" data-nav-section>
151
187
  <div class="chart-card__header">
152
188
  <h2 class="chart-card__title">Drift</h2>
153
189
  <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: How far the actual work deviated from the original plan." data-tooltip="How far the actual work deviated from the original plan."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg></span>
@@ -160,7 +196,7 @@ try {
160
196
  </section>
161
197
 
162
198
  <!-- Outputs Section -->
163
- <section class="chart-card" id="outputs-section" data-nav-section style="display:none">
199
+ <section class="chart-card" id="outputs-section" data-nav-section>
164
200
  <div class="chart-card__header">
165
201
  <h2 class="chart-card__title">Outputs &amp; Artifacts</h2>
166
202
  <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Files, data, and summaries produced by this convoy." data-tooltip="Files, data, and summaries produced by this convoy."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg></span>
@@ -173,7 +209,7 @@ try {
173
209
  </section>
174
210
 
175
211
  <!-- Event Timeline Section -->
176
- <section class="chart-card" id="event-timeline-section" data-nav-section style="display:none">
212
+ <section class="chart-card" id="event-timeline-section" data-nav-section>
177
213
  <div class="chart-card__header">
178
214
  <h2 class="chart-card__title">Event Timeline</h2>
179
215
  <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Chronological log of everything that happened during this run." data-tooltip="Chronological log of everything that happened during this run."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg></span>
@@ -187,221 +223,9 @@ try {
187
223
  </div>
188
224
  </div>
189
225
  </section>
226
+ </div><!-- .view-convoy-detail -->
190
227
 
191
- <!-- Filter Bar -->
192
- <div class="filter-bar" id="filter-bar">
193
- <div class="filter-group">
194
- <label class="filter-label" for="filter-date-from">From</label>
195
- <input class="filter-input" type="date" id="filter-date-from" />
196
- </div>
197
- <div class="filter-group">
198
- <label class="filter-label" for="filter-date-to">To</label>
199
- <input class="filter-input" type="date" id="filter-date-to" />
200
- </div>
201
- <div class="filter-group">
202
- <label class="filter-label" for="filter-agent">Agent</label>
203
- <select class="filter-select" id="filter-agent">
204
- <option value="">All agents</option>
205
- </select>
206
- </div>
207
- <div class="filter-group">
208
- <label class="filter-label" for="filter-outcome">Outcome</label>
209
- <select class="filter-select" id="filter-outcome">
210
- <option value="">All outcomes</option>
211
- <option value="success">Success</option>
212
- <option value="partial">Partial</option>
213
- <option value="failed">Failed</option>
214
- </select>
215
- </div>
216
- <div class="filter-group">
217
- <label class="filter-label" for="filter-convoy">Convoy</label>
218
- <select class="filter-select" id="filter-convoy">
219
- <option value="">All convoys</option>
220
- </select>
221
- </div>
222
- <div class="filter-group">
223
- <label class="filter-label" for="filter-pipeline">Pipeline</label>
224
- <select class="filter-select" id="filter-pipeline">
225
- <option value="">All</option>
226
- </select>
227
- </div>
228
- <button class="dash-btn dash-btn--ghost filter-reset" id="filter-reset" type="button">Reset</button>
229
- </div>
230
-
231
- <!-- Convoy Status Section -->
232
- <section class="chart-card convoy-status" id="convoy-section" data-nav-section style="display:none">
233
- <div class="chart-card__header">
234
- <h2 class="chart-card__title">Convoy Status</h2>
235
- <p class="chart-card__desc" id="convoy-desc">Select a convoy to view details</p>
236
- </div>
237
- <div class="chart-card__body" id="convoy-body">
238
- </div>
239
- </section>
240
-
241
- <!-- Convoy Pipeline (Chaining) Section -->
242
- <section class="chart-card" id="convoy-pipeline-section" data-nav-section style="display:none">
243
- <div class="chart-card__header">
244
- <h2 class="chart-card__title">Convoy Pipeline</h2>
245
- <p class="chart-card__desc" id="convoy-pipeline-desc">Pipeline convoy chain progress</p>
246
- </div>
247
- <div class="chart-card__body" id="convoy-pipeline-body">
248
- </div>
249
- </section>
250
-
251
- <!-- KPI Row -->
252
- <section class="kpi-row" id="kpi-row" data-nav-section>
253
- <div class="kpi-card" id="kpi-sessions">
254
- <span class="kpi-card__label">Total Sessions</span>
255
- <span class="kpi-card__value">&mdash;</span>
256
- <span class="kpi-card__sub"></span>
257
- </div>
258
- <div class="kpi-card" id="kpi-success">
259
- <span class="kpi-card__label">Success Rate</span>
260
- <span class="kpi-card__value">&mdash;</span>
261
- <span class="kpi-card__sub"></span>
262
- </div>
263
- <div class="kpi-card" id="kpi-delegations">
264
- <span class="kpi-card__label">Total Delegations</span>
265
- <span class="kpi-card__value">&mdash;</span>
266
- <span class="kpi-card__sub"></span>
267
- </div>
268
- <div class="kpi-card" id="kpi-duration">
269
- <span class="kpi-card__label">Avg Duration</span>
270
- <span class="kpi-card__value">&mdash;</span>
271
- <span class="kpi-card__sub"></span>
272
- </div>
273
- <div class="kpi-card" id="kpi-retries">
274
- <span class="kpi-card__label">Total Retries</span>
275
- <span class="kpi-card__value">&mdash;</span>
276
- <span class="kpi-card__sub"></span>
277
- </div>
278
- <div class="kpi-card" id="kpi-lessons">
279
- <span class="kpi-card__label">Lessons Added</span>
280
- <span class="kpi-card__value">&mdash;</span>
281
- <span class="kpi-card__sub"></span>
282
- </div>
283
- </section>
284
-
285
- <!-- Pipeline View (Steroids-inspired) -->
286
- <section class="chart-card" id="pipeline-section" data-nav-section>
287
- <div class="chart-card__header">
288
- <h2 class="chart-card__title">Task Pipeline</h2>
289
- <p class="chart-card__desc">Delegation flow across execution phases</p>
290
- </div>
291
- <div class="chart-card__body" id="pipeline-view">
292
- <div class="loading-skeleton"></div>
293
- </div>
294
- </section>
295
-
296
- <!-- Charts Row 1 -->
297
- <div class="charts-row" id="agent-section" data-nav-section>
298
- <section class="chart-card">
299
- <div class="chart-card__header">
300
- <h2 class="chart-card__title">Sessions by Agent</h2>
301
- <p class="chart-card__desc">Stacked by outcome</p>
302
- </div>
303
- <div class="chart-card__body" id="agent-chart">
304
- <div class="loading-skeleton"></div>
305
- </div>
306
- </section>
307
- <section class="chart-card" id="tier-section" data-nav-section>
308
- <div class="chart-card__header">
309
- <h2 class="chart-card__title">Tier Distribution</h2>
310
- <p class="chart-card__desc">Delegation model tiers</p>
311
- </div>
312
- <div class="chart-card__body" id="tier-chart">
313
- <div class="loading-skeleton"></div>
314
- </div>
315
- </section>
316
- </div>
317
-
318
- <!-- Charts Row: Delegation Insights -->
319
- <div class="charts-row" id="delegation-section" data-nav-section>
320
- <section class="chart-card">
321
- <div class="chart-card__header">
322
- <h2 class="chart-card__title">Delegation Mechanism</h2>
323
- <p class="chart-card__desc">Sub-agent vs background split</p>
324
- </div>
325
- <div class="chart-card__body" id="mechanism-chart">
326
- <div class="loading-skeleton"></div>
327
- </div>
328
- </section>
329
- <section class="chart-card">
330
- <div class="chart-card__header">
331
- <h2 class="chart-card__title">Delegation Outcomes</h2>
332
- <p class="chart-card__desc">Success rate by delegation</p>
333
- </div>
334
- <div class="chart-card__body" id="delegation-outcome-chart">
335
- <div class="loading-skeleton"></div>
336
- </div>
337
- </section>
338
- </div>
339
-
340
- <!-- Charts Row 2 -->
341
- <div class="charts-row" id="timeline-section" data-nav-section>
342
- <section class="chart-card">
343
- <div class="chart-card__header">
344
- <h2 class="chart-card__title">Timeline</h2>
345
- <p class="chart-card__desc">Sessions and delegations over time</p>
346
- </div>
347
- <div class="chart-card__body" id="timeline-chart">
348
- <div class="loading-skeleton"></div>
349
- </div>
350
- </section>
351
- <section class="chart-card" id="model-section" data-nav-section>
352
- <div class="chart-card__header">
353
- <h2 class="chart-card__title">Model Usage</h2>
354
- <p class="chart-card__desc">Sessions by model</p>
355
- </div>
356
- <div class="chart-card__body" id="model-chart">
357
- <div class="loading-skeleton"></div>
358
- </div>
359
- </section>
360
- </div>
361
-
362
- <!-- Execution Log (Duvo-inspired) -->
363
- <section class="chart-card" id="execution-section" data-nav-section>
364
- <div class="chart-card__header">
365
- <h2 class="chart-card__title">Execution Log</h2>
366
- <p class="chart-card__desc">Recent agent activity, step by step</p>
367
- </div>
368
- <div class="chart-card__body" id="execution-log">
369
- <div class="loading-skeleton"></div>
370
- </div>
371
- </section>
372
-
373
- <!-- Panel Results -->
374
- <section class="chart-card" id="panel-section" data-nav-section>
375
- <div class="chart-card__header">
376
- <h2 class="chart-card__title">Panel Reviews</h2>
377
- <p class="chart-card__desc">Quality gate verdicts and fix items</p>
378
- </div>
379
- <div class="chart-card__body" id="panel-chart">
380
- <div class="loading-skeleton"></div>
381
- </div>
382
- </section>
383
228
 
384
- <!-- Fast Reviews -->
385
- <section class="chart-card" id="reviews-section" data-nav-section>
386
- <div class="chart-card__header">
387
- <h2 class="chart-card__title">Fast Reviews</h2>
388
- <p class="chart-card__desc">Single-reviewer quality gate results</p>
389
- </div>
390
- <div class="chart-card__body chart-card__body--table" id="reviews-table">
391
- <div class="loading-skeleton"></div>
392
- </div>
393
- </section>
394
-
395
- <!-- Sessions Table -->
396
- <section class="chart-card" id="sessions-section" data-nav-section>
397
- <div class="chart-card__header">
398
- <h2 class="chart-card__title">Recent Sessions</h2>
399
- <p class="chart-card__desc">Last 15 sessions by timestamp</p>
400
- </div>
401
- <div class="chart-card__body chart-card__body--table" id="sessions-table">
402
- <div class="loading-skeleton"></div>
403
- </div>
404
- </section>
405
229
  </main>
406
230
  </div>
407
231
  </Layout>
@@ -577,1257 +401,95 @@ try {
577
401
  if (existing) existing.remove();
578
402
  }
579
403
 
580
- // ── KPI Rendering ────────────────────────────────────────
581
-
582
- function renderKpis(sessions, delegations, reviews) {
583
- const total = sessions.length;
584
- const isEmpty = total === 0;
585
- const successCount = sessions.filter((s) => s.outcome === 'success').length;
586
- const rate = total > 0 ? Math.round((successCount / total) * 100) : 0;
587
- const durSessions = sessions.filter((s) => s.duration_min != null);
588
- const avgDur =
589
- durSessions.length > 0
590
- ? Math.round(
591
- durSessions.reduce((sum, s) => sum + (s.duration_min || 0), 0) /
592
- durSessions.length
593
- )
594
- : 0;
595
- const uniqueAgents = new Set(delegations.map((d) => d.agent)).size;
596
-
597
- // Toggle ghost class on KPI row
598
- const kpiRow = document.querySelector('.kpi-row');
599
- if (kpiRow) kpiRow.classList.toggle('kpi-row--empty', isEmpty);
600
-
601
- const kpiSessions = document.getElementById('kpi-sessions');
602
- const kpiSuccess = document.getElementById('kpi-success');
603
- const kpiDelegations = document.getElementById('kpi-delegations');
604
- const kpiDuration = document.getElementById('kpi-duration');
605
-
606
- if (kpiSessions) {
607
- kpiSessions.querySelector('.kpi-card__value').textContent = isEmpty ? '0' : total;
608
- kpiSessions.querySelector('.kpi-card__sub').innerHTML = isEmpty
609
- ? '<span class="kpi-card__hint">No sessions yet</span>'
610
- : '<span class="kpi-trend kpi-trend--up">\u2191</span> ' + successCount + ' successful';
611
- }
612
- if (kpiSuccess) {
613
- if (isEmpty) {
614
- kpiSuccess.querySelector('.kpi-card__value').textContent = '\u2014';
615
- kpiSuccess.querySelector('.kpi-card__sub').innerHTML =
616
- '<span class="kpi-card__hint">No sessions yet</span>';
617
- } else {
618
- const trendClass =
619
- rate >= 80 ? 'up' : rate >= 60 ? 'neutral' : 'down';
620
- kpiSuccess.querySelector('.kpi-card__value').textContent = rate + '%';
621
- kpiSuccess.querySelector('.kpi-card__sub').innerHTML =
622
- '<span class="kpi-trend kpi-trend--' +
623
- trendClass +
624
- '">' +
625
- (trendClass === 'up' ? '\u2191' : trendClass === 'down' ? '\u2193' : '\u2192') +
626
- '</span> across all sessions';
627
- }
628
- }
629
- if (kpiDelegations) {
630
- kpiDelegations.querySelector('.kpi-card__value').textContent =
631
- delegations.length === 0 ? '0' : delegations.length;
632
- kpiDelegations.querySelector('.kpi-card__sub').innerHTML = isEmpty
633
- ? '<span class="kpi-card__hint">No delegations yet</span>'
634
- : uniqueAgents + ' unique agents';
635
- }
636
- if (kpiDuration) {
637
- kpiDuration.querySelector('.kpi-card__value').textContent = isEmpty ? '\u2014' : avgDur + 'm';
638
- kpiDuration.querySelector('.kpi-card__sub').innerHTML = isEmpty
639
- ? '<span class="kpi-card__hint">No duration yet</span>'
640
- : '<span class="kpi-trend kpi-trend--neutral">\u2192</span> per session';
641
- }
642
-
643
- // Retries KPI
644
- const totalRetries = sessions.reduce((sum, s) => sum + (s.retries || 0), 0);
645
- const kpiRetries = document.getElementById('kpi-retries');
646
- if (kpiRetries) {
647
- kpiRetries.querySelector('.kpi-card__value').textContent = isEmpty ? '0' : totalRetries;
648
- const retriedSessions = sessions.filter((s) => (s.retries || 0) > 0).length;
649
- kpiRetries.querySelector('.kpi-card__sub').innerHTML = isEmpty
650
- ? '<span class="kpi-card__hint">No retries yet</span>'
651
- : retriedSessions + ' sessions with retries';
652
- }
653
-
654
- // Lessons KPI
655
- const totalLessons = sessions.reduce(
656
- (sum, s) => sum + (s.lessons_added ? s.lessons_added.length : 0),
657
- 0
658
- );
659
- const kpiLessons = document.getElementById('kpi-lessons');
660
- if (kpiLessons) {
661
- kpiLessons.querySelector('.kpi-card__value').textContent = isEmpty ? '0' : totalLessons;
662
- const discoveryCount = sessions.reduce(
663
- (sum, s) => sum + (s.discoveries ? s.discoveries.length : 0),
664
- 0
665
- );
666
- kpiLessons.querySelector('.kpi-card__sub').innerHTML = isEmpty
667
- ? '<span class="kpi-card__hint">No lessons yet</span>'
668
- : discoveryCount + ' issues discovered';
669
- }
670
- }
671
-
672
- // ── Pipeline View ─────────────────────────────────────────
673
-
674
- function renderPipeline(delegations) {
675
- const el = document.getElementById('pipeline-view');
676
- if (!el) return;
677
-
678
- if (delegations.length === 0) {
679
- el.innerHTML = emptyStateHtml('pipeline', 'No pipeline activity yet', 'Delegation phases appear here as tasks flow through Foundation, Integration, Validation, and QA stages.');
680
- return;
681
- }
682
-
683
- const phases = { 1: 0, 2: 0, 3: 0, 4: 0 };
684
- delegations.forEach((d) => {
685
- const p = d.phase || 1;
686
- if (phases[p] !== undefined) phases[p]++;
687
- });
688
-
689
- const stageConfig = [
690
- {
691
- label: 'Foundation',
692
- phase: 1,
693
- iconClass: 'pending',
694
- icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="2"/><line x1="8" y1="10" x2="16" y2="10"/><line x1="8" y1="14" x2="13" y2="14"/></svg>',
695
- },
696
- {
697
- label: 'Integration',
698
- phase: 2,
699
- iconClass: 'active',
700
- icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',
701
- },
702
- {
703
- label: 'Validation',
704
- phase: 3,
705
- iconClass: 'review',
706
- icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>',
707
- },
708
- {
709
- label: 'QA Gate',
710
- phase: 4,
711
- iconClass: 'done',
712
- icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>',
713
- },
714
- ];
715
-
716
- el.innerHTML =
717
- '<div class="pipeline">' +
718
- stageConfig
719
- .map(
720
- (stage, i) =>
721
- (i > 0 ? '<div class="pipeline-arrow">\u2192</div>' : '') +
722
- '<div class="pipeline-stage">' +
723
- '<div class="pipeline-stage__icon pipeline-stage__icon--' +
724
- stage.iconClass +
725
- '">' +
726
- stage.icon +
727
- '</div>' +
728
- '<span class="pipeline-stage__count">' +
729
- (phases[stage.phase] || 0) +
730
- '</span>' +
731
- '<span class="pipeline-stage__label">' +
732
- stage.label +
733
- '</span>' +
734
- '</div>'
735
- )
736
- .join('') +
737
- '</div>';
404
+ // ── View Management ─────────────────────────────────────
405
+ function showHomeView() {
406
+ const home = document.getElementById('view-home');
407
+ const detail = document.getElementById('view-convoy-detail');
408
+ const breadcrumbs = document.getElementById('breadcrumbs');
409
+ if (home) delete home.dataset.viewHidden;
410
+ if (detail) detail.dataset.viewHidden = '';
411
+ if (breadcrumbs) breadcrumbs.dataset.viewHidden = '';
412
+ document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = 'none');
413
+ document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = '');
414
+ const url = new URL(window.location);
415
+ url.searchParams.delete('convoy');
416
+ history.pushState({}, '', url);
738
417
  }
739
418
 
740
- // ── Agent Chart ───────────────────────────────────────────
741
-
742
- function renderAgentChart(sessions) {
743
- const el = document.getElementById('agent-chart');
744
- if (!el) return;
745
-
746
- if (sessions.length === 0) {
747
- el.innerHTML = emptyStateHtml('agents', 'No agent sessions yet', 'A breakdown of sessions per agent will appear here — stacked by outcome (success, partial, failed).');
748
- return;
749
- }
750
-
751
- const agentMap = {};
752
- sessions.forEach((s) => {
753
- if (!agentMap[s.agent])
754
- agentMap[s.agent] = { success: 0, partial: 0, failed: 0, total: 0 };
755
- agentMap[s.agent][s.outcome] = (agentMap[s.agent][s.outcome] || 0) + 1;
756
- agentMap[s.agent].total++;
757
- });
758
-
759
- const agents = Object.entries(agentMap).sort(
760
- (a, b) => b[1].total - a[1].total
761
- );
762
- const maxTotal = Math.max(...agents.map(([, d]) => d.total));
763
-
764
- el.innerHTML = agents
765
- .map(
766
- ([name, data]) =>
767
- '<div class="bar-row">' +
768
- '<span class="bar-label">' +
769
- escapeHtml(name) +
770
- '</span>' +
771
- '<div class="bar-track">' +
772
- (data.success > 0
773
- ? '<div class="bar-segment bar--success" style="width: ' +
774
- ((data.success / maxTotal) * 100).toFixed(1) + '%"></div>'
775
- : '') +
776
- (data.partial > 0
777
- ? '<div class="bar-segment bar--partial" style="width: ' +
778
- ((data.partial / maxTotal) * 100).toFixed(1) + '%"></div>'
779
- : '') +
780
- (data.failed > 0
781
- ? '<div class="bar-segment bar--failed" style="width: ' +
782
- ((data.failed / maxTotal) * 100).toFixed(1) + '%"></div>'
783
- : '') +
784
- '</div>' +
785
- '<span class="bar-value">' +
786
- data.total +
787
- '</span>' +
788
- '</div>'
789
- )
790
- .join('');
419
+ function showConvoyDetailView(convoyId, convoyName) {
420
+ const home = document.getElementById('view-home');
421
+ const detail = document.getElementById('view-convoy-detail');
422
+ const breadcrumbs = document.getElementById('breadcrumbs');
423
+ if (home) home.dataset.viewHidden = '';
424
+ if (detail) delete detail.dataset.viewHidden;
425
+ if (breadcrumbs) delete breadcrumbs.dataset.viewHidden;
426
+ document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = 'none');
427
+ document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = '');
428
+ const crumbText = document.getElementById('breadcrumbs-convoy');
429
+ if (crumbText) crumbText.textContent = convoyName || convoyId;
430
+ const url = new URL(window.location);
431
+ url.searchParams.set('convoy', convoyId);
432
+ history.pushState({}, '', url);
433
+ loadConvoyDetail(convoyId);
434
+ window.scrollTo({ top: 0, behavior: 'smooth' });
791
435
  }
792
436
 
793
- // ── Tier Donut Chart ──────────────────────────────────────
794
-
795
- function renderTierChart(delegations) {
796
- const el = document.getElementById('tier-chart');
797
- if (!el) return;
798
-
799
- if (delegations.length === 0) {
800
- el.innerHTML = emptyStateHtml('tiers', 'No tier data yet', 'Model tier distribution (Premium, Standard, Utility, Economy) will be visualized as a donut chart.');
801
- return;
802
- }
803
-
804
- const tierCounts = {};
805
- delegations.forEach((d) => {
806
- tierCounts[d.tier] = (tierCounts[d.tier] || 0) + 1;
807
- });
808
-
809
- const order = ['premium', 'standard', 'utility', 'economy'];
810
- const tiers = order
811
- .filter((t) => tierCounts[t])
812
- .map((t) => ({ name: t, count: tierCounts[t] }));
813
-
814
- const total = delegations.length;
815
- const r = 70;
816
- const circumference = 2 * Math.PI * r;
817
- let cumOffset = 0;
818
-
819
- const circles = tiers.map((t) => {
820
- const pct = t.count / total;
821
- const dashLen = pct * circumference;
822
- // Skip round linecap for single-segment donuts to avoid overlap artifact
823
- const linecap = tiers.length === 1 ? 'butt' : 'round';
824
- const segment =
825
- '<circle cx="90" cy="90" r="' +
826
- r +
827
- '" fill="none" ' +
828
- 'stroke="' +
829
- (TIER_COLORS[t.name] || '#64748b') +
830
- '" stroke-width="18" ' +
831
- 'stroke-dasharray="' +
832
- dashLen.toFixed(2) +
833
- ' ' +
834
- (circumference - dashLen).toFixed(2) +
835
- '" ' +
836
- 'stroke-dashoffset="' +
837
- (-cumOffset).toFixed(2) +
838
- '" ' +
839
- 'transform="rotate(-90 90 90)" ' +
840
- 'stroke-linecap="' + linecap + '"/>';
841
- cumOffset += dashLen;
842
- return segment;
843
- });
844
-
845
- const legend = tiers
846
- .map(
847
- (t) =>
848
- '<div class="legend-item">' +
849
- '<span class="legend-dot" style="background: ' +
850
- (TIER_COLORS[t.name] || '#64748b') +
851
- '"></span>' +
852
- '<span class="legend-name">' +
853
- t.name +
854
- '</span>' +
855
- '<span class="legend-count">' +
856
- t.count +
857
- ' (' +
858
- Math.round((t.count / total) * 100) +
859
- '%)</span>' +
860
- '</div>'
861
- )
862
- .join('');
863
-
864
- el.innerHTML =
865
- '<div class="donut-container">' +
866
- '<div class="donut-wrap">' +
867
- '<svg viewBox="0 0 180 180" class="donut-svg">' +
868
- circles.join('') +
869
- '</svg>' +
870
- '<div class="donut-center">' +
871
- '<span class="donut-total">' +
872
- total +
873
- '</span>' +
874
- '<span class="donut-total-label">total</span>' +
875
- '</div>' +
876
- '</div>' +
877
- '<div class="donut-legend">' +
878
- legend +
879
- '</div>' +
880
- '</div>';
881
- }
882
-
883
- // ── Mechanism Donut Chart ─────────────────────────────────
884
-
885
- function renderMechanismChart(delegations) {
886
- const el = document.getElementById('mechanism-chart');
887
- if (!el) return;
888
-
889
- if (delegations.length === 0) {
890
- el.innerHTML = emptyStateHtml('mechanism', 'No delegation data yet', 'The split between sub-agent (inline) and background (worktree) delegations will be shown here.');
891
- return;
892
- }
893
-
894
- const mechCounts = {};
895
- delegations.forEach((d) => {
896
- const mech = d.mechanism || 'unknown';
897
- mechCounts[mech] = (mechCounts[mech] || 0) + 1;
898
- });
899
-
900
- var MECH_COLORS = {
901
- 'sub-agent': '#3b82f6',
902
- 'background': '#a78bfa',
903
- 'unknown': '#64748b',
904
- };
905
-
906
- var MECH_LABELS = {
907
- 'sub-agent': 'Sub-agent (inline)',
908
- 'background': 'Background (worktree)',
909
- 'unknown': 'Unknown',
910
- };
911
-
912
- var mechOrder = ['sub-agent', 'background', 'unknown'];
913
- var mechs = mechOrder
914
- .filter(function (m) { return mechCounts[m]; })
915
- .map(function (m) { return { name: m, count: mechCounts[m] }; });
916
-
917
- var total = delegations.length;
918
- var r = 70;
919
- var circumference = 2 * Math.PI * r;
920
- var cumOffset = 0;
921
-
922
- var circles = mechs.map(function (m) {
923
- var pct = m.count / total;
924
- var dashLen = pct * circumference;
925
- // Skip round linecap for single-segment donuts to avoid overlap artifact
926
- var linecap = mechs.length === 1 ? 'butt' : 'round';
927
- var segment =
928
- '<circle cx="90" cy="90" r="' + r + '" fill="none" ' +
929
- 'stroke="' + (MECH_COLORS[m.name] || '#64748b') + '" stroke-width="18" ' +
930
- 'stroke-dasharray="' + dashLen.toFixed(2) + ' ' + (circumference - dashLen).toFixed(2) + '" ' +
931
- 'stroke-dashoffset="' + (-cumOffset).toFixed(2) + '" ' +
932
- 'transform="rotate(-90 90 90)" stroke-linecap="' + linecap + '"/>';
933
- cumOffset += dashLen;
934
- return segment;
935
- });
936
-
937
- var legend = mechs
938
- .map(function (m) {
939
- return '<div class="legend-item">' +
940
- '<span class="legend-dot" style="background: ' + (MECH_COLORS[m.name] || '#64748b') + '"></span>' +
941
- '<span class="legend-name">' + (MECH_LABELS[m.name] || m.name) + '</span>' +
942
- '<span class="legend-count">' + m.count + ' (' + Math.round((m.count / total) * 100) + '%)</span>' +
943
- '</div>';
944
- })
945
- .join('');
946
-
947
- el.innerHTML =
948
- '<div class="donut-container">' +
949
- '<div class="donut-wrap">' +
950
- '<svg viewBox="0 0 180 180" class="donut-svg">' +
951
- circles.join('') +
952
- '</svg>' +
953
- '<div class="donut-center">' +
954
- '<span class="donut-total">' + total + '</span>' +
955
- '<span class="donut-total-label">total</span>' +
956
- '</div>' +
957
- '</div>' +
958
- '<div class="donut-legend">' +
959
- legend +
960
- '</div>' +
961
- '</div>';
962
- }
963
-
964
- // ── Delegation Outcome Chart ──────────────────────────────
965
-
966
- function renderDelegationOutcomeChart(delegations) {
967
- var el = document.getElementById('delegation-outcome-chart');
968
- if (!el) return;
437
+ // ── Convoy List ─────────────────────────────────────────
438
+ function renderConvoyList() {
439
+ const data = window.__DASHBOARD_DATA__;
440
+ const list = data?.convoyList ?? [];
441
+ const wrap = document.getElementById('convoy-list-table-wrap');
442
+ const emptyEl = document.getElementById('convoy-list-empty');
443
+ if (!wrap) return;
444
+
445
+ const search = (document.getElementById('cl-filter-search')?.value || '').toLowerCase();
446
+ const status = document.getElementById('cl-filter-status')?.value || '';
447
+ const fromDate = document.getElementById('cl-filter-from')?.value || '';
448
+ const toDate = document.getElementById('cl-filter-to')?.value || '';
449
+
450
+ let filtered = list;
451
+ if (search) filtered = filtered.filter(c => (c.name || c.id || '').toLowerCase().includes(search));
452
+ if (status) filtered = filtered.filter(c => c.status === status);
453
+ if (fromDate) filtered = filtered.filter(c => c.created_at && c.created_at >= fromDate);
454
+ if (toDate) filtered = filtered.filter(c => c.created_at && c.created_at.slice(0, 10) <= toDate);
969
455
 
970
- if (delegations.length === 0) {
971
- el.innerHTML = emptyStateHtml('outcomes', 'No outcome data yet', 'Delegation results — success, partial, failed, redirected — will be tracked and compared here.');
456
+ if (filtered.length === 0) {
457
+ wrap.innerHTML = '';
458
+ if (emptyEl) emptyEl.style.display = '';
972
459
  return;
973
460
  }
461
+ if (emptyEl) emptyEl.style.display = 'none';
974
462
 
975
- var OUTCOME_COLORS = {
976
- success: '#22c55e',
977
- partial: '#f59e0b',
978
- failed: '#ef4444',
979
- redirected: '#64748b',
463
+ const statusBadgeClass = (s) => {
464
+ const map = { done: '--done', running: '--running', failed: '--failed', 'gate-failed': '--gate-failed', pending: '--pending' };
465
+ return 'status-badge ' + (map[s] || '');
980
466
  };
981
467
 
982
- var outcomeCounts = {};
983
- delegations.forEach(function (d) {
984
- var outcome = d.outcome || 'unknown';
985
- outcomeCounts[outcome] = (outcomeCounts[outcome] || 0) + 1;
986
- });
987
-
988
- var outcomes = Object.entries(outcomeCounts).sort(function (a, b) { return b[1] - a[1]; });
989
- var maxCount = Math.max.apply(null, outcomes.map(function (o) { return o[1]; }));
990
-
991
- el.innerHTML = outcomes
992
- .map(function (entry) {
993
- var name = entry[0];
994
- var count = entry[1];
995
- return '<div class="bar-row">' +
996
- '<span class="bar-label">' + escapeHtml(name) + '</span>' +
997
- '<div class="bar-track">' +
998
- '<div class="bar-segment" style="width: ' + ((count / maxCount) * 100).toFixed(1) + '%; background: ' + (OUTCOME_COLORS[name] || '#64748b') + '"></div>' +
999
- '</div>' +
1000
- '<span class="bar-value">' + count + '</span>' +
1001
- '</div>';
1002
- })
1003
- .join('');
1004
- }
1005
-
1006
- // ── Timeline Chart ────────────────────────────────────────
1007
-
1008
- function renderTimelineChart(sessions, delegations) {
1009
- const el = document.getElementById('timeline-chart');
1010
- if (!el) return;
1011
-
1012
- const dateMap = {};
1013
- sessions.forEach((s) => {
1014
- const key = s.timestamp.slice(0, 10);
1015
- if (!dateMap[key]) dateMap[key] = { sessions: 0, delegations: 0 };
1016
- dateMap[key].sessions++;
1017
- });
1018
- delegations.forEach((d) => {
1019
- const key = d.timestamp.slice(0, 10);
1020
- if (!dateMap[key]) dateMap[key] = { sessions: 0, delegations: 0 };
1021
- dateMap[key].delegations++;
1022
- });
1023
-
1024
- const dates = Object.entries(dateMap).sort(([a], [b]) =>
1025
- a.localeCompare(b)
1026
- );
1027
-
1028
- if (dates.length === 0) {
1029
- el.innerHTML = emptyStateHtml('timeline', 'No timeline data yet', 'A daily activity chart will build here as sessions and delegations accumulate over time.');
1030
- return;
1031
- }
1032
-
1033
- const maxVal = Math.max(
1034
- ...dates.map(([, d]) => Math.max(d.sessions, d.delegations))
1035
- );
1036
- const w = 500;
1037
- const h = 180;
1038
- const pad = { top: 10, right: 10, bottom: 28, left: 10 };
1039
- const plotW = w - pad.left - pad.right;
1040
- const plotH = h - pad.top - pad.bottom;
1041
- // Prevent sparse layout when there are very few dates
1042
- const groupWidth = dates.length <= 3
1043
- ? Math.min(100, plotW / dates.length)
1044
- : plotW / dates.length;
1045
- const barWidth = Math.min(dates.length <= 3 ? 24 : 16, groupWidth * 0.35);
1046
- // Center the bars when there are few dates
1047
- const timelineStartX = dates.length <= 3
1048
- ? pad.left + (plotW - dates.length * groupWidth) / 2
1049
- : pad.left;
1050
-
1051
- let rects = '';
1052
- let labels = '';
1053
-
1054
- dates.forEach(([date, data], i) => {
1055
- const x = timelineStartX + i * groupWidth + groupWidth / 2;
1056
- const sH = maxVal > 0 ? (data.sessions / maxVal) * plotH : 0;
1057
- const dH = maxVal > 0 ? (data.delegations / maxVal) * plotH : 0;
1058
-
1059
- rects +=
1060
- '<rect x="' +
1061
- (x - barWidth - 1).toFixed(1) +
1062
- '" y="' +
1063
- (pad.top + plotH - sH).toFixed(1) +
1064
- '" width="' +
1065
- barWidth.toFixed(1) +
1066
- '" height="' +
1067
- sH.toFixed(1) +
1068
- '" fill="#3b82f6" rx="3" opacity="0.85"/>';
1069
- rects +=
1070
- '<rect x="' +
1071
- (x + 1).toFixed(1) +
1072
- '" y="' +
1073
- (pad.top + plotH - dH).toFixed(1) +
1074
- '" width="' +
1075
- barWidth.toFixed(1) +
1076
- '" height="' +
1077
- dH.toFixed(1) +
1078
- '" fill="#a78bfa" rx="3" opacity="0.65"/>';
1079
- labels +=
1080
- '<text x="' +
1081
- x.toFixed(1) +
1082
- '" y="' +
1083
- (h - 6) +
1084
- '" text-anchor="middle" fill="#5a5a6e" font-size="10">' +
1085
- formatShortDate(date) +
1086
- '</text>';
1087
- });
1088
-
1089
- el.innerHTML =
1090
- '<svg viewBox="0 0 ' +
1091
- w +
1092
- ' ' +
1093
- h +
1094
- '" class="timeline-svg" preserveAspectRatio="xMidYMid meet">' +
1095
- rects +
1096
- labels +
1097
- '</svg>' +
1098
- '<div class="timeline-legend">' +
1099
- '<div class="timeline-legend__item">' +
1100
- '<span class="timeline-legend__dot" style="background: #3b82f6"></span>' +
1101
- 'Sessions</div>' +
1102
- '<div class="timeline-legend__item">' +
1103
- '<span class="timeline-legend__dot" style="background: #a78bfa"></span>' +
1104
- 'Delegations</div>' +
1105
- '</div>';
1106
- }
1107
-
1108
- // ── Model Chart ───────────────────────────────────────────
1109
-
1110
- function renderModelChart(sessions) {
1111
- const el = document.getElementById('model-chart');
1112
- if (!el) return;
1113
-
1114
- if (sessions.length === 0) {
1115
- el.innerHTML = emptyStateHtml('models', 'No model data yet', 'Model utilization across sessions — Claude Opus, GPT-5, Gemini, etc. — will be compared here.');
1116
- return;
1117
- }
1118
-
1119
- const modelCounts = {};
1120
- sessions.forEach((s) => {
1121
- modelCounts[s.model] = (modelCounts[s.model] || 0) + 1;
1122
- });
1123
-
1124
- const models = Object.entries(modelCounts).sort((a, b) => b[1] - a[1]);
1125
- const maxCount = Math.max(...models.map(([, c]) => c));
1126
-
1127
- el.innerHTML = models
1128
- .map(
1129
- ([name, count]) =>
1130
- '<div class="bar-row">' +
1131
- '<span class="bar-label">' +
1132
- escapeHtml(name) +
1133
- '</span>' +
1134
- '<div class="bar-track">' +
1135
- '<div class="bar-segment" style="width: ' +
1136
- ((count / maxCount) * 100).toFixed(1) +
1137
- '%; background: ' +
1138
- (MODEL_COLORS[name] || '#64748b') +
1139
- '"></div>' +
1140
- '</div>' +
1141
- '<span class="bar-value">' +
1142
- count +
1143
- '</span>' +
1144
- '</div>'
1145
- )
1146
- .join('');
1147
- }
1148
-
1149
- // ── Execution Log ─────────────────────────────────────────
1150
-
1151
- function renderExecutionLog(sessions) {
1152
- const el = document.getElementById('execution-log');
1153
- if (!el) return;
1154
-
1155
- const sorted = sessions
1156
- .slice()
1157
- .sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp))
1158
- .slice(0, 10);
1159
-
1160
- if (sorted.length === 0) {
1161
- el.innerHTML = emptyStateHtml('execLog', 'No execution history yet', 'A step-by-step trace of agent activity — with outcomes, durations, and metadata — will appear here.');
1162
- return;
1163
- }
1164
-
1165
- el.innerHTML =
1166
- '<div class="exec-log">' +
1167
- sorted
1168
- .map(
1169
- (s, i) =>
1170
- '<div class="exec-step">' +
1171
- '<div class="exec-step__indicator">' +
1172
- '<div class="exec-step__dot exec-step__dot--' +
1173
- s.outcome +
1174
- '">' +
1175
- (OUTCOME_ICONS[s.outcome] || '') +
1176
- '</div>' +
1177
- (i < sorted.length - 1
1178
- ? '<div class="exec-step__line"></div>'
1179
- : '') +
1180
- '</div>' +
1181
- '<div class="exec-step__content">' +
1182
- '<div class="exec-step__header">' +
1183
- '<span class="exec-step__agent">' +
1184
- escapeHtml(s.agent) +
1185
- '</span>' +
1186
- '<span class="exec-step__badge exec-step__badge--' +
1187
- s.outcome +
1188
- '">' +
1189
- s.outcome +
1190
- '</span>' +
1191
- '</div>' +
1192
- '<div class="exec-step__task">' +
1193
- escapeHtml(s.task) +
1194
- '</div>' +
1195
- '<div class="exec-step__meta">' +
1196
- '<span class="exec-step__meta-item">\uD83D\uDD52 ' +
1197
- formatTime(s.timestamp) +
1198
- '</span>' +
1199
- (s.duration_min != null
1200
- ? '<span class="exec-step__meta-item">\u23F1 ' +
1201
- s.duration_min +
1202
- 'm</span>'
1203
- : '') +
1204
- (s.files_changed != null
1205
- ? '<span class="exec-step__meta-item">\uD83D\uDCC1 ' +
1206
- s.files_changed +
1207
- ' files</span>'
1208
- : '') +
1209
- (s.model
1210
- ? '<span class="exec-step__meta-item">\uD83E\uDD16 ' +
1211
- escapeHtml(s.model) +
1212
- '</span>'
1213
- : '') +
1214
- (s.retries > 0
1215
- ? '<span class="exec-step__meta-item">\uD83D\uDD04 ' +
1216
- s.retries +
1217
- ' retries</span>'
1218
- : '') +
1219
- (s.lessons_added && s.lessons_added.length > 0
1220
- ? '<span class="exec-step__meta-item">\uD83D\uDCA1 ' +
1221
- s.lessons_added.length +
1222
- ' lessons</span>'
1223
- : '') +
1224
- (s.discoveries && s.discoveries.length > 0
1225
- ? '<span class="exec-step__meta-item">\uD83D\uDD0D ' +
1226
- s.discoveries.length +
1227
- ' discoveries</span>'
1228
- : '') +
1229
- '</div>' +
1230
- '</div>' +
1231
- '</div>'
1232
- )
1233
- .join('') +
1234
- '</div>';
1235
- }
1236
-
1237
- // ── Panel Chart ───────────────────────────────────────────
1238
-
1239
- function renderPanelChart(panels) {
1240
- const el = document.getElementById('panel-chart');
1241
- if (!el) return;
1242
-
1243
- if (panels.length === 0) {
1244
- el.innerHTML = emptyStateHtml('panels', 'No panel reviews yet', 'Quality gate verdicts from majority-vote panels — with pass/block counts and must-fix items — will be shown here.');
1245
- return;
1246
- }
1247
-
1248
- el.innerHTML =
1249
- '<div class="panel-grid">' +
1250
- panels
1251
- .map(
1252
- (p) =>
1253
- '<div class="panel-item">' +
1254
- '<div class="panel-item__header">' +
1255
- '<span class="panel-item__key">' +
1256
- escapeHtml(p.panel_key) +
1257
- '</span>' +
1258
- '<span class="panel-item__verdict panel-item__verdict--' +
1259
- p.verdict +
1260
- '">' +
1261
- p.verdict +
1262
- '</span>' +
1263
- '</div>' +
1264
- '<div class="panel-item__votes">' +
1265
- Array.from({ length: p.pass_count })
1266
- .map(
1267
- () =>
1268
- '<div class="panel-item__vote panel-item__vote--pass">\u2713</div>'
1269
- )
1270
- .join('') +
1271
- Array.from({ length: p.block_count })
1272
- .map(
1273
- () =>
1274
- '<div class="panel-item__vote panel-item__vote--block">\u2717</div>'
1275
- )
1276
- .join('') +
1277
- '</div>' +
1278
- '<div class="panel-item__fixes">' +
1279
- (p.must_fix > 0
1280
- ? '<strong>' + p.must_fix + ' must-fix</strong>'
1281
- : '') +
1282
- (p.must_fix > 0 && p.should_fix > 0 ? ' \u00B7 ' : '') +
1283
- (p.should_fix > 0 ? p.should_fix + ' should-fix' : '') +
1284
- (p.must_fix === 0 && p.should_fix === 0 ? 'Clean' : '') +
1285
- '</div>' +
1286
- '<div class="panel-item__meta">' +
1287
- '<span class="panel-item__meta-item">\uD83E\uDD16 ' + escapeHtml(p.reviewer_model || 'unknown') + '</span>' +
1288
- (p.attempt > 1 ? '<span class="panel-item__meta-item">\uD83D\uDD04 attempt ' + p.attempt + '</span>' : '') +
1289
- (p.artifacts_count ? '<span class="panel-item__meta-item">\uD83D\uDCC4 ' + p.artifacts_count + ' artifacts</span>' : '') +
1290
- '</div>' +
1291
- '</div>'
1292
- )
1293
- .join('') +
1294
- '</div>';
1295
- }
1296
-
1297
- // ── Sessions Table ────────────────────────────────────────
1298
-
1299
- function renderSessionsTable(sessions) {
1300
- const el = document.getElementById('sessions-table');
1301
- if (!el) return;
1302
-
1303
- const sorted = sessions
1304
- .slice()
1305
- .sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp))
1306
- .slice(0, 15);
1307
-
1308
- if (sorted.length === 0) {
1309
- el.innerHTML = emptyStateHtml('sessions', 'No session records yet', 'A detailed table of recent sessions — with timestamps, agents, tasks, outcomes, and linked issues — will populate here.');
1310
- return;
1311
- }
1312
-
1313
- el.innerHTML =
1314
- '<table class="sessions-table">' +
1315
- '<thead><tr>' +
1316
- '<th>Timestamp</th>' +
1317
- '<th>Agent</th>' +
1318
- '<th>Task</th>' +
1319
- '<th>Outcome</th>' +
1320
- '<th>Duration</th>' +
1321
- '<th>Files</th>' +
1322
- '<th>Retries</th>' +
1323
- '<th>Issue</th>' +
1324
- '</tr></thead>' +
1325
- '<tbody>' +
1326
- sorted
1327
- .map(
1328
- (s) =>
1329
- '<tr>' +
1330
- '<td>' +
1331
- formatTime(s.timestamp) +
1332
- '</td>' +
1333
- '<td class="td-agent">' +
1334
- escapeHtml(s.agent) +
1335
- '</td>' +
1336
- '<td class="td-task">' +
1337
- escapeHtml(s.task) +
1338
- '</td>' +
1339
- '<td><span class="outcome-badge outcome-badge--' +
1340
- s.outcome +
1341
- '">' +
1342
- s.outcome +
1343
- '</span></td>' +
1344
- '<td class="td-num">' +
1345
- (s.duration_min != null ? s.duration_min + 'm' : '\u2014') +
1346
- '</td>' +
1347
- '<td class="td-num">' +
1348
- (s.files_changed != null ? s.files_changed : '\u2014') +
1349
- '</td>' +
1350
- '<td class="td-num">' +
1351
- (s.retries != null ? s.retries : '\u2014') +
1352
- '</td>' +
1353
- '<td class="td-issue">' +
1354
- (s.tracker_issue ? escapeHtml(s.tracker_issue) : '\u2014') +
1355
- '</td>' +
1356
- '</tr>'
1357
- )
1358
- .join('') +
1359
- '</tbody></table>';
1360
- }
1361
-
1362
- // ── Main ──────────────────────────────────────────────────
1363
-
1364
- // Store raw data globally for filtering/export
1365
- let rawSessions = [];
1366
- let rawDelegations = [];
1367
- let rawPanels = [];
1368
- let rawReviews = [];
1369
- let rawConvoys = [];
1370
- let rawPipelines = [];
1371
-
1372
- function applyFilters() {
1373
- const dateFrom = document.getElementById('filter-date-from').value;
1374
- const dateTo = document.getElementById('filter-date-to').value;
1375
- const agentFilter = document.getElementById('filter-agent').value;
1376
- const outcomeFilter = document.getElementById('filter-outcome').value;
1377
- const convoyFilter = document.getElementById('filter-convoy').value;
1378
- const pipelineFilter = document.getElementById('filter-pipeline')?.value || '';
1379
-
1380
- function matchDate(ts) {
1381
- const date = ts.slice(0, 10);
1382
- if (dateFrom && date < dateFrom) return false;
1383
- if (dateTo && date > dateTo) return false;
1384
- return true;
1385
- }
1386
-
1387
- let sessions = rawSessions.filter((s) => {
1388
- if (!matchDate(s.timestamp)) return false;
1389
- if (agentFilter && s.agent !== agentFilter) return false;
1390
- if (outcomeFilter && s.outcome !== outcomeFilter) return false;
1391
- return true;
1392
- });
1393
-
1394
- let delegations = rawDelegations.filter((d) => {
1395
- if (!matchDate(d.timestamp)) return false;
1396
- if (agentFilter && d.agent !== agentFilter) return false;
1397
- if (outcomeFilter && d.outcome !== outcomeFilter) return false;
1398
- return true;
1399
- });
1400
-
1401
- let panels = rawPanels.filter((p) => matchDate(p.timestamp));
1402
- let reviews = rawReviews.filter((r) => {
1403
- if (!matchDate(r.timestamp)) return false;
1404
- if (agentFilter && r.agent !== agentFilter) return false;
1405
- return true;
1406
- });
1407
-
1408
- // Pipeline filter: restrict events to convoy_ids within the selected pipeline
1409
- if (pipelineFilter) {
1410
- const activePipeline = rawPipelines.find((p) => p.id === pipelineFilter);
1411
- const pipelineConvoyIds = new Set((activePipeline && activePipeline.convoy_ids) || []);
1412
- if (pipelineConvoyIds.size > 0) {
1413
- sessions = sessions.filter((s) => !s.convoy_id || pipelineConvoyIds.has(s.convoy_id));
1414
- delegations = delegations.filter((d) => !d.convoy_id || pipelineConvoyIds.has(d.convoy_id));
1415
- panels = panels.filter((p2) => !p2.convoy_id || pipelineConvoyIds.has(p2.convoy_id));
1416
- reviews = reviews.filter((r) => !r.convoy_id || pipelineConvoyIds.has(r.convoy_id));
1417
- }
1418
- }
1419
-
1420
- if (convoyFilter) {
1421
- sessions = sessions.filter((s) => s.convoy_id === convoyFilter);
1422
- delegations = delegations.filter((d) => d.convoy_id === convoyFilter);
1423
- panels = panels.filter((p) => p.convoy_id === convoyFilter);
1424
- reviews = reviews.filter((r) => r.convoy_id === convoyFilter);
1425
- }
1426
-
1427
- const convoySection = document.getElementById('convoy-section');
1428
- if (convoySection) {
1429
- convoySection.style.display = convoyFilter ? '' : 'none';
1430
- if (convoyFilter) {
1431
- const convoy = rawConvoys.find((c) => c.id === convoyFilter);
1432
- renderConvoyStatus(convoy);
1433
- }
1434
- }
1435
-
1436
- // Show/hide convoy pipeline section based on pipeline filter
1437
- const pipelineSectionEl = document.getElementById('convoy-pipeline-section');
1438
- if (pipelineSectionEl) {
1439
- if (pipelineFilter) {
1440
- const activePipeline = rawPipelines.find((p) => p.id === pipelineFilter);
1441
- renderConvoyPipeline(activePipeline, rawConvoys);
1442
- } else {
1443
- pipelineSectionEl.style.display = 'none';
1444
- }
1445
- }
1446
-
1447
- renderAll(sessions, delegations, panels, reviews);
1448
- }
1449
-
1450
- function populateAgentFilter(sessions, delegations, reviews) {
1451
- const agents = new Set();
1452
- sessions.forEach((s) => agents.add(s.agent));
1453
- delegations.forEach((d) => agents.add(d.agent));
1454
- reviews.forEach((r) => agents.add(r.agent));
1455
- const select = document.getElementById('filter-agent');
1456
- if (!select) return;
1457
- // Keep the "All agents" option, remove old dynamic options
1458
- while (select.options.length > 1) select.remove(1);
1459
- Array.from(agents).sort().forEach((a) => {
1460
- const opt = document.createElement('option');
1461
- opt.value = a;
1462
- opt.textContent = a;
1463
- select.appendChild(opt);
1464
- });
1465
- }
1466
-
1467
- function renderAll(sessions, delegations, panels, reviews) {
1468
- const allEmpty = sessions.length === 0 && delegations.length === 0 && panels.length === 0 && reviews.length === 0;
1469
- if (allEmpty) {
1470
- renderWelcomeBanner();
1471
- } else {
1472
- removeWelcomeBanner();
1473
- }
1474
-
1475
- renderKpis(sessions, delegations, reviews);
1476
- renderPipeline(delegations);
1477
- renderAgentChart(sessions);
1478
- renderTierChart(delegations);
1479
- renderMechanismChart(delegations);
1480
- renderDelegationOutcomeChart(delegations);
1481
- renderTimelineChart(sessions, delegations);
1482
- renderModelChart(sessions);
1483
- renderExecutionLog(sessions);
1484
- renderPanelChart(panels);
1485
- renderReviewsTable(reviews);
1486
- renderSessionsTable(sessions);
1487
- }
1488
-
1489
- // ── Reviews Table ─────────────────────────────────────────
1490
-
1491
- function renderReviewsTable(reviews) {
1492
- const el = document.getElementById('reviews-table');
1493
- if (!el) return;
1494
-
1495
- const sorted = reviews
1496
- .slice()
1497
- .sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp))
1498
- .slice(0, 20);
1499
-
1500
- if (sorted.length === 0) {
1501
- el.innerHTML = emptyStateHtml('panels', 'No fast reviews yet', 'Single-reviewer quality gate results — with verdicts, issue counts, and escalation status — will be listed here.');
1502
- return;
1503
- }
1504
-
1505
- el.innerHTML =
1506
- '<table class="sessions-table">' +
1507
- '<thead><tr>' +
1508
- '<th>Timestamp</th>' +
1509
- '<th>Agent</th>' +
1510
- '<th>Verdict</th>' +
1511
- '<th>Critical</th>' +
1512
- '<th>Major</th>' +
1513
- '<th>Minor</th>' +
1514
- '<th>Confidence</th>' +
1515
- '<th>Attempt</th>' +
1516
- '<th>Escalated</th>' +
1517
- '<th>Issue</th>' +
1518
- '</tr></thead>' +
1519
- '<tbody>' +
1520
- sorted
1521
- .map(
1522
- (r) =>
1523
- '<tr>' +
1524
- '<td>' + formatTime(r.timestamp) + '</td>' +
1525
- '<td class="td-agent">' + escapeHtml(r.agent || '') + '</td>' +
1526
- '<td><span class="outcome-badge outcome-badge--' + (r.verdict === 'pass' ? 'success' : 'failed') + '">' + r.verdict + '</span></td>' +
1527
- '<td class="td-num">' + (r.issues_critical ?? 0) + '</td>' +
1528
- '<td class="td-num">' + (r.issues_major ?? 0) + '</td>' +
1529
- '<td class="td-num">' + (r.issues_minor ?? 0) + '</td>' +
1530
- '<td class="td-num">' + (r.confidence || '\u2014') + '</td>' +
1531
- '<td class="td-num">' + (r.attempt ?? 1) + '</td>' +
1532
- '<td class="td-num">' + (r.escalated ? '\u26A0' : '\u2014') + '</td>' +
1533
- '<td class="td-issue">' + (r.tracker_issue ? escapeHtml(r.tracker_issue) : '\u2014') + '</td>' +
1534
- '</tr>'
1535
- )
1536
- .join('') +
1537
- '</tbody></table>';
1538
- }
1539
-
1540
- // ── Export ─────────────────────────────────────────────────
1541
-
1542
- function exportData() {
1543
- const events = [
1544
- ...rawSessions,
1545
- ...rawDelegations,
1546
- ...rawPanels,
1547
- ...rawReviews,
1548
- ].sort((a, b) => a.timestamp.localeCompare(b.timestamp));
1549
- const blob = new Blob([events.map((e) => JSON.stringify(e)).join('\n') + '\n'], { type: 'application/x-ndjson' });
1550
- const url = URL.createObjectURL(blob);
1551
- const a = document.createElement('a');
1552
- a.href = url;
1553
- a.download = 'opencastle-events-' + new Date().toISOString().slice(0, 10) + '.ndjson';
1554
- a.click();
1555
- URL.revokeObjectURL(url);
1556
- }
1557
-
1558
- function populateConvoyFilter(convoys) {
1559
- const select = document.getElementById('filter-convoy');
1560
- if (!select) return;
1561
- while (select.options.length > 1) select.remove(1);
1562
- const sorted = convoys.slice().sort((a, b) => b.created_at.localeCompare(a.created_at));
1563
- sorted.forEach((c) => {
1564
- const opt = document.createElement('option');
1565
- opt.value = c.id;
1566
- opt.textContent = c.name + ' (' + c.status + ')';
1567
- select.appendChild(opt);
1568
- });
1569
- }
1570
-
1571
- function renderConvoyStatus(convoy) {
1572
- const descEl = document.getElementById('convoy-desc');
1573
- const bodyEl = document.getElementById('convoy-body');
1574
- if (!descEl || !bodyEl) return;
1575
-
1576
- if (!convoy) {
1577
- bodyEl.innerHTML = emptyStateHtml('pipeline', 'Convoy not found', 'No matching convoy data available.');
1578
- return;
1579
- }
1580
-
1581
- descEl.textContent = convoy.name + ' — ' + (convoy.branch || 'no branch');
1582
-
1583
- const s = convoy.summary || {};
1584
- const total = s.total || (convoy.tasks ? convoy.tasks.length : 0);
1585
- const done = s.done || 0;
1586
- const pct = total > 0 ? Math.round((done / total) * 100) : 0;
1587
-
1588
- const statusClass = convoy.status === 'done' ? 'success'
1589
- : (convoy.status === 'failed' || convoy.status === 'gate-failed') ? 'failed'
1590
- : convoy.status === 'running' ? 'partial' : '';
1591
-
1592
- let html = '';
1593
- html += '<div class="convoy-overview">';
1594
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Status</span><span class="outcome-badge outcome-badge--' + statusClass + '">' + escapeHtml(convoy.status) + '</span></div>';
1595
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Branch</span><span class="convoy-stat__value">' + escapeHtml(convoy.branch || '\u2014') + '</span></div>';
1596
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Tasks</span><span class="convoy-stat__value">' + done + '/' + total + '</span></div>';
1597
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Events</span><span class="convoy-stat__value">' + (convoy.events_count || 0) + '</span></div>';
1598
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Started</span><span class="convoy-stat__value">' + (convoy.started_at ? formatTime(convoy.started_at) : '\u2014') + '</span></div>';
1599
- if (convoy.total_tokens != null) {
1600
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Tokens</span><span class="convoy-stat__value">' + formatTokens(convoy.total_tokens) + '</span></div>';
1601
- }
1602
- if (convoy.finished_at) {
1603
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Finished</span><span class="convoy-stat__value">' + formatTime(convoy.finished_at) + '</span></div>';
1604
- }
1605
- const convoyDur = formatDuration(convoy.started_at, convoy.finished_at);
1606
- if (convoyDur) {
1607
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Duration</span><span class="convoy-stat__value">' + convoyDur + '</span></div>';
1608
- }
1609
- if (convoy.total_cost_usd != null && convoy.total_cost_usd > 0) {
1610
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Cost</span><span class="convoy-stat__value">$' + convoy.total_cost_usd.toFixed(2) + '</span></div>';
1611
- }
1612
- const failedCount = (s.failed || 0) + (s.timedOut || 0);
1613
- if (failedCount > 0) {
1614
- html += '<div class="convoy-stat"><span class="convoy-stat__label">Failed</span><span class="convoy-stat__value convoy-stat__value--error">' + failedCount + '</span></div>';
1615
- }
1616
- html += '</div>';
1617
-
1618
- html += '<div class="convoy-progress">';
1619
- html += '<div class="convoy-progress__bar"><div class="convoy-progress__fill" style="width:' + pct + '%"></div></div>';
1620
- html += '<span class="convoy-progress__label">' + pct + '% complete</span>';
1621
- html += '</div>';
1622
-
1623
- if (convoy.tasks && convoy.tasks.length > 0) {
1624
- html += '<table class="sessions-table convoy-tasks">';
1625
- html += '<thead><tr><th>Task</th><th>Phase</th><th>Agent</th><th>Adapter</th><th>Status</th><th>Retries</th><th>Tokens</th><th>Duration</th></tr></thead>';
1626
- html += '<tbody>';
1627
- convoy.tasks.forEach(function(t) {
1628
- const tStatus = t.status === 'done' ? 'success'
1629
- : (t.status === 'failed' || t.status === 'timed-out') ? 'failed'
1630
- : t.status === 'running' ? 'partial' : '';
1631
- html += '<tr>';
1632
- html += '<td>' + escapeHtml(t.id) + '</td>';
1633
- html += '<td class="td-num">' + t.phase + '</td>';
1634
- html += '<td class="td-agent">' + escapeHtml(t.agent) + '</td>';
1635
- html += '<td>' + escapeHtml(t.adapter || '\u2014') + '</td>';
1636
- html += '<td><span class="outcome-badge outcome-badge--' + tStatus + '">' + escapeHtml(t.status) + '</span></td>';
1637
- html += '<td class="td-num">' + (t.retries || 0) + '</td>';
1638
- html += '<td class="td-num">' + (t.total_tokens != null ? formatTokens(t.total_tokens) : '\u2014') + '</td>';
1639
- html += '<td class="td-num">' + (formatDuration(t.started_at, t.finished_at) || '\u2014') + '</td>';
1640
- html += '</tr>';
1641
- });
1642
- html += '</tbody></table>';
1643
- }
1644
-
1645
- bodyEl.innerHTML = html;
1646
- }
1647
-
1648
- // ── Pipeline Filter Population ───────────────────────────
1649
-
1650
- function populatePipelineFilter(pipelines) {
1651
- const select = document.getElementById('filter-pipeline');
1652
- if (!select) return;
1653
- while (select.options.length > 1) select.remove(1);
1654
- const sorted = pipelines.slice().sort((a, b) =>
1655
- (b.created_at || '').localeCompare(a.created_at || '')
1656
- );
1657
- sorted.forEach((p) => {
1658
- const opt = document.createElement('option');
1659
- opt.value = p.id;
1660
- opt.textContent = (p.name || p.id) + ' (' + (p.status || 'unknown') + ')';
1661
- select.appendChild(opt);
1662
- });
1663
- }
1664
-
1665
- // ── Convoy Pipeline (Chaining) Render ────────────────────
1666
-
1667
- function renderConvoyPipeline(pipeline, convoys) {
1668
- const sectionEl = document.getElementById('convoy-pipeline-section');
1669
- const descEl = document.getElementById('convoy-pipeline-desc');
1670
- const bodyEl = document.getElementById('convoy-pipeline-body');
1671
- if (!sectionEl || !bodyEl) return;
1672
-
1673
- if (!pipeline) {
1674
- sectionEl.style.display = 'none';
1675
- return;
1676
- }
1677
-
1678
- sectionEl.style.display = '';
1679
- if (descEl) {
1680
- descEl.textContent =
1681
- (pipeline.name || pipeline.id) + ' \u2014 ' + (pipeline.branch || 'no branch');
468
+ let html = '<table class="convoy-list-table"><thead><tr>' +
469
+ '<th>Name</th><th>Status</th><th>Tasks</th><th>Created</th><th>Duration</th>' +
470
+ '</tr></thead><tbody>';
471
+
472
+ for (const c of filtered) {
473
+ const name = escapeHtml(c.name || c.id);
474
+ const dateStr = c.created_at ? formatTime(c.created_at) : '\u2014';
475
+ const duration = c.started_at && c.finished_at ? formatDuration(c.started_at, c.finished_at) : (c.status === 'running' ? 'In progress' : '\u2014');
476
+ const taskCount = c.task_count ?? c.taskCount ?? '\u2014';
477
+ html += '<tr data-convoy-id="' + escapeHtml(c.id) + '" class="task-row--clickable">' +
478
+ '<td><strong>' + name + '</strong></td>' +
479
+ '<td><span class="' + statusBadgeClass(c.status) + '">' + escapeHtml(c.status || 'unknown') + '</span></td>' +
480
+ '<td>' + taskCount + '</td>' +
481
+ '<td>' + dateStr + '</td>' +
482
+ '<td>' + (duration || '\u2014') + '</td>' +
483
+ '</tr>';
1682
484
  }
485
+ html += '</tbody></table>';
486
+ wrap.innerHTML = html;
1683
487
 
1684
- const convoyIds = pipeline.convoy_ids || [];
1685
- const pipelineConvoys = convoyIds
1686
- .map((id) => convoys.find((c) => c.id === id))
1687
- .filter(Boolean);
1688
-
1689
- const total = pipelineConvoys.length;
1690
- const done = pipelineConvoys.filter((c) => c.status === 'done').length;
1691
- const failed = pipelineConvoys.filter(
1692
- (c) => c.status === 'failed' || c.status === 'gate-failed'
1693
- ).length;
1694
- const totalTasks = pipelineConvoys.reduce((sum, c) => {
1695
- const s = c.summary || {};
1696
- return sum + (s.total || (c.tasks ? c.tasks.length : 0));
1697
- }, 0);
1698
- const doneTasks = pipelineConvoys.reduce((sum, c) => {
1699
- const s = c.summary || {};
1700
- return sum + (s.done || 0);
1701
- }, 0);
1702
- const totalTokens = pipelineConvoys.reduce((sum, c) => sum + (c.total_tokens || 0), 0);
1703
-
1704
- const pct =
1705
- totalTasks > 0
1706
- ? Math.round((doneTasks / totalTasks) * 100)
1707
- : total > 0
1708
- ? Math.round((done / total) * 100)
1709
- : 0;
1710
-
1711
- const statusClass =
1712
- pipeline.status === 'done'
1713
- ? 'success'
1714
- : pipeline.status === 'failed' || pipeline.status === 'gate-failed'
1715
- ? 'failed'
1716
- : pipeline.status === 'running'
1717
- ? 'partial'
1718
- : '';
1719
-
1720
- let html = '<div class="convoy-overview">';
1721
- html +=
1722
- '<div class="convoy-stat"><span class="convoy-stat__label">Status</span>' +
1723
- '<span class="outcome-badge outcome-badge--' + statusClass + '">' +
1724
- escapeHtml(pipeline.status || 'unknown') + '</span></div>';
1725
- html +=
1726
- '<div class="convoy-stat"><span class="convoy-stat__label">Branch</span>' +
1727
- '<span class="convoy-stat__value">' + escapeHtml(pipeline.branch || '\u2014') + '</span></div>';
1728
- html +=
1729
- '<div class="convoy-stat"><span class="convoy-stat__label">Convoys</span>' +
1730
- '<span class="convoy-stat__value">' + done + '/' + total + '</span></div>';
1731
- if (totalTasks > 0) {
1732
- html +=
1733
- '<div class="convoy-stat"><span class="convoy-stat__label">Tasks</span>' +
1734
- '<span class="convoy-stat__value">' + doneTasks + '/' + totalTasks + '</span></div>';
1735
- }
1736
- if (totalTokens > 0) {
1737
- html +=
1738
- '<div class="convoy-stat"><span class="convoy-stat__label">Tokens</span>' +
1739
- '<span class="convoy-stat__value">' + formatTokens(totalTokens) + '</span></div>';
1740
- }
1741
- html +=
1742
- '<div class="convoy-stat"><span class="convoy-stat__label">Started</span>' +
1743
- '<span class="convoy-stat__value">' +
1744
- (pipeline.started_at ? formatTime(pipeline.started_at) : '\u2014') + '</span></div>';
1745
- if (pipeline.finished_at) {
1746
- html +=
1747
- '<div class="convoy-stat"><span class="convoy-stat__label">Finished</span>' +
1748
- '<span class="convoy-stat__value">' + formatTime(pipeline.finished_at) + '</span></div>';
1749
- }
1750
- const pipelineDur = formatDuration(pipeline.started_at, pipeline.finished_at);
1751
- if (pipelineDur) {
1752
- html +=
1753
- '<div class="convoy-stat"><span class="convoy-stat__label">Duration</span>' +
1754
- '<span class="convoy-stat__value">' + pipelineDur + '</span></div>';
1755
- }
1756
- if (pipeline.total_cost_usd != null && pipeline.total_cost_usd > 0) {
1757
- html +=
1758
- '<div class="convoy-stat"><span class="convoy-stat__label">Cost</span>' +
1759
- '<span class="convoy-stat__value">$' + pipeline.total_cost_usd.toFixed(2) + '</span></div>';
1760
- }
1761
- html += '</div>';
1762
-
1763
- // Convoy chain visualization
1764
- html += '<div class="convoy-chain">';
1765
- pipelineConvoys.forEach((convoy, i) => {
1766
- const cs = convoy.summary || {};
1767
- const cDone = cs.done || 0;
1768
- const cTotal = cs.total || (convoy.tasks ? convoy.tasks.length : 0);
1769
- const cTokens = convoy.total_tokens || 0;
1770
- const isActive =
1771
- (pipeline.current_convoy_id && pipeline.current_convoy_id === convoy.id) ||
1772
- convoy.status === 'running';
1773
- const nodeStatusClass =
1774
- convoy.status === 'done'
1775
- ? 'done'
1776
- : convoy.status === 'failed' || convoy.status === 'gate-failed'
1777
- ? 'failed'
1778
- : isActive
1779
- ? 'active'
1780
- : 'pending';
1781
- const badgeClass =
1782
- convoy.status === 'done'
1783
- ? 'success'
1784
- : convoy.status === 'failed' || convoy.status === 'gate-failed'
1785
- ? 'failed'
1786
- : convoy.status === 'running'
1787
- ? 'partial'
1788
- : '';
1789
-
1790
- if (i > 0) {
1791
- html += '<div class="convoy-chain__connector">\u2192</div>';
1792
- }
1793
- html +=
1794
- '<div class="convoy-chain__node convoy-chain__node--' + nodeStatusClass +
1795
- '" data-convoy-id="' + escapeHtml(convoy.id) + '" title="Click to filter to this convoy">';
1796
- html += '<div class="convoy-chain__node-name">' + escapeHtml(convoy.name || convoy.id) + '</div>';
1797
- html +=
1798
- '<span class="outcome-badge outcome-badge--' + badgeClass + '">' +
1799
- escapeHtml(convoy.status) + '</span>';
1800
- if (cTotal > 0) {
1801
- html += '<div class="convoy-chain__node-meta">' + cDone + '/' + cTotal + ' tasks</div>';
1802
- }
1803
- if (cTokens > 0) {
1804
- html += '<div class="convoy-chain__node-meta">' + formatTokens(cTokens) + ' tokens</div>';
1805
- }
1806
- html += '</div>';
1807
- });
1808
- html += '</div>';
1809
-
1810
- // Progress bar
1811
- html += '<div class="convoy-progress">';
1812
- html +=
1813
- '<div class="convoy-progress__bar">' +
1814
- '<div class="convoy-progress__fill" style="width:' + pct + '%"></div></div>';
1815
- html +=
1816
- '<span class="convoy-progress__label">' + pct + '% complete' +
1817
- (failed > 0 ? ' \u00B7 ' + failed + ' failed' : '') + '</span>';
1818
- html += '</div>';
1819
-
1820
- bodyEl.innerHTML = html;
1821
-
1822
- // Click handlers for convoy drill-down
1823
- bodyEl.querySelectorAll('.convoy-chain__node').forEach((node) => {
1824
- node.addEventListener('click', () => {
1825
- const convoyId = node.dataset.convoyId;
1826
- const sel = document.getElementById('filter-convoy');
1827
- if (sel && convoyId) {
1828
- sel.value = convoyId;
1829
- applyFilters();
1830
- }
488
+ wrap.querySelectorAll('tr[data-convoy-id]').forEach(row => {
489
+ row.addEventListener('click', () => {
490
+ const id = row.dataset.convoyId;
491
+ const nameCell = row.querySelector('td strong');
492
+ showConvoyDetailView(id, nameCell ? nameCell.textContent : id);
1831
493
  });
1832
494
  });
1833
495
  }
@@ -1874,30 +536,6 @@ try {
1874
536
  return hr + 'h ' + remMin + 'm';
1875
537
  }
1876
538
 
1877
- // ── Convoy Selector ──────────────────────────────────────
1878
-
1879
- function populateConvoySelector() {
1880
- const data = window.__DASHBOARD_DATA__;
1881
- const select = document.getElementById('convoy-select');
1882
- if (!select || !data || !data.convoyList) return;
1883
-
1884
- select.innerHTML = '<option value="">Select convoy\u2026</option>';
1885
- const list = data.convoyList;
1886
- for (const c of list) {
1887
- const opt = document.createElement('option');
1888
- opt.value = c.id;
1889
- const dateStr = c.created_at ? c.created_at.slice(0, 10) : '';
1890
- opt.textContent = (c.name || c.id) + ' \u2014 ' + c.status + ' (' + dateStr + ')';
1891
- select.appendChild(opt);
1892
- }
1893
-
1894
- // Default: select latest (first in list)
1895
- if (list.length > 0) {
1896
- select.value = list[0].id;
1897
- loadConvoyDetail(list[0].id);
1898
- }
1899
- }
1900
-
1901
539
  async function loadConvoyDetail(convoyId) {
1902
540
  if (!convoyId) {
1903
541
  renderConvoyDetailHeader(null);
@@ -1934,9 +572,9 @@ try {
1934
572
  }
1935
573
 
1936
574
  function renderConvoyDetailHeader(detail) {
1937
- const nameEl = document.getElementById('selected-convoy-name');
1938
- const statusEl = document.getElementById('selected-convoy-status');
1939
- const metaEl = document.getElementById('selected-convoy-meta');
575
+ const nameEl = document.getElementById('detail-hero-title');
576
+ const statusEl = document.getElementById('detail-hero-status');
577
+ const metaEl = document.getElementById('detail-hero-meta');
1940
578
 
1941
579
  if (!detail || !detail.convoy) {
1942
580
  if (nameEl) nameEl.textContent = 'No convoy selected';
@@ -1963,11 +601,6 @@ try {
1963
601
  'gate-failed': 'This run stopped because a quality check failed.',
1964
602
  'hook-failed': 'This run stopped because a lifecycle script failed.',
1965
603
  };
1966
- const explanationEl = document.getElementById('convoy-status-explanation');
1967
- if (explanationEl) {
1968
- explanationEl.textContent = statusExplanations[c.status] || '';
1969
- explanationEl.style.display = statusExplanations[c.status] ? '' : 'none';
1970
- }
1971
604
  if (metaEl) {
1972
605
  let html = '';
1973
606
  if (c.branch) html += '<span class="convoy-meta__item">🌿 ' + escapeHtml(c.branch) + '</span>';
@@ -2509,57 +1142,22 @@ try {
2509
1142
  }
2510
1143
 
2511
1144
  async function main() {
2512
- const events = await loadNdjson(base + 'data/events.ndjson');
2513
- const pipelines = await loadNdjson(base + 'data/pipelines.ndjson');
2514
1145
  const convoys = window.__DASHBOARD_DATA__?.convoyList ?? [];
2515
1146
 
2516
- const sessions = events.filter((e) => e.type === 'session');
2517
- const delegations = events.filter((e) => e.type === 'delegation');
2518
- const panels = events.filter((e) => e.type === 'panel');
2519
- const reviews = events.filter((e) => e.type === 'review');
2520
-
2521
- rawSessions = sessions;
2522
- rawDelegations = delegations;
2523
- rawPanels = panels;
2524
- rawReviews = reviews;
2525
- rawConvoys = convoys;
2526
- rawPipelines = pipelines;
2527
-
2528
- populateAgentFilter(sessions, delegations, reviews);
2529
- populateConvoyFilter(convoys);
2530
- populatePipelineFilter(pipelines);
2531
-
2532
- // ── Read URL params ───────────────────────────────────
2533
1147
  const urlParams = new URLSearchParams(window.location.search);
2534
1148
  const convoyParam = urlParams.get('convoy');
1149
+
2535
1150
  if (convoyParam === 'active') {
2536
- const running = rawConvoys.find((c) => c.status === 'running');
2537
- const latest = rawConvoys.slice().sort((a, b) => b.created_at.localeCompare(a.created_at))[0];
1151
+ const running = convoys.find((c) => c.status === 'running');
1152
+ const latest = convoys.slice().sort((a, b) => b.created_at.localeCompare(a.created_at))[0];
2538
1153
  const target = running || latest;
2539
- if (target) {
2540
- const sel = document.getElementById('filter-convoy');
2541
- if (sel) sel.value = target.id;
2542
- }
1154
+ if (target) showConvoyDetailView(target.id, target.name || target.id);
2543
1155
  } else if (convoyParam) {
2544
- const sel = document.getElementById('filter-convoy');
2545
- if (sel) sel.value = convoyParam;
1156
+ showConvoyDetailView(convoyParam, convoyParam);
2546
1157
  }
2547
1158
 
2548
- renderAll(sessions, delegations, panels, reviews);
2549
-
2550
- // Apply convoy param after initial render (shows convoy section if needed)
2551
- if (convoyParam) applyFilters();
2552
-
2553
- // ── Overall stats + convoy selector ──────────────────
2554
1159
  renderOverallStats();
2555
- populateConvoySelector();
2556
-
2557
- const convoySelectEl = document.getElementById('convoy-select');
2558
- if (convoySelectEl) {
2559
- convoySelectEl.addEventListener('change', function() {
2560
- loadConvoyDetail(this.value);
2561
- });
2562
- }
1160
+ renderConvoyList();
2563
1161
 
2564
1162
  var loadMoreBtn = document.getElementById('event-timeline-more-btn');
2565
1163
  if (loadMoreBtn) {
@@ -2569,66 +1167,47 @@ try {
2569
1167
  });
2570
1168
  }
2571
1169
 
2572
- // ── Filter event listeners ────────────────────────────
2573
- document.getElementById('filter-date-from')?.addEventListener('change', applyFilters);
2574
- document.getElementById('filter-date-to')?.addEventListener('change', applyFilters);
2575
- document.getElementById('filter-agent')?.addEventListener('change', applyFilters);
2576
- document.getElementById('filter-outcome')?.addEventListener('change', applyFilters);
2577
- document.getElementById('filter-convoy')?.addEventListener('change', applyFilters);
2578
- document.getElementById('filter-pipeline')?.addEventListener('change', applyFilters);
2579
- document.getElementById('filter-reset')?.addEventListener('click', () => {
2580
- document.getElementById('filter-date-from').value = '';
2581
- document.getElementById('filter-date-to').value = '';
2582
- document.getElementById('filter-agent').value = '';
2583
- document.getElementById('filter-outcome').value = '';
2584
- document.getElementById('filter-convoy').value = '';
2585
- document.getElementById('filter-pipeline').value = '';
2586
- applyFilters();
1170
+ document.getElementById('breadcrumbs-home')?.addEventListener('click', (e) => {
1171
+ e.preventDefault();
1172
+ showHomeView();
2587
1173
  });
2588
1174
 
2589
- // ── Auto-refresh for live convoy monitoring ───────────
2590
- let refreshInterval = null;
2591
- function startAutoRefresh() {
2592
- if (refreshInterval) return;
2593
- refreshInterval = setInterval(async () => {
2594
- const freshEvents = await loadNdjson(base + 'data/events.ndjson');
2595
- const freshConvoys = await loadJson(base + 'data/convoy-list.json');
2596
- const freshPipelines = await loadNdjson(base + 'data/pipelines.ndjson');
2597
- rawSessions = freshEvents.filter((e) => e.type === 'session');
2598
- rawDelegations = freshEvents.filter((e) => e.type === 'delegation');
2599
- rawPanels = freshEvents.filter((e) => e.type === 'panel');
2600
- rawReviews = freshEvents.filter((e) => e.type === 'review');
2601
- rawConvoys = freshConvoys;
2602
- rawPipelines = freshPipelines;
2603
- const currentValue = document.getElementById('filter-convoy')?.value;
2604
- const currentPipelineValue = document.getElementById('filter-pipeline')?.value;
2605
- populateConvoyFilter(freshConvoys);
2606
- populatePipelineFilter(freshPipelines);
2607
- const sel = document.getElementById('filter-convoy');
2608
- if (sel && currentValue) sel.value = currentValue;
2609
- const pSel = document.getElementById('filter-pipeline');
2610
- if (pSel && currentPipelineValue) pSel.value = currentPipelineValue;
2611
- applyFilters();
2612
- }, 5000);
2613
- }
2614
-
2615
- const selectedConvoy = rawConvoys.find((c) => c.id === document.getElementById('filter-convoy')?.value);
2616
- if (convoyParam === 'active' || (selectedConvoy && selectedConvoy.status === 'running')) {
2617
- startAutoRefresh();
2618
- }
1175
+ document.getElementById('cl-filter-search')?.addEventListener('input', renderConvoyList);
1176
+ document.getElementById('cl-filter-status')?.addEventListener('change', renderConvoyList);
1177
+ document.getElementById('cl-filter-from')?.addEventListener('change', renderConvoyList);
1178
+ document.getElementById('cl-filter-to')?.addEventListener('change', renderConvoyList);
1179
+ document.getElementById('cl-filter-reset')?.addEventListener('click', () => {
1180
+ const s = document.getElementById('cl-filter-search'); if (s) s.value = '';
1181
+ const st = document.getElementById('cl-filter-status'); if (st) st.value = '';
1182
+ const f = document.getElementById('cl-filter-from'); if (f) f.value = '';
1183
+ const t = document.getElementById('cl-filter-to'); if (t) t.value = '';
1184
+ renderConvoyList();
1185
+ });
2619
1186
 
2620
- // ── Export button ─────────────────────────────────────
2621
- document.getElementById('export-btn')?.addEventListener('click', exportData);
1187
+ window.addEventListener('popstate', () => {
1188
+ const params = new URLSearchParams(window.location.search);
1189
+ const c = params.get('convoy');
1190
+ if (c) {
1191
+ loadConvoyDetail(c);
1192
+ const home = document.getElementById('view-home');
1193
+ const detail = document.getElementById('view-convoy-detail');
1194
+ const breadcrumbs = document.getElementById('breadcrumbs');
1195
+ if (home) home.dataset.viewHidden = '';
1196
+ if (detail) delete detail.dataset.viewHidden;
1197
+ if (breadcrumbs) delete breadcrumbs.dataset.viewHidden;
1198
+ document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = 'none');
1199
+ document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = '');
1200
+ } else {
1201
+ showHomeView();
1202
+ }
1203
+ });
2622
1204
 
2623
- // ── Sidebar Navigation ────────────────────────────────
2624
1205
  initSidebarNav();
2625
1206
  }
2626
-
2627
1207
  function initSidebarNav() {
2628
- const links = document.querySelectorAll('.dash-sidebar__link');
2629
- const sections = document.querySelectorAll('[data-nav-section]');
1208
+ const links = document.querySelectorAll(".dash-sidebar__link");
1209
+ const sections = document.querySelectorAll("[data-nav-section]");
2630
1210
 
2631
- // Intersection observer for active state
2632
1211
  const observer = new IntersectionObserver(
2633
1212
  (entries) => {
2634
1213
  entries.forEach((entry) => {
@@ -2636,55 +1215,50 @@ try {
2636
1215
  const id = entry.target.id;
2637
1216
  links.forEach((link) => {
2638
1217
  link.classList.toggle(
2639
- 'dash-sidebar__link--active',
1218
+ "dash-sidebar__link--active",
2640
1219
  link.dataset.section === id
2641
1220
  );
2642
1221
  });
2643
1222
  }
2644
1223
  });
2645
1224
  },
2646
- { rootMargin: '-20% 0px -70% 0px', threshold: 0 }
1225
+ { rootMargin: "-20% 0px -70% 0px", threshold: 0 }
2647
1226
  );
2648
1227
 
2649
1228
  sections.forEach((s) => observer.observe(s));
2650
1229
 
2651
- // Convoy-detail sections that start hidden and need a convoy selected first
2652
- const CONVOY_DETAIL_SECTIONS = ['tasks-section', 'quality-section', 'reliability-section', 'drift-section', 'outputs-section', 'event-timeline-section'];
1230
+ const CONVOY_DETAIL_SECTIONS = ["tasks-section", "quality-section", "reliability-section", "drift-section", "outputs-section", "event-timeline-section"];
2653
1231
 
2654
- // Smooth scroll on click
2655
1232
  links.forEach((link) => {
2656
- link.addEventListener('click', async (e) => {
1233
+ link.addEventListener("click", async (e) => {
2657
1234
  e.preventDefault();
2658
1235
  const sectionId = link.dataset.section;
2659
1236
 
2660
1237
  if (CONVOY_DETAIL_SECTIONS.includes(sectionId)) {
2661
- // Auto-select and load convoy detail if none selected yet
2662
- const convoySelectEl = document.getElementById('convoy-select');
2663
- if (convoySelectEl && !convoySelectEl.value && convoySelectEl.options.length > 1) {
2664
- convoySelectEl.value = convoySelectEl.options[1].value;
2665
- await loadConvoyDetail(convoySelectEl.value);
2666
- }
2667
- } else if (sectionId === 'convoy-section') {
2668
- const convoyFilterEl = document.getElementById('filter-convoy');
2669
- if (convoyFilterEl && !convoyFilterEl.value && convoyFilterEl.options.length > 1) {
2670
- convoyFilterEl.value = convoyFilterEl.options[1].value;
2671
- applyFilters();
2672
- }
2673
- } else if (sectionId === 'convoy-pipeline-section') {
2674
- const pipelineSelect = document.getElementById('filter-pipeline');
2675
- if (pipelineSelect && !pipelineSelect.value && pipelineSelect.options.length > 1) {
2676
- pipelineSelect.value = pipelineSelect.options[1].value;
2677
- applyFilters();
1238
+ const convoyList = window.__DASHBOARD_DATA__?.convoyList ?? [];
1239
+ if (!window.__SELECTED_CONVOY__ && convoyList.length > 0) {
1240
+ showConvoyDetailView(convoyList[0].id, convoyList[0].name || convoyList[0].id);
2678
1241
  }
2679
1242
  }
2680
1243
 
2681
1244
  const target = document.getElementById(sectionId);
2682
1245
  if (target) {
2683
- target.scrollIntoView({ behavior: 'smooth', block: 'start' });
1246
+ target.scrollIntoView({ behavior: "smooth", block: "start" });
2684
1247
  }
2685
1248
  });
2686
1249
  });
1250
+
1251
+ // Set initial nav visibility based on current view
1252
+ const initialParams = new URLSearchParams(window.location.search);
1253
+ if (initialParams.get('convoy')) {
1254
+ document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = 'none');
1255
+ document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = '');
1256
+ } else {
1257
+ document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = 'none');
1258
+ document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = '');
1259
+ }
2687
1260
  }
2688
1261
 
1262
+
2689
1263
  main();
2690
1264
  </script>