dsh-hive-panel 0.2.3 → 0.3.0
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/CHANGELOG.md +46 -16
- package/README.md +72 -52
- package/README.zh-CN.md +45 -34
- package/SPEC.md +77 -40
- package/docs/DESIGN.md +4 -3
- package/docs/QUEEN-ACTIVATION.md +2 -2
- package/lib/client.js +243 -154
- package/lib/index.js +14 -1
- package/lib/queen.js +4 -4
- package/package.json +1 -1
- package/scripts/verify-queen-activation.mjs +5 -4
- package/scripts/verify.mjs +50 -7
- package/src/panel.css +34 -0
- package/src/panel.js +242 -153
package/src/panel.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Hive panel — zero-dependency ESM renderer for hive-panel 0.
|
|
1
|
+
// Hive panel — zero-dependency ESM renderer for hive-panel 0.5.0 snapshots.
|
|
2
2
|
// User-provided values are always written with textContent; no raw HTML is assigned.
|
|
3
3
|
//
|
|
4
4
|
// Visible copy is translated through the built-in \`messages\` dictionaries
|
|
@@ -35,7 +35,8 @@ const ACTION_META = Object.freeze({
|
|
|
35
35
|
remove: { labelKey: "action.remove", helpKey: "help.action.remove" },
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
const MIN_PLAN_CARDS =
|
|
38
|
+
const MIN_PLAN_CARDS = 0;
|
|
39
|
+
const DEFAULT_PLAN_CARDS = 50;
|
|
39
40
|
|
|
40
41
|
const PANEL_STYLES = `.hive { position: relative; }
|
|
41
42
|
|
|
@@ -1984,6 +1985,38 @@ dialog.hive-dialog .hive-dialog-foot { flex: 0 0 auto; }
|
|
|
1984
1985
|
dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
1985
1986
|
.hive-card-run-output { max-height: 20lh; overflow: auto; }
|
|
1986
1987
|
.hive-card-actions { flex-wrap: wrap; justify-content: flex-end; }
|
|
1988
|
+
/* Virtual lanes: fixed 26px cards, 2px gaps, 28px stride. */
|
|
1989
|
+
.hive-lane-cards {
|
|
1990
|
+
display: block;
|
|
1991
|
+
flex: 1 1 auto;
|
|
1992
|
+
min-height: 0;
|
|
1993
|
+
padding: 7px;
|
|
1994
|
+
overflow-x: hidden;
|
|
1995
|
+
overflow-y: auto;
|
|
1996
|
+
}
|
|
1997
|
+
.hive-lane-virtual { position: relative; width: 100%; min-width: 0; }
|
|
1998
|
+
.hive-lane-virtual .hive-card {
|
|
1999
|
+
position: absolute;
|
|
2000
|
+
left: 0;
|
|
2001
|
+
right: 0;
|
|
2002
|
+
display: flex;
|
|
2003
|
+
align-items: center;
|
|
2004
|
+
height: 26px;
|
|
2005
|
+
min-height: 26px;
|
|
2006
|
+
padding: 2px 8px;
|
|
2007
|
+
overflow: hidden;
|
|
2008
|
+
border-radius: var(--hive-radius-sm);
|
|
2009
|
+
}
|
|
2010
|
+
.hive-lane-virtual .hive-card-title {
|
|
2011
|
+
width: 100%;
|
|
2012
|
+
overflow: hidden;
|
|
2013
|
+
font-size: 12px;
|
|
2014
|
+
line-height: 16px;
|
|
2015
|
+
text-overflow: ellipsis;
|
|
2016
|
+
white-space: nowrap;
|
|
2017
|
+
}
|
|
2018
|
+
.hive-agent-count { font: inherit; cursor: pointer; }
|
|
2019
|
+
.hive-agent-count:disabled { cursor: default; }
|
|
1987
2020
|
`;
|
|
1988
2021
|
|
|
1989
2022
|
const LANE_LABEL_KEYS = Object.freeze({
|
|
@@ -2041,7 +2074,6 @@ export const messages = Object.freeze({
|
|
|
2041
2074
|
"stats.byRoleTitle": "by role: ",
|
|
2042
2075
|
"status.actionFailed": "action failed",
|
|
2043
2076
|
"status.disconnected": "disconnected",
|
|
2044
|
-
"agents.empty": "No agents yet.",
|
|
2045
2077
|
"agents.openAria": "Open agent",
|
|
2046
2078
|
"agent.idle": "idle",
|
|
2047
2079
|
"agent.task": "task",
|
|
@@ -2199,17 +2231,17 @@ export const messages = Object.freeze({
|
|
|
2199
2231
|
"help.action.unfreeze": "Resume: agents can claim pending tasks again.",
|
|
2200
2232
|
"help.action.add": "New task: create a pending task with a role and file scope.",
|
|
2201
2233
|
"help.action.plan": "Set the Queen a goal: split a goal into tasks, preview the plan, then write it to the board.",
|
|
2202
|
-
"help.action.claim": "Claim:
|
|
2234
|
+
"help.action.claim": "Claim: take a pending task for an agent; the claim lasts 5 minutes.",
|
|
2203
2235
|
"help.action.done": "Done: mark a claimed task complete, optionally with a commit sha.",
|
|
2204
2236
|
"help.action.fail": "Fail: mark a claimed task failed and record the reason.",
|
|
2205
2237
|
"help.action.retry": "Retry: put a failed task back in the queue.",
|
|
2206
|
-
"help.action.remove": "Delete this task
|
|
2238
|
+
"help.action.remove": "Delete this task permanently. A claimed task has to be released or reopened first.",
|
|
2207
2239
|
"plan.dialogTitle": "Set the Queen a goal",
|
|
2208
2240
|
"plan.dialogAria": "Plan tasks from a goal",
|
|
2209
2241
|
"plan.goal": "Goal",
|
|
2210
2242
|
"plan.goalHint": "Describe the outcome; the Queen will split it into tasks.",
|
|
2211
2243
|
"plan.maxCards": "Max tasks",
|
|
2212
|
-
"plan.maxCardsHint": "
|
|
2244
|
+
"plan.maxCardsHint": "0 = no limit",
|
|
2213
2245
|
"plan.preview": "Preview plan",
|
|
2214
2246
|
"plan.previewAria": "Ask the Queen to draft a task plan without writing it",
|
|
2215
2247
|
"plan.previewing": "Planning…",
|
|
@@ -2229,7 +2261,7 @@ export const messages = Object.freeze({
|
|
|
2229
2261
|
"plan.deps": "deps",
|
|
2230
2262
|
"plan.none": "—",
|
|
2231
2263
|
"plan.goalRequired": "Enter a goal first.",
|
|
2232
|
-
"plan.maxInvalid": "Max tasks must be a
|
|
2264
|
+
"plan.maxInvalid": "Max tasks must be a whole number of 0 or more (0 = no limit).",
|
|
2233
2265
|
"plan.previewFirst": "Preview the plan before writing tasks.",
|
|
2234
2266
|
"plan.previewFailed": "Could not read the plan.",
|
|
2235
2267
|
"plan.applyHint": "The preview is read-only; writing calls plan again with apply=true.",
|
|
@@ -2283,7 +2315,6 @@ export const messages = Object.freeze({
|
|
|
2283
2315
|
"stats.byRoleTitle": "按角色:",
|
|
2284
2316
|
"status.actionFailed": "操作失败",
|
|
2285
2317
|
"status.disconnected": "连接断开",
|
|
2286
|
-
"agents.empty": "后台暂无智能体。",
|
|
2287
2318
|
"agents.openAria": "打开智能体",
|
|
2288
2319
|
"agent.idle": "空闲",
|
|
2289
2320
|
"agent.task": "任务",
|
|
@@ -2441,17 +2472,17 @@ export const messages = Object.freeze({
|
|
|
2441
2472
|
"help.action.unfreeze": "恢复:恢复认领,智能体可以继续接取待办任务。",
|
|
2442
2473
|
"help.action.add": "新建任务:添加一条带角色和文件范围的待办任务。",
|
|
2443
2474
|
"help.action.plan": "给女王设目标:让女王把目标拆成任务计划,预览后再写入看板。",
|
|
2444
|
-
"help.action.claim": "
|
|
2475
|
+
"help.action.claim": "认领:以某个智能体的名义接取一条待办任务,认领有效期 5 分钟。",
|
|
2445
2476
|
"help.action.done": "完成:把已认领的任务标为完成,可选填写提交 SHA。",
|
|
2446
2477
|
"help.action.fail": "标记失败:把已认领的任务标为失败,并写明原因。",
|
|
2447
2478
|
"help.action.retry": "重试:把失败或受阻的任务放回队列。",
|
|
2448
|
-
"help.action.remove": "
|
|
2479
|
+
"help.action.remove": "永久删除这张任务;已认领的任务需要先释放或重开。",
|
|
2449
2480
|
"plan.dialogTitle": "给女王设目标",
|
|
2450
2481
|
"plan.dialogAria": "按目标规划任务",
|
|
2451
2482
|
"plan.goal": "目标",
|
|
2452
2483
|
"plan.goalHint": "描述想达成的结果,女王会把它拆成任务。",
|
|
2453
2484
|
"plan.maxCards": "最大任务数",
|
|
2454
|
-
"plan.maxCardsHint": "
|
|
2485
|
+
"plan.maxCardsHint": "0 = 不限",
|
|
2455
2486
|
"plan.preview": "预览计划",
|
|
2456
2487
|
"plan.previewAria": "让女王先给出任务计划,不写入看板",
|
|
2457
2488
|
"plan.previewing": "规划中…",
|
|
@@ -2471,7 +2502,7 @@ export const messages = Object.freeze({
|
|
|
2471
2502
|
"plan.deps": "依赖",
|
|
2472
2503
|
"plan.none": "—",
|
|
2473
2504
|
"plan.goalRequired": "请先填写目标。",
|
|
2474
|
-
"plan.maxInvalid": "
|
|
2505
|
+
"plan.maxInvalid": "最大任务数必须是 0 或更大的整数。",
|
|
2475
2506
|
"plan.previewFirst": "请先预览计划,再写入任务。",
|
|
2476
2507
|
"plan.previewFailed": "无法解析计划。",
|
|
2477
2508
|
"plan.applyHint": "预览不会写入;写入时会带 apply=true 再调用一次 plan。",
|
|
@@ -2481,7 +2512,7 @@ export const messages = Object.freeze({
|
|
|
2481
2512
|
"toast.dismiss": "关闭",
|
|
2482
2513
|
"toast.planWritten": "任务已写入",
|
|
2483
2514
|
"toast.taskRemoved": "任务已删除",
|
|
2484
|
-
"toast.pickupHint": "supervisor
|
|
2515
|
+
"toast.pickupHint": "supervisor 会自动接任务。",
|
|
2485
2516
|
}),
|
|
2486
2517
|
});
|
|
2487
2518
|
|
|
@@ -2599,6 +2630,9 @@ function normalizeCard(task) {
|
|
|
2599
2630
|
owner: asString(task.owner),
|
|
2600
2631
|
scope: normalizeScope(task.scope),
|
|
2601
2632
|
reason: asString(task.reason),
|
|
2633
|
+
stateChangedAt: asString(task.stateChangedAt),
|
|
2634
|
+
createdAt: asString(task.createdAt),
|
|
2635
|
+
updatedAt: asString(task.updatedAt),
|
|
2602
2636
|
lastRun: normalizeLastRun(task.lastRun),
|
|
2603
2637
|
};
|
|
2604
2638
|
}
|
|
@@ -3470,6 +3504,7 @@ export function mount(root, options = {}) {
|
|
|
3470
3504
|
let toastNode = null;
|
|
3471
3505
|
let stageFilter = "all";
|
|
3472
3506
|
let stageChipEntries = [];
|
|
3507
|
+
const laneRenderState = new Map();
|
|
3473
3508
|
let eventsExpanded = false;
|
|
3474
3509
|
let initBusy = false;
|
|
3475
3510
|
let initOutput = null;
|
|
@@ -3525,6 +3560,13 @@ export function mount(root, options = {}) {
|
|
|
3525
3560
|
const statsNode = element(doc, "div", "hive-stats");
|
|
3526
3561
|
bar.appendChild(statsNode);
|
|
3527
3562
|
|
|
3563
|
+
const agentsCount = element(doc, "button", "hive-stat hive-agent-count");
|
|
3564
|
+
setAttr(agentsCount, "type", "button");
|
|
3565
|
+
agentsCount.addEventListener("click", () => {
|
|
3566
|
+
if (agentsCount._agent) openAgentDrawer(agentsCount._agent);
|
|
3567
|
+
});
|
|
3568
|
+
bar.appendChild(agentsCount);
|
|
3569
|
+
|
|
3528
3570
|
const queenBadge = element(doc, "span", "hive-queen-badge is-hidden", "");
|
|
3529
3571
|
bar.appendChild(queenBadge);
|
|
3530
3572
|
|
|
@@ -3632,23 +3674,8 @@ export function mount(root, options = {}) {
|
|
|
3632
3674
|
initPane.appendChild(initCard);
|
|
3633
3675
|
main.appendChild(initPane);
|
|
3634
3676
|
|
|
3635
|
-
// Agents strip.
|
|
3636
|
-
const agentsStrip = element(doc, "section", "hive-agents-strip");
|
|
3637
|
-
setAttr(agentsStrip, "aria-label", translate("pane.agents"));
|
|
3638
|
-
const agentsLabel = element(doc, "span", "hive-strip-label", "");
|
|
3639
|
-
agentsStrip.appendChild(agentsLabel);
|
|
3640
|
-
const agentsCount = element(doc, "span", "hive-count", "0");
|
|
3641
|
-
agentsStrip.appendChild(agentsCount);
|
|
3642
|
-
const agentPills = element(doc, "div", "hive-agent-pills");
|
|
3643
|
-
agentsStrip.appendChild(agentPills);
|
|
3644
|
-
|
|
3645
3677
|
// Board pane.
|
|
3646
3678
|
const boardPane = element(doc, "section", "hive-pane hive-board");
|
|
3647
|
-
const boardHead = element(doc, "div", "hive-pane-head");
|
|
3648
|
-
const boardLabel = element(doc, "span", null, "");
|
|
3649
|
-
boardHead.appendChild(boardLabel);
|
|
3650
|
-
const boardCount = element(doc, "span", "hive-count", "0");
|
|
3651
|
-
boardHead.appendChild(boardCount);
|
|
3652
3679
|
const stage = element(doc, "div", "hive-stage");
|
|
3653
3680
|
const stageChips = element(doc, "div", "hive-stage-chips");
|
|
3654
3681
|
setAttr(stageChips, "aria-label", translate("board.filtersAria"));
|
|
@@ -3657,7 +3684,6 @@ export function mount(root, options = {}) {
|
|
|
3657
3684
|
stage.appendChild(stageChips);
|
|
3658
3685
|
stage.appendChild(filterEmpty);
|
|
3659
3686
|
stage.appendChild(lanesNode);
|
|
3660
|
-
boardPane.appendChild(boardHead);
|
|
3661
3687
|
boardPane.appendChild(stage);
|
|
3662
3688
|
main.appendChild(boardPane);
|
|
3663
3689
|
|
|
@@ -3684,7 +3710,6 @@ export function mount(root, options = {}) {
|
|
|
3684
3710
|
frame.appendChild(bar);
|
|
3685
3711
|
frame.appendChild(freezeSlot);
|
|
3686
3712
|
frame.appendChild(queenHint);
|
|
3687
|
-
frame.appendChild(agentsStrip);
|
|
3688
3713
|
frame.appendChild(main);
|
|
3689
3714
|
frame.appendChild(eventsDrawer);
|
|
3690
3715
|
|
|
@@ -3775,10 +3800,7 @@ export function mount(root, options = {}) {
|
|
|
3775
3800
|
setAttr(actionsNode, "aria-label", translate("actions.aria"));
|
|
3776
3801
|
setAttr(helpButton, "title", translate("menu.open"));
|
|
3777
3802
|
setAttr(helpButton, "aria-label", translate("menu.open"));
|
|
3778
|
-
setAttr(agentsStrip, "aria-label", translate("pane.agents"));
|
|
3779
3803
|
setAttr(stageChips, "aria-label", translate("board.filtersAria"));
|
|
3780
|
-
agentsLabel.textContent = translate("pane.agents");
|
|
3781
|
-
boardLabel.textContent = translate("pane.board");
|
|
3782
3804
|
eventsLabel.textContent = translate("pane.events");
|
|
3783
3805
|
const eventsToggleLabel = eventsExpanded ? translate("events.collapse") : translate("events.showAll");
|
|
3784
3806
|
setAttr(eventsToggle, "title", eventsToggleLabel);
|
|
@@ -4163,7 +4185,7 @@ export function mount(root, options = {}) {
|
|
|
4163
4185
|
setAttr(maxInput, "min", String(MIN_PLAN_CARDS));
|
|
4164
4186
|
setAttr(maxInput, "step", "1");
|
|
4165
4187
|
setAttr(maxInput, "aria-label", translate("plan.maxCards"));
|
|
4166
|
-
maxInput.value =
|
|
4188
|
+
maxInput.value = String(DEFAULT_PLAN_CARDS);
|
|
4167
4189
|
maxField.appendChild(maxInput);
|
|
4168
4190
|
maxField.appendChild(element(doc, "span", "hive-field-hint", translate("plan.maxCardsHint")));
|
|
4169
4191
|
row.appendChild(maxField);
|
|
@@ -4221,7 +4243,7 @@ export function mount(root, options = {}) {
|
|
|
4221
4243
|
cards: [],
|
|
4222
4244
|
previewed: false,
|
|
4223
4245
|
goal: "",
|
|
4224
|
-
maxCards:
|
|
4246
|
+
maxCards: DEFAULT_PLAN_CARDS,
|
|
4225
4247
|
token: 0,
|
|
4226
4248
|
busy: false,
|
|
4227
4249
|
nodes: {
|
|
@@ -4807,17 +4829,24 @@ export function mount(root, options = {}) {
|
|
|
4807
4829
|
}
|
|
4808
4830
|
}
|
|
4809
4831
|
|
|
4832
|
+
/** Read the Max tasks field: a whole number >= 0 (0 = unlimited), or null when invalid. */
|
|
4833
|
+
function readPlanMaxCards(state) {
|
|
4834
|
+
const raw = fieldValue(state.nodes.maxCards).trim();
|
|
4835
|
+
const maxCards = Number(raw);
|
|
4836
|
+
return raw !== "" && Number.isSafeInteger(maxCards) && maxCards >= MIN_PLAN_CARDS ? maxCards : null;
|
|
4837
|
+
}
|
|
4838
|
+
|
|
4810
4839
|
async function previewPlan() {
|
|
4811
4840
|
const state = planState;
|
|
4812
4841
|
if (!state || state.busy) return;
|
|
4813
4842
|
const goal = fieldValue(state.nodes.goal).trim();
|
|
4814
|
-
const maxCards =
|
|
4843
|
+
const maxCards = readPlanMaxCards(state);
|
|
4815
4844
|
if (!goal) {
|
|
4816
4845
|
setPlanError(state, translate("plan.goalRequired"));
|
|
4817
4846
|
focusNode(state.nodes.goal);
|
|
4818
4847
|
return;
|
|
4819
4848
|
}
|
|
4820
|
-
if (
|
|
4849
|
+
if (maxCards === null) {
|
|
4821
4850
|
setPlanError(state, translate("plan.maxInvalid"));
|
|
4822
4851
|
focusNode(state.nodes.maxCards);
|
|
4823
4852
|
return;
|
|
@@ -4860,12 +4889,12 @@ export function mount(root, options = {}) {
|
|
|
4860
4889
|
const state = planState;
|
|
4861
4890
|
if (!state || state.busy) return;
|
|
4862
4891
|
const goal = fieldValue(state.nodes.goal).trim();
|
|
4863
|
-
const maxCards =
|
|
4892
|
+
const maxCards = readPlanMaxCards(state);
|
|
4864
4893
|
if (!state.previewed || state.cards.length === 0) {
|
|
4865
4894
|
setPlanError(state, translate("plan.previewFirst"));
|
|
4866
4895
|
return;
|
|
4867
4896
|
}
|
|
4868
|
-
if (
|
|
4897
|
+
if (maxCards === null) {
|
|
4869
4898
|
setPlanError(state, translate("plan.maxInvalid"));
|
|
4870
4899
|
return;
|
|
4871
4900
|
}
|
|
@@ -5266,6 +5295,15 @@ export function mount(root, options = {}) {
|
|
|
5266
5295
|
dialog.appendChild(head);
|
|
5267
5296
|
|
|
5268
5297
|
const body = element(doc, "div", "hive-dialog-body hive-card-body");
|
|
5298
|
+
if (Array.isArray(card.scope) && card.scope.length > 0) {
|
|
5299
|
+
const drawerScopes = element(doc, "div", "hive-scopes");
|
|
5300
|
+
for (const scope of card.scope) {
|
|
5301
|
+
const chip = element(doc, "span", "hive-scope", scope);
|
|
5302
|
+
setAttr(chip, "title", scope);
|
|
5303
|
+
drawerScopes.appendChild(chip);
|
|
5304
|
+
}
|
|
5305
|
+
body.appendChild(drawerScopes);
|
|
5306
|
+
}
|
|
5269
5307
|
const runActions = [];
|
|
5270
5308
|
body.appendChild(buildRunSection(card.lastRun, runActions));
|
|
5271
5309
|
dialog.appendChild(body);
|
|
@@ -5867,105 +5905,51 @@ export function mount(root, options = {}) {
|
|
|
5867
5905
|
}
|
|
5868
5906
|
|
|
5869
5907
|
function renderAgents(model) {
|
|
5870
|
-
clearNode(agentPills);
|
|
5871
5908
|
if (model.initialised === false) {
|
|
5872
|
-
agentsCount.
|
|
5909
|
+
agentsCount.className = "hive-stat hive-agent-count is-hidden";
|
|
5910
|
+
agentsCount.textContent = translate("pane.agents") + " 0";
|
|
5911
|
+
agentsCount._agent = null;
|
|
5912
|
+
agentsCount.disabled = true;
|
|
5873
5913
|
return;
|
|
5874
5914
|
}
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
const task = agent.task || translate("agent.idle");
|
|
5898
|
-
const pill = element(doc, "button", "hive-agent-pill");
|
|
5899
|
-
setAttr(pill, "type", "button");
|
|
5900
|
-
const label =
|
|
5901
|
-
translate("agents.openAria") +
|
|
5902
|
-
" " +
|
|
5903
|
-
name +
|
|
5904
|
-
" · " +
|
|
5905
|
-
(agent.state || translate("agent.idle")) +
|
|
5906
|
-
" · " +
|
|
5907
|
-
task;
|
|
5908
|
-
setAttr(pill, "title", label);
|
|
5909
|
-
setAttr(pill, "aria-label", label);
|
|
5910
|
-
|
|
5911
|
-
pill.appendChild(element(doc, "span", "hive-agent-pill-name", name));
|
|
5912
|
-
const dot = element(doc, "span", "hive-dot is-" + safeClassToken(agent.state));
|
|
5913
|
-
setAttr(dot, "title", agent.state || translate("agent.idle"));
|
|
5914
|
-
pill.appendChild(dot);
|
|
5915
|
-
const taskNode = element(doc, "span", "hive-agent-pill-task", task);
|
|
5916
|
-
setAttr(taskNode, "title", task);
|
|
5917
|
-
pill.appendChild(taskNode);
|
|
5918
|
-
|
|
5919
|
-
pill.addEventListener("click", () => {
|
|
5920
|
-
openAgentDrawer(agent);
|
|
5915
|
+
const count = model.agents.length;
|
|
5916
|
+
agentsCount.className = "hive-stat hive-agent-count";
|
|
5917
|
+
agentsCount.textContent = translate("pane.agents") + " " + String(count);
|
|
5918
|
+
const first = count > 0 ? model.agents[0] : null;
|
|
5919
|
+
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;
|
|
5925
|
+
setAttr(agentsCount, "title", label);
|
|
5926
|
+
setAttr(agentsCount, "aria-label", label);
|
|
5927
|
+
}
|
|
5928
|
+
|
|
5929
|
+
function renderCard(card, lane, existing) {
|
|
5930
|
+
const node = existing || element(doc, "article", "hive-card");
|
|
5931
|
+
const title = card.title || translate("card.untitled");
|
|
5932
|
+
if (!existing) {
|
|
5933
|
+
setAttr(node, "tabindex", "0");
|
|
5934
|
+
setAttr(node, "role", "button");
|
|
5935
|
+
node.addEventListener("click", () => {
|
|
5936
|
+
if (node._hiveCard) openDrawer(node._hiveCard, node._hiveLane, node);
|
|
5921
5937
|
});
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
node
|
|
5935
|
-
|
|
5936
|
-
const meta = [];
|
|
5937
|
-
if (card.role) meta.push(translate("card.role") + " " + card.role);
|
|
5938
|
-
if (card.owner) meta.push(translate("card.owner") + " " + card.owner);
|
|
5939
|
-
if (meta.length) node.appendChild(element(doc, "div", "hive-card-meta", meta.join(" · ")));
|
|
5940
|
-
|
|
5941
|
-
if (card.scope.length) {
|
|
5942
|
-
const scopes = element(doc, "div", "hive-scopes");
|
|
5943
|
-
for (const scope of card.scope) {
|
|
5944
|
-
const chip = element(doc, "span", "hive-scope", scope);
|
|
5945
|
-
setAttr(chip, "title", scope);
|
|
5946
|
-
scopes.appendChild(chip);
|
|
5947
|
-
}
|
|
5948
|
-
node.appendChild(scopes);
|
|
5949
|
-
}
|
|
5950
|
-
|
|
5951
|
-
if (card.reason) {
|
|
5952
|
-
node.appendChild(element(doc, "div", "hive-reason", card.reason));
|
|
5953
|
-
}
|
|
5954
|
-
|
|
5955
|
-
const foot = element(doc, "div", "hive-card-foot");
|
|
5956
|
-
foot.appendChild(element(doc, "span", "hive-card-id", card.id || translate("card.noId")));
|
|
5957
|
-
foot.appendChild(element(doc, "span", "hive-card-state", laneLabel(lane)));
|
|
5958
|
-
node.appendChild(foot);
|
|
5959
|
-
|
|
5960
|
-
node.addEventListener("click", () => openDrawer(card, lane, node));
|
|
5961
|
-
node.addEventListener("keydown", (event) => {
|
|
5962
|
-
if (!event || (event.key !== "Enter" && event.key !== " ")) return;
|
|
5963
|
-
if (typeof event.preventDefault === "function") event.preventDefault();
|
|
5964
|
-
openDrawer(card, lane, node);
|
|
5965
|
-
});
|
|
5938
|
+
node.addEventListener("keydown", (event) => {
|
|
5939
|
+
if (!event || (event.key !== "Enter" && event.key !== " ")) return;
|
|
5940
|
+
if (typeof event.preventDefault === "function") event.preventDefault();
|
|
5941
|
+
if (node._hiveCard) openDrawer(node._hiveCard, node._hiveLane, node);
|
|
5942
|
+
});
|
|
5943
|
+
node._hiveTitle = element(doc, "div", "hive-card-title", "");
|
|
5944
|
+
node.appendChild(node._hiveTitle);
|
|
5945
|
+
}
|
|
5946
|
+
node._hiveCard = card;
|
|
5947
|
+
node._hiveLane = lane;
|
|
5948
|
+
node._hiveTitle.textContent = title;
|
|
5949
|
+
setAttr(node, "aria-label", translate("card.openAria") + " " + title);
|
|
5950
|
+
setAttr(node, "title", title);
|
|
5966
5951
|
return node;
|
|
5967
5952
|
}
|
|
5968
|
-
|
|
5969
5953
|
function renderStageChips(model) {
|
|
5970
5954
|
clearNode(stageChips);
|
|
5971
5955
|
setAttr(stageChips, "aria-label", translate("board.filtersAria"));
|
|
@@ -6006,34 +5990,112 @@ export function mount(root, options = {}) {
|
|
|
6006
5990
|
if (lastModel) renderLanes(lastModel);
|
|
6007
5991
|
}
|
|
6008
5992
|
|
|
5993
|
+
function cardSortTime(card) {
|
|
5994
|
+
const stateChanged = parseDate(card.stateChangedAt);
|
|
5995
|
+
if (stateChanged) return stateChanged.getTime();
|
|
5996
|
+
const updated = parseDate(card.updatedAt);
|
|
5997
|
+
if (updated) return updated.getTime();
|
|
5998
|
+
const created = parseDate(card.createdAt);
|
|
5999
|
+
if (created) return created.getTime();
|
|
6000
|
+
const id = asString(card.id);
|
|
6001
|
+
const numeric = id.match(/(\d+)$/);
|
|
6002
|
+
return numeric ? Number(numeric[1]) : Number.NaN;
|
|
6003
|
+
}
|
|
6004
|
+
|
|
6005
|
+
function compareCardsNewestFirst(left, right) {
|
|
6006
|
+
const leftTime = cardSortTime(left);
|
|
6007
|
+
const rightTime = cardSortTime(right);
|
|
6008
|
+
if (Number.isFinite(leftTime) && Number.isFinite(rightTime) && leftTime !== rightTime) {
|
|
6009
|
+
return rightTime - leftTime;
|
|
6010
|
+
}
|
|
6011
|
+
if (Number.isFinite(leftTime) !== Number.isFinite(rightTime)) {
|
|
6012
|
+
return Number.isFinite(leftTime) ? -1 : 1;
|
|
6013
|
+
}
|
|
6014
|
+
return asString(right.id).localeCompare(asString(left.id));
|
|
6015
|
+
}
|
|
6016
|
+
|
|
6017
|
+
const LANE_ROW_HEIGHT = 28;
|
|
6018
|
+
const LANE_ROW_BUFFER = 10;
|
|
6019
|
+
const LANE_VIEWPORT_FALLBACK = 480;
|
|
6020
|
+
|
|
6021
|
+
function createLaneState(lane) {
|
|
6022
|
+
const column = element(doc, "section", "hive-lane hive-lane-" + lane);
|
|
6023
|
+
const head = element(doc, "div", "hive-lane-head");
|
|
6024
|
+
head.appendChild(element(doc, "span", "hive-lane-name", laneLabel(lane)));
|
|
6025
|
+
const count = element(doc, "span", "hive-count", "0");
|
|
6026
|
+
head.appendChild(count);
|
|
6027
|
+
column.appendChild(head);
|
|
6028
|
+
|
|
6029
|
+
const list = element(doc, "div", "hive-lane-cards");
|
|
6030
|
+
const inner = element(doc, "div", "hive-lane-virtual");
|
|
6031
|
+
list.appendChild(inner);
|
|
6032
|
+
column.appendChild(list);
|
|
6033
|
+
lanesNode.appendChild(column);
|
|
6034
|
+
|
|
6035
|
+
const state = { lane, column, list, inner, count, cards: [], visible: new Map() };
|
|
6036
|
+
list.addEventListener("scroll", () => renderLaneVirtual(state));
|
|
6037
|
+
return state;
|
|
6038
|
+
}
|
|
6039
|
+
|
|
6040
|
+
function renderLaneVirtual(state) {
|
|
6041
|
+
const cards = state.cards;
|
|
6042
|
+
const total = cards.length;
|
|
6043
|
+
const row = LANE_ROW_HEIGHT;
|
|
6044
|
+
const viewport =
|
|
6045
|
+
Number.isFinite(state.list.clientHeight) && state.list.clientHeight > 0
|
|
6046
|
+
? state.list.clientHeight
|
|
6047
|
+
: LANE_VIEWPORT_FALLBACK;
|
|
6048
|
+
const scrollTop = Number(state.list.scrollTop) || 0;
|
|
6049
|
+
const start = Math.max(0, Math.floor(scrollTop / row) - LANE_ROW_BUFFER);
|
|
6050
|
+
const end = Math.min(total, Math.ceil((scrollTop + viewport) / row) + LANE_ROW_BUFFER);
|
|
6051
|
+
const height = total === 0 ? 0 : total * row - 2;
|
|
6052
|
+
setStyle(state.inner, "height", String(height) + "px");
|
|
6053
|
+
|
|
6054
|
+
const next = new Map();
|
|
6055
|
+
for (let index = start; index < end; index += 1) {
|
|
6056
|
+
const card = cards[index];
|
|
6057
|
+
const key = String(card.id || "idx:" + index);
|
|
6058
|
+
const entry = state.visible.get(key);
|
|
6059
|
+
const node = renderCard(card, state.lane, entry ? entry.node : null);
|
|
6060
|
+
setStyle(node, "top", String(index * row) + "px");
|
|
6061
|
+
if (!entry) state.inner.appendChild(node);
|
|
6062
|
+
next.set(key, { node, index });
|
|
6063
|
+
}
|
|
6064
|
+
for (const [key, entry] of state.visible) {
|
|
6065
|
+
if (!next.has(key) && entry.node.parentNode) entry.node.parentNode.removeChild(entry.node);
|
|
6066
|
+
}
|
|
6067
|
+
state.visible = next;
|
|
6068
|
+
state.count.textContent = String(total);
|
|
6069
|
+
}
|
|
6070
|
+
|
|
6009
6071
|
function renderLanes(model) {
|
|
6010
|
-
clearNode(lanesNode);
|
|
6011
6072
|
if (model.initialised === false) {
|
|
6012
|
-
|
|
6073
|
+
clearNode(lanesNode);
|
|
6074
|
+
laneRenderState.clear();
|
|
6013
6075
|
filterEmpty.textContent = "";
|
|
6014
6076
|
filterEmpty.className = "hive-filter-empty";
|
|
6015
6077
|
return;
|
|
6016
6078
|
}
|
|
6017
|
-
|
|
6079
|
+
const seen = new Set();
|
|
6018
6080
|
for (const lane of LANE_ORDER) {
|
|
6019
|
-
const cards = model.lanes[lane] || [];
|
|
6081
|
+
const cards = [...(model.lanes[lane] || [])].sort(compareCardsNewestFirst);
|
|
6082
|
+
let state = laneRenderState.get(lane);
|
|
6083
|
+
if (!state) {
|
|
6084
|
+
state = createLaneState(lane);
|
|
6085
|
+
laneRenderState.set(lane, state);
|
|
6086
|
+
}
|
|
6087
|
+
state.cards = cards;
|
|
6020
6088
|
const classes = ["hive-lane", "hive-lane-" + lane];
|
|
6021
6089
|
if (cards.length === 0) classes.push("is-empty");
|
|
6022
6090
|
if (stageFilter !== "all" && stageFilter !== lane) classes.push("is-filtered-out");
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
list.appendChild(emptyState("—"));
|
|
6032
|
-
} else {
|
|
6033
|
-
for (const card of cards) list.appendChild(renderCard(card, lane));
|
|
6034
|
-
}
|
|
6035
|
-
column.appendChild(list);
|
|
6036
|
-
lanesNode.appendChild(column);
|
|
6091
|
+
state.column.className = classes.join(" ");
|
|
6092
|
+
renderLaneVirtual(state);
|
|
6093
|
+
seen.add(lane);
|
|
6094
|
+
}
|
|
6095
|
+
for (const [lane, state] of laneRenderState) {
|
|
6096
|
+
if (seen.has(lane)) continue;
|
|
6097
|
+
if (state.column.parentNode) state.column.parentNode.removeChild(state.column);
|
|
6098
|
+
laneRenderState.delete(lane);
|
|
6037
6099
|
}
|
|
6038
6100
|
|
|
6039
6101
|
const visible = stageFilter === "all" ? model.lanes : { [stageFilter]: model.lanes[stageFilter] || [] };
|
|
@@ -6231,6 +6293,9 @@ export function mount(root, options = {}) {
|
|
|
6231
6293
|
unschedule(timer);
|
|
6232
6294
|
timer = null;
|
|
6233
6295
|
}
|
|
6296
|
+
if (typeof doc.removeEventListener === "function") {
|
|
6297
|
+
doc.removeEventListener("visibilitychange", onVisibilityChange);
|
|
6298
|
+
}
|
|
6234
6299
|
closeHelp(false);
|
|
6235
6300
|
closePlanDialog(false);
|
|
6236
6301
|
closeLimitsDialog(false);
|
|
@@ -6294,9 +6359,33 @@ export function mount(root, options = {}) {
|
|
|
6294
6359
|
}
|
|
6295
6360
|
}
|
|
6296
6361
|
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6362
|
+
function stopPolling() {
|
|
6363
|
+
if (timer === null) return;
|
|
6364
|
+
unschedule(timer);
|
|
6365
|
+
timer = null;
|
|
6366
|
+
}
|
|
6367
|
+
|
|
6368
|
+
function startPolling() {
|
|
6369
|
+
if (destroyed || timer !== null || doc.hidden) return;
|
|
6370
|
+
timer = schedule(() => {
|
|
6371
|
+
void refresh();
|
|
6372
|
+
}, intervalMs);
|
|
6373
|
+
}
|
|
6374
|
+
|
|
6375
|
+
function onVisibilityChange() {
|
|
6376
|
+
if (destroyed) return;
|
|
6377
|
+
if (doc.hidden) {
|
|
6378
|
+
stopPolling();
|
|
6379
|
+
} else {
|
|
6380
|
+
startPolling();
|
|
6381
|
+
void refresh();
|
|
6382
|
+
}
|
|
6383
|
+
}
|
|
6384
|
+
|
|
6385
|
+
if (typeof doc.addEventListener === "function") {
|
|
6386
|
+
doc.addEventListener("visibilitychange", onVisibilityChange);
|
|
6387
|
+
}
|
|
6388
|
+
startPolling();
|
|
6300
6389
|
void refresh();
|
|
6301
6390
|
|
|
6302
6391
|
return { setSnapshot, destroy, refresh, rerender };
|