@d86e/hive-panel 0.4.0 → 0.4.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 +1 -1
- package/public/panel.css +11 -0
- package/public/panel.js +143 -13
package/package.json
CHANGED
package/public/panel.css
CHANGED
|
@@ -1086,3 +1086,14 @@ dialog.hive-dialog .hive-card-subline,
|
|
|
1086
1086
|
dialog.hive-dialog .hive-settings-role-name { min-width: 0; overflow-wrap: anywhere; }
|
|
1087
1087
|
dialog.hive-dialog .hive-dialog-foot { flex-wrap: wrap; }
|
|
1088
1088
|
|
|
1089
|
+
dialog.hive-dialog {
|
|
1090
|
+
display: flex;
|
|
1091
|
+
flex-direction: column;
|
|
1092
|
+
max-height: 80vh;
|
|
1093
|
+
}
|
|
1094
|
+
dialog.hive-dialog .hive-dialog-head,
|
|
1095
|
+
dialog.hive-dialog .hive-dialog-foot { flex: 0 0 auto; }
|
|
1096
|
+
dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
1097
|
+
.hive-card-run-output { max-height: 20lh; overflow: auto; }
|
|
1098
|
+
.hive-card-actions { flex-wrap: wrap; justify-content: flex-end; }
|
|
1099
|
+
|
package/public/panel.js
CHANGED
|
@@ -404,6 +404,14 @@ const PANEL_STYLES = `.hive { position: relative; }
|
|
|
404
404
|
font-size: 12px;
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
+
.hive-agents-error {
|
|
408
|
+
min-width: 0;
|
|
409
|
+
overflow-wrap: anywhere;
|
|
410
|
+
color: var(--hive-danger);
|
|
411
|
+
font-family: var(--hive-mono);
|
|
412
|
+
font-size: 12px;
|
|
413
|
+
}
|
|
414
|
+
|
|
407
415
|
.hive-stage-chips {
|
|
408
416
|
display: flex;
|
|
409
417
|
flex: 0 0 auto;
|
|
@@ -1498,7 +1506,8 @@ const PANEL_STYLES = `.hive { position: relative; }
|
|
|
1498
1506
|
}
|
|
1499
1507
|
|
|
1500
1508
|
.hive-card-run-output {
|
|
1501
|
-
max-height: 360px;
|
|
1509
|
+
max-height: 360px;
|
|
1510
|
+
max-height: 20lh; /* longer output scrolls inside the pre */
|
|
1502
1511
|
margin: 0;
|
|
1503
1512
|
padding: 10px;
|
|
1504
1513
|
overflow: auto;
|
|
@@ -1965,6 +1974,16 @@ dialog.hive-dialog .hive-dialog-title,
|
|
|
1965
1974
|
dialog.hive-dialog .hive-card-subline,
|
|
1966
1975
|
dialog.hive-dialog .hive-settings-role-name { min-width: 0; overflow-wrap: anywhere; }
|
|
1967
1976
|
dialog.hive-dialog .hive-dialog-foot { flex-wrap: wrap; }
|
|
1977
|
+
dialog.hive-dialog {
|
|
1978
|
+
display: flex;
|
|
1979
|
+
flex-direction: column;
|
|
1980
|
+
max-height: 80vh;
|
|
1981
|
+
}
|
|
1982
|
+
dialog.hive-dialog .hive-dialog-head,
|
|
1983
|
+
dialog.hive-dialog .hive-dialog-foot { flex: 0 0 auto; }
|
|
1984
|
+
dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
1985
|
+
.hive-card-run-output { max-height: 20lh; overflow: auto; }
|
|
1986
|
+
.hive-card-actions { flex-wrap: wrap; justify-content: flex-end; }
|
|
1968
1987
|
`;
|
|
1969
1988
|
|
|
1970
1989
|
const LANE_LABEL_KEYS = Object.freeze({
|
|
@@ -2042,6 +2061,9 @@ export const messages = Object.freeze({
|
|
|
2042
2061
|
"drawer.removeClaimed": "A claimed task must be released or reopened before it can be deleted.",
|
|
2043
2062
|
"drawer.rawJson": "raw json",
|
|
2044
2063
|
"drawer.lastRun": "Last run",
|
|
2064
|
+
"drawer.runOverlaps": "Also writing",
|
|
2065
|
+
"drawer.runLessons": "Read {count} lessons",
|
|
2066
|
+
"drawer.runNoLessons": "No lessons to read",
|
|
2045
2067
|
"drawer.noRuns": "No runs yet",
|
|
2046
2068
|
"drawer.copyOutput": "Copy output",
|
|
2047
2069
|
"drawer.openChat": "Open agent chat",
|
|
@@ -2281,6 +2303,9 @@ export const messages = Object.freeze({
|
|
|
2281
2303
|
"drawer.removeClaimed": "已认领的任务必须先释放或重开才能删除。",
|
|
2282
2304
|
"drawer.rawJson": "原始 JSON",
|
|
2283
2305
|
"drawer.lastRun": "最近一次执行",
|
|
2306
|
+
"drawer.runOverlaps": "同时写入",
|
|
2307
|
+
"drawer.runLessons": "读取了 {count} 条经验",
|
|
2308
|
+
"drawer.runNoLessons": "没有可读取的经验",
|
|
2284
2309
|
"drawer.noRuns": "还没有执行记录",
|
|
2285
2310
|
"drawer.copyOutput": "复制输出",
|
|
2286
2311
|
"drawer.openChat": "打开智能体对话",
|
|
@@ -2493,12 +2518,56 @@ function normalizeScope(scope) {
|
|
|
2493
2518
|
return [];
|
|
2494
2519
|
}
|
|
2495
2520
|
|
|
2521
|
+
/**
|
|
2522
|
+
* Normalize the optional `overlaps` announcements of a run record: other agents
|
|
2523
|
+
* have declared they are writing the same paths too. An entry without a
|
|
2524
|
+
* non-empty agent is dropped; a missing or malformed list is empty, so the
|
|
2525
|
+
* drawer renders no overlap row.
|
|
2526
|
+
* @param {unknown} value
|
|
2527
|
+
* @returns {Array<{key:string,agent:string,task:string,expiresAt:string}>}
|
|
2528
|
+
*/
|
|
2529
|
+
function normalizeOverlaps(value) {
|
|
2530
|
+
const overlaps = [];
|
|
2531
|
+
for (const entry of asArray(value)) {
|
|
2532
|
+
if (!isRecord(entry)) continue;
|
|
2533
|
+
const agent = asString(entry.agent);
|
|
2534
|
+
if (agent.trim() === "") continue;
|
|
2535
|
+
overlaps.push({
|
|
2536
|
+
key: asString(entry.key),
|
|
2537
|
+
agent,
|
|
2538
|
+
task: asString(entry.task),
|
|
2539
|
+
expiresAt: asString(entry.expiresAt),
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2542
|
+
return overlaps;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
/**
|
|
2546
|
+
* Normalize the optional `lessons` recall summary of a run record. A missing
|
|
2547
|
+
* or malformed record is null; a count-only, scopes-only or error-only record
|
|
2548
|
+
* survives so the drawer can still render its "no lessons" line.
|
|
2549
|
+
* @param {unknown} value
|
|
2550
|
+
* @returns {null|{count:number,scopes:string[],error?:string}}
|
|
2551
|
+
*/
|
|
2552
|
+
function normalizeLessons(value) {
|
|
2553
|
+
if (!isRecord(value)) return null;
|
|
2554
|
+
const lessons = {
|
|
2555
|
+
count: asCount(value.count, 0),
|
|
2556
|
+
scopes: asArray(value.scopes)
|
|
2557
|
+
.map((scope) => asString(scope))
|
|
2558
|
+
.filter((scope) => scope.trim() !== ""),
|
|
2559
|
+
};
|
|
2560
|
+
const error = asString(value.error);
|
|
2561
|
+
if (error !== "") lessons.error = error;
|
|
2562
|
+
return lessons;
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2496
2565
|
/**
|
|
2497
2566
|
* Normalize `lastRun` (written by hive-runner to .hive/runs/<cardId>.json).
|
|
2498
2567
|
* A missing record is null; a malformed one is dropped instead of leaking
|
|
2499
2568
|
* half-parsed values into the drawer.
|
|
2500
2569
|
* @param {unknown} value
|
|
2501
|
-
* @returns {null|{agent:string,startedAt:string,endedAt:string,status:string,commit:string,exitCode:number|null,sessionId:string,output:string}}
|
|
2570
|
+
* @returns {null|{agent:string,startedAt:string,endedAt:string,status:string,commit:string,exitCode:number|null,sessionId:string,output:string,overlaps:Array<{key:string,agent:string,task:string,expiresAt:string}>,lessons:null|{count:number,scopes:string[],error?:string}}}
|
|
2502
2571
|
*/
|
|
2503
2572
|
function normalizeLastRun(value) {
|
|
2504
2573
|
if (!isRecord(value)) return null;
|
|
@@ -2515,6 +2584,10 @@ function normalizeLastRun(value) {
|
|
|
2515
2584
|
// navigate can open that conversation, an older record simply has none.
|
|
2516
2585
|
sessionId: asString(value.sessionId),
|
|
2517
2586
|
output: asString(value.output),
|
|
2587
|
+
// Consensus announcements from the other writers of these paths.
|
|
2588
|
+
overlaps: normalizeOverlaps(value.overlaps),
|
|
2589
|
+
// Memory recall summary: how many lessons the worker read before its run.
|
|
2590
|
+
lessons: normalizeLessons(value.lessons),
|
|
2518
2591
|
};
|
|
2519
2592
|
}
|
|
2520
2593
|
|
|
@@ -2671,6 +2744,7 @@ function toolbarActions(writable, mode) {
|
|
|
2671
2744
|
* laneOrder: string[],
|
|
2672
2745
|
* stats: {total:number, byState:Record<string,number>, byRole:Record<string,number>, oldestPending:{id:string,createdAt:string}|null},
|
|
2673
2746
|
* agents: Array<{agent:string,state:string,task:string,files:string[],updatedAt:string}>,
|
|
2747
|
+
* boardError: string|null,
|
|
2674
2748
|
* events: Array<{ts:string,kind:string,task:string,actor:string}>,
|
|
2675
2749
|
* actions: Array<{name:string,labelKey:string,body?:object}>
|
|
2676
2750
|
* }}
|
|
@@ -2749,6 +2823,9 @@ export function renderModel(snapshot) {
|
|
|
2749
2823
|
laneOrder: [...LANE_ORDER],
|
|
2750
2824
|
stats: normalizeStats(source.stats, tasks),
|
|
2751
2825
|
agents: normalizeAgents(source.board),
|
|
2826
|
+
// A board read that failed is not the same as an idle swarm: keep the
|
|
2827
|
+
// diagnostic so the agents strip can show it instead of "no agents".
|
|
2828
|
+
boardError: asString(source.boardError) || null,
|
|
2752
2829
|
events: normalizeEvents(source.events),
|
|
2753
2830
|
actions: initialised ? toolbarActions(writable, mode) : [],
|
|
2754
2831
|
};
|
|
@@ -5066,13 +5143,20 @@ export function mount(root, options = {}) {
|
|
|
5066
5143
|
* The card drawer's "Last run" block. With no record it is one muted line;
|
|
5067
5144
|
* with a record it shows status, agent, timestamps and the short commit above
|
|
5068
5145
|
* the worker output (monospace, internally scrollable) and a copy button.
|
|
5069
|
-
* A record
|
|
5070
|
-
*
|
|
5146
|
+
* A record with overlapping writers adds one "Also writing" row, a record with
|
|
5147
|
+
* a lessons summary adds one recall row, and a record whose worker Session is
|
|
5148
|
+
* known, on a host that provides `openSession`, also gets the "Open agent
|
|
5149
|
+
* chat" button.
|
|
5071
5150
|
* @param {object|null} run - normalized `lastRun` (see normalizeLastRun)
|
|
5072
5151
|
* @returns {HTMLElement}
|
|
5073
5152
|
*/
|
|
5074
|
-
function buildRunSection(run) {
|
|
5153
|
+
function buildRunSection(run, actionHost) {
|
|
5075
5154
|
const section = element(doc, "div", "hive-card-run");
|
|
5155
|
+
const addAction = (node) => {
|
|
5156
|
+
if (Array.isArray(actionHost)) actionHost.push(node);
|
|
5157
|
+
else if (actionHost && typeof actionHost.appendChild === "function") actionHost.appendChild(node);
|
|
5158
|
+
else section.appendChild(node);
|
|
5159
|
+
};
|
|
5076
5160
|
section.appendChild(element(doc, "div", "hive-card-run-title", translate("drawer.lastRun")));
|
|
5077
5161
|
if (!run) {
|
|
5078
5162
|
section.appendChild(element(doc, "div", "hive-note hive-card-run-empty", translate("drawer.noRuns")));
|
|
@@ -5087,6 +5171,30 @@ export function mount(root, options = {}) {
|
|
|
5087
5171
|
const meta = element(doc, "div", "hive-card-run-meta", metaPartsText);
|
|
5088
5172
|
setAttr(meta, "title", metaPartsText);
|
|
5089
5173
|
section.appendChild(meta);
|
|
5174
|
+
// Consensus announcements: the other agents that announced the same paths. Invalid
|
|
5175
|
+
// entries are dropped by normalizeLastRun, duplicates collapse to one name,
|
|
5176
|
+
// and no overlapping writer means no row at all.
|
|
5177
|
+
const writers = [];
|
|
5178
|
+
for (const overlap of run.overlaps) {
|
|
5179
|
+
const agent = asString(overlap.agent);
|
|
5180
|
+
if (agent !== "" && !writers.includes(agent)) writers.push(agent);
|
|
5181
|
+
}
|
|
5182
|
+
if (writers.length > 0) {
|
|
5183
|
+
const overlapsLabel = translate("drawer.runOverlaps");
|
|
5184
|
+
// The zh dictionary copy uses the full-width colon elsewhere in the panel.
|
|
5185
|
+
const separator = /[\u4e00-\u9fff]/.test(overlapsLabel) ? ":" : ": ";
|
|
5186
|
+
section.appendChild(
|
|
5187
|
+
element(doc, "div", "hive-card-run-meta", overlapsLabel + separator + writers.join(", ")),
|
|
5188
|
+
);
|
|
5189
|
+
}
|
|
5190
|
+
// Memory recall: the worker always reports whether it read lessons, so the
|
|
5191
|
+
// block keeps one line even when the record predates that field.
|
|
5192
|
+
const lessonCount = run.lessons ? asCount(run.lessons.count, 0) : 0;
|
|
5193
|
+
const lessonsText =
|
|
5194
|
+
lessonCount > 0
|
|
5195
|
+
? translate("drawer.runLessons").replace("{count}", String(lessonCount))
|
|
5196
|
+
: translate("drawer.runNoLessons");
|
|
5197
|
+
section.appendChild(element(doc, "div", "hive-card-run-meta", lessonsText));
|
|
5090
5198
|
section.appendChild(element(doc, "pre", "hive-card-run-output", run.output));
|
|
5091
5199
|
const foot = element(doc, "div", "hive-card-run-foot");
|
|
5092
5200
|
const copy = element(doc, "button", "hive-btn hive-btn-ghost hive-card-run-copy", translate("drawer.copyOutput"));
|
|
@@ -5096,10 +5204,14 @@ export function mount(root, options = {}) {
|
|
|
5096
5204
|
copy.addEventListener("click", () => {
|
|
5097
5205
|
copyToClipboard(doc, run.output);
|
|
5098
5206
|
});
|
|
5099
|
-
|
|
5207
|
+
if (Array.isArray(actionHost) || actionHost) addAction(copy);
|
|
5208
|
+
else foot.appendChild(copy);
|
|
5100
5209
|
// Only render the jump-to-chat control when both halves exist: a recorded
|
|
5101
|
-
// worker Session and a host navigation callback.
|
|
5102
|
-
|
|
5210
|
+
// worker Session and a host navigation callback. The status does not matter:
|
|
5211
|
+
// a running card exposes its Session as soon as the worker starts, and the
|
|
5212
|
+
// button must be there while the card is still in progress. No disabled stub.
|
|
5213
|
+
const canOpenChat = asString(run.sessionId) !== "" && typeof openSession === "function";
|
|
5214
|
+
if (canOpenChat) {
|
|
5103
5215
|
const chat = element(doc, "button", "hive-btn hive-btn-ghost hive-card-run-open", translate("drawer.openChat"));
|
|
5104
5216
|
setAttr(chat, "type", "button");
|
|
5105
5217
|
setAttr(chat, "title", translate("drawer.openChat"));
|
|
@@ -5111,9 +5223,10 @@ export function mount(root, options = {}) {
|
|
|
5111
5223
|
reportError(error);
|
|
5112
5224
|
}
|
|
5113
5225
|
});
|
|
5114
|
-
|
|
5226
|
+
if (Array.isArray(actionHost) || actionHost) addAction(chat);
|
|
5227
|
+
else foot.appendChild(chat);
|
|
5115
5228
|
}
|
|
5116
|
-
section.appendChild(foot);
|
|
5229
|
+
if (!actionHost) section.appendChild(foot);
|
|
5117
5230
|
return section;
|
|
5118
5231
|
}
|
|
5119
5232
|
|
|
@@ -5153,7 +5266,8 @@ export function mount(root, options = {}) {
|
|
|
5153
5266
|
dialog.appendChild(head);
|
|
5154
5267
|
|
|
5155
5268
|
const body = element(doc, "div", "hive-dialog-body hive-card-body");
|
|
5156
|
-
|
|
5269
|
+
const runActions = [];
|
|
5270
|
+
body.appendChild(buildRunSection(card.lastRun, runActions));
|
|
5157
5271
|
dialog.appendChild(body);
|
|
5158
5272
|
|
|
5159
5273
|
const actions = actionsForState(lane, lastModel ? lastModel.writable : false);
|
|
@@ -5167,9 +5281,10 @@ export function mount(root, options = {}) {
|
|
|
5167
5281
|
),
|
|
5168
5282
|
);
|
|
5169
5283
|
}
|
|
5170
|
-
if (actions.length > 0) {
|
|
5284
|
+
if (runActions.length > 0 || actions.length > 0) {
|
|
5171
5285
|
const foot = element(doc, "div", "hive-dialog-foot hive-card-actions");
|
|
5172
5286
|
setAttr(foot, "aria-label", translate("drawer.cardActions"));
|
|
5287
|
+
for (const runAction of runActions) foot.appendChild(runAction);
|
|
5173
5288
|
const claimed = asString(card.state || lane) === "claimed";
|
|
5174
5289
|
for (const action of actions) {
|
|
5175
5290
|
const destructive = action.name === "remove";
|
|
@@ -5758,8 +5873,23 @@ export function mount(root, options = {}) {
|
|
|
5758
5873
|
return;
|
|
5759
5874
|
}
|
|
5760
5875
|
agentsCount.textContent = String(model.agents.length);
|
|
5876
|
+
// A failed board read must never look like an idle swarm: show the CLI
|
|
5877
|
+
// diagnostic in the strip instead of the "no agents" empty state.
|
|
5878
|
+
if (model.boardError) {
|
|
5879
|
+
const error = element(
|
|
5880
|
+
doc,
|
|
5881
|
+
"span",
|
|
5882
|
+
"hive-agents-error",
|
|
5883
|
+
summarizeActionOutput(model.boardError, 400) || model.boardError,
|
|
5884
|
+
);
|
|
5885
|
+
setAttr(error, "title", model.boardError);
|
|
5886
|
+
setAttr(error, "role", "status");
|
|
5887
|
+
agentPills.appendChild(error);
|
|
5888
|
+
}
|
|
5761
5889
|
if (model.agents.length === 0) {
|
|
5762
|
-
|
|
5890
|
+
if (!model.boardError) {
|
|
5891
|
+
agentPills.appendChild(element(doc, "span", "hive-agents-empty", translate("agents.empty")));
|
|
5892
|
+
}
|
|
5763
5893
|
return;
|
|
5764
5894
|
}
|
|
5765
5895
|
for (const agent of model.agents) {
|