@d86e/hive-panel 1.0.4 → 1.0.6

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.4",
3
+ "version": "1.0.6",
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
@@ -1148,3 +1148,8 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
1148
1148
  .hive-agents-technical-summary { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; cursor: pointer; }
1149
1149
  .hive-agents-technical-json { max-height: 220px; margin-top: 8px; }
1150
1150
 
1151
+ .hive-supervisor-inline-sep { color: var(--hive-fg-faint); }
1152
+ .hive-supervisor-inline-state.is-normal::before { background: var(--hive-ok); }
1153
+ .hive-supervisor-inline-state.is-paused::before { background: var(--hive-warn); }
1154
+ .hive-supervisor-inline-state.is-unresponsive::before { background: var(--hive-fg-faint); }
1155
+
package/public/panel.js CHANGED
@@ -2033,6 +2033,10 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
2033
2033
  .hive-agents-technical { border-top: 1px solid var(--hive-line-2); padding-top: 8px; }
2034
2034
  .hive-agents-technical-summary { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; cursor: pointer; }
2035
2035
  .hive-agents-technical-json { max-height: 220px; margin-top: 8px; }
2036
+ .hive-supervisor-inline-sep { color: var(--hive-fg-faint); }
2037
+ .hive-supervisor-inline-state.is-normal::before { background: var(--hive-ok); }
2038
+ .hive-supervisor-inline-state.is-paused::before { background: var(--hive-warn); }
2039
+ .hive-supervisor-inline-state.is-unresponsive::before { background: var(--hive-fg-faint); }
2036
2040
  `;
2037
2041
 
2038
2042
  const LANE_LABEL_KEYS = Object.freeze({
@@ -2134,7 +2138,14 @@ export const messages = Object.freeze({
2134
2138
  "supervisor.runningCount": "running {count}",
2135
2139
  "supervisor.idle": "idle",
2136
2140
  "supervisor.backoff": "backoff",
2137
- "supervisor.paused": "paused",
2141
+ "supervisor.paused": "Paused",
2142
+ "supervisor.normal": "Normal",
2143
+ "supervisor.unresponsive": "Unresponsive",
2144
+ "supervisor.noData": "No supervisor data",
2145
+ "supervisor.lastCheck": "Last check {seconds}s ago",
2146
+ "supervisor.tooltipRunning": "Running {count}",
2147
+ "supervisor.tooltipQueued": "Queued {count}",
2148
+ "supervisor.tooltipError": "Last error: {error}",
2138
2149
  "supervisor.resume": "resume",
2139
2150
  "supervisor.resumeAria": "Resume the supervisor for {repo}",
2140
2151
  "supervisor.resumeFailed": "Could not resume the supervisor",
@@ -2389,6 +2400,13 @@ export const messages = Object.freeze({
2389
2400
  "supervisor.idle": "空闲",
2390
2401
  "supervisor.backoff": "退避",
2391
2402
  "supervisor.paused": "已暂停",
2403
+ "supervisor.normal": "正常",
2404
+ "supervisor.unresponsive": "未响应",
2405
+ "supervisor.noData": "无监督器数据",
2406
+ "supervisor.lastCheck": "最近一次检查 {seconds} 秒前",
2407
+ "supervisor.tooltipRunning": "运行中 {count} 个",
2408
+ "supervisor.tooltipQueued": "待办 {count} 个",
2409
+ "supervisor.tooltipError": "最近错误:{error}",
2392
2410
  "supervisor.resume": "恢复",
2393
2411
  "supervisor.resumeAria": "恢复 {repo} 的 supervisor",
2394
2412
  "supervisor.resumeFailed": "恢复 supervisor 失败",
@@ -3093,13 +3111,40 @@ function normalizeSupervisorStatus(payload) {
3093
3111
  supervisorCount(source.agents) ??
3094
3112
  supervisorCount(source.inflight) ??
3095
3113
  supervisorCount(source.count);
3114
+ const roleRows = normalizeSupervisorRoles(source);
3115
+ let queued = isRecord(source.backlog) ? supervisorCount(source.backlog.queued) : null;
3116
+ if (queued === null) {
3117
+ let total = 0;
3118
+ let found = false;
3119
+ for (const role of roleRows) {
3120
+ if (supervisorNumber(role.queued) !== null) {
3121
+ total += supervisorNumber(role.queued);
3122
+ found = true;
3123
+ }
3124
+ }
3125
+ queued = found ? total : null;
3126
+ }
3127
+ const lastError = asString(
3128
+ source.lastError || source.environmentError || source.limitsError,
3129
+ );
3130
+ const lastCheckAt = asString(source.lastCheckAt || source.last_check_at);
3096
3131
  let state = "idle";
3097
3132
  if (paused) state = "paused";
3098
3133
  else if (source.backoff === true || /backoff|back-off|retry|delay|wait/.test(rawState)) state = "backoff";
3099
3134
  else if (/run|active|busy|working/.test(rawState)) state = "running";
3100
3135
  else if (/idle|ready|free/.test(rawState)) state = "idle";
3101
3136
  else if (running !== null && running > 0) state = "running";
3102
- rows.set(repo, { repo, state, running, roles: normalizeSupervisorRoles(source), workers: normalizeSupervisorWorkers(source) });
3137
+ rows.set(repo, {
3138
+ repo,
3139
+ state,
3140
+ paused,
3141
+ running,
3142
+ queued,
3143
+ lastCheckAt,
3144
+ lastError,
3145
+ roles: roleRows,
3146
+ workers: normalizeSupervisorWorkers(source),
3147
+ });
3103
3148
  }
3104
3149
  return [...rows.values()].sort((left, right) => left.repo.localeCompare(right.repo));
3105
3150
  }
@@ -3635,6 +3680,7 @@ export function mount(root, options = {}) {
3635
3680
  const supervisorInline = element(doc, "span", "hive-supervisor-inline is-hidden");
3636
3681
  setAttr(supervisorInline, "aria-label", translate("supervisor.aria"));
3637
3682
  const supervisorInlineLabel = element(doc, "span", "hive-supervisor-inline-label", translate("supervisor.label"));
3683
+ const supervisorInlineSep = element(doc, "span", "hive-supervisor-inline-sep", "·");
3638
3684
  const supervisorInlineState = element(doc, "span", "hive-supervisor-inline-state", "");
3639
3685
  const supervisorInlineResume = element(doc, "button", "hive-btn hive-supervisor-inline-resume is-hidden", translate("supervisor.resume"));
3640
3686
  setAttr(supervisorInlineResume, "type", "button");
@@ -3642,6 +3688,7 @@ export function mount(root, options = {}) {
3642
3688
  if (supervisorInlineRow) void resumeSupervisor(supervisorInlineRow, supervisorInlineResume);
3643
3689
  });
3644
3690
  supervisorInline.appendChild(supervisorInlineLabel);
3691
+ supervisorInline.appendChild(supervisorInlineSep);
3645
3692
  supervisorInline.appendChild(supervisorInlineState);
3646
3693
  supervisorInline.appendChild(supervisorInlineResume);
3647
3694
  bar.appendChild(supervisorInline);
@@ -5963,36 +6010,58 @@ export function mount(root, options = {}) {
5963
6010
  supervisorInlineState.className = "hive-supervisor-inline-state";
5964
6011
  supervisorInlineState.textContent = "";
5965
6012
  supervisorInlineResume.className = "hive-btn hive-supervisor-inline-resume is-hidden";
5966
- setAttr(supervisorInline, "aria-label", translate("supervisor.aria"));
5967
6013
  supervisorInlineLabel.textContent = translate("supervisor.label");
5968
- if (!lastModel || !Array.isArray(supervisorData) || supervisorData.length === 0) return;
5969
- const row = supervisorData.find((entry) => entry.repo === lastModel.repo);
5970
- if (!row) return;
6014
+ supervisorInlineSep.textContent = "·";
6015
+ if (!lastModel) return;
6016
+
6017
+ const row = Array.isArray(supervisorData)
6018
+ ? supervisorData.find((entry) => entry.repo === lastModel.repo)
6019
+ : null;
6020
+ const now = Date.now();
6021
+ const lastCheck = row ? parseDate(row.lastCheckAt) : null;
6022
+ const fresh = lastCheck !== null && now - lastCheck.getTime() <= 90_000;
6023
+ const paused = Boolean(row && (row.paused === true || row.state === "paused"));
6024
+ const status = paused ? "paused" : fresh ? "normal" : "unresponsive";
6025
+ const label =
6026
+ status === "normal"
6027
+ ? translate("supervisor.normal")
6028
+ : status === "paused"
6029
+ ? translate("supervisor.paused")
6030
+ : translate("supervisor.unresponsive");
5971
6031
 
5972
- supervisorInlineRow = row;
5973
6032
  supervisorInline.className = "hive-supervisor-inline";
5974
- let stateLabel = translate("supervisor.idle");
5975
- if (row.state === "running") {
5976
- stateLabel =
5977
- row.running === null || row.running === undefined
5978
- ? translate("supervisor.running")
5979
- : translate("supervisor.runningCount").replace("{count}", String(row.running));
5980
- } else if (row.state === "backoff") {
5981
- stateLabel = translate("supervisor.backoff");
5982
- } else if (row.state === "paused") {
5983
- stateLabel = translate("supervisor.paused");
5984
- }
5985
- supervisorInlineState.className = "hive-supervisor-inline-state is-" + row.state;
5986
- supervisorInlineState.textContent = stateLabel;
5987
-
5988
- if (row.state === "paused") {
6033
+ supervisorInlineRow = row || null;
6034
+ supervisorInlineState.className = "hive-supervisor-inline-state is-" + status;
6035
+ supervisorInlineState.textContent = label;
6036
+
6037
+ const details = [];
6038
+ if (lastCheck) {
6039
+ details.push(
6040
+ translate("supervisor.lastCheck").replace(
6041
+ "{seconds}",
6042
+ String(Math.max(0, Math.floor((now - lastCheck.getTime()) / 1000))),
6043
+ ),
6044
+ );
6045
+ } else {
6046
+ details.push(translate("supervisor.noData"));
6047
+ }
6048
+ const running = row ? supervisorWorkerCount(row) : null;
6049
+ details.push(translate("supervisor.tooltipRunning").replace("{count}", String(running === null ? 0 : running)));
6050
+ details.push(translate("supervisor.tooltipQueued").replace("{count}", String(row && row.queued !== null && row.queued !== undefined ? row.queued : 0)));
6051
+ if (row && row.lastError) {
6052
+ details.push(translate("supervisor.tooltipError").replace("{error}", asString(row.lastError)));
6053
+ }
6054
+ const tooltip = details.join(" · ");
6055
+ setAttr(supervisorInline, "title", tooltip);
6056
+ setAttr(supervisorInline, "aria-label", tooltip);
6057
+
6058
+ if (paused && row) {
5989
6059
  const aria = translate("supervisor.resumeAria").replace("{repo}", row.repo);
5990
6060
  supervisorInlineResume.className = "hive-btn hive-supervisor-inline-resume";
5991
6061
  setAttr(supervisorInlineResume, "title", aria);
5992
6062
  setAttr(supervisorInlineResume, "aria-label", aria);
5993
6063
  }
5994
6064
  }
5995
-
5996
6065
  function setSupervisorData(rows) {
5997
6066
  supervisorData = Array.isArray(rows) ? rows : [];
5998
6067
  renderSupervisor();
@@ -6101,11 +6170,7 @@ export function mount(root, options = {}) {
6101
6170
  const label = translate("stats.oldest") + (duration ? " " + duration : "");
6102
6171
  const oldest = element(doc, "span", "hive-stat is-warn hive-oldest");
6103
6172
  oldest.appendChild(element(doc, "span", "hive-oldest-label", label));
6104
- if (pending.id) {
6105
- oldest.appendChild(element(doc, "span", "hive-oldest-sep", " · "));
6106
- oldest.appendChild(element(doc, "code", "hive-oldest-id", pending.id));
6107
- }
6108
- setAttr(oldest, "title", label + (pending.id ? " · " + pending.id : ""));
6173
+ setAttr(oldest, "title", label);
6109
6174
  statsNode.appendChild(oldest);
6110
6175
  }
6111
6176