@d86e/hive-panel 1.0.10 → 1.0.12

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.10",
3
+ "version": "1.0.12",
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
@@ -1189,3 +1189,34 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
1189
1189
  .hive-scope-path { max-width: 100%; padding: 2px 6px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-sm); background: var(--hive-bg-layer-1); color: var(--hive-fg-soft); font-family: var(--hive-mono); font-size: 10.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
1190
1190
  .hive-scope-more { padding: 2px 6px; font-size: 10.5px; }
1191
1191
 
1192
+ /* Dependency rows in the task dialog. */
1193
+ .hive-deps { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
1194
+ .hive-dep-row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
1195
+ .hive-dep-label { flex: 0 0 48px; padding-top: 2px; color: var(--hive-fg-faint); font-size: 11px; font-weight: 600; line-height: 1.5; }
1196
+ .hive-dep-items { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
1197
+ .hive-dep-item { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 6px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-sm); background: transparent; color: var(--hive-fg-soft); font-size: 11px; line-height: 1.5; text-align: left; cursor: pointer; }
1198
+ .hive-dep-item:hover { background: var(--hive-hover); color: var(--hive-fg); }
1199
+ .hive-dep-status { flex: 0 0 auto; font-size: 10px; line-height: 1; }
1200
+ .hive-dep-status.is-done { color: var(--hive-ok); }
1201
+ .hive-dep-status.is-failed { color: var(--hive-danger); }
1202
+ .hive-dep-status.is-pending { color: var(--hive-fg-faint); }
1203
+ .hive-dep-status.is-claimed { color: var(--hive-accent); }
1204
+ .hive-dep-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1205
+
1206
+ /* Reusable dialog sections: one heading, optional hint, and one inset surface. */
1207
+ .hive-section { display: block; margin: 0 0 12px; }
1208
+ .hive-section:last-child { margin-bottom: 0; }
1209
+ .hive-card-run,
1210
+ .hive-scope-block,
1211
+ .hive-deps { display: block; margin: 0 0 12px; }
1212
+ .hive-section-head { display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
1213
+ .hive-section-heading { flex: 1 1 auto; min-width: 0; }
1214
+ .hive-section-title { margin: 0; color: var(--hive-fg); font-size: 14px; font-weight: 650; line-height: 1.5; }
1215
+ .hive-section-hint { margin-top: 2px; color: var(--hive-fg-faint); font-size: 12px; line-height: 1.5; }
1216
+ .hive-section-caret { flex: 0 0 auto; padding-top: 2px; color: var(--hive-fg-faint); font-size: 11px; line-height: 1.5; }
1217
+ .hive-section-body { margin-top: 7px; }
1218
+ .hive-section-body.is-hidden { display: none; }
1219
+ .hive-section-content { padding: 10px; border: 1px solid var(--hive-line); border-radius: var(--hive-radius-md); background: var(--hive-bg-layer-1); }
1220
+ .hive-section-content > :first-child { margin-top: 0; }
1221
+ .hive-section-content > :last-child { margin-bottom: 0; }
1222
+
package/public/panel.js CHANGED
@@ -2070,6 +2070,35 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
2070
2070
  .hive-scope-list { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
2071
2071
  .hive-scope-path { max-width: 100%; padding: 2px 6px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-sm); background: var(--hive-bg-layer-1); color: var(--hive-fg-soft); font-family: var(--hive-mono); font-size: 10.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
2072
2072
  .hive-scope-more { padding: 2px 6px; font-size: 10.5px; }
2073
+ /* Dependency rows in the task dialog. */
2074
+ .hive-deps { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
2075
+ .hive-dep-row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
2076
+ .hive-dep-label { flex: 0 0 48px; padding-top: 2px; color: var(--hive-fg-faint); font-size: 11px; font-weight: 600; line-height: 1.5; }
2077
+ .hive-dep-items { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
2078
+ .hive-dep-item { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 6px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-sm); background: transparent; color: var(--hive-fg-soft); font-size: 11px; line-height: 1.5; text-align: left; cursor: pointer; }
2079
+ .hive-dep-item:hover { background: var(--hive-hover); color: var(--hive-fg); }
2080
+ .hive-dep-status { flex: 0 0 auto; font-size: 10px; line-height: 1; }
2081
+ .hive-dep-status.is-done { color: var(--hive-ok); }
2082
+ .hive-dep-status.is-failed { color: var(--hive-danger); }
2083
+ .hive-dep-status.is-pending { color: var(--hive-fg-faint); }
2084
+ .hive-dep-status.is-claimed { color: var(--hive-accent); }
2085
+ .hive-dep-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2086
+ /* Reusable dialog sections: one heading, optional hint, and one inset surface. */
2087
+ .hive-section { display: block; margin: 0 0 12px; }
2088
+ .hive-section:last-child { margin-bottom: 0; }
2089
+ .hive-card-run,
2090
+ .hive-scope-block,
2091
+ .hive-deps { display: block; margin: 0 0 12px; }
2092
+ .hive-section-head { display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
2093
+ .hive-section-heading { flex: 1 1 auto; min-width: 0; }
2094
+ .hive-section-title { margin: 0; color: var(--hive-fg); font-size: 14px; font-weight: 650; line-height: 1.5; }
2095
+ .hive-section-hint { margin-top: 2px; color: var(--hive-fg-faint); font-size: 12px; line-height: 1.5; }
2096
+ .hive-section-caret { flex: 0 0 auto; padding-top: 2px; color: var(--hive-fg-faint); font-size: 11px; line-height: 1.5; }
2097
+ .hive-section-body { margin-top: 7px; }
2098
+ .hive-section-body.is-hidden { display: none; }
2099
+ .hive-section-content { padding: 10px; border: 1px solid var(--hive-line); border-radius: var(--hive-radius-md); background: var(--hive-bg-layer-1); }
2100
+ .hive-section-content > :first-child { margin-top: 0; }
2101
+ .hive-section-content > :last-child { margin-bottom: 0; }
2073
2102
  `;
2074
2103
 
2075
2104
  const LANE_LABEL_KEYS = Object.freeze({
@@ -2165,6 +2194,9 @@ export const messages = Object.freeze({
2165
2194
  "drawer.lastRun": "Last run",
2166
2195
  "drawer.noOutput": "(no output)",
2167
2196
  "drawer.scopeTitle": "Work scope",
2197
+ "drawer.dependenciesTitle": "Dependencies",
2198
+ "drawer.dependsOn": "Depends on",
2199
+ "drawer.requiredBy": "Required by",
2168
2200
  "drawer.scopeHint": "Directories/files this task changes.",
2169
2201
  "drawer.scopeMore": "+{count} items",
2170
2202
  "drawer.runOverlaps": "Also writing",
@@ -2440,6 +2472,9 @@ export const messages = Object.freeze({
2440
2472
  "drawer.lastRun": "最近一次执行",
2441
2473
  "drawer.noOutput": "(无输出)",
2442
2474
  "drawer.scopeTitle": "工作范围",
2475
+ "drawer.dependenciesTitle": "依赖",
2476
+ "drawer.dependsOn": "依赖",
2477
+ "drawer.requiredBy": "被依赖",
2443
2478
  "drawer.scopeHint": "这个任务改动的目录/文件",
2444
2479
  "drawer.scopeMore": "+{count} 项",
2445
2480
  "drawer.runOverlaps": "同时写入",
@@ -2747,9 +2782,11 @@ function normalizeCard(task) {
2747
2782
  return {
2748
2783
  id: asString(task.id),
2749
2784
  title: asString(task.title),
2785
+ state: asString(task.state),
2750
2786
  role: asString(task.role),
2751
2787
  owner: asString(task.owner),
2752
2788
  scope: normalizeScope(task.scope),
2789
+ after: Array.isArray(task.after) ? task.after.map((id) => asString(id)).filter(Boolean) : [],
2753
2790
  reason: asString(task.reason),
2754
2791
  stateChangedAt: asString(task.stateChangedAt),
2755
2792
  createdAt: asString(task.createdAt),
@@ -2976,6 +3013,7 @@ export function renderModel(snapshot) {
2976
3013
  writable,
2977
3014
  lanes,
2978
3015
  laneOrder: [...LANE_ORDER],
3016
+ taskList: tasks.map(normalizeCard),
2979
3017
  stats: normalizeStats(source.stats, tasks),
2980
3018
  agents: normalizeAgents(source.board),
2981
3019
  // A board read that failed is not the same as an idle swarm: keep the
@@ -5719,16 +5757,57 @@ function renderMarkdownInto(doc, host, source) {
5719
5757
  flushParagraph();
5720
5758
  }
5721
5759
 
5760
+ function createSection(options = {}) {
5761
+ const section = element(doc, "section", "hive-section" + (options.className ? " " + options.className : ""));
5762
+ const head = element(doc, "button", "hive-section-head");
5763
+ setAttr(head, "type", "button");
5764
+ setAttr(head, "aria-expanded", "true");
5765
+ const heading = element(doc, "div", "hive-section-heading");
5766
+ const title = element(
5767
+ doc,
5768
+ "h3",
5769
+ "hive-section-title" + (options.titleClass ? " " + options.titleClass : ""),
5770
+ options.title || "",
5771
+ );
5772
+ heading.appendChild(title);
5773
+ if (options.hint) heading.appendChild(element(doc, "div", "hive-section-hint", options.hint));
5774
+ const caret = element(doc, "span", "hive-section-caret", "▾");
5775
+ setAttr(caret, "aria-hidden", "true");
5776
+ head.appendChild(heading);
5777
+ head.appendChild(caret);
5778
+ const headLabel = options.hint ? options.title + " — " + options.hint : options.title;
5779
+ setAttr(head, "title", headLabel);
5780
+ setAttr(head, "aria-label", headLabel);
5781
+ const body = element(doc, "div", "hive-section-body");
5782
+ const content = element(doc, "div", "hive-section-content");
5783
+ body.appendChild(content);
5784
+ section.appendChild(head);
5785
+ section.appendChild(body);
5786
+ let collapsed = false;
5787
+ head.addEventListener("click", () => {
5788
+ collapsed = !collapsed;
5789
+ body.className = "hive-section-body" + (collapsed ? " is-hidden" : "");
5790
+ caret.textContent = collapsed ? "▸" : "▾";
5791
+ setAttr(head, "aria-expanded", collapsed ? "false" : "true");
5792
+ });
5793
+ return { section, content, title, head };
5794
+ }
5795
+
5722
5796
  function buildRunSection(run, actionHost) {
5723
- const section = element(doc, "div", "hive-card-run");
5797
+ const part = createSection({
5798
+ title: translate("drawer.lastRun"),
5799
+ className: "hive-card-run",
5800
+ titleClass: "hive-card-run-title",
5801
+ });
5802
+ const section = part.section;
5803
+ const content = part.content;
5724
5804
  const addAction = (node) => {
5725
5805
  if (Array.isArray(actionHost)) actionHost.push(node);
5726
5806
  else if (actionHost && typeof actionHost.appendChild === "function") actionHost.appendChild(node);
5727
5807
  else section.appendChild(node);
5728
5808
  };
5729
- section.appendChild(element(doc, "div", "hive-card-run-title", translate("drawer.lastRun")));
5730
5809
  if (!run) {
5731
- section.appendChild(element(doc, "div", "hive-note hive-card-run-empty", translate("drawer.noRuns")));
5810
+ content.appendChild(element(doc, "div", "hive-note hive-card-run-empty", translate("drawer.noRuns")));
5732
5811
  return section;
5733
5812
  }
5734
5813
  const started = formatRunStamp(run.startedAt);
@@ -5739,7 +5818,7 @@ function renderMarkdownInto(doc, host, source) {
5739
5818
  const metaPartsText = metaParts.filter(Boolean).join(" · ");
5740
5819
  const meta = element(doc, "div", "hive-card-run-meta", metaPartsText);
5741
5820
  setAttr(meta, "title", metaPartsText);
5742
- section.appendChild(meta);
5821
+ content.appendChild(meta);
5743
5822
  // Consensus announcements: the other agents that announced the same paths. Invalid
5744
5823
  // entries are dropped by normalizeLastRun, duplicates collapse to one name,
5745
5824
  // and no overlapping writer means no row at all.
@@ -5752,7 +5831,7 @@ function renderMarkdownInto(doc, host, source) {
5752
5831
  const overlapsLabel = translate("drawer.runOverlaps");
5753
5832
  // The zh dictionary copy uses the full-width colon elsewhere in the panel.
5754
5833
  const separator = /[\u4e00-\u9fff]/.test(overlapsLabel) ? ":" : ": ";
5755
- section.appendChild(
5834
+ content.appendChild(
5756
5835
  element(doc, "div", "hive-card-run-meta", overlapsLabel + separator + writers.join(", ")),
5757
5836
  );
5758
5837
  }
@@ -5763,7 +5842,7 @@ function renderMarkdownInto(doc, host, source) {
5763
5842
  lessonCount > 0
5764
5843
  ? translate("drawer.runLessons").replace("{count}", String(lessonCount))
5765
5844
  : translate("drawer.runNoLessons");
5766
- section.appendChild(element(doc, "div", "hive-card-run-meta", lessonsText));
5845
+ content.appendChild(element(doc, "div", "hive-card-run-meta", lessonsText));
5767
5846
  const output = element(doc, "div", "hive-card-run-output hive-markdown");
5768
5847
  const outputText = asString(run.output);
5769
5848
  if (outputText.trim() === "") {
@@ -5771,7 +5850,7 @@ function renderMarkdownInto(doc, host, source) {
5771
5850
  } else {
5772
5851
  renderMarkdownInto(doc, output, outputText);
5773
5852
  }
5774
- section.appendChild(output);
5853
+ content.appendChild(output);
5775
5854
  const foot = element(doc, "div", "hive-card-run-foot");
5776
5855
  const copy = element(doc, "button", "hive-btn hive-btn-ghost hive-card-run-copy", translate("drawer.copyOutput"));
5777
5856
  setAttr(copy, "type", "button");
@@ -5806,6 +5885,63 @@ function renderMarkdownInto(doc, host, source) {
5806
5885
  return section;
5807
5886
  }
5808
5887
 
5888
+ function renderDependencies(card, body) {
5889
+ const tasks = lastModel && Array.isArray(lastModel.taskList) ? lastModel.taskList : [];
5890
+ const byId = new Map();
5891
+ for (const task of tasks) if (task && task.id) byId.set(task.id, task);
5892
+ const dependsOn = (Array.isArray(card.after) ? card.after : [])
5893
+ .map((id) => byId.get(id))
5894
+ .filter(Boolean);
5895
+ const requiredBy = tasks.filter(
5896
+ (task) =>
5897
+ task &&
5898
+ task.id !== card.id &&
5899
+ Array.isArray(task.after) &&
5900
+ task.after.includes(card.id),
5901
+ );
5902
+ if (dependsOn.length === 0 && requiredBy.length === 0) return;
5903
+
5904
+ const part = createSection({
5905
+ title: translate("drawer.dependenciesTitle"),
5906
+ className: "hive-deps",
5907
+ });
5908
+ const block = part.section;
5909
+ const content = part.content;
5910
+ const addRow = (label, list) => {
5911
+ if (list.length === 0) return;
5912
+ const row = element(doc, "div", "hive-dep-row");
5913
+ row.appendChild(element(doc, "div", "hive-dep-label", label));
5914
+ const items = element(doc, "div", "hive-dep-items");
5915
+ for (const task of list) {
5916
+ const button = element(doc, "button", "hive-dep-item");
5917
+ setAttr(button, "type", "button");
5918
+ const status = asString(task.state) || "pending";
5919
+ const marker = element(
5920
+ doc,
5921
+ "span",
5922
+ "hive-dep-status is-" + safeClassToken(status),
5923
+ status === "done" ? "✓" : "●",
5924
+ );
5925
+ setAttr(marker, "title", laneLabel(status));
5926
+ button.appendChild(marker);
5927
+ const title = task.title || task.id || translate("card.untitled");
5928
+ button.appendChild(element(doc, "span", "hive-dep-title", title));
5929
+ const aria = translate("card.openAria") + " " + title;
5930
+ setAttr(button, "title", aria);
5931
+ setAttr(button, "aria-label", aria);
5932
+ button.addEventListener("click", () => {
5933
+ openDrawer(task, status);
5934
+ });
5935
+ items.appendChild(button);
5936
+ }
5937
+ row.appendChild(items);
5938
+ content.appendChild(row);
5939
+ };
5940
+ addRow(translate("drawer.dependsOn"), dependsOn);
5941
+ addRow(translate("drawer.requiredBy"), requiredBy);
5942
+ if (content.children.length > 0) body.appendChild(block);
5943
+ }
5944
+
5809
5945
  function openDrawer(card, lane, trigger) {
5810
5946
  closeHelp(false);
5811
5947
  closePlanDialog(false);
@@ -5842,9 +5978,13 @@ function renderMarkdownInto(doc, host, source) {
5842
5978
 
5843
5979
  const body = element(doc, "div", "hive-dialog-body hive-card-body");
5844
5980
  if (Array.isArray(card.scope) && card.scope.length > 0) {
5845
- const scopeBlock = element(doc, "div", "hive-scope-block");
5846
- scopeBlock.appendChild(element(doc, "div", "hive-scope-title", translate("drawer.scopeTitle")));
5847
- scopeBlock.appendChild(element(doc, "div", "hive-scope-hint", translate("drawer.scopeHint")));
5981
+ const scopePart = createSection({
5982
+ title: translate("drawer.scopeTitle"),
5983
+ hint: translate("drawer.scopeHint"),
5984
+ className: "hive-scope-block",
5985
+ titleClass: "hive-scope-title",
5986
+ });
5987
+ const scopeBlock = scopePart.section;
5848
5988
  const scopeList = element(doc, "div", "hive-scope-list");
5849
5989
  const scopes = card.scope.filter((scope) => asString(scope) !== "");
5850
5990
  const visibleScopes = scopes.slice(0, 5);
@@ -5862,6 +6002,8 @@ function renderMarkdownInto(doc, host, source) {
5862
6002
  translate("drawer.scopeMore").replace("{count}", String(hiddenScopes.length)),
5863
6003
  );
5864
6004
  setAttr(more, "type", "button");
6005
+ setAttr(more, "title", translate("drawer.scopeMore").replace("{count}", String(hiddenScopes.length)));
6006
+ setAttr(more, "aria-label", translate("drawer.scopeMore").replace("{count}", String(hiddenScopes.length)));
5865
6007
  more.addEventListener("click", () => {
5866
6008
  for (const scope of hiddenScopes) {
5867
6009
  const path = element(doc, "code", "hive-scope-path", asString(scope));
@@ -5872,10 +6014,11 @@ function renderMarkdownInto(doc, host, source) {
5872
6014
  });
5873
6015
  scopeList.appendChild(more);
5874
6016
  }
5875
- scopeBlock.appendChild(scopeList);
6017
+ scopePart.content.appendChild(scopeList);
5876
6018
  body.appendChild(scopeBlock);
5877
6019
  }
5878
6020
 
6021
+ renderDependencies(card, body);
5879
6022
  const runActions = [];
5880
6023
  body.appendChild(buildRunSection(card.lastRun, runActions));
5881
6024
  dialog.appendChild(body);