dsh-hive-panel 0.1.0 → 0.1.1
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 +23 -0
- package/README.md +6 -4
- package/README.zh-CN.md +4 -3
- package/SPEC.md +47 -16
- package/cordis.patch.yml +3 -0
- package/docs/DESIGN.md +29 -11
- package/lib/client.js +261 -38
- package/lib/index.js +76 -11
- package/lib/queen.js +129 -42
- package/package.json +1 -1
- package/scripts/verify.mjs +86 -4
- package/src/panel.js +261 -38
package/lib/client.js
CHANGED
|
@@ -730,6 +730,61 @@ const PANEL_STYLES = `.hive { position: relative; }
|
|
|
730
730
|
}
|
|
731
731
|
|
|
732
732
|
.hive-queen-hint.is-visible { display: flex; }
|
|
733
|
+
.hive-queen-badge {
|
|
734
|
+
padding: 2px 8px;
|
|
735
|
+
border: 1px solid var(--hive-line, #232b38);
|
|
736
|
+
border-radius: 999px;
|
|
737
|
+
font-size: 10px;
|
|
738
|
+
font-weight: 650;
|
|
739
|
+
letter-spacing: 0.09em;
|
|
740
|
+
line-height: 1.5;
|
|
741
|
+
text-transform: uppercase;
|
|
742
|
+
white-space: nowrap;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
.hive-queen-badge.is-hidden { display: none; }
|
|
746
|
+
|
|
747
|
+
.hive-queen-badge.is-active {
|
|
748
|
+
border-color: color-mix(in srgb, var(--hive-accent, #58c4dc) 45%, transparent);
|
|
749
|
+
background: var(--hive-accent-soft);
|
|
750
|
+
color: var(--hive-accent, #58c4dc);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.hive-queen-badge.is-inactive {
|
|
754
|
+
border-color: var(--hive-line, #232b38);
|
|
755
|
+
background: var(--hive-surface);
|
|
756
|
+
color: var(--hive-fg-soft);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
.hive-queen-hint.is-offer {
|
|
760
|
+
border-bottom-color: var(--hive-line, #232b38);
|
|
761
|
+
background: var(--hive-surface);
|
|
762
|
+
color: var(--hive-fg-soft);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
.hive-queen-offer {
|
|
766
|
+
display: flex;
|
|
767
|
+
flex-wrap: wrap;
|
|
768
|
+
align-items: center;
|
|
769
|
+
gap: 8px;
|
|
770
|
+
max-width: 76ch;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
.hive-queen-offer.is-hidden,
|
|
774
|
+
.hive-queen-exit.is-hidden { display: none; }
|
|
775
|
+
|
|
776
|
+
.hive-queen-takeover {
|
|
777
|
+
border-color: color-mix(in srgb, var(--hive-accent, #58c4dc) 45%, var(--hive-line, #232b38));
|
|
778
|
+
background: var(--hive-accent-soft);
|
|
779
|
+
color: var(--hive-accent, #58c4dc);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.hive-queen-takeover:disabled {
|
|
783
|
+
opacity: 0.6;
|
|
784
|
+
cursor: wait;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
|
|
733
788
|
|
|
734
789
|
.hive-queen-text {
|
|
735
790
|
max-width: 76ch;
|
|
@@ -964,6 +1019,23 @@ const PANEL_STYLES = `.hive { position: relative; }
|
|
|
964
1019
|
line-height: 1.5;
|
|
965
1020
|
}
|
|
966
1021
|
|
|
1022
|
+
.hive-oldest {
|
|
1023
|
+
max-width: 100%;
|
|
1024
|
+
overflow-wrap: anywhere;
|
|
1025
|
+
white-space: normal;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
.hive-oldest-label { min-width: 0; }
|
|
1029
|
+
|
|
1030
|
+
.hive-oldest-sep { opacity: 0.65; }
|
|
1031
|
+
|
|
1032
|
+
.hive-oldest-id {
|
|
1033
|
+
font-family: var(--hive-mono);
|
|
1034
|
+
font-size: 9.5px;
|
|
1035
|
+
font-weight: 400;
|
|
1036
|
+
overflow-wrap: anywhere;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
967
1039
|
/* -------------------------------------------------------------------- spacing */
|
|
968
1040
|
.hive {
|
|
969
1041
|
gap: 8px;
|
|
@@ -1090,7 +1162,7 @@ const messages = Object.freeze({
|
|
|
1090
1162
|
"action.modeTitle": "Toggle board mode",
|
|
1091
1163
|
"action.retry": "retry",
|
|
1092
1164
|
"action.unfreeze": "unfreeze",
|
|
1093
|
-
"pane.agents": "
|
|
1165
|
+
"pane.agents": "workers",
|
|
1094
1166
|
"pane.board": "board",
|
|
1095
1167
|
"pane.events": "events",
|
|
1096
1168
|
"board.hint": "5 lanes",
|
|
@@ -1112,11 +1184,18 @@ const messages = Object.freeze({
|
|
|
1112
1184
|
"mode.title": "mode:",
|
|
1113
1185
|
"stats.cards": "tasks",
|
|
1114
1186
|
"stats.oldest": "oldest",
|
|
1187
|
+
"stats.duration.justNow": "just now",
|
|
1188
|
+
"stats.duration.minute": "{count} min",
|
|
1189
|
+
"stats.duration.minutes": "{count} min",
|
|
1190
|
+
"stats.duration.hour": "{count} hr",
|
|
1191
|
+
"stats.duration.hours": "{count} hr",
|
|
1192
|
+
"stats.duration.day": "{count} day",
|
|
1193
|
+
"stats.duration.days": "{count} days",
|
|
1115
1194
|
"stats.byRoleTitle": "by role: ",
|
|
1116
1195
|
"status.actionFailed": "action failed",
|
|
1117
1196
|
"status.disconnected": "disconnected",
|
|
1118
|
-
"agents.empty": "No
|
|
1119
|
-
"agents.openAria": "Open
|
|
1197
|
+
"agents.empty": "No workers in the background.",
|
|
1198
|
+
"agents.openAria": "Open worker",
|
|
1120
1199
|
"agent.idle": "idle",
|
|
1121
1200
|
"agent.task": "task",
|
|
1122
1201
|
"agent.unknown": "unknown",
|
|
@@ -1173,7 +1252,7 @@ const messages = Object.freeze({
|
|
|
1173
1252
|
"prompt.after": "After task ids (comma separated, optional)",
|
|
1174
1253
|
"prompt.commitMessage": "Commit message",
|
|
1175
1254
|
"prompt.paths": "Paths (comma separated, optional)",
|
|
1176
|
-
"prompt.claimAgent": "Claim as
|
|
1255
|
+
"prompt.claimAgent": "Claim as worker",
|
|
1177
1256
|
"prompt.commitSha": "Commit sha (optional)",
|
|
1178
1257
|
"prompt.failReason": "Failure reason",
|
|
1179
1258
|
"action.plan": "Give the Queen a goal",
|
|
@@ -1190,7 +1269,7 @@ const messages = Object.freeze({
|
|
|
1190
1269
|
"help.uninitialised": "Initialise Hive with the button in the main area before using board actions.",
|
|
1191
1270
|
"init.repo": "repository",
|
|
1192
1271
|
"init.title": "This repo hasn't been initialised for Hive.",
|
|
1193
|
-
"init.description": "Initialising writes the role files, hooks and task refs this board reads, and turns this session into the swarm: the
|
|
1272
|
+
"init.description": "Initialising writes the role files, hooks and task refs this board reads, and turns this session into the swarm: the Queen splits the goal, and the swarm keeps taking tasks until they are done — as long as the DSH process stays up.",
|
|
1194
1273
|
"init.button": "Initialise Hive",
|
|
1195
1274
|
"init.buttonAria": "Initialise Hive in this repository",
|
|
1196
1275
|
"init.busy": "Initialising Hive…",
|
|
@@ -1203,13 +1282,23 @@ const messages = Object.freeze({
|
|
|
1203
1282
|
"init.queenExit": "Exit from the chat window:",
|
|
1204
1283
|
"init.queenCommand": "/queen off",
|
|
1205
1284
|
"init.queenOutput": "Initialisation output",
|
|
1285
|
+
"queen.status.active": "Queen active",
|
|
1286
|
+
"queen.status.inactive": "Queen not active",
|
|
1287
|
+
"queen.source.auto": "auto",
|
|
1288
|
+
"queen.source.manual": "manual",
|
|
1289
|
+
"queen.activeTitle": "Queen mode is active ({source})",
|
|
1290
|
+
"queen.inactiveTitle": "The Queen has not taken over this session",
|
|
1291
|
+
"queen.offer": "The Queen has not taken over this session.",
|
|
1292
|
+
"queen.takeover": "Let the Queen take over",
|
|
1293
|
+
"queen.takeoverAria": "Let the Queen take over this session",
|
|
1294
|
+
"queen.takeoverBusy": "Taking over...",
|
|
1206
1295
|
"help.hint": "Open a task to see the actions for that task.",
|
|
1207
1296
|
"help.action.freeze": "Freeze: nobody can claim new tasks except tasks tagged fix.",
|
|
1208
|
-
"help.action.unfreeze": "Unfreeze:
|
|
1297
|
+
"help.action.unfreeze": "Unfreeze: workers can claim pending tasks again.",
|
|
1209
1298
|
"help.action.add": "New task: create a pending task with a role and file scope.",
|
|
1210
1299
|
"help.action.plan": "Give the Queen a goal: split a goal into tasks, preview the plan, then write it to the board.",
|
|
1211
1300
|
"help.action.commit": "Commit: commit the selected paths with a message.",
|
|
1212
|
-
"help.action.claim": "Claim: lease a pending task for
|
|
1301
|
+
"help.action.claim": "Claim: lease a pending task for a worker.",
|
|
1213
1302
|
"help.action.done": "Done: mark a claimed task complete, optionally with a commit sha.",
|
|
1214
1303
|
"help.action.fail": "Fail: mark a claimed task failed and record the reason.",
|
|
1215
1304
|
"help.action.retry": "Retry: put a failed or blocked task back in the queue.",
|
|
@@ -1217,7 +1306,7 @@ const messages = Object.freeze({
|
|
|
1217
1306
|
"help.params.add": "title, role, scope[], after[]",
|
|
1218
1307
|
"help.params.plan": "goal, maxCards",
|
|
1219
1308
|
"help.params.commit": "message, set[]",
|
|
1220
|
-
"help.params.claim": "id,
|
|
1309
|
+
"help.params.claim": "id, worker",
|
|
1221
1310
|
"help.params.done": "id, sha?",
|
|
1222
1311
|
"help.params.fail": "id, reason",
|
|
1223
1312
|
"help.params.retry": "id",
|
|
@@ -1268,7 +1357,7 @@ const messages = Object.freeze({
|
|
|
1268
1357
|
"action.modeTitle": "切换看板模式",
|
|
1269
1358
|
"action.retry": "重试",
|
|
1270
1359
|
"action.unfreeze": "解冻",
|
|
1271
|
-
"pane.agents": "
|
|
1360
|
+
"pane.agents": "工蜂",
|
|
1272
1361
|
"pane.board": "任务",
|
|
1273
1362
|
"pane.events": "事件",
|
|
1274
1363
|
"board.hint": "5 条泳道",
|
|
@@ -1290,11 +1379,18 @@ const messages = Object.freeze({
|
|
|
1290
1379
|
"mode.title": "模式:",
|
|
1291
1380
|
"stats.cards": "个任务",
|
|
1292
1381
|
"stats.oldest": "最久待办",
|
|
1382
|
+
"stats.duration.justNow": "刚刚",
|
|
1383
|
+
"stats.duration.minute": "{count} 分钟",
|
|
1384
|
+
"stats.duration.minutes": "{count} 分钟",
|
|
1385
|
+
"stats.duration.hour": "{count} 小时",
|
|
1386
|
+
"stats.duration.hours": "{count} 小时",
|
|
1387
|
+
"stats.duration.day": "{count} 天",
|
|
1388
|
+
"stats.duration.days": "{count} 天",
|
|
1293
1389
|
"stats.byRoleTitle": "按角色:",
|
|
1294
1390
|
"status.actionFailed": "操作失败",
|
|
1295
1391
|
"status.disconnected": "连接断开",
|
|
1296
|
-
"agents.empty": "
|
|
1297
|
-
"agents.openAria": "
|
|
1392
|
+
"agents.empty": "后台暂无工蜂。",
|
|
1393
|
+
"agents.openAria": "打开工蜂",
|
|
1298
1394
|
"agent.idle": "空闲",
|
|
1299
1395
|
"agent.task": "任务",
|
|
1300
1396
|
"agent.unknown": "未知",
|
|
@@ -1351,10 +1447,10 @@ const messages = Object.freeze({
|
|
|
1351
1447
|
"prompt.after": "排在哪些任务之后(任务 ID,逗号分隔,可选)",
|
|
1352
1448
|
"prompt.commitMessage": "提交信息",
|
|
1353
1449
|
"prompt.paths": "路径(逗号分隔,可选)",
|
|
1354
|
-
"prompt.claimAgent": "
|
|
1450
|
+
"prompt.claimAgent": "以哪个工蜂认领",
|
|
1355
1451
|
"prompt.commitSha": "提交 SHA(可选)",
|
|
1356
1452
|
"prompt.failReason": "失败原因",
|
|
1357
|
-
"action.plan": "
|
|
1453
|
+
"action.plan": "给蜂皇下目标",
|
|
1358
1454
|
"help.open": "这些按钮是做什么的",
|
|
1359
1455
|
"menu.open": "更多操作与说明",
|
|
1360
1456
|
"help.title": "按钮说明",
|
|
@@ -1377,17 +1473,27 @@ const messages = Object.freeze({
|
|
|
1377
1473
|
"init.failed": "初始化失败",
|
|
1378
1474
|
"init.output": "标准输出",
|
|
1379
1475
|
"init.noOutput": "(无输出)",
|
|
1380
|
-
"init.queen": "
|
|
1476
|
+
"init.queen": "本会话输入框已接入蜂皇模式(蜂皇只拆解任务,不亲自干活)。",
|
|
1381
1477
|
"init.queenExit": "退出请在聊天窗口输入:",
|
|
1382
1478
|
"init.queenCommand": "/queen off",
|
|
1383
1479
|
"init.queenOutput": "初始化输出",
|
|
1480
|
+
"queen.status.active": "蜂皇已接管",
|
|
1481
|
+
"queen.status.inactive": "蜂皇未接管",
|
|
1482
|
+
"queen.source.auto": "自动",
|
|
1483
|
+
"queen.source.manual": "手动",
|
|
1484
|
+
"queen.activeTitle": "蜂皇模式已接管({source})",
|
|
1485
|
+
"queen.inactiveTitle": "蜂皇尚未接管本会话",
|
|
1486
|
+
"queen.offer": "蜂皇尚未接管本会话。",
|
|
1487
|
+
"queen.takeover": "让蜂皇接管",
|
|
1488
|
+
"queen.takeoverAria": "让蜂皇接管本会话",
|
|
1489
|
+
"queen.takeoverBusy": "正在接管…",
|
|
1384
1490
|
"help.hint": "点开任务可查看该任务自己的操作。",
|
|
1385
1491
|
"help.action.freeze": "冻结:除带 fix 标签的任务外,任何人都不再能认领新任务。",
|
|
1386
|
-
"help.action.unfreeze": "
|
|
1492
|
+
"help.action.unfreeze": "解冻:恢复认领,工蜂可以继续接取待办任务。",
|
|
1387
1493
|
"help.action.add": "新建任务:添加一条带角色和文件范围的待办任务。",
|
|
1388
|
-
"help.action.plan": "
|
|
1494
|
+
"help.action.plan": "给蜂皇下目标:让蜂皇把目标拆成任务计划,预览后再写入看板。",
|
|
1389
1495
|
"help.action.commit": "提交:按提交信息提交选中的路径。",
|
|
1390
|
-
"help.action.claim": "
|
|
1496
|
+
"help.action.claim": "认领:以某个工蜂的名义短期租下这条待办任务。",
|
|
1391
1497
|
"help.action.done": "完成:把已认领的任务标为完成,可选填写提交 SHA。",
|
|
1392
1498
|
"help.action.fail": "标记失败:把已认领的任务标为失败,并写明原因。",
|
|
1393
1499
|
"help.action.retry": "重试:把失败或受阻的任务放回队列。",
|
|
@@ -1395,18 +1501,18 @@ const messages = Object.freeze({
|
|
|
1395
1501
|
"help.params.add": "title、role、scope[]、after[]",
|
|
1396
1502
|
"help.params.plan": "goal、maxCards",
|
|
1397
1503
|
"help.params.commit": "message、set[]",
|
|
1398
|
-
"help.params.claim": "id
|
|
1504
|
+
"help.params.claim": "id、工蜂",
|
|
1399
1505
|
"help.params.done": "id、sha?",
|
|
1400
1506
|
"help.params.fail": "id、reason",
|
|
1401
1507
|
"help.params.retry": "id",
|
|
1402
|
-
"plan.dialogTitle": "
|
|
1508
|
+
"plan.dialogTitle": "给蜂皇下目标",
|
|
1403
1509
|
"plan.dialogAria": "按目标规划任务",
|
|
1404
1510
|
"plan.goal": "目标",
|
|
1405
|
-
"plan.goalHint": "
|
|
1511
|
+
"plan.goalHint": "描述想达成的结果,蜂皇会把它拆成任务。",
|
|
1406
1512
|
"plan.maxCards": "最大卡数",
|
|
1407
1513
|
"plan.maxCardsHint": "至少 1",
|
|
1408
1514
|
"plan.preview": "预览计划",
|
|
1409
|
-
"plan.previewAria": "
|
|
1515
|
+
"plan.previewAria": "让蜂皇先给出任务计划,不写入看板",
|
|
1410
1516
|
"plan.previewing": "规划中…",
|
|
1411
1517
|
"plan.write": "写入任务",
|
|
1412
1518
|
"plan.writing": "写入中…",
|
|
@@ -1531,10 +1637,26 @@ function normalizeStats(stats, tasks) {
|
|
|
1531
1637
|
}
|
|
1532
1638
|
}
|
|
1533
1639
|
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1640
|
+
let oldestPending = null;
|
|
1641
|
+
const rawOldest = source.oldestPending;
|
|
1642
|
+
if (isRecord(rawOldest)) {
|
|
1643
|
+
const id =
|
|
1644
|
+
typeof rawOldest.id === "string" || typeof rawOldest.id === "number" ? String(rawOldest.id) : "";
|
|
1645
|
+
const createdValue =
|
|
1646
|
+
rawOldest.createdAt !== undefined && rawOldest.createdAt !== null
|
|
1647
|
+
? rawOldest.createdAt
|
|
1648
|
+
: rawOldest.created !== undefined && rawOldest.created !== null
|
|
1649
|
+
? rawOldest.created
|
|
1650
|
+
: rawOldest.at;
|
|
1651
|
+
const createdAt =
|
|
1652
|
+
typeof createdValue === "string" || typeof createdValue === "number" ? String(createdValue) : "";
|
|
1653
|
+
if (id || createdAt) oldestPending = { id, createdAt };
|
|
1654
|
+
} else if (typeof rawOldest === "string" || typeof rawOldest === "number") {
|
|
1655
|
+
const text = String(rawOldest);
|
|
1656
|
+
if (text) {
|
|
1657
|
+
oldestPending = parseDate(text) ? { id: "", createdAt: text } : { id: text, createdAt: "" };
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1538
1660
|
|
|
1539
1661
|
return { total, byState, byRole, oldestPending };
|
|
1540
1662
|
}
|
|
@@ -1609,9 +1731,10 @@ function helpGroups(mode) {
|
|
|
1609
1731
|
* @param {object} snapshot
|
|
1610
1732
|
* @returns {{
|
|
1611
1733
|
* at: string, repo: string, mode: string, initialised: boolean, writable: boolean,
|
|
1734
|
+
* queen: {active:boolean, source:"auto"|"manual"|null, repo:string}|null,
|
|
1612
1735
|
* lanes: Record<string, Array<{id:string,title:string,role:string,owner:string,scope:string[],reason:string}>>,
|
|
1613
1736
|
* laneOrder: string[],
|
|
1614
|
-
* stats: {total:number, byState:Record<string,number>, byRole:Record<string,number>, oldestPending:string|null},
|
|
1737
|
+
* stats: {total:number, byState:Record<string,number>, byRole:Record<string,number>, oldestPending:{id:string,createdAt:string}|null},
|
|
1615
1738
|
* agents: Array<{agent:string,state:string,task:string,files:string[],updatedAt:string}>,
|
|
1616
1739
|
* events: Array<{ts:string,kind:string,task:string,actor:string}>,
|
|
1617
1740
|
* actions: Array<{name:string,labelKey:string,body?:object}>
|
|
@@ -1639,12 +1762,26 @@ function renderModel(snapshot) {
|
|
|
1639
1762
|
: "free";
|
|
1640
1763
|
const writable = source.writable === true;
|
|
1641
1764
|
const initialised = source.initialised !== false;
|
|
1765
|
+
const rawQueen = isRecord(source.queen) ? source.queen : null;
|
|
1766
|
+
const queenActive = rawQueen !== null && rawQueen.active === true;
|
|
1767
|
+
const queen =
|
|
1768
|
+
rawQueen === null
|
|
1769
|
+
? null
|
|
1770
|
+
: {
|
|
1771
|
+
active: queenActive,
|
|
1772
|
+
source:
|
|
1773
|
+
queenActive && (rawQueen.source === "auto" || rawQueen.source === "manual")
|
|
1774
|
+
? rawQueen.source
|
|
1775
|
+
: null,
|
|
1776
|
+
repo: typeof rawQueen.repo === "string" ? rawQueen.repo : "",
|
|
1777
|
+
};
|
|
1642
1778
|
|
|
1643
1779
|
return {
|
|
1644
1780
|
at: asString(source.at),
|
|
1645
1781
|
repo: asString(source.repo),
|
|
1646
1782
|
mode,
|
|
1647
1783
|
initialised,
|
|
1784
|
+
queen,
|
|
1648
1785
|
writable,
|
|
1649
1786
|
lanes,
|
|
1650
1787
|
laneOrder: [...LANE_ORDER],
|
|
@@ -2150,6 +2287,7 @@ function mount(root, options = {}) {
|
|
|
2150
2287
|
let initErrorMessage = "";
|
|
2151
2288
|
let initRequestSeq = 0;
|
|
2152
2289
|
let queenNotice = false;
|
|
2290
|
+
let queenBusy = false;
|
|
2153
2291
|
let supervisorData = [];
|
|
2154
2292
|
let supervisorRequest = null;
|
|
2155
2293
|
let limitsOverlay = null;
|
|
@@ -2175,6 +2313,9 @@ function mount(root, options = {}) {
|
|
|
2175
2313
|
const statsNode = element(doc, "div", "hive-stats");
|
|
2176
2314
|
bar.appendChild(statsNode);
|
|
2177
2315
|
|
|
2316
|
+
const queenBadge = element(doc, "span", "hive-queen-badge is-hidden", "");
|
|
2317
|
+
bar.appendChild(queenBadge);
|
|
2318
|
+
|
|
2178
2319
|
const statusNode = element(doc, "span", "hive-status", "");
|
|
2179
2320
|
bar.appendChild(statusNode);
|
|
2180
2321
|
|
|
@@ -2220,12 +2361,22 @@ function mount(root, options = {}) {
|
|
|
2220
2361
|
const queenCommand = element(doc, "code", "hive-queen-command", "");
|
|
2221
2362
|
queenExit.appendChild(queenExitText);
|
|
2222
2363
|
queenExit.appendChild(queenCommand);
|
|
2364
|
+
const queenOffer = element(doc, "div", "hive-queen-offer is-hidden");
|
|
2365
|
+
const queenTakeoverButton = element(doc, "button", "hive-btn hive-queen-takeover", translate("queen.takeover"));
|
|
2366
|
+
setAttr(queenTakeoverButton, "type", "button");
|
|
2367
|
+
setAttr(queenTakeoverButton, "title", translate("queen.takeoverAria"));
|
|
2368
|
+
setAttr(queenTakeoverButton, "aria-label", translate("queen.takeoverAria"));
|
|
2369
|
+
queenTakeoverButton.addEventListener("click", () => {
|
|
2370
|
+
void runQueenOn(queenTakeoverButton);
|
|
2371
|
+
});
|
|
2372
|
+
queenOffer.appendChild(queenTakeoverButton);
|
|
2223
2373
|
const queenOutputDetails = element(doc, "details", "hive-init-output hive-queen-output is-hidden");
|
|
2224
2374
|
const queenOutputSummary = element(doc, "summary", "hive-output-summary", "");
|
|
2225
2375
|
const queenOutputPre = element(doc, "pre", "hive-output-pre", "");
|
|
2226
2376
|
queenOutputDetails.appendChild(queenOutputSummary);
|
|
2227
2377
|
queenOutputDetails.appendChild(queenOutputPre);
|
|
2228
2378
|
queenHint.appendChild(queenHintText);
|
|
2379
|
+
queenHint.appendChild(queenOffer);
|
|
2229
2380
|
queenHint.appendChild(queenExit);
|
|
2230
2381
|
queenHint.appendChild(queenOutputDetails);
|
|
2231
2382
|
|
|
@@ -3362,6 +3513,21 @@ function mount(root, options = {}) {
|
|
|
3362
3513
|
return result.payload;
|
|
3363
3514
|
}
|
|
3364
3515
|
|
|
3516
|
+
async function runQueenOn(button) {
|
|
3517
|
+
if (destroyed || queenBusy) return;
|
|
3518
|
+
const model = lastModel;
|
|
3519
|
+
if (!model || model.initialised === false || (model.queen && model.queen.active)) return;
|
|
3520
|
+
queenBusy = true;
|
|
3521
|
+
renderQueenHint(model);
|
|
3522
|
+
try {
|
|
3523
|
+
await postAction("queen-on", {});
|
|
3524
|
+
} finally {
|
|
3525
|
+
queenBusy = false;
|
|
3526
|
+
if (!destroyed && lastModel) renderQueenHint(lastModel);
|
|
3527
|
+
else if (button && typeof button.focus === "function") button.focus();
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
|
|
3365
3531
|
async function runInitialise() {
|
|
3366
3532
|
if (destroyed || initBusy) return;
|
|
3367
3533
|
const model = lastModel;
|
|
@@ -3527,9 +3693,45 @@ function mount(root, options = {}) {
|
|
|
3527
3693
|
}
|
|
3528
3694
|
|
|
3529
3695
|
function renderQueenHint(model) {
|
|
3530
|
-
const
|
|
3531
|
-
|
|
3532
|
-
|
|
3696
|
+
const initialised = Boolean(model && model.initialised !== false);
|
|
3697
|
+
const state = model && isRecord(model.queen) ? model.queen : null;
|
|
3698
|
+
const active = state ? state.active === true : Boolean(queenNotice);
|
|
3699
|
+
const show = initialised && Boolean(state || queenNotice);
|
|
3700
|
+
const offer = show && !active;
|
|
3701
|
+
|
|
3702
|
+
if (initialised && state) {
|
|
3703
|
+
const source =
|
|
3704
|
+
state.source === "auto"
|
|
3705
|
+
? translate("queen.source.auto")
|
|
3706
|
+
: state.source === "manual"
|
|
3707
|
+
? translate("queen.source.manual")
|
|
3708
|
+
: "";
|
|
3709
|
+
const title = active
|
|
3710
|
+
? source
|
|
3711
|
+
? translate("queen.activeTitle").replace("{source}", source)
|
|
3712
|
+
: translate("queen.status.active")
|
|
3713
|
+
: translate("queen.inactiveTitle");
|
|
3714
|
+
queenBadge.className = "hive-queen-badge " + (active ? "is-active" : "is-inactive");
|
|
3715
|
+
queenBadge.textContent = active ? translate("queen.status.active") : translate("queen.status.inactive");
|
|
3716
|
+
setAttr(queenBadge, "title", title);
|
|
3717
|
+
setAttr(queenBadge, "aria-label", title);
|
|
3718
|
+
} else {
|
|
3719
|
+
queenBadge.className = "hive-queen-badge is-hidden";
|
|
3720
|
+
queenBadge.textContent = "";
|
|
3721
|
+
setAttr(queenBadge, "title", "");
|
|
3722
|
+
setAttr(queenBadge, "aria-label", "");
|
|
3723
|
+
}
|
|
3724
|
+
|
|
3725
|
+
queenHint.className = "hive-queen-hint" + (show ? " is-visible" : "") + (offer ? " is-offer" : "");
|
|
3726
|
+
queenHintText.textContent = active ? translate("init.queen") : translate("queen.offer");
|
|
3727
|
+
queenOffer.className = "hive-queen-offer" + (offer ? "" : " is-hidden");
|
|
3728
|
+
queenTakeoverButton.disabled = queenBusy;
|
|
3729
|
+
queenTakeoverButton.textContent = queenBusy ? translate("queen.takeoverBusy") : translate("queen.takeover");
|
|
3730
|
+
const takeoverAria = queenBusy ? translate("queen.takeoverBusy") : translate("queen.takeoverAria");
|
|
3731
|
+
setAttr(queenTakeoverButton, "title", takeoverAria);
|
|
3732
|
+
setAttr(queenTakeoverButton, "aria-label", takeoverAria);
|
|
3733
|
+
|
|
3734
|
+
queenExit.className = "hive-queen-exit" + (active ? "" : " is-hidden");
|
|
3533
3735
|
queenExitText.textContent = translate("init.queenExit");
|
|
3534
3736
|
queenCommand.textContent = translate("init.queenCommand");
|
|
3535
3737
|
queenOutputSummary.textContent = translate("init.queenOutput");
|
|
@@ -3537,7 +3739,7 @@ function mount(root, options = {}) {
|
|
|
3537
3739
|
const output = initOutput && initOutput.stdout ? initOutput.stdout : translate("init.noOutput");
|
|
3538
3740
|
queenOutputPre.textContent = output;
|
|
3539
3741
|
queenOutputDetails.className =
|
|
3540
|
-
"hive-init-output hive-queen-output" + (show && initOutput ? "" : " is-hidden");
|
|
3742
|
+
"hive-init-output hive-queen-output" + (show && active && initOutput ? "" : " is-hidden");
|
|
3541
3743
|
}
|
|
3542
3744
|
|
|
3543
3745
|
function supervisorEndpoint(op) {
|
|
@@ -3685,6 +3887,23 @@ function mount(root, options = {}) {
|
|
|
3685
3887
|
}
|
|
3686
3888
|
}
|
|
3687
3889
|
|
|
3890
|
+
function durationLabel(count, singularKey, pluralKey) {
|
|
3891
|
+
const key = count === 1 ? singularKey : pluralKey;
|
|
3892
|
+
return translate(key).replace("{count}", String(count));
|
|
3893
|
+
}
|
|
3894
|
+
|
|
3895
|
+
function elapsedLabel(createdAt) {
|
|
3896
|
+
const date = parseDate(createdAt);
|
|
3897
|
+
if (!date) return "";
|
|
3898
|
+
const seconds = Math.max(0, Math.floor((Date.now() - date.getTime()) / 1000));
|
|
3899
|
+
if (seconds < 60) return translate("stats.duration.justNow");
|
|
3900
|
+
const minutes = Math.floor(seconds / 60);
|
|
3901
|
+
if (minutes < 60) return durationLabel(minutes, "stats.duration.minute", "stats.duration.minutes");
|
|
3902
|
+
const hours = Math.floor(minutes / 60);
|
|
3903
|
+
if (hours < 24) return durationLabel(hours, "stats.duration.hour", "stats.duration.hours");
|
|
3904
|
+
return durationLabel(Math.floor(hours / 24), "stats.duration.day", "stats.duration.days");
|
|
3905
|
+
}
|
|
3906
|
+
|
|
3688
3907
|
function renderStats(model) {
|
|
3689
3908
|
clearNode(statsNode);
|
|
3690
3909
|
const total = element(doc, "span", "hive-stat is-total");
|
|
@@ -3700,18 +3919,21 @@ function mount(root, options = {}) {
|
|
|
3700
3919
|
}
|
|
3701
3920
|
|
|
3702
3921
|
if (model.stats.oldestPending) {
|
|
3703
|
-
const
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
)
|
|
3709
|
-
|
|
3922
|
+
const pending = model.stats.oldestPending;
|
|
3923
|
+
const duration = elapsedLabel(pending.createdAt);
|
|
3924
|
+
const label = translate("stats.oldest") + (duration ? " " + duration : "");
|
|
3925
|
+
const oldest = element(doc, "span", "hive-stat is-warn hive-oldest");
|
|
3926
|
+
oldest.appendChild(element(doc, "span", "hive-oldest-label", label));
|
|
3927
|
+
if (pending.id) {
|
|
3928
|
+
oldest.appendChild(element(doc, "span", "hive-oldest-sep", " · "));
|
|
3929
|
+
oldest.appendChild(element(doc, "code", "hive-oldest-id", pending.id));
|
|
3930
|
+
}
|
|
3931
|
+
setAttr(oldest, "title", label + (pending.id ? " · " + pending.id : ""));
|
|
3710
3932
|
statsNode.appendChild(oldest);
|
|
3711
3933
|
}
|
|
3712
3934
|
|
|
3713
3935
|
const roleSummary = Object.keys(model.stats.byRole)
|
|
3714
|
-
.map((role) => role + " " + model.stats.byRole[role])
|
|
3936
|
+
.map((role) => role + " " + asCount(model.stats.byRole[role], 0))
|
|
3715
3937
|
.join(" · ");
|
|
3716
3938
|
setAttr(statsNode, "title", roleSummary ? translate("stats.byRoleTitle") + roleSummary : "");
|
|
3717
3939
|
}
|
|
@@ -4003,6 +4225,7 @@ function mount(root, options = {}) {
|
|
|
4003
4225
|
initOutput = null;
|
|
4004
4226
|
initErrorMessage = "";
|
|
4005
4227
|
queenNotice = false;
|
|
4228
|
+
queenBusy = false;
|
|
4006
4229
|
stageFilter = "all";
|
|
4007
4230
|
stageChipEntries = [];
|
|
4008
4231
|
eventsExpanded = false;
|