@d86e/hive-panel 1.0.23 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/public/panel.js CHANGED
@@ -8,6 +8,7 @@
8
8
  const LANE_ORDER = Object.freeze(["pending", "claimed", "done", "failed"]);
9
9
  const MAX_EVENTS = 80;
10
10
  const DEFAULT_SNAPSHOT_URL = "/api/snapshot";
11
+ const DEFAULT_STATUS_URL = "/api/status";
11
12
  const DEFAULT_ACTIONS_URL = "/api/actions";
12
13
  const DEFAULT_SUPERVISOR_URL = "/api/hive-runner";
13
14
  const DEFAULT_TASKS_URL = "/api/tasks";
@@ -2154,6 +2155,41 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
2154
2155
  .hive-event.is-expanded .hive-event-sentence { flex-basis: 100%; white-space: normal; }
2155
2156
  .hive-event.is-expanded .hive-event-raw { flex-basis: 100%; }
2156
2157
  .hive-limits-source { color: var(--hive-fg-faint); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
2158
+ /* First-paint list skeletons: real chrome, grey rows only inside lists. */
2159
+ .hive-lane-initial { display: flex; flex-direction: column; gap: 6px; padding: 0; }
2160
+ .hive-lane-initial.is-hidden { display: none; }
2161
+ .hive-lane-initial-row { height: 26px; border-radius: var(--hive-radius-sm); background: var(--hive-line-2); opacity: 0.65; }
2162
+ .hive-events-initial { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
2163
+ .hive-events-initial-row { height: 28px; border-radius: var(--hive-radius-sm); background: var(--hive-line-2); opacity: 0.65; }
2164
+ .hive-events-retry { margin: 6px 0 0; }
2165
+ .hive-lane-head .hive-count { min-width: 0; margin-left: 4px; padding: 0; border-radius: 0; background: none; color: var(--hive-fg-faint); font-family: var(--hive-font, inherit); font-size: 10px; font-weight: 500; line-height: 1.4; }
2166
+ .hive-card-check { flex: 0 0 auto; width: 14px; height: 14px; margin: 0 2px 0 0; accent-color: var(--hive-accent); }
2167
+ .hive-lane { position: relative; }
2168
+ .hive-menu { position: absolute; z-index: 30; top: 34px; right: 8px; display: flex; flex-direction: column; min-width: 150px; padding: 4px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-md); background: var(--hive-bg-layer-2); box-shadow: var(--dsw-elevation-panel, 0 8px 22px rgba(0, 0, 0, 0.18)); }
2169
+ .hive-menu.is-hidden { display: none; }
2170
+ .hive-menu-item { padding: 6px 9px; border: 0; border-radius: var(--hive-radius-sm); background: transparent; color: var(--hive-fg-soft); font: inherit; font-size: 11px; text-align: left; cursor: pointer; }
2171
+ .hive-menu-item:hover { background: var(--hive-hover); color: var(--hive-fg); }
2172
+ .hive-menu-item.is-danger { color: var(--hive-danger); }
2173
+ .hive-lane-menu-button { padding: 0 5px; font-size: 14px; line-height: 1.2; }
2174
+ .hive-events-head { position: relative; }
2175
+ .hive-event-check { flex: 0 0 auto; width: 13px; height: 13px; margin: 0 2px 0 0; accent-color: var(--hive-accent); }
2176
+ .hive-event.is-selected { background: var(--hive-selected); }
2177
+ .hive-events-menu { right: 8px; top: 30px; }
2178
+ .hive-events-menu-button { padding: 0 5px; font-size: 14px; line-height: 1.2; }
2179
+ .hive-event-prune { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--hive-line-2); background: var(--hive-bg-layer-1); }
2180
+ .hive-event-prune.is-hidden { display: none; }
2181
+ .hive-event-prune-label { display: inline-flex; align-items: center; gap: 5px; color: var(--hive-fg-soft); font-size: 10px; }
2182
+ .hive-event-prune-input { width: auto; min-width: 160px; padding: 2px 5px; font-size: 10px; }
2183
+ .hive-event-prune-count { color: var(--hive-fg-faint); font-size: 10px; }
2184
+ .hive-event-prune-confirm { padding: 2px 7px; font-size: 10px; }
2185
+ .hive-card-check, .hive-event-check { position: relative; z-index: 2; pointer-events: auto; cursor: pointer; }
2186
+ .hive-menu-selection { padding: 4px 9px 5px; border-bottom: 1px solid var(--hive-line-2); color: var(--hive-fg-faint); font-size: 10px; letter-spacing: 0; }
2187
+ .hive-events-page-error { display: flex; align-items: center; gap: 6px; padding: 6px 2px; color: var(--hive-danger); font-size: 10px; }
2188
+ .hive-events-page-error-reason { color: var(--hive-fg-faint); }
2189
+ .hive-events-page-retry { padding: 1px 6px; font-size: 10px; }
2190
+ .hive-supervisor-inline-toggle { height: auto; min-height: 0; padding: 0 2px; border: 0; background: transparent; color: var(--hive-fg-soft); font-size: 12px; line-height: 1; }
2191
+ .hive-supervisor-inline-toggle:hover { background: transparent; color: var(--hive-fg); }
2192
+ .hive-supervisor-inline-toggle.is-hidden { display: none; }
2157
2193
  `;
2158
2194
 
2159
2195
  const LANE_LABEL_KEYS = Object.freeze({
@@ -2185,11 +2221,29 @@ export const messages = Object.freeze({
2185
2221
  "pane.board": "Task board",
2186
2222
  "pane.events": "events",
2187
2223
  "board.filtersAria": "Filter by state",
2224
+ "board.more": "More actions",
2225
+ "board.selectTask": "Select task",
2226
+ "board.selectAll": "Select all",
2227
+ "board.clearSelection": "Clear selection",
2228
+ "board.deleteSelected": "Delete selected",
2229
+ "board.deleteConfirm": "Delete {count} selected tasks? This cannot be undone.",
2230
+ "board.claimedNoDelete": "In-progress tasks cannot be deleted; abort or wait for them to finish.",
2231
+ "batch.skippedClaimed": "{count} in-progress tasks skipped",
2232
+ "events.selectAll": "Select all",
2233
+ "events.clearSelection": "Clear selection",
2234
+ "events.selectionCount": "Selected {count}",
2235
+ "events.deleteSelected": "Delete selected events",
2236
+ "events.deleteConfirm": "Delete {count} selected events? This cannot be undone.",
2237
+ "events.pruneBefore": "Delete events before",
2238
+ "events.pruneCount": "Will delete {count} events before {time}",
2239
+ "events.pruneConfirm": "Delete {count} events before {time}? This cannot be undone.",
2240
+ "batch.running": "Applying...",
2241
+ "batch.summary": "Succeeded {ok}, failed {fail}",
2242
+ "batch.failed": "Batch failed",
2243
+ "batch.unavailable": "API unavailable ({status})",
2188
2244
  "board.loadMore": "Load more",
2189
- "board.latest": "Back to latest",
2190
2245
  "board.recycled": "Recycled {count} older tasks",
2191
2246
  "board.reloadLatest": "Reload latest",
2192
- "board.latestAria": "Scroll back to the newest tasks",
2193
2247
  "board.loading": "Loading…",
2194
2248
  "board.loadFailed": "Could not load more",
2195
2249
  "board.retry": "Retry",
@@ -2228,6 +2282,8 @@ export const messages = Object.freeze({
2228
2282
  "loading.slow": "Loading · waited {seconds}s",
2229
2283
  "loading.failed": "Could not load",
2230
2284
  "loading.retry": "Retry",
2285
+ "loading.tasks": "Loading…",
2286
+ "loading.events": "Loading…",
2231
2287
  "loading.retryAria": "Retry loading the board",
2232
2288
  "loading.aria": "Loading the board",
2233
2289
  "agents.openAria": "Open agent",
@@ -2296,8 +2352,12 @@ export const messages = Object.freeze({
2296
2352
  "events.loaded": "Loaded {loaded} / {total}",
2297
2353
  "events.filterAria": "Filter events by kind",
2298
2354
  "events.filterAll": "All kinds",
2355
+ "events.filterOther": "Other",
2356
+ "events.actor.legacy": "Agent",
2299
2357
  "events.recycled": "Recycled {count} older events",
2300
2358
  "events.loadFailed": "Could not load events",
2359
+ "events.pageFailed": "Older events failed to load",
2360
+ "events.retry": "Retry",
2301
2361
  "events.details": "Details",
2302
2362
  "events.field.time": "Time",
2303
2363
  "events.field.actor": "Who",
@@ -2352,8 +2412,11 @@ export const messages = Object.freeze({
2352
2412
  "supervisor.tooltipError": "Last error: {error}",
2353
2413
  "supervisor.scopeBlockedTitle": "Cross-repository call blocked",
2354
2414
  "supervisor.scopeBlocked": "{tool} asked for repository {repo}, but this Session only controls {cwd}. The call was rejected.",
2415
+ "supervisor.pause": "pause",
2355
2416
  "supervisor.resume": "resume",
2417
+ "supervisor.pauseAria": "Pause the supervisor for {repo}",
2356
2418
  "supervisor.resumeAria": "Resume the supervisor for {repo}",
2419
+ "supervisor.pauseFailed": "Could not pause the supervisor",
2357
2420
  "supervisor.resumeFailed": "Could not resume the supervisor",
2358
2421
  "limits.open": "Settings",
2359
2422
  "limits.openAria": "Open agent concurrency settings",
@@ -2539,11 +2602,29 @@ export const messages = Object.freeze({
2539
2602
  "pane.board": "任务看板",
2540
2603
  "pane.events": "事件",
2541
2604
  "board.filtersAria": "按状态筛选",
2605
+ "board.more": "更多操作",
2606
+ "board.selectTask": "选择任务",
2607
+ "board.selectAll": "全选",
2608
+ "board.clearSelection": "清除选择",
2609
+ "board.deleteSelected": "删除所选",
2610
+ "board.deleteConfirm": "删除所选的 {count} 个任务?不可撤销。",
2611
+ "board.claimedNoDelete": "进行中的任务不能删除,请先中止或等它完成",
2612
+ "batch.skippedClaimed": "{count} 条进行中被跳过",
2613
+ "events.selectAll": "全选",
2614
+ "events.clearSelection": "清除选择",
2615
+ "events.selectionCount": "已选 {count}",
2616
+ "events.deleteSelected": "删除所选事件",
2617
+ "events.deleteConfirm": "删除所选的 {count} 条事件?不可撤销。",
2618
+ "events.pruneBefore": "删除此时间之前的事件",
2619
+ "events.pruneCount": "将删除 {time} 之前的 {count} 条事件",
2620
+ "events.pruneConfirm": "删除 {time} 之前的 {count} 条事件?不可撤销。",
2621
+ "batch.running": "处理中…",
2622
+ "batch.summary": "成功 {ok},失败 {fail}",
2623
+ "batch.failed": "批量操作失败",
2624
+ "batch.unavailable": "接口不可用({status})",
2542
2625
  "board.loadMore": "加载更多",
2543
- "board.latest": "回到最新",
2544
2626
  "board.recycled": "已回收更早的 {count} 条",
2545
2627
  "board.reloadLatest": "重新加载",
2546
- "board.latestAria": "滚动回最新任务",
2547
2628
  "board.loading": "加载中…",
2548
2629
  "board.loadFailed": "加载失败",
2549
2630
  "board.retry": "重试",
@@ -2582,6 +2663,8 @@ export const messages = Object.freeze({
2582
2663
  "loading.slow": "正在读取 · 已等 {seconds}s",
2583
2664
  "loading.failed": "读取失败",
2584
2665
  "loading.retry": "重试",
2666
+ "loading.tasks": "加载中…",
2667
+ "loading.events": "加载中…",
2585
2668
  "loading.retryAria": "重试读取看板",
2586
2669
  "loading.aria": "正在读取看板",
2587
2670
  "agents.openAria": "打开智能体",
@@ -2650,8 +2733,12 @@ export const messages = Object.freeze({
2650
2733
  "events.loaded": "已加载 {loaded} / {total}",
2651
2734
  "events.filterAria": "按事件类型筛选",
2652
2735
  "events.filterAll": "全部事件",
2736
+ "events.filterOther": "其它",
2737
+ "events.actor.legacy": "智能体",
2653
2738
  "events.recycled": "已回收更早的 {count} 条",
2654
2739
  "events.loadFailed": "事件加载失败",
2740
+ "events.pageFailed": "更早的事件加载失败",
2741
+ "events.retry": "重试",
2655
2742
  "events.details": "详情",
2656
2743
  "events.field.time": "时间",
2657
2744
  "events.field.actor": "谁",
@@ -2706,8 +2793,11 @@ export const messages = Object.freeze({
2706
2793
  "supervisor.tooltipError": "最近错误:{error}",
2707
2794
  "supervisor.scopeBlockedTitle": "跨仓库调用被拒绝",
2708
2795
  "supervisor.scopeBlocked": "{tool} 发起跨仓库请求:仓库 {repo},但本会话只允许操作 {cwd};该调用已被拒绝。",
2796
+ "supervisor.pause": "暂停",
2709
2797
  "supervisor.resume": "恢复",
2798
+ "supervisor.pauseAria": "暂停 {repo} 的 supervisor",
2710
2799
  "supervisor.resumeAria": "恢复 {repo} 的 supervisor",
2800
+ "supervisor.pauseFailed": "暂停 supervisor 失败",
2711
2801
  "supervisor.resumeFailed": "恢复 supervisor 失败",
2712
2802
  "limits.open": "设置",
2713
2803
  "limits.openAria": "打开智能体并发上限设置",
@@ -3574,6 +3664,10 @@ function normalizeSupervisorStatus(payload) {
3574
3664
  lastError,
3575
3665
  roles: roleRows,
3576
3666
  workers: normalizeSupervisorWorkers(source),
3667
+ workersKnown: Array.isArray(source.workers),
3668
+ unmanaged: source.unmanaged === true || source.waiting === "no-queen-session",
3669
+ waiting: asString(source.waiting),
3670
+ queenSessionId: asString(source.queenSessionId),
3577
3671
  });
3578
3672
  }
3579
3673
  const result = [...rows.values()].sort((left, right) => left.repo.localeCompare(right.repo));
@@ -4010,11 +4104,13 @@ export function mount(root, options = {}) {
4010
4104
  const opts = isRecord(options) ? options : {};
4011
4105
  const view = doc.defaultView || globalThis;
4012
4106
  const snapshotUrl = asString(opts.snapshotUrl) || DEFAULT_SNAPSHOT_URL;
4107
+ const statusUrl = asString(opts.statusUrl) || DEFAULT_STATUS_URL;
4013
4108
  const supervisorUrl = asString(opts.supervisorUrl) || DEFAULT_SUPERVISOR_URL;
4014
4109
  const actionsUrl = (asString(opts.actionsUrl) || DEFAULT_ACTIONS_URL).replace(/\/+$/, "");
4015
4110
  const tasksUrl = asString(opts.tasksUrl) || DEFAULT_TASKS_URL;
4016
4111
  const taskUrl = asString(opts.taskUrl) || DEFAULT_TASK_URL;
4017
4112
  const eventsUrl = asString(opts.eventsUrl) || DEFAULT_EVENTS_URL;
4113
+ const batchUrl = asString(opts.batchUrl) || "/api/action";
4018
4114
 
4019
4115
  const requestedInterval = Number(opts.intervalMs);
4020
4116
  const intervalMs =
@@ -4097,6 +4193,14 @@ export function mount(root, options = {}) {
4097
4193
  let loadingActive = false;
4098
4194
  let loadingTicks = 0;
4099
4195
  let loadingTimer = null;
4196
+ let statusData = null;
4197
+ let initialDataLoaded = false;
4198
+ let initialDataPromise = null;
4199
+ const taskSlices = { pending: [], claimed: [], done: [], failed: [] };
4200
+ const taskSlicePages = {};
4201
+ const selectedTasks = new Set();
4202
+ const selectedEvents = new Set();
4203
+ let batchBusy = false;
4100
4204
  let loadingPanelError = "";
4101
4205
  let drawerNode = null;
4102
4206
  let drawerState = null;
@@ -4138,6 +4242,10 @@ export function mount(root, options = {}) {
4138
4242
  signature: "",
4139
4243
  expanded: new Set(),
4140
4244
  rowNodes: new Map(),
4245
+ kindCounts: new Map(),
4246
+ pageError: "",
4247
+ noMore: false,
4248
+ pageFailureCount: 0,
4141
4249
  };
4142
4250
  let initBusy = false;
4143
4251
  let initOutput = null;
@@ -4183,15 +4291,21 @@ export function mount(root, options = {}) {
4183
4291
  const supervisorInlineLabel = element(doc, "span", "hive-supervisor-inline-label", translate("supervisor.label"));
4184
4292
  const supervisorInlineSep = element(doc, "span", "hive-supervisor-inline-sep", "·");
4185
4293
  const supervisorInlineState = element(doc, "span", "hive-supervisor-inline-state", "");
4186
- const supervisorInlineResume = element(doc, "button", "hive-btn hive-supervisor-inline-resume is-hidden", translate("supervisor.resume"));
4187
- setAttr(supervisorInlineResume, "type", "button");
4188
- supervisorInlineResume.addEventListener("click", () => {
4189
- if (supervisorInlineRow) void resumeSupervisor(supervisorInlineRow, supervisorInlineResume);
4294
+ const supervisorInlineToggle = element(doc, "button", "hive-btn hive-supervisor-inline-toggle is-hidden", "");
4295
+ setAttr(supervisorInlineToggle, "type", "button");
4296
+ setAttr(supervisorInlineToggle, "data-next-action", "pause");
4297
+ supervisorInlineToggle.addEventListener("click", () => {
4298
+ if (!supervisorInlineRow) return;
4299
+ if (supervisorInlineToggle.getAttribute("data-next-action") === "resume") {
4300
+ void resumeSupervisor(supervisorInlineRow, supervisorInlineToggle);
4301
+ } else {
4302
+ void pauseSupervisor(supervisorInlineRow, supervisorInlineToggle);
4303
+ }
4190
4304
  });
4191
4305
  supervisorInline.appendChild(supervisorInlineLabel);
4192
4306
  supervisorInline.appendChild(supervisorInlineSep);
4193
4307
  supervisorInline.appendChild(supervisorInlineState);
4194
- supervisorInline.appendChild(supervisorInlineResume);
4308
+ supervisorInline.appendChild(supervisorInlineToggle);
4195
4309
  bar.appendChild(supervisorInline);
4196
4310
 
4197
4311
  const statsNode = element(doc, "div", "hive-stats");
@@ -4341,15 +4455,7 @@ export function mount(root, options = {}) {
4341
4455
  stage.appendChild(stageChips);
4342
4456
  stage.appendChild(filterEmpty);
4343
4457
  stage.appendChild(lanesNode);
4344
- const skeletonNode = element(doc, "div", "hive-skeleton");
4345
- for (const lane of LANE_ORDER) {
4346
- const laneNode = element(doc, "section", "hive-skeleton-lane");
4347
- laneNode.appendChild(element(doc, "div", "hive-skeleton-head", laneLabel(lane)));
4348
- for (let row = 0; row < 3; row += 1) {
4349
- laneNode.appendChild(element(doc, "div", "hive-skeleton-row", ""));
4350
- }
4351
- skeletonNode.appendChild(laneNode);
4352
- }
4458
+ const skeletonNode = element(doc, "div", "hive-skeleton is-hidden");
4353
4459
  const loadingPanel = element(doc, "div", "hive-loading is-hidden");
4354
4460
  setAttr(loadingPanel, "role", "status");
4355
4461
  setAttr(loadingPanel, "aria-live", "polite");
@@ -4381,8 +4487,122 @@ export function mount(root, options = {}) {
4381
4487
  eventsHead.appendChild(eventsCount);
4382
4488
  eventsHead.appendChild(eventsFilter);
4383
4489
  eventsHead.appendChild(eventsRecycle);
4490
+ const eventsMoreButton = element(doc, "button", "hive-btn hive-btn-ghost hive-events-menu-button", "…");
4491
+ setAttr(eventsMoreButton, "type", "button");
4492
+ setAttr(eventsMoreButton, "title", translate("board.more"));
4493
+ setAttr(eventsMoreButton, "aria-label", translate("board.more"));
4494
+ setAttr(eventsMoreButton, "aria-expanded", "false");
4495
+ eventsHead.appendChild(eventsMoreButton);
4496
+ const eventsMenu = element(doc, "div", "hive-menu hive-events-menu is-hidden");
4497
+ const eventsPrune = element(doc, "div", "hive-event-prune is-hidden");
4498
+ const pruneLabel = element(doc, "label", "hive-event-prune-label");
4499
+ pruneLabel.appendChild(element(doc, "span", null, translate("events.pruneBefore")));
4500
+ const pruneInput = element(doc, "input", "hive-event-prune-input");
4501
+ setAttr(pruneInput, "type", "datetime-local");
4502
+ pruneLabel.appendChild(pruneInput);
4503
+ const pruneCount = element(doc, "div", "hive-event-prune-count", "");
4504
+ const pruneConfirm = element(doc, "button", "hive-btn hive-btn-danger hive-event-prune-confirm", translate("events.pruneBefore"));
4505
+ setAttr(pruneConfirm, "type", "button");
4506
+ eventsPrune.appendChild(pruneLabel);
4507
+ eventsPrune.appendChild(pruneCount);
4508
+ eventsPrune.appendChild(pruneConfirm);
4509
+ const eventMenuAction = (labelKey, handler, danger = false) => {
4510
+ const button = element(doc, "button", "hive-menu-item" + (danger ? " is-danger" : ""), translate(labelKey));
4511
+ setAttr(button, "type", "button");
4512
+ button.addEventListener("click", () => {
4513
+ eventsMenu.className = "hive-menu hive-events-menu is-hidden";
4514
+ setAttr(eventsMoreButton, "aria-expanded", "false");
4515
+ handler();
4516
+ });
4517
+ eventsMenu.appendChild(button);
4518
+ return button;
4519
+ };
4520
+ const eventsSelectionCount = element(doc, "div", "hive-menu-selection", "");
4521
+ eventsMenu.appendChild(eventsSelectionCount);
4522
+ const eventSelectAllButton = eventMenuAction("events.selectAll", () => {
4523
+ for (const event of eventState.items) selectedEvents.add(eventKey(event));
4524
+ syncEventSelectionChecks();
4525
+ updateEventSelectionUi();
4526
+ });
4527
+ const eventClearSelectionButton = eventMenuAction("events.clearSelection", () => {
4528
+ selectedEvents.clear();
4529
+ syncEventSelectionChecks();
4530
+ updateEventSelectionUi();
4531
+ });
4532
+ const eventDeleteButton = eventMenuAction("events.deleteSelected", () => {
4533
+ const keys = [...selectedEvents];
4534
+ if (keys.length === 0) return;
4535
+ if (!confirmImpl || !confirmImpl(translate("events.deleteConfirm").replace("{count}", String(keys.length)))) return;
4536
+ selectedEvents.clear();
4537
+ updateEventSelectionUi();
4538
+ void runBatch("events-delete", { ids: keys, keys });
4539
+ }, true);
4540
+ eventMenuAction("events.pruneBefore", () => {
4541
+ eventsPrune.className = "hive-event-prune";
4542
+ pruneInput.value = "";
4543
+ pruneCount.textContent = translate("events.pruneCount").replace("{count}", "0").replace("{time}", "—");
4544
+ focusNode(pruneInput);
4545
+ });
4546
+ function updateEventSelectionUi() {
4547
+ const count = selectedEvents.size;
4548
+ eventsSelectionCount.textContent = translate("events.selectionCount").replace("{count}", String(count));
4549
+ eventDeleteButton.disabled = count === 0;
4550
+ eventSelectAllButton.disabled = eventState.items.length === 0;
4551
+ eventClearSelectionButton.disabled = count === 0;
4552
+ }
4553
+ function syncEventSelectionChecks() {
4554
+ for (const [key, entry] of eventState.rowNodes) {
4555
+ const check = (entry.row.children || []).find((child) => String(child.className).split(/\s+/).includes("hive-event-check"));
4556
+ if (!check) continue;
4557
+ const selected = selectedEvents.has(key);
4558
+ check.checked = selected;
4559
+ entry.row.className = "hive-event" + (entry.details && entry.details.open ? " is-expanded" : "") + (selected ? " is-selected" : "");
4560
+ }
4561
+ }
4562
+ eventsMoreButton.addEventListener("click", () => {
4563
+ const open = eventsMenu.className.includes("is-hidden");
4564
+ eventsMenu.className = "hive-menu hive-events-menu" + (open ? "" : " is-hidden");
4565
+ setAttr(eventsMoreButton, "aria-expanded", open ? "true" : "false");
4566
+ if (open) updateEventSelectionUi();
4567
+ });
4568
+ const pruneBefore = () => {
4569
+ const value = String(pruneInput.value || "");
4570
+ if (!value) return null;
4571
+ const time = Date.parse(value);
4572
+ return Number.isFinite(time) ? time : null;
4573
+ };
4574
+ pruneInput.addEventListener("input", () => {
4575
+ const time = pruneBefore();
4576
+ if (time === null) {
4577
+ pruneCount.textContent = translate("events.pruneCount").replace("{count}", "0").replace("{time}", "—");
4578
+ return;
4579
+ }
4580
+ const count = eventState.items.filter((event) => {
4581
+ const ts = Date.parse(event.ts);
4582
+ return Number.isFinite(ts) && ts < time;
4583
+ }).length;
4584
+ pruneCount.textContent = translate("events.pruneCount").replace("{count}", String(count)).replace("{time}", new Date(time).toLocaleString());
4585
+ });
4586
+ pruneConfirm.addEventListener("click", () => {
4587
+ const time = pruneBefore();
4588
+ if (time === null) return;
4589
+ const count = eventState.items.filter((event) => {
4590
+ const ts = Date.parse(event.ts);
4591
+ return Number.isFinite(ts) && ts < time;
4592
+ }).length;
4593
+ const message = translate("events.pruneConfirm").replace("{count}", String(count)).replace("{time}", new Date(time).toLocaleString());
4594
+ if (!confirmImpl || !confirmImpl(message)) return;
4595
+ eventsPrune.className = "hive-event-prune is-hidden";
4596
+ void runBatch("events-prune", { before: new Date(time).toISOString() });
4597
+ });
4598
+ eventsHead.appendChild(eventsMenu);
4384
4599
  const eventsList = element(doc, "div", "hive-scroll hive-event-list");
4600
+ const eventsSkeleton = element(doc, "div", "hive-events-initial");
4601
+ for (let index = 0; index < 3; index += 1) {
4602
+ eventsSkeleton.appendChild(element(doc, "div", "hive-events-initial-row", ""));
4603
+ }
4385
4604
  eventsDrawer.appendChild(eventsHead);
4605
+ eventsDrawer.appendChild(eventsPrune);
4386
4606
  eventsDrawer.appendChild(eventsList);
4387
4607
  eventsFilter.addEventListener("change", () => {
4388
4608
  eventState.filter = eventsFilter.value || "";
@@ -4393,6 +4613,9 @@ export function mount(root, options = {}) {
4393
4613
  eventState.signature = "";
4394
4614
  eventState.expanded.clear();
4395
4615
  eventState.rowNodes.clear();
4616
+ eventState.pageError = "";
4617
+ eventState.noMore = false;
4618
+ eventState.pageFailureCount = 0;
4396
4619
  eventsList.scrollTop = 0;
4397
4620
  void loadEventPage(true);
4398
4621
  });
@@ -7077,7 +7300,8 @@ function renderMarkdownInto(doc, host, source) {
7077
7300
  supervisorInline.className = "hive-supervisor-inline is-hidden";
7078
7301
  supervisorInlineState.className = "hive-supervisor-inline-state";
7079
7302
  supervisorInlineState.textContent = "";
7080
- supervisorInlineResume.className = "hive-btn hive-supervisor-inline-resume is-hidden";
7303
+ supervisorInlineToggle.className = "hive-btn hive-supervisor-inline-toggle is-hidden";
7304
+ setAttr(supervisorInlineToggle, "data-next-action", "pause");
7081
7305
  supervisorInlineLabel.textContent = translate("supervisor.label");
7082
7306
  supervisorInlineSep.textContent = "·";
7083
7307
  if (!lastModel) return;
@@ -7127,11 +7351,14 @@ function renderMarkdownInto(doc, host, source) {
7127
7351
  setAttr(supervisorInline, "title", tooltip);
7128
7352
  setAttr(supervisorInline, "aria-label", tooltip);
7129
7353
 
7130
- if (paused && row) {
7131
- const aria = translate("supervisor.resumeAria").replace("{repo}", row.repo);
7132
- supervisorInlineResume.className = "hive-btn hive-supervisor-inline-resume";
7133
- setAttr(supervisorInlineResume, "title", aria);
7134
- setAttr(supervisorInlineResume, "aria-label", aria);
7354
+ if (row) {
7355
+ const nextAction = paused ? "resume" : "pause";
7356
+ supervisorInlineToggle.className = "hive-btn hive-supervisor-inline-toggle";
7357
+ supervisorInlineToggle.textContent = translate(paused ? "supervisor.resume" : "supervisor.pause");
7358
+ setAttr(supervisorInlineToggle, "data-next-action", nextAction);
7359
+ const aria = translate(paused ? "supervisor.resumeAria" : "supervisor.pauseAria").replace("{repo}", row.repo);
7360
+ setAttr(supervisorInlineToggle, "title", aria);
7361
+ setAttr(supervisorInlineToggle, "aria-label", aria);
7135
7362
  }
7136
7363
  }
7137
7364
  function setSupervisorData(rows) {
@@ -7204,6 +7431,32 @@ function renderMarkdownInto(doc, host, source) {
7204
7431
  }
7205
7432
  }
7206
7433
 
7434
+ async function pauseSupervisor(row, button) {
7435
+ if (destroyed || !fetchImpl) return;
7436
+ if (button) button.disabled = true;
7437
+ try {
7438
+ const response = await fetchImpl(supervisorEndpoint("pause"), {
7439
+ method: "POST",
7440
+ headers: { "content-type": "application/json", accept: "application/json" },
7441
+ body: JSON.stringify({ repo: row.repo }),
7442
+ });
7443
+ if (!response || response.ok === false) throw new Error("supervisor pause failed");
7444
+ let payload = null;
7445
+ try {
7446
+ payload = await response.json();
7447
+ } catch {
7448
+ payload = null;
7449
+ }
7450
+ if (payload && payload.ok === false) throw new Error("supervisor pause failed");
7451
+ await refreshSupervisor(true);
7452
+ } catch (error) {
7453
+ if (button) button.disabled = false;
7454
+ if (!destroyed) {
7455
+ showToast("error", translate("supervisor.pauseFailed"), actionErrorDetail(error) || translate("supervisor.pauseFailed"));
7456
+ }
7457
+ }
7458
+ }
7459
+
7207
7460
  async function resumeSupervisor(row, button) {
7208
7461
  if (destroyed || !fetchImpl) return;
7209
7462
  if (button) button.disabled = true;
@@ -7293,16 +7546,6 @@ function renderMarkdownInto(doc, host, source) {
7293
7546
  const banner = element(doc, "div", "hive-freeze-banner");
7294
7547
  setAttr(banner, "role", "status");
7295
7548
  banner.appendChild(element(doc, "span", "hive-freeze-text", translate("mode.freeze.banner")));
7296
- if (model.writable) {
7297
- const button = element(doc, "button", "hive-btn", translate("action.unfreeze"));
7298
- setAttr(button, "type", "button");
7299
- setAttr(button, "title", translate("help.action.unfreeze"));
7300
- setAttr(button, "aria-label", translate("help.action.unfreeze"));
7301
- button.addEventListener("click", () => {
7302
- void postAction("mode", { mode: "free", reason: "panel" });
7303
- });
7304
- banner.appendChild(button);
7305
- }
7306
7549
  freezeSlot.appendChild(banner);
7307
7550
  }
7308
7551
 
@@ -7325,55 +7568,261 @@ function renderMarkdownInto(doc, host, source) {
7325
7568
  function renderAgents(model) {
7326
7569
  if (model.initialised === false) {
7327
7570
  agentsCount.className = "hive-stat hive-agent-count is-hidden";
7328
- agentsCount.textContent = translate("pane.agents") + " 0";
7571
+ agentsCount.textContent = "0";
7329
7572
  agentsCount._agent = null;
7330
7573
  agentsCount.disabled = true;
7331
7574
  return;
7332
7575
  }
7333
7576
  const identities = model.agents.length;
7334
7577
  const row = currentSupervisorRow();
7335
- const workers = supervisorWorkerCount(row);
7336
- const running = workers !== null ? workers : identities;
7578
+ const managed = Boolean(row && row.unmanaged !== true && row.waiting !== "no-queen-session");
7579
+ const hasWorkers = Boolean(managed && row.workersKnown === true && Array.isArray(row.workers));
7580
+ const workers = hasWorkers ? row.workers.length : null;
7337
7581
  const claimed = asCount(model.stats.byState.claimed, (model.lanes.claimed || []).length);
7338
7582
  const waitingToReclaim = workers === 0 && claimed > 0;
7339
7583
  agentsCount.className = "hive-stat hive-agent-count";
7340
- agentsCount.textContent = waitingToReclaim
7341
- ? translate("agents.waitingReclaim").replace("{count}", String(claimed))
7342
- : translate("pane.agents") + " " + String(running);
7343
- const first = identities > 0 ? model.agents[0] : null;
7344
- agentsCount._agent = first;
7345
7584
  agentsCount.disabled = false;
7585
+ agentsCount._agent = identities > 0 ? model.agents[0] : null;
7586
+ if (!hasWorkers) {
7587
+ agentsCount.textContent = "—";
7588
+ const label = model.boardError ? model.boardError : "";
7589
+ setAttr(agentsCount, "title", label);
7590
+ setAttr(agentsCount, "aria-label", label);
7591
+ return;
7592
+ }
7593
+ agentsCount.textContent = String(workers);
7346
7594
  const message = waitingToReclaim
7347
7595
  ? translate("agents.waitingReclaimTooltip").replace("{count}", String(claimed))
7348
- : workers !== null
7349
- ? translate("agents.runningTooltip")
7350
- .replace("{running}", String(running))
7351
- .replace("{identities}", String(identities))
7352
- : translate("agents.fallbackTooltip").replace("{identities}", String(identities));
7596
+ : translate("agents.runningTooltip")
7597
+ .replace("{running}", String(workers))
7598
+ .replace("{identities}", String(identities));
7353
7599
  const label = model.boardError ? message + " · " + model.boardError : message;
7354
7600
  setAttr(agentsCount, "title", label);
7355
7601
  setAttr(agentsCount, "aria-label", label);
7356
7602
  }
7357
7603
 
7604
+ function selectedCount() {
7605
+ return selectedTasks.size + selectedEvents.size;
7606
+ }
7607
+
7608
+ function setBatchBusyState(busy) {
7609
+ for (const state of laneRenderState.values()) {
7610
+ if (!state.menu) continue;
7611
+ for (const child of state.menu.children || []) {
7612
+ if ("disabled" in child) child.disabled = busy;
7613
+ }
7614
+ }
7615
+ if (typeof eventSelectAllButton !== "undefined") {
7616
+ eventSelectAllButton.disabled = busy || eventState.items.length === 0;
7617
+ eventClearSelectionButton.disabled = busy || selectedEvents.size === 0;
7618
+ eventDeleteButton.disabled = busy || selectedEvents.size === 0;
7619
+ pruneConfirm.disabled = busy;
7620
+ }
7621
+ }
7622
+
7623
+ async function readBatchResponse(response) {
7624
+ const status = Number(response && response.status) || 0;
7625
+ const contentType = response && response.headers && typeof response.headers.get === "function"
7626
+ ? String(response.headers.get("content-type") || "")
7627
+ : "";
7628
+ let text = "";
7629
+ if (response && typeof response.text === "function") {
7630
+ try {
7631
+ text = await response.text();
7632
+ } catch {
7633
+ text = "";
7634
+ }
7635
+ }
7636
+ if (text !== "") {
7637
+ if (contentType !== "" && !contentType.includes("json")) {
7638
+ return { status, text, invalid: true };
7639
+ }
7640
+ try {
7641
+ return { status, data: JSON.parse(text) };
7642
+ } catch {
7643
+ return { status, text, invalid: true };
7644
+ }
7645
+ }
7646
+ if (response && typeof response.json === "function") {
7647
+ try {
7648
+ return { status, data: await response.json() };
7649
+ } catch {
7650
+ return { status, text: "", invalid: true };
7651
+ }
7652
+ }
7653
+ return { status, text: "", invalid: true };
7654
+ }
7655
+
7656
+ async function fallbackTaskBatch(op, payload) {
7657
+ if (op !== "tasks-rm") return null;
7658
+ const ids = Array.isArray(payload.ids) ? payload.ids : [];
7659
+ const results = [];
7660
+ for (const id of ids) {
7661
+ const result = await requestAction("remove", { id });
7662
+ results.push({ id, ok: result.ok === true, error: result.ok ? "" : actionErrorDetail(result.error) });
7663
+ }
7664
+ return results;
7665
+ }
7666
+
7667
+ function taskStateById(id) {
7668
+ const wanted = String(id);
7669
+ for (const lane of LANE_ORDER) {
7670
+ const task = (taskSlices[lane] || []).find((entry) => String(entry.id) === wanted);
7671
+ if (task) return String(task.state || lane);
7672
+ }
7673
+ if (lastModel) {
7674
+ for (const lane of LANE_ORDER) {
7675
+ const card = ((lastModel.lanes && lastModel.lanes[lane]) || []).find((entry) => String(entry.id) === wanted);
7676
+ if (card) return String(card.state || lane);
7677
+ }
7678
+ const task = (lastModel.taskList || []).find((entry) => String(entry.id) === wanted);
7679
+ if (task) return String(task.state || "pending");
7680
+ }
7681
+ return "";
7682
+ }
7683
+
7684
+ function batchSummaryText(okCount, failCount, skipped) {
7685
+ let text = translate("batch.summary").replace("{ok}", String(okCount)).replace("{fail}", String(failCount));
7686
+ if (skipped > 0) text += " · " + translate("batch.skippedClaimed").replace("{count}", String(skipped));
7687
+ return text;
7688
+ }
7689
+
7690
+ async function runBatch(op, payload, laneNames = []) {
7691
+ if (batchBusy || !fetchImpl) return;
7692
+ batchBusy = true;
7693
+ setBatchBusyState(true);
7694
+ let skippedClaimed = 0;
7695
+ try {
7696
+ if (op === "tasks-rm" && Array.isArray(payload.ids)) {
7697
+ const deletable = [];
7698
+ for (const id of payload.ids) {
7699
+ if (taskStateById(id) === "claimed") skippedClaimed += 1;
7700
+ else deletable.push(id);
7701
+ }
7702
+ payload = { ...payload, ids: deletable };
7703
+ if (deletable.length === 0) {
7704
+ showToast(skippedClaimed > 0 ? "error" : "success", batchSummaryText(0, 0, skippedClaimed), "");
7705
+ return;
7706
+ }
7707
+ }
7708
+ let status = 0;
7709
+ let results = null;
7710
+ try {
7711
+ const response = await fetchImpl(batchUrl, {
7712
+ method: "POST",
7713
+ headers: { "content-type": "application/json", accept: "application/json" },
7714
+ body: JSON.stringify({ op, ...payload }),
7715
+ });
7716
+ status = Number(response && response.status) || 0;
7717
+ const parsed = await readBatchResponse(response);
7718
+ if (!response || response.ok === false || parsed.invalid || !parsed.data) {
7719
+ if (status === 404 || status === 405 || status === 501 || parsed.invalid) {
7720
+ results = await fallbackTaskBatch(op, payload);
7721
+ if (results === null) {
7722
+ const error = new Error("batch endpoint unavailable");
7723
+ error.unavailable = true;
7724
+ error.status = status;
7725
+ error.detail = asString(parsed.text || (parsed.data && parsed.data.error));
7726
+ throw error;
7727
+ }
7728
+ } else {
7729
+ throw new Error("batch failed");
7730
+ }
7731
+ } else {
7732
+ results = Array.isArray(parsed.data.results) ? parsed.data.results : [];
7733
+ }
7734
+ } catch (error) {
7735
+ if (error && error.unavailable) throw error;
7736
+ if (status === 404 || status === 405 || status === 501 || /not found/i.test(String(error && error.message))) {
7737
+ results = await fallbackTaskBatch(op, payload);
7738
+ if (results === null) {
7739
+ const unavailable = new Error("batch endpoint unavailable");
7740
+ unavailable.unavailable = true;
7741
+ unavailable.status = status;
7742
+ throw unavailable;
7743
+ }
7744
+ } else {
7745
+ throw error;
7746
+ }
7747
+ }
7748
+ const failures = (results || []).filter((entry) => entry && entry.ok === false);
7749
+ const okCount = (results || []).filter((entry) => entry && entry.ok === true).length;
7750
+ const summary = batchSummaryText(okCount, failures.length, skippedClaimed);
7751
+ const detail = failures.map((entry) => asString(entry.id || entry.key || "") + ": " + asString(entry.error || entry.stderr || "")).filter(Boolean).join("; ");
7752
+ showToast(failures.length > 0 ? "error" : "success", summary, detail);
7753
+ if (op.startsWith("events-")) {
7754
+ await loadInitialEvents();
7755
+ } else if (laneNames.length > 0) {
7756
+ await Promise.all(laneNames.map((lane) => loadInitialLane(lane)));
7757
+ }
7758
+ } catch (error) {
7759
+ if (error && error.unavailable) {
7760
+ showToast("error", translate("batch.unavailable").replace("{status}", String(error.status || "?")), asString(error.detail || ""));
7761
+ } else {
7762
+ showToast("error", translate("batch.failed"), actionErrorDetail(error));
7763
+ }
7764
+ reportError(error);
7765
+ } finally {
7766
+ batchBusy = false;
7767
+ setBatchBusyState(false);
7768
+ }
7769
+ }
7770
+
7358
7771
  function renderCard(card, lane, existing) {
7359
7772
  const node = existing || element(doc, "article", "hive-card");
7360
7773
  const title = card.title || translate("card.untitled");
7361
7774
  if (!existing) {
7362
7775
  setAttr(node, "tabindex", "0");
7363
7776
  setAttr(node, "role", "button");
7364
- node.addEventListener("click", () => {
7777
+ node.addEventListener("click", (event) => {
7778
+ const target = event && event.target;
7779
+ if (target && (target === node._hiveCheck || String(target.className || "").includes("hive-card-check"))) return;
7365
7780
  if (node._hiveCard) void openCardDetail(node._hiveCard, node._hiveLane, node);
7366
7781
  });
7367
7782
  node.addEventListener("keydown", (event) => {
7368
- if (!event || (event.key !== "Enter" && event.key !== " ")) return;
7783
+ if (!event) return;
7784
+ const target = event.target;
7785
+ if (target && (target === node._hiveCheck || String(target.tagName || "").toUpperCase() === "INPUT")) return;
7786
+ if (event.key !== "Enter" && event.key !== " ") return;
7369
7787
  if (typeof event.preventDefault === "function") event.preventDefault();
7370
7788
  if (node._hiveCard) void openCardDetail(node._hiveCard, node._hiveLane, node);
7371
7789
  });
7372
7790
  node._hiveTitle = element(doc, "div", "hive-card-title", "");
7791
+ node._hiveCheck = element(doc, "input", "hive-card-check");
7792
+ setAttr(node._hiveCheck, "type", "checkbox");
7793
+ setAttr(node._hiveCheck, "aria-label", translate("board.selectTask"));
7794
+ const applyTaskSelection = (checked) => {
7795
+ node._hiveKnown = checked;
7796
+ if (checked) selectedTasks.add(String(card.id));
7797
+ else selectedTasks.delete(String(card.id));
7798
+ };
7799
+ node._hiveCheck.addEventListener("click", (event) => {
7800
+ if (event && typeof event.stopPropagation === "function") event.stopPropagation();
7801
+ const browserToggled = node._hiveCheck.checked !== node._hiveKnown;
7802
+ const next = browserToggled ? node._hiveCheck.checked : !node._hiveKnown;
7803
+ node._hiveCheck.checked = next;
7804
+ applyTaskSelection(next);
7805
+ });
7806
+ node._hiveCheck.addEventListener("change", () => {
7807
+ const next = node._hiveCheck.checked;
7808
+ if (next === node._hiveKnown) return;
7809
+ applyTaskSelection(next);
7810
+ });
7811
+ node.appendChild(node._hiveCheck);
7373
7812
  node.appendChild(node._hiveTitle);
7374
7813
  }
7375
7814
  node._hiveCard = card;
7376
7815
  node._hiveLane = lane;
7816
+ if (node._hiveCheck) {
7817
+ const claimed = String(card.state || lane) === "claimed";
7818
+ node._hiveCheck.checked = selectedTasks.has(String(card.id));
7819
+ node._hiveKnown = node._hiveCheck.checked;
7820
+ node._hiveCheck.disabled = claimed;
7821
+ const label = claimed ? translate("board.claimedNoDelete") : translate("board.selectTask");
7822
+ setAttr(node._hiveCheck, "title", label);
7823
+ setAttr(node._hiveCheck, "aria-label", label);
7824
+ node._hiveCheck.className = "hive-card-check" + (claimed ? " is-disabled" : "");
7825
+ }
7377
7826
  node._hiveTitle.textContent = title;
7378
7827
  setAttr(node, "aria-label", translate("card.openAria") + " " + title);
7379
7828
  setAttr(node, "title", title);
@@ -7484,12 +7933,58 @@ function renderMarkdownInto(doc, host, source) {
7484
7933
  const headActions = element(doc, "span", "hive-lane-head-actions");
7485
7934
  const topMore = element(doc, "button", "hive-btn hive-btn-ghost hive-lane-more-top is-hidden", translate("board.loadMore"));
7486
7935
  setAttr(topMore, "type", "button");
7487
- const latest = element(doc, "button", "hive-btn hive-btn-ghost hive-lane-latest", translate("board.latest"));
7488
- setAttr(latest, "type", "button");
7489
- setAttr(latest, "title", translate("board.latestAria"));
7490
- setAttr(latest, "aria-label", translate("board.latestAria"));
7491
7936
  headActions.appendChild(topMore);
7492
- headActions.appendChild(latest);
7937
+ const menuButton = element(doc, "button", "hive-btn hive-btn-ghost hive-lane-menu-button", "…");
7938
+ setAttr(menuButton, "type", "button");
7939
+ setAttr(menuButton, "title", translate("board.more"));
7940
+ setAttr(menuButton, "aria-label", translate("board.more"));
7941
+ setAttr(menuButton, "aria-expanded", "false");
7942
+ headActions.appendChild(menuButton);
7943
+ const menu = element(doc, "div", "hive-menu hive-lane-menu is-hidden");
7944
+ const addMenuAction = (labelKey, handler, danger = false) => {
7945
+ const button = element(doc, "button", "hive-menu-item" + (danger ? " is-danger" : ""), translate(labelKey));
7946
+ setAttr(button, "type", "button");
7947
+ button.addEventListener("click", (event) => {
7948
+ if (event && typeof event.stopPropagation === "function") event.stopPropagation();
7949
+ closeLaneMenu();
7950
+ handler();
7951
+ });
7952
+ menu.appendChild(button);
7953
+ return button;
7954
+ };
7955
+ const laneNamesForSelection = () => {
7956
+ const lanes = new Set();
7957
+ for (const laneName of LANE_ORDER) {
7958
+ for (const card of taskSlices[laneName] || []) {
7959
+ if (selectedTasks.has(String(card.id))) lanes.add(laneName);
7960
+ }
7961
+ }
7962
+ return [...lanes];
7963
+ };
7964
+ addMenuAction("board.selectAll", () => {
7965
+ for (const card of state.cards || []) selectedTasks.add(String(card.id));
7966
+ if (lastModel) renderLanes(lastModel);
7967
+ });
7968
+ addMenuAction("board.clearSelection", () => {
7969
+ selectedTasks.clear();
7970
+ if (lastModel) renderLanes(lastModel);
7971
+ });
7972
+ addMenuAction("board.deleteSelected", () => {
7973
+ const ids = [...selectedTasks];
7974
+ if (ids.length === 0) return;
7975
+ if (!confirmImpl || !confirmImpl(translate("board.deleteConfirm").replace("{count}", String(ids.length)))) return;
7976
+ const lanes = laneNamesForSelection();
7977
+ selectedTasks.clear();
7978
+ void runBatch("tasks-rm", { ids }, lanes);
7979
+ }, true);
7980
+ menuButton.addEventListener("click", (event) => {
7981
+ if (event && typeof event.stopPropagation === "function") event.stopPropagation();
7982
+ const open = menu.className.includes("is-hidden");
7983
+ closeLaneMenu();
7984
+ menu.className = "hive-menu hive-lane-menu" + (open ? "" : " is-hidden");
7985
+ setAttr(menuButton, "aria-expanded", open ? "true" : "false");
7986
+ });
7987
+ column.appendChild(menu);
7493
7988
  head.appendChild(headActions);
7494
7989
  column.appendChild(head);
7495
7990
  const recycle = element(doc, "div", "hive-lane-recycle is-hidden");
@@ -7503,10 +7998,15 @@ function renderMarkdownInto(doc, host, source) {
7503
7998
  const list = element(doc, "div", "hive-lane-cards");
7504
7999
  const inner = element(doc, "div", "hive-lane-virtual");
7505
8000
  list.appendChild(inner);
8001
+ const initialSkeleton = element(doc, "div", "hive-lane-initial");
8002
+ for (let index = 0; index < 3; index += 1) {
8003
+ initialSkeleton.appendChild(element(doc, "div", "hive-lane-initial-row", ""));
8004
+ }
8005
+ list.appendChild(initialSkeleton);
7506
8006
  column.appendChild(list);
7507
8007
  lanesNode.appendChild(column);
7508
8008
 
7509
- const state = { lane, column, list, inner, count, cards: [], visible: new Map() };
8009
+ const state = { lane, column, list, inner, count, cards: [], visible: new Map(), initialSkeleton, initialLoading: true, menu, menuButton };
7510
8010
  const loadingRow = element(doc, "div", "hive-lane-loading is-hidden", translate("board.loading"));
7511
8011
  list.appendChild(loadingRow);
7512
8012
  list.addEventListener("scroll", () => {
@@ -7544,15 +8044,19 @@ function renderMarkdownInto(doc, host, source) {
7544
8044
  recycleButton.addEventListener("click", () => {
7545
8045
  void reloadLaneLatest(state.lane, state);
7546
8046
  });
7547
- latest.addEventListener("click", () => {
7548
- state.list.scrollTop = 0;
7549
- });
7550
8047
  state.topMore = topMore;
7551
- state.latest = latest;
7552
8048
  observeLaneResize(state);
7553
8049
  return state;
7554
8050
  }
7555
8051
 
8052
+ function closeLaneMenu() {
8053
+ for (const state of laneRenderState.values()) {
8054
+ if (!state.menu) continue;
8055
+ state.menu.className = "hive-menu hive-lane-menu is-hidden";
8056
+ if (state.menuButton) setAttr(state.menuButton, "aria-expanded", "false");
8057
+ }
8058
+ }
8059
+
7556
8060
  function laneViewportHeight(state) {
7557
8061
  let height = 0;
7558
8062
  try {
@@ -7834,6 +8338,14 @@ function renderMarkdownInto(doc, host, source) {
7834
8338
  laneRenderState.set(lane, state);
7835
8339
  }
7836
8340
  state.cards = cards;
8341
+ if (state.initialSkeleton) {
8342
+ if (state.initialLoading) {
8343
+ state.initialSkeleton.className = "hive-lane-initial";
8344
+ } else {
8345
+ if (state.initialSkeleton.parentNode) state.initialSkeleton.parentNode.removeChild(state.initialSkeleton);
8346
+ state.initialSkeleton = null;
8347
+ }
8348
+ }
7837
8349
  const classes = ["hive-lane", "hive-lane-" + lane];
7838
8350
  if (cards.length === 0) classes.push("is-empty");
7839
8351
  if (stageFilter !== "all" && stageFilter !== lane) classes.push("is-filtered-out");
@@ -7842,18 +8354,17 @@ function renderMarkdownInto(doc, host, source) {
7842
8354
  const pageInfo = model.lanePages && model.lanePages[lane] ? model.lanePages[lane] : null;
7843
8355
  const loaded = cards.length;
7844
8356
  const total = pageInfo ? pageInfo.total : loaded;
7845
- state.count.textContent = total > loaded ? loaded + " / " + total : String(loaded);
8357
+ state.count.textContent = state.initialLoading ? "—" : total > loaded ? loaded + " / " + total : String(loaded);
7846
8358
  const hasMore = Boolean(pageInfo && pageInfo.hasMore);
7847
8359
  state.more.className = "hive-btn hive-btn-ghost hive-lane-more" + (hasMore ? "" : " is-hidden");
7848
8360
  state.recycle.className = "hive-lane-recycle" + (state.recycled > 0 ? "" : " is-hidden");
7849
8361
  state.recycleText.textContent = state.recycled > 0
7850
8362
  ? translate("board.recycled").replace("{count}", String(state.recycled)) + " · "
7851
8363
  : "";
7852
- state.loadingRow.className = "hive-lane-loading" + (state.loadingPage ? "" : " is-hidden");
8364
+ state.loadingRow.className = "hive-lane-loading" + (state.loadingPage && !state.initialLoading ? "" : " is-hidden");
7853
8365
  state.topMore.className = "hive-btn hive-btn-ghost hive-lane-more-top" + (hasMore ? "" : " is-hidden");
7854
8366
  state.topMore.disabled = state.loadingPage === true;
7855
8367
  state.topMore.textContent = state.loadingPage ? translate("board.loading") : translate("board.loadMore");
7856
- state.latest.className = "hive-btn hive-btn-ghost hive-lane-latest" + (loaded > 0 ? "" : " is-hidden");
7857
8368
  state.more.disabled = state.loadingPage === true;
7858
8369
  state.more.textContent = state.loadingPage
7859
8370
  ? translate("board.loading")
@@ -7884,12 +8395,53 @@ function renderMarkdownInto(doc, host, source) {
7884
8395
  }
7885
8396
  }
7886
8397
 
8398
+ function eventPageCursor(cursor) {
8399
+ const number = Number(cursor);
8400
+ return Number.isFinite(number) && number >= 0 ? Math.floor(number) : 0;
8401
+ }
8402
+
7887
8403
  function eventPageUrl(cursor) {
7888
- const params = ["cursor=" + encodeURIComponent(String(cursor)), "limit=80"];
8404
+ const params = ["cursor=" + encodeURIComponent(String(eventPageCursor(cursor))), "limit=80"];
7889
8405
  if (eventState.filter) params.push("kind=" + encodeURIComponent(eventState.filter));
7890
8406
  return eventsUrl + (eventsUrl.includes("?") ? "&" : "?") + params.join("&");
7891
8407
  }
7892
8408
 
8409
+ async function readEventPagePayload(response) {
8410
+ const status = Number(response && response.status) || 0;
8411
+ if (!response || response.ok === false) {
8412
+ let detail = "";
8413
+ if (response && typeof response.text === "function") {
8414
+ try { detail = String(await response.text()).trim(); } catch { detail = ""; }
8415
+ }
8416
+ const reason = translate("events.pageFailed") + (status ? " (" + String(status) + ")" : "");
8417
+ const error = new Error(reason + (detail ? ": " + detail.slice(0, 160) : ""));
8418
+ error.pageReason = reason;
8419
+ throw error;
8420
+ }
8421
+ const contentType = response.headers && typeof response.headers.get === "function"
8422
+ ? String(response.headers.get("content-type") || "")
8423
+ : "";
8424
+ if (contentType !== "" && !contentType.includes("json")) {
8425
+ const error = new Error(translate("events.pageFailed") + ": " + contentType);
8426
+ error.pageReason = translate("events.pageFailed") + " (invalid content-type)";
8427
+ throw error;
8428
+ }
8429
+ let payload;
8430
+ try {
8431
+ payload = await response.json();
8432
+ } catch {
8433
+ const error = new Error(translate("events.pageFailed") + ": invalid JSON");
8434
+ error.pageReason = translate("events.pageFailed") + " (invalid JSON)";
8435
+ throw error;
8436
+ }
8437
+ if (!payload || typeof payload !== "object" || !Array.isArray(payload.items)) {
8438
+ const error = new Error(translate("events.pageFailed") + ": invalid payload");
8439
+ error.pageReason = translate("events.pageFailed") + " (invalid payload)";
8440
+ throw error;
8441
+ }
8442
+ return payload;
8443
+ }
8444
+
7893
8445
  function initializeEventState(model) {
7894
8446
  if (!eventState.initialized || eventState.repo !== model.repo) {
7895
8447
  eventState.items = model.events.slice();
@@ -7899,6 +8451,9 @@ function renderMarkdownInto(doc, host, source) {
7899
8451
  eventState.recycled = 0;
7900
8452
  eventState.loading = false;
7901
8453
  eventState.error = "";
8454
+ eventState.pageError = "";
8455
+ eventState.noMore = false;
8456
+ eventState.pageFailureCount = 0;
7902
8457
  eventState.repo = model.repo;
7903
8458
  eventState.initialized = true;
7904
8459
  eventState.paged = false;
@@ -7922,17 +8477,47 @@ function renderMarkdownInto(doc, host, source) {
7922
8477
  eventsRecycle.textContent = eventState.recycled > 0
7923
8478
  ? translate("events.recycled").replace("{count}", String(eventState.recycled))
7924
8479
  : "";
7925
- const kinds = Array.isArray(model.eventKinds) ? model.eventKinds : [];
8480
+ const knownKinds = new Set([
8481
+ "task_add", "add", "task_claim", "claim", "task_done", "done", "task_fail", "fail",
8482
+ "task_edit", "edit", "task_split", "split", "task_supersede", "supersede", "reopen",
8483
+ "task_reopen", "task_delete", "rm", "task_plan", "commit_announce", "guard", "lesson",
8484
+ "arch_review", "queen_intervention", "queen_boundary_violation", "service_down",
8485
+ "service_started", "mode", "checkpoint", "renew", "claim_overlap",
8486
+ ]);
8487
+ const counts = new Map(eventState.kindCounts);
8488
+ for (const entry of Array.isArray(model.eventKinds) ? model.eventKinds : []) {
8489
+ if (!entry || !entry.kind) continue;
8490
+ counts.set(String(entry.kind), asCount(entry.count, 0));
8491
+ }
8492
+ const loadedCounts = new Map();
8493
+ for (const event of eventState.items) {
8494
+ const kind = asString(event.kind);
8495
+ if (kind) loadedCounts.set(kind, (loadedCounts.get(kind) || 0) + 1);
8496
+ }
8497
+ for (const [kind, count] of loadedCounts) {
8498
+ if (!counts.has(kind) || asCount(counts.get(kind), 0) < count) counts.set(kind, count);
8499
+ }
8500
+ if (eventState.filter && !counts.has(eventState.filter)) counts.set(eventState.filter, 0);
8501
+ const hasEvents = asCount(eventState.total, 0) > 0 || eventState.items.length > 0;
8502
+ if (hasEvents) eventState.kindCounts = counts;
8503
+ else eventState.kindCounts.clear();
7926
8504
  clearNode(eventsFilter);
7927
8505
  const all = element(doc, "option", null, translate("events.filterAll"));
7928
8506
  setAttr(all, "value", "");
7929
8507
  eventsFilter.appendChild(all);
7930
- for (const entry of kinds) {
7931
- if (!entry.kind) continue;
7932
- const option = element(doc, "option", null, entry.kind + " (" + String(entry.count) + ")");
7933
- setAttr(option, "value", entry.kind);
7934
- eventsFilter.appendChild(option);
8508
+ if (hasEvents) {
8509
+ const ordered = [...counts.entries()].sort((left, right) => right[1] - left[1] || left[0].localeCompare(right[0]));
8510
+ for (const [kind, count] of ordered) {
8511
+ const label = knownKinds.has(kind) ? kind : translate("events.filterOther");
8512
+ const option = element(doc, "option", null, label + " (" + String(count) + ")");
8513
+ setAttr(option, "value", kind);
8514
+ setAttr(option, "title", kind);
8515
+ eventsFilter.appendChild(option);
8516
+ }
8517
+ } else {
8518
+ eventState.filter = "";
7935
8519
  }
8520
+ eventsFilter.disabled = model.initialised === false;
7936
8521
  eventsFilter.value = eventState.filter;
7937
8522
  }
7938
8523
 
@@ -7950,6 +8535,7 @@ function renderMarkdownInto(doc, host, source) {
7950
8535
  if (!actor) return "—";
7951
8536
  if (actor === "queen") return translate("events.actor.queen");
7952
8537
  if (actor === "supervisor") return translate("events.actor.supervisor");
8538
+ if (actor === "dsh") return translate("events.actor.legacy");
7953
8539
  const worker = /^worker:(.+)$/.exec(actor);
7954
8540
  if (worker) return worker[1];
7955
8541
  return actor;
@@ -8249,13 +8835,38 @@ function renderMarkdownInto(doc, host, source) {
8249
8835
 
8250
8836
  function eventKey(event) {
8251
8837
  const raw = event.raw || {};
8252
- const ref = raw.task || raw.card || raw.cardId || raw.id || event.task || "";
8253
- return [event.ts, event.kind, event.actor || raw.actor || "", ref].join("|");
8838
+ const ref = raw.task || event.task || "";
8839
+ return JSON.stringify([String(event.ts || ""), String(event.kind || ""), String(event.actor || raw.actor || ""), String(ref)]);
8254
8840
  }
8255
8841
 
8256
8842
  function createEventRow(event) {
8257
8843
  const key = eventKey(event);
8258
8844
  const row = element(doc, "div", "hive-event");
8845
+ const check = element(doc, "input", "hive-event-check");
8846
+ setAttr(check, "type", "checkbox");
8847
+ setAttr(check, "aria-label", translate("board.selectTask"));
8848
+ check.checked = selectedEvents.has(key);
8849
+ let known = check.checked;
8850
+ if (check.checked) row.className = "hive-event is-selected";
8851
+ const applySelected = (next) => {
8852
+ known = next;
8853
+ if (next) selectedEvents.add(key);
8854
+ else selectedEvents.delete(key);
8855
+ row.className = "hive-event" + (details.open ? " is-expanded" : "") + (next ? " is-selected" : "");
8856
+ updateEventSelectionUi();
8857
+ };
8858
+ check.addEventListener("click", (inputEvent) => {
8859
+ if (inputEvent && typeof inputEvent.stopPropagation === "function") inputEvent.stopPropagation();
8860
+ const browserToggled = check.checked !== known;
8861
+ const next = browserToggled ? check.checked : !known;
8862
+ check.checked = next;
8863
+ applySelected(next);
8864
+ });
8865
+ check.addEventListener("change", () => {
8866
+ if (check.checked === known) return;
8867
+ applySelected(check.checked);
8868
+ });
8869
+ row.appendChild(check);
8259
8870
  row.appendChild(element(doc, "span", "hive-event-sentence", eventSentence(event)));
8260
8871
  const details = element(doc, "details", "hive-event-raw");
8261
8872
  details.appendChild(element(doc, "summary", "hive-event-summary", translate("events.details")));
@@ -8270,14 +8881,14 @@ function renderMarkdownInto(doc, host, source) {
8270
8881
  if (eventState.expanded.has(key)) {
8271
8882
  details.open = true;
8272
8883
  setAttr(details, "open", "");
8273
- row.className = "hive-event is-expanded";
8884
+ row.className = "hive-event is-expanded" + (selectedEvents.has(key) ? " is-selected" : "");
8274
8885
  }
8275
8886
  details.addEventListener("toggle", () => {
8276
8887
  if (details.open) {
8277
- row.className = "hive-event is-expanded";
8888
+ row.className = "hive-event is-expanded" + (selectedEvents.has(key) ? " is-selected" : "");
8278
8889
  eventState.expanded.add(key);
8279
8890
  } else {
8280
- row.className = "hive-event";
8891
+ row.className = "hive-event" + (selectedEvents.has(key) ? " is-selected" : "");
8281
8892
  eventState.expanded.delete(key);
8282
8893
  }
8283
8894
  });
@@ -8286,11 +8897,19 @@ function renderMarkdownInto(doc, host, source) {
8286
8897
  }
8287
8898
 
8288
8899
  function renderEventRows() {
8900
+ for (const child of [...(eventsList.children || [])]) {
8901
+ const classes = String(child.className).split(/\s+/);
8902
+ if (classes.includes("hive-events-initial") || classes.includes("hive-events-page-error")) {
8903
+ eventsList.removeChild(child);
8904
+ }
8905
+ }
8289
8906
  const signature =
8290
8907
  eventState.filter +
8291
8908
  "|" + String(eventState.items.length) +
8292
8909
  "|" + String(eventState.recycled) +
8293
8910
  "|" + String(eventState.error ? 1 : 0) +
8911
+ "|" + eventState.pageError +
8912
+ "|" + String(eventState.noMore ? 1 : 0) +
8294
8913
  "|" + (eventState.items[0] ? eventState.items[0].ts : "") +
8295
8914
  "|" + (eventState.items[eventState.items.length - 1] ? eventState.items[eventState.items.length - 1].ts : "");
8296
8915
  if (signature === eventState.signature) return;
@@ -8339,10 +8958,29 @@ function renderMarkdownInto(doc, host, source) {
8339
8958
  cursor = entry.row;
8340
8959
  }
8341
8960
  restoreEventAnchor(anchor);
8961
+ if (eventState.pageError) {
8962
+ const errorRow = element(doc, "div", "hive-events-page-error");
8963
+ setAttr(errorRow, "role", "status");
8964
+ setAttr(errorRow, "title", eventState.pageError);
8965
+ errorRow.appendChild(element(doc, "span", "hive-events-page-error-text", translate("events.pageFailed")));
8966
+ const reason = eventState.pageError.startsWith(translate("events.pageFailed"))
8967
+ ? eventState.pageError.slice(translate("events.pageFailed").length).trim()
8968
+ : eventState.pageError;
8969
+ if (reason) errorRow.appendChild(element(doc, "span", "hive-events-page-error-reason", reason));
8970
+ const retry = element(doc, "button", "hive-btn hive-btn-ghost hive-events-page-retry", translate("events.retry"));
8971
+ setAttr(retry, "type", "button");
8972
+ retry.addEventListener("click", () => {
8973
+ eventState.pageError = "";
8974
+ eventState.signature = "";
8975
+ void loadEventPage(false);
8976
+ });
8977
+ errorRow.appendChild(retry);
8978
+ eventsList.appendChild(errorRow);
8979
+ }
8342
8980
  }
8343
8981
 
8344
8982
  function maybeLoadEventPage() {
8345
- if (eventState.loading || !fetchImpl || !lastModel) return;
8983
+ if (eventState.loading || eventState.pageError || eventState.noMore || !fetchImpl || !lastModel) return;
8346
8984
  if (eventState.items.length >= eventState.total) return;
8347
8985
  const list = eventsList;
8348
8986
  if (list.scrollHeight <= list.clientHeight) return;
@@ -8351,25 +8989,25 @@ function renderMarkdownInto(doc, host, source) {
8351
8989
 
8352
8990
  async function loadEventPage(reset) {
8353
8991
  if (eventState.loading || !fetchImpl || !lastModel) return;
8992
+ if (!reset && eventState.pageError) return;
8354
8993
  eventState.loading = true;
8355
- eventState.error = "";
8356
8994
  eventState.paged = true;
8357
- const cursor = reset ? 0 : eventState.cursor;
8995
+ const cursor = reset ? 0 : eventPageCursor(eventState.cursor);
8358
8996
  try {
8359
8997
  const response = await fetchImpl(eventPageUrl(cursor), {
8360
8998
  cache: "no-store",
8361
8999
  headers: { accept: "application/json" },
8362
9000
  });
8363
- if (!response || response.ok === false) throw new Error("events page failed");
8364
- const payload = await response.json();
8365
- const items = normalizeEvents(Array.isArray(payload && payload.items) ? payload.items : []);
8366
- const total = asCount(payload && payload.total, eventState.total);
8367
- const next = asCount(payload && payload.cursor, cursor + items.length);
9001
+ const payload = await readEventPagePayload(response);
9002
+ const items = normalizeEvents(payload.items);
9003
+ const total = asCount(payload.total, eventState.total);
9004
+ const next = asCount(payload.cursor, cursor + items.length);
9005
+ const noMore = payload.hasMore === false || (payload.hasMore !== true && next >= total) || items.length === 0;
8368
9006
  if (reset) {
8369
9007
  eventState.items = items;
8370
9008
  eventState.recycled = 0;
8371
9009
  eventsList.scrollTop = 0;
8372
- } else {
9010
+ } else if (items.length > 0) {
8373
9011
  eventState.items = eventState.items.concat(items);
8374
9012
  if (eventState.items.length > 5000) {
8375
9013
  const dropped = eventState.items.length - 5000;
@@ -8377,15 +9015,24 @@ function renderMarkdownInto(doc, host, source) {
8377
9015
  eventState.recycled += dropped;
8378
9016
  }
8379
9017
  }
8380
- eventState.cursor = next;
9018
+ eventState.cursor = eventPageCursor(next);
8381
9019
  eventState.total = total;
9020
+ eventState.noMore = noMore;
9021
+ eventState.pageError = "";
9022
+ eventState.pageFailureCount = 0;
8382
9023
  eventState.signature = "";
8383
- if (!destroyed && lastModel) renderEvents(lastModel);
9024
+ if (!destroyed && lastModel) {
9025
+ renderEventHeader(lastModel);
9026
+ renderEventRows();
9027
+ }
8384
9028
  } catch (error) {
8385
- eventState.error = translate("events.loadFailed");
8386
- reportError(error);
8387
- eventState.signature = "";
8388
- if (!destroyed && lastModel) renderEvents(lastModel);
9029
+ if (!destroyed) {
9030
+ eventState.pageError = asString(error && (error.pageReason || error.message)) || translate("events.pageFailed");
9031
+ eventState.pageFailureCount += 1;
9032
+ eventState.signature = "";
9033
+ if (!destroyed && lastModel) renderEventRows();
9034
+ reportError(error);
9035
+ }
8389
9036
  } finally {
8390
9037
  eventState.loading = false;
8391
9038
  }
@@ -8410,7 +9057,7 @@ function renderMarkdownInto(doc, host, source) {
8410
9057
  renderEventRows();
8411
9058
  }
8412
9059
 
8413
- function render(model) {
9060
+ function renderChrome(model) {
8414
9061
  repoNode.textContent = model.repo || "—";
8415
9062
  setAttr(repoNode, "title", model.repo);
8416
9063
 
@@ -8423,6 +9070,10 @@ function renderMarkdownInto(doc, host, source) {
8423
9070
  renderAgents(model);
8424
9071
  renderStageChips(model);
8425
9072
  renderLanes(model);
9073
+ }
9074
+
9075
+ function render(model) {
9076
+ renderChrome(model);
8426
9077
  renderEvents(model);
8427
9078
  }
8428
9079
 
@@ -8479,6 +9130,10 @@ function renderMarkdownInto(doc, host, source) {
8479
9130
  eventState.signature = "";
8480
9131
  eventState.expanded.clear();
8481
9132
  eventState.rowNodes.clear();
9133
+ eventState.kindCounts.clear();
9134
+ eventState.pageError = "";
9135
+ eventState.noMore = false;
9136
+ eventState.pageFailureCount = 0;
8482
9137
  eventsList.scrollTop = 0;
8483
9138
  planTriggerButton = null;
8484
9139
  closeHelp(false);
@@ -8488,9 +9143,195 @@ function renderMarkdownInto(doc, host, source) {
8488
9143
  closeToast();
8489
9144
  }
8490
9145
 
9146
+ function normalizeStatusPayload(data) {
9147
+ if (!data || typeof data !== "object") return data;
9148
+ if (data.counts && !data.stats) {
9149
+ const tasks = data.counts.tasks || {};
9150
+ const byState = tasks.byState || {};
9151
+ const lanePages = {};
9152
+ for (const lane of LANE_ORDER) {
9153
+ const total = Number(byState[lane]) || 0;
9154
+ lanePages[lane] = { total, cursor: 0, hasMore: total > 0 };
9155
+ }
9156
+ return {
9157
+ ...data,
9158
+ partial: true,
9159
+ mode: data.mode || { mode: "free" },
9160
+ board: [],
9161
+ stats: {
9162
+ total: Number(tasks.total) || 0,
9163
+ byState,
9164
+ byRole: tasks.byRole || {},
9165
+ oldestPending: null,
9166
+ },
9167
+ lanePages,
9168
+ eventTotal: Number(data.counts.events && data.counts.events.total) || 0,
9169
+ eventKinds: (data.counts.events && data.counts.events.kinds) || [],
9170
+ };
9171
+ }
9172
+ return data;
9173
+ }
9174
+ function emptyLanePages() {
9175
+ const pages = {};
9176
+ for (const lane of LANE_ORDER) {
9177
+ const statusPage = statusData && statusData.lanePages ? statusData.lanePages[lane] : null;
9178
+ pages[lane] = {
9179
+ total: statusPage ? asCount(statusPage.total, 0) : 0,
9180
+ cursor: statusPage ? asCount(statusPage.cursor, 0) : 0,
9181
+ hasMore: Boolean(statusPage && statusPage.hasMore),
9182
+ };
9183
+ }
9184
+ return pages;
9185
+ }
9186
+
9187
+ function buildStatusSnapshot() {
9188
+ const base = isRecord(statusData) ? statusData : {};
9189
+ const lanePages = emptyLanePages();
9190
+ for (const lane of LANE_ORDER) {
9191
+ const page = taskSlicePages[lane];
9192
+ if (!page) continue;
9193
+ lanePages[lane] = page;
9194
+ }
9195
+ return {
9196
+ ...base,
9197
+ tasks: LANE_ORDER.flatMap((lane) => taskSlices[lane] || []),
9198
+ lanePages,
9199
+ events: eventState.items,
9200
+ eventTotal: Math.max(eventState.total, asCount(base.eventTotal, 0)),
9201
+ eventKinds: Array.isArray(base.eventKinds) ? base.eventKinds : [],
9202
+ };
9203
+ }
9204
+
9205
+ function refreshStatusChrome() {
9206
+ if (!statusData) return;
9207
+ lastSnapshot = buildStatusSnapshot();
9208
+ lastModel = renderModel(lastSnapshot);
9209
+ renderChrome(lastModel);
9210
+ }
9211
+
9212
+ function hideEventSkeleton() {
9213
+ if (eventsSkeleton && eventsSkeleton.parentNode) eventsSkeleton.parentNode.removeChild(eventsSkeleton);
9214
+ }
9215
+
9216
+ function applyStatus(data) {
9217
+ statusData = isRecord(data) ? normalizeStatusPayload(data) : {};
9218
+ const snapshot = buildStatusSnapshot();
9219
+ lastSnapshot = snapshot;
9220
+ lastModel = renderModel(snapshot);
9221
+ finishLoading();
9222
+ setStatus(null);
9223
+ renderChrome(lastModel);
9224
+ // Event filters come from status, but rows stay in their loading skeleton
9225
+ // until the independent events request finishes.
9226
+ initializeEventState(lastModel);
9227
+ eventsCount.textContent = "—";
9228
+ hideEventSkeleton();
9229
+ eventsList.appendChild(eventsSkeleton);
9230
+ }
9231
+
9232
+ async function loadInitialLane(lane) {
9233
+ const state = laneRenderState.get(lane);
9234
+ if (!state || !fetchImpl) {
9235
+ if (state) {
9236
+ state.initialLoading = false;
9237
+ renderLanes(lastModel);
9238
+ }
9239
+ return;
9240
+ }
9241
+ try {
9242
+ const url = tasksUrl + (tasksUrl.includes("?") ? "&" : "?") +
9243
+ "state=" + encodeURIComponent(lane) + "&cursor=0&limit=200";
9244
+ const response = await fetchImpl(url, { cache: "no-store", headers: { accept: "application/json" } });
9245
+ if (!response || response.ok === false) throw new Error("tasks failed for " + lane);
9246
+ const payload = await response.json();
9247
+ const items = Array.isArray(payload && payload.items) ? payload.items : [];
9248
+ const total = asCount(payload && payload.total, items.length);
9249
+ const cursor = asCount(payload && payload.cursor, items.length);
9250
+ taskSlices[lane] = items;
9251
+ taskSlicePages[lane] = { total, cursor, hasMore: Boolean(payload && payload.hasMore) };
9252
+ state.initialLoading = false;
9253
+ if (!destroyed) refreshStatusChrome();
9254
+ } catch (error) {
9255
+ state.initialLoading = false;
9256
+ state.pageFailure = actionErrorDetail(error) || translate("loading.failed");
9257
+ if (!destroyed && lastModel) renderLanes(lastModel);
9258
+ reportError(error);
9259
+ }
9260
+ }
9261
+
9262
+ async function loadInitialEvents() {
9263
+ if (!fetchImpl) return;
9264
+ try {
9265
+ const url = eventsUrl + (eventsUrl.includes("?") ? "&" : "?") + "cursor=0&limit=80";
9266
+ const response = await fetchImpl(url, { cache: "no-store", headers: { accept: "application/json" } });
9267
+ if (!response || response.ok === false) throw new Error("events failed");
9268
+ const payload = await response.json();
9269
+ const items = normalizeEvents(Array.isArray(payload && payload.items) ? payload.items : []);
9270
+ eventState.initialized = true;
9271
+ eventState.repo = statusData ? asString(statusData.repo) : "";
9272
+ eventState.items = items;
9273
+ eventState.total = asCount(payload && payload.total, items.length);
9274
+ eventState.cursor = asCount(payload && payload.cursor, items.length);
9275
+ eventState.pollCursor = statusData ? asCount(statusData.eventTotal, eventState.total) : eventState.total;
9276
+ eventState.filter = "";
9277
+ eventState.recycled = 0;
9278
+ eventState.paged = false;
9279
+ eventState.pageError = "";
9280
+ eventState.noMore = payload.hasMore === false || eventState.cursor >= eventState.total;
9281
+ eventState.signature = "";
9282
+ hideEventSkeleton();
9283
+ if (!destroyed && lastModel) {
9284
+ eventsFilter.disabled = false;
9285
+ renderEventHeader(lastModel);
9286
+ renderEventRows();
9287
+ }
9288
+ } catch (error) {
9289
+ hideEventSkeleton();
9290
+ eventState.error = "";
9291
+ if (!destroyed) {
9292
+ clearNode(eventsList);
9293
+ const message = actionErrorDetail(error) || translate("events.loadFailed");
9294
+ eventsList.appendChild(element(doc, "div", "hive-event-error", translate("events.loadFailed") + ": " + message));
9295
+ const retry = element(doc, "button", "hive-btn hive-btn-ghost hive-events-retry", translate("loading.retry"));
9296
+ retry.addEventListener("click", () => {
9297
+ void loadInitialEvents();
9298
+ });
9299
+ eventsList.appendChild(retry);
9300
+ reportError(error);
9301
+ }
9302
+ }
9303
+ }
9304
+
9305
+ async function startInitialData() {
9306
+ if (initialDataPromise) return initialDataPromise;
9307
+ initialDataPromise = (async () => {
9308
+ if (!statusData || statusData.initialised === false) {
9309
+ for (const lane of LANE_ORDER) {
9310
+ const state = laneRenderState.get(lane);
9311
+ if (state) state.initialLoading = false;
9312
+ }
9313
+ hideEventSkeleton();
9314
+ if (lastModel) renderLanes(lastModel);
9315
+ return;
9316
+ }
9317
+ await Promise.all([
9318
+ ...LANE_ORDER.map((lane) => loadInitialLane(lane)),
9319
+ loadInitialEvents(),
9320
+ ]);
9321
+ initialDataLoaded = true;
9322
+ })().finally(() => {
9323
+ initialDataPromise = null;
9324
+ });
9325
+ return initialDataPromise;
9326
+ }
9327
+
8491
9328
  function setSnapshot(snapshot) {
8492
9329
  if (destroyed) return null;
8493
9330
  lastSnapshot = isRecord(snapshot) ? snapshot : {};
9331
+ statusData = lastSnapshot;
9332
+ initialDataLoaded = true;
9333
+ for (const state of laneRenderState.values()) state.initialLoading = false;
9334
+ hideEventSkeleton();
8494
9335
  const model = renderModel(lastSnapshot);
8495
9336
  if (lastModel && lastModel.repo !== model.repo) resetRepoState();
8496
9337
  lastModel = model;
@@ -8520,6 +9361,35 @@ function renderMarkdownInto(doc, host, source) {
8520
9361
  }
8521
9362
  return;
8522
9363
  }
9364
+ if (!statusData && !initialDataLoaded) {
9365
+ try {
9366
+ const response = await fetchImpl(statusUrl, {
9367
+ cache: "no-store",
9368
+ headers: { accept: "application/json" },
9369
+ });
9370
+ if (response && response.ok !== false) {
9371
+ const data = await response.json();
9372
+ if (!destroyed) {
9373
+ const hasPageData = Boolean(
9374
+ (Array.isArray(data.tasks) && data.tasks.length > 0) ||
9375
+ (Array.isArray(data.events) && data.events.length > 0) ||
9376
+ Object.values(data.lanePages || {}).some((page) => page && Array.isArray(page.items) && page.items.length > 0),
9377
+ );
9378
+ if (data.partial === true || !hasPageData) {
9379
+ applyStatus(data);
9380
+ await startInitialData();
9381
+ return;
9382
+ }
9383
+ setSnapshot(data);
9384
+ statusData = data;
9385
+ initialDataLoaded = true;
9386
+ return;
9387
+ }
9388
+ }
9389
+ } catch {
9390
+ // Older hosts do not expose /api/status; fall back to the full snapshot.
9391
+ }
9392
+ }
8523
9393
  try {
8524
9394
  const response = await fetchImpl(snapshotUrl, {
8525
9395
  cache: "no-store",
@@ -8539,6 +9409,74 @@ function renderMarkdownInto(doc, host, source) {
8539
9409
  }
8540
9410
  }
8541
9411
 
9412
+ function isNodeVisible(node) {
9413
+ if (!node || !node.parentNode) return false;
9414
+ if (String(node.className).split(/\s+/).includes("is-hidden")) return false;
9415
+ if (typeof node.getBoundingClientRect === "function") {
9416
+ const rect = node.getBoundingClientRect();
9417
+ if (rect && (Number(rect.width) === 0 || Number(rect.height) === 0)) return false;
9418
+ }
9419
+ return true;
9420
+ }
9421
+
9422
+ async function pollEventsIncremental() {
9423
+ if (!fetchImpl || !initialDataLoaded || eventState.filter) return;
9424
+ if (!isNodeVisible(eventsDrawer)) return;
9425
+ const after = Math.max(0, Math.floor(Number(eventState.pollCursor) || 0));
9426
+ try {
9427
+ const url = eventsUrl + (eventsUrl.includes("?") ? "&" : "?") +
9428
+ "after=" + encodeURIComponent(String(after)) + "&limit=50";
9429
+ const response = await fetchImpl(url, { cache: "no-store", headers: { accept: "application/json" } });
9430
+ if (!response || response.ok === false) return;
9431
+ const payload = await response.json();
9432
+ const items = normalizeEvents(Array.isArray(payload && payload.items) ? payload.items : []);
9433
+ const nextCursor = asCount(payload && payload.cursor, after);
9434
+ const total = asCount(payload && payload.total, eventState.total);
9435
+ eventState.pollCursor = nextCursor;
9436
+ eventState.total = Math.max(total, eventState.items.length);
9437
+ const known = new Set(eventState.items.map((event) => eventKey(event)));
9438
+ const fresh = items.filter((event) => !known.has(eventKey(event)));
9439
+ if (fresh.length > 0) {
9440
+ eventState.items = fresh.concat(eventState.items);
9441
+ eventState.signature = "";
9442
+ if (!destroyed && lastModel) {
9443
+ renderEventHeader(lastModel);
9444
+ renderEventRows();
9445
+ }
9446
+ }
9447
+ } catch (error) {
9448
+ reportError(error);
9449
+ }
9450
+ }
9451
+
9452
+ async function pollVisibleData() {
9453
+ if (destroyed || doc.hidden) return;
9454
+ if (!initialDataLoaded || !statusData) {
9455
+ await refresh();
9456
+ return;
9457
+ }
9458
+ try {
9459
+ const response = await fetchImpl(statusUrl, {
9460
+ cache: "no-store",
9461
+ headers: { accept: "application/json" },
9462
+ });
9463
+ if (response && response.ok !== false) {
9464
+ const data = await response.json();
9465
+ if (!destroyed && data) {
9466
+ const normalized = normalizeStatusPayload(data);
9467
+ statusData = { ...statusData, ...(normalized && normalized.partial === true ? normalized : data) };
9468
+ refreshStatusChrome();
9469
+ eventsCount.textContent = translate("events.loaded")
9470
+ .replace("{loaded}", String(eventState.items.length))
9471
+ .replace("{total}", String(eventState.total));
9472
+ }
9473
+ }
9474
+ } catch (error) {
9475
+ reportError(error);
9476
+ }
9477
+ await pollEventsIncremental();
9478
+ }
9479
+
8542
9480
  function refresh() {
8543
9481
  if (destroyed) return Promise.resolve();
8544
9482
  void refreshSupervisor().catch(() => {
@@ -8658,16 +9596,32 @@ function renderMarkdownInto(doc, host, source) {
8658
9596
  agentsCount.disabled = disabled;
8659
9597
  }
8660
9598
 
8661
- function showSkeletonStats() {
8662
- clearNode(statsNode);
8663
- for (let index = 0; index < 2; index += 1) {
8664
- statsNode.appendChild(element(doc, "span", "hive-skeleton-pill", ""));
9599
+ function primeInitialUI() {
9600
+ for (const lane of LANE_ORDER) {
9601
+ if (laneRenderState.has(lane)) continue;
9602
+ const state = createLaneState(lane);
9603
+ state.initialLoading = true;
9604
+ state.count.textContent = "—";
9605
+ laneRenderState.set(lane, state);
8665
9606
  }
8666
- agentsCount.textContent = "…";
8667
- agentsCount.disabled = true;
9607
+ eventsLabel.textContent = translate("pane.events");
9608
+ eventsCount.textContent = "—";
9609
+ eventsFilter.disabled = true;
9610
+ eventsList.appendChild(eventsSkeleton);
9611
+ showStatusPlaceholders();
9612
+ }
9613
+
9614
+ function showStatusPlaceholders() {
9615
+ clearNode(statsNode);
9616
+ statsNode.appendChild(element(doc, "span", "hive-stat is-total", "—"));
9617
+ agentsCount.textContent = "—";
8668
9618
  queenBadge.className = "hive-queen-badge is-hidden";
8669
9619
  }
8670
9620
 
9621
+ function showSkeletonStats() {
9622
+ showStatusPlaceholders();
9623
+ }
9624
+
8671
9625
  function showLoadingPanel(text) {
8672
9626
  loadingText.textContent = text;
8673
9627
  loadingPanel.className = "hive-loading";
@@ -8694,13 +9648,11 @@ function renderMarkdownInto(doc, host, source) {
8694
9648
  loadingTicks = 0;
8695
9649
  loadingPanelError = "";
8696
9650
  loadingPanel.className = "hive-loading is-hidden";
8697
- loadingBadge.className = "hive-loading-badge";
8698
- loadingBadge.textContent = translate("loading.label");
8699
- skeletonNode.className = "hive-skeleton";
9651
+ loadingBadge.className = "hive-loading-badge is-hidden";
9652
+ skeletonNode.className = "hive-skeleton is-hidden";
8700
9653
  showSkeletonStats();
8701
9654
  setLoadingInteractions(true);
8702
9655
  stopLoadingTimer();
8703
- loadingTimer = scheduleTimeout(loadingTick, 1000);
8704
9656
  }
8705
9657
 
8706
9658
  function finishLoading() {
@@ -8732,7 +9684,7 @@ function renderMarkdownInto(doc, host, source) {
8732
9684
  function startPolling() {
8733
9685
  if (destroyed || timer !== null || doc.hidden) return;
8734
9686
  timer = schedule(() => {
8735
- void refresh();
9687
+ if (!doc.hidden) void pollVisibleData();
8736
9688
  }, intervalMs);
8737
9689
  }
8738
9690
 
@@ -8742,13 +9694,15 @@ function renderMarkdownInto(doc, host, source) {
8742
9694
  stopPolling();
8743
9695
  } else {
8744
9696
  startPolling();
8745
- void refresh();
9697
+ if (initialDataLoaded) void pollVisibleData();
9698
+ else void refresh();
8746
9699
  }
8747
9700
  }
8748
9701
 
8749
9702
  if (typeof doc.addEventListener === "function") {
8750
9703
  doc.addEventListener("visibilitychange", onVisibilityChange);
8751
9704
  }
9705
+ primeInitialUI();
8752
9706
  beginLoading();
8753
9707
  startPolling();
8754
9708
  void refresh();