@d86e/hive-panel 1.0.1 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d86e/hive-panel",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A read-only board for a Hive swarm: agents, task lanes and the event tail, served from the refs and files you already have.",
5
5
  "type": "module",
6
6
  "bin": {
package/public/panel.css CHANGED
@@ -1131,3 +1131,20 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
1131
1131
  .hive-agent-count { font: inherit; cursor: pointer; }
1132
1132
  .hive-agent-count:disabled { cursor: default; }
1133
1133
 
1134
+ /* Agents dialog */
1135
+ .hive-agents-dialog { width: min(560px, 92vw); max-height: 80vh; }
1136
+ .hive-agents-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; }
1137
+ .hive-agents-empty-note { padding: 10px 0; color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; }
1138
+ .hive-agent-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--hive-line-2); }
1139
+ .hive-agent-row-main { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
1140
+ .hive-agent-row-name { color: var(--hive-fg); font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
1141
+ .hive-agent-row-task { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
1142
+ .hive-agent-row-meta { color: var(--hive-fg-faint); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
1143
+ .hive-agents-workers-title { padding-top: 4px; color: var(--hive-fg); font-size: 14px; font-weight: 700; line-height: 1.5; }
1144
+ .hive-agent-worker-row { padding: 8px 0; border-bottom: 1px solid var(--hive-line-2); }
1145
+ .hive-agent-worker-task { color: var(--hive-fg); font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
1146
+ .hive-agent-worker-meta { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
1147
+ .hive-agents-technical { border-top: 1px solid var(--hive-line-2); padding-top: 8px; }
1148
+ .hive-agents-technical-summary { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; cursor: pointer; }
1149
+ .hive-agents-technical-json { max-height: 220px; margin-top: 8px; }
1150
+
package/public/panel.js CHANGED
@@ -2017,6 +2017,22 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
2017
2017
  }
2018
2018
  .hive-agent-count { font: inherit; cursor: pointer; }
2019
2019
  .hive-agent-count:disabled { cursor: default; }
2020
+ /* Agents dialog */
2021
+ .hive-agents-dialog { width: min(560px, 92vw); max-height: 80vh; }
2022
+ .hive-agents-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; }
2023
+ .hive-agents-empty-note { padding: 10px 0; color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; }
2024
+ .hive-agent-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--hive-line-2); }
2025
+ .hive-agent-row-main { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
2026
+ .hive-agent-row-name { color: var(--hive-fg); font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
2027
+ .hive-agent-row-task { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
2028
+ .hive-agent-row-meta { color: var(--hive-fg-faint); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
2029
+ .hive-agents-workers-title { padding-top: 4px; color: var(--hive-fg); font-size: 14px; font-weight: 700; line-height: 1.5; }
2030
+ .hive-agent-worker-row { padding: 8px 0; border-bottom: 1px solid var(--hive-line-2); }
2031
+ .hive-agent-worker-task { color: var(--hive-fg); font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
2032
+ .hive-agent-worker-meta { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
2033
+ .hive-agents-technical { border-top: 1px solid var(--hive-line-2); padding-top: 8px; }
2034
+ .hive-agents-technical-summary { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; cursor: pointer; }
2035
+ .hive-agents-technical-json { max-height: 220px; margin-top: 8px; }
2020
2036
  `;
2021
2037
 
2022
2038
  const LANE_LABEL_KEYS = Object.freeze({
@@ -2075,6 +2091,16 @@ export const messages = Object.freeze({
2075
2091
  "status.actionFailed": "action failed",
2076
2092
  "status.disconnected": "disconnected",
2077
2093
  "agents.openAria": "Open agent",
2094
+ "agents.runningTooltip": "Running {running} / board identities {identities}",
2095
+ "agents.fallbackTooltip": "Board identities {identities} (supervisor disconnected or repository not registered)",
2096
+ "agents.modalEmpty": "No agents.",
2097
+ "agents.fileCount": "{count} files",
2098
+ "agents.workersTitle": "Active work units",
2099
+ "agents.workerStarted": "Started {time}",
2100
+ "agents.workerElapsed": "Running for {duration}",
2101
+ "agents.technical": "Technical details",
2102
+ "agents.waitingReclaim": "Waiting to reclaim {count}",
2103
+ "agents.waitingReclaimTooltip": "{count} tasks are claimed but no agent is running (waiting to be reclaimed after a process restart)",
2078
2104
  "agent.idle": "idle",
2079
2105
  "agent.task": "task",
2080
2106
  "agent.unknown": "unknown",
@@ -2316,6 +2342,16 @@ export const messages = Object.freeze({
2316
2342
  "status.actionFailed": "操作失败",
2317
2343
  "status.disconnected": "连接断开",
2318
2344
  "agents.openAria": "打开智能体",
2345
+ "agents.runningTooltip": "运行中 {running} / 公告板身份 {identities}",
2346
+ "agents.fallbackTooltip": "公告板身份 {identities}(监督器未连接或未注册该仓库)",
2347
+ "agents.modalEmpty": "暂无智能体。",
2348
+ "agents.fileCount": "{count} 个文件",
2349
+ "agents.workersTitle": "运行中的工作单元",
2350
+ "agents.workerStarted": "开始于 {time}",
2351
+ "agents.workerElapsed": "已运行 {duration}",
2352
+ "agents.technical": "技术详情",
2353
+ "agents.waitingReclaim": "等待回收 {count}",
2354
+ "agents.waitingReclaimTooltip": "有 {count} 个任务被认领但当前没有运行中的工作单元(进程重启后等待回收)",
2319
2355
  "agent.idle": "空闲",
2320
2356
  "agent.task": "任务",
2321
2357
  "agent.unknown": "未知",
@@ -2889,7 +2925,7 @@ function normalizeSupervisorRoles(source) {
2889
2925
  const ensure = (role) => {
2890
2926
  const name = asString(role).trim();
2891
2927
  if (!name) return null;
2892
- if (!rows.has(name)) rows.set(name, { role: name, limit: null, inFlight: null, queued: null });
2928
+ if (!rows.has(name)) rows.set(name, { role: name, limit: null, live: null, inFlight: null, queued: null });
2893
2929
  return rows.get(name);
2894
2930
  };
2895
2931
  const setLimit = (role, value) => {
@@ -2923,6 +2959,12 @@ function normalizeSupervisorRoles(source) {
2923
2959
  break;
2924
2960
  }
2925
2961
  }
2962
+ for (const field of ["live", "liveCount", "live_count", "workers", "workerCount"]) {
2963
+ if (supervisorNumber(raw[field]) !== null) {
2964
+ row.live = supervisorNumber(raw[field]);
2965
+ break;
2966
+ }
2967
+ }
2926
2968
  for (const field of ["queued", "queue", "queued_count", "pending", "pending_count", "waiting", "waiting_count", "backlog"]) {
2927
2969
  if (supervisorNumber(raw[field]) !== null) {
2928
2970
  row.queued = supervisorNumber(raw[field]);
@@ -3009,6 +3051,26 @@ function supervisorEntriesFrom(payload, depth = 0) {
3009
3051
  }
3010
3052
 
3011
3053
  /** Normalize the supervisor status endpoint into per-repository rows. */
3054
+ function normalizeSupervisorWorkers(source) {
3055
+ const raw = source && Array.isArray(source.workers) ? source.workers : [];
3056
+ const rows = [];
3057
+ for (const entry of raw) {
3058
+ if (!isRecord(entry)) continue;
3059
+ const cardId = asString(entry.cardId || entry.card || entry.task || entry.id);
3060
+ if (!cardId) continue;
3061
+ rows.push({
3062
+ cardId,
3063
+ role: asString(entry.role),
3064
+ agent: asString(entry.agent || entry.adapter),
3065
+ agentName: asString(entry.agentName || entry.agent_name || entry.name),
3066
+ sessionId: asString(entry.sessionId || entry.session_id),
3067
+ startedAt: asString(entry.startedAt || entry.started_at),
3068
+ lastOutputAt: asString(entry.lastOutputAt || entry.last_output_at),
3069
+ });
3070
+ }
3071
+ return rows;
3072
+ }
3073
+
3012
3074
  function normalizeSupervisorStatus(payload) {
3013
3075
  const rows = new Map();
3014
3076
  for (const raw of supervisorEntriesFrom(payload)) {
@@ -3031,11 +3093,30 @@ function normalizeSupervisorStatus(payload) {
3031
3093
  else if (/run|active|busy|working/.test(rawState)) state = "running";
3032
3094
  else if (/idle|ready|free/.test(rawState)) state = "idle";
3033
3095
  else if (running !== null && running > 0) state = "running";
3034
- rows.set(repo, { repo, state, running, roles: normalizeSupervisorRoles(source) });
3096
+ rows.set(repo, { repo, state, running, roles: normalizeSupervisorRoles(source), workers: normalizeSupervisorWorkers(source) });
3035
3097
  }
3036
3098
  return [...rows.values()].sort((left, right) => left.repo.localeCompare(right.repo));
3037
3099
  }
3038
3100
 
3101
+ function supervisorWorkerCount(row) {
3102
+ if (!row) return null;
3103
+ if (Array.isArray(row.workers) && row.workers.length > 0) return row.workers.length;
3104
+ const direct = supervisorNumber(row.running);
3105
+ if (direct !== null) return direct;
3106
+ let total = 0;
3107
+ let found = false;
3108
+ for (const role of Array.isArray(row.roles) ? row.roles : []) {
3109
+ if (!isRecord(role)) continue;
3110
+ const live = supervisorNumber(role.live);
3111
+ const inFlight = live !== null ? live : supervisorNumber(role.inFlight);
3112
+ if (inFlight !== null) {
3113
+ total += inFlight;
3114
+ found = true;
3115
+ }
3116
+ }
3117
+ return found ? total : null;
3118
+ }
3119
+
3039
3120
  function element(doc, tag, className, text) {
3040
3121
  const node = doc.createElement(tag);
3041
3122
  if (className) node.className = className;
@@ -3563,7 +3644,7 @@ export function mount(root, options = {}) {
3563
3644
  const agentsCount = element(doc, "button", "hive-stat hive-agent-count");
3564
3645
  setAttr(agentsCount, "type", "button");
3565
3646
  agentsCount.addEventListener("click", () => {
3566
- if (agentsCount._agent) openAgentDrawer(agentsCount._agent);
3647
+ openAgentsDialog();
3567
3648
  });
3568
3649
  bar.appendChild(agentsCount);
3569
3650
 
@@ -5155,6 +5236,101 @@ export function mount(root, options = {}) {
5155
5236
  return body;
5156
5237
  }
5157
5238
 
5239
+ function taskTitleForId(id) {
5240
+ const wanted = asString(id);
5241
+ if (!wanted || !lastModel) return "";
5242
+ for (const lane of LANE_ORDER) {
5243
+ for (const card of lastModel.lanes[lane] || []) {
5244
+ if (asString(card.id) === wanted) return card.title || wanted;
5245
+ }
5246
+ }
5247
+ return wanted;
5248
+ }
5249
+
5250
+ function openAgentsDialog() {
5251
+ closeHelp(false);
5252
+ closePlanDialog(false);
5253
+ closeAddDialog(false);
5254
+ closeDrawer(false);
5255
+ closeLimitsDialog(false);
5256
+
5257
+ const dialog = element(doc, "dialog", "hive-dialog hive-agents-dialog");
5258
+ setAttr(dialog, "role", "dialog");
5259
+ setAttr(dialog, "aria-modal", "true");
5260
+ setAttr(dialog, "aria-label", translate("pane.agents"));
5261
+ bindDialogDismiss(dialog, () => {
5262
+ closeModalDialog(dialog);
5263
+ if (!destroyed) focusNode(agentsCount);
5264
+ });
5265
+
5266
+ const head = element(doc, "div", "hive-dialog-head");
5267
+ const titleBox = element(doc, "div", "hive-dialog-head-title");
5268
+ titleBox.appendChild(element(doc, "h2", "hive-dialog-title", translate("pane.agents")));
5269
+ head.appendChild(titleBox);
5270
+ const closeButton = dialogCloseButton(() => {
5271
+ closeModalDialog(dialog);
5272
+ if (!destroyed) focusNode(agentsCount);
5273
+ });
5274
+ head.appendChild(closeButton);
5275
+ dialog.appendChild(head);
5276
+
5277
+ const body = element(doc, "div", "hive-dialog-body hive-agents-body");
5278
+ const agents = lastModel && Array.isArray(lastModel.agents) ? lastModel.agents : [];
5279
+ if (agents.length === 0) {
5280
+ body.appendChild(element(doc, "div", "hive-agents-empty-note", translate("agents.modalEmpty")));
5281
+ }
5282
+ for (const agent of agents) {
5283
+ const row = element(doc, "div", "hive-agent-row");
5284
+ const dot = element(doc, "span", "hive-dot is-" + safeClassToken(agent.state));
5285
+ setAttr(dot, "title", agent.state || translate("agent.idle"));
5286
+ row.appendChild(dot);
5287
+ const content = element(doc, "div", "hive-agent-row-main");
5288
+ content.appendChild(element(doc, "div", "hive-agent-row-name", agent.agent || translate("agent.unknown")));
5289
+ const task = taskTitleForId(agent.task);
5290
+ content.appendChild(
5291
+ element(doc, "div", "hive-agent-row-task", task || translate("agent.idle")),
5292
+ );
5293
+ const meta = [translate("agents.fileCount").replace("{count}", String((agent.files || []).length))];
5294
+ const activity = elapsedLabel(agent.updatedAt);
5295
+ if (activity) meta.push(activity);
5296
+ const metaNode = element(doc, "div", "hive-agent-row-meta", meta.join(" · "));
5297
+ if (agent.updatedAt) setAttr(metaNode, "title", agent.updatedAt);
5298
+ content.appendChild(metaNode);
5299
+ row.appendChild(content);
5300
+ body.appendChild(row);
5301
+ }
5302
+
5303
+ const supervisor = currentSupervisorRow();
5304
+ const workers = supervisor && Array.isArray(supervisor.workers) ? supervisor.workers : [];
5305
+ if (workers.length > 0) {
5306
+ body.appendChild(element(doc, "div", "hive-agents-workers-title", translate("agents.workersTitle")));
5307
+ for (const worker of workers) {
5308
+ const row = element(doc, "div", "hive-agent-worker-row");
5309
+ row.appendChild(
5310
+ element(doc, "div", "hive-agent-worker-task", taskTitleForId(worker.cardId) || worker.cardId),
5311
+ );
5312
+ const meta = [];
5313
+ if (worker.role) meta.push(worker.role);
5314
+ if (worker.startedAt) meta.push(translate("agents.workerStarted").replace("{time}", formatRunStamp(worker.startedAt)));
5315
+ const elapsed = elapsedLabel(worker.startedAt);
5316
+ if (elapsed) meta.push(translate("agents.workerElapsed").replace("{duration}", elapsed));
5317
+ row.appendChild(element(doc, "div", "hive-agent-worker-meta", meta.join(" · ") || worker.agentName || worker.agent || ""));
5318
+ body.appendChild(row);
5319
+ }
5320
+ }
5321
+
5322
+ const technical = element(doc, "details", "hive-agents-technical");
5323
+ technical.appendChild(element(doc, "summary", "hive-agents-technical-summary", translate("agents.technical")));
5324
+ technical.appendChild(
5325
+ element(doc, "pre", "hive-json hive-agents-technical-json", JSON.stringify({ agents, workers }, null, 2)),
5326
+ );
5327
+ body.appendChild(technical);
5328
+ dialog.appendChild(body);
5329
+
5330
+ showModalDialog(dialog);
5331
+ focusNode(closeButton);
5332
+ }
5333
+
5158
5334
  function openAgentDrawer(agent) {
5159
5335
  const raw = findRawAgent(agent) || { ...agent };
5160
5336
  const title = agent.agent || translate("agent.unknown");
@@ -5490,6 +5666,14 @@ export function mount(root, options = {}) {
5490
5666
  return;
5491
5667
  }
5492
5668
 
5669
+ // The init action succeeded, so the repository IS initialised. Switch the
5670
+ // open panel out of the init card on this render instead of waiting for the
5671
+ // next poll (a freshly initialised repo may have no refs for a while, and a
5672
+ // failed/racy snapshot fetch must not leave the stale init card up).
5673
+ if (lastSnapshot && typeof lastSnapshot === "object") {
5674
+ setSnapshot({ ...lastSnapshot, initialised: true });
5675
+ }
5676
+
5493
5677
  queenNotice = true;
5494
5678
  initErrorMessage = "";
5495
5679
  if (lastModel) {
@@ -5751,6 +5935,7 @@ export function mount(root, options = {}) {
5751
5935
  function setSupervisorData(rows) {
5752
5936
  supervisorData = Array.isArray(rows) ? rows : [];
5753
5937
  renderSupervisor();
5938
+ if (lastModel) renderAgents(lastModel);
5754
5939
  }
5755
5940
 
5756
5941
  async function refreshSupervisor(force = false) {
@@ -5912,16 +6097,27 @@ export function mount(root, options = {}) {
5912
6097
  agentsCount.disabled = true;
5913
6098
  return;
5914
6099
  }
5915
- const count = model.agents.length;
6100
+ const identities = model.agents.length;
6101
+ const row = currentSupervisorRow();
6102
+ const workers = supervisorWorkerCount(row);
6103
+ const running = workers !== null ? workers : identities;
6104
+ const claimed = asCount(model.stats.byState.claimed, (model.lanes.claimed || []).length);
6105
+ const waitingToReclaim = workers === 0 && claimed > 0;
5916
6106
  agentsCount.className = "hive-stat hive-agent-count";
5917
- agentsCount.textContent = translate("pane.agents") + " " + String(count);
5918
- const first = count > 0 ? model.agents[0] : null;
6107
+ agentsCount.textContent = waitingToReclaim
6108
+ ? translate("agents.waitingReclaim").replace("{count}", String(claimed))
6109
+ : translate("pane.agents") + " " + String(running);
6110
+ const first = identities > 0 ? model.agents[0] : null;
5919
6111
  agentsCount._agent = first;
5920
- agentsCount.disabled = !first;
5921
- const message = first
5922
- ? translate("agents.openAria") + " " + (first.agent || translate("agent.unknown"))
5923
- : translate("pane.agents");
5924
- const label = model.boardError || message;
6112
+ agentsCount.disabled = false;
6113
+ const message = waitingToReclaim
6114
+ ? translate("agents.waitingReclaimTooltip").replace("{count}", String(claimed))
6115
+ : workers !== null
6116
+ ? translate("agents.runningTooltip")
6117
+ .replace("{running}", String(running))
6118
+ .replace("{identities}", String(identities))
6119
+ : translate("agents.fallbackTooltip").replace("{identities}", String(identities));
6120
+ const label = model.boardError ? message + " · " + model.boardError : message;
5925
6121
  setAttr(agentsCount, "title", label);
5926
6122
  setAttr(agentsCount, "aria-label", label);
5927
6123
  }