dsh-hive-panel 0.1.0 → 0.1.2
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 +34 -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 +257 -34
- 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 +257 -34
package/src/panel.js
CHANGED
|
@@ -703,6 +703,61 @@ const PANEL_STYLES = `.hive { position: relative; }
|
|
|
703
703
|
}
|
|
704
704
|
|
|
705
705
|
.hive-queen-hint.is-visible { display: flex; }
|
|
706
|
+
.hive-queen-badge {
|
|
707
|
+
padding: 2px 8px;
|
|
708
|
+
border: 1px solid var(--hive-line, #232b38);
|
|
709
|
+
border-radius: 999px;
|
|
710
|
+
font-size: 10px;
|
|
711
|
+
font-weight: 650;
|
|
712
|
+
letter-spacing: 0.09em;
|
|
713
|
+
line-height: 1.5;
|
|
714
|
+
text-transform: uppercase;
|
|
715
|
+
white-space: nowrap;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.hive-queen-badge.is-hidden { display: none; }
|
|
719
|
+
|
|
720
|
+
.hive-queen-badge.is-active {
|
|
721
|
+
border-color: color-mix(in srgb, var(--hive-accent, #58c4dc) 45%, transparent);
|
|
722
|
+
background: var(--hive-accent-soft);
|
|
723
|
+
color: var(--hive-accent, #58c4dc);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.hive-queen-badge.is-inactive {
|
|
727
|
+
border-color: var(--hive-line, #232b38);
|
|
728
|
+
background: var(--hive-surface);
|
|
729
|
+
color: var(--hive-fg-soft);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.hive-queen-hint.is-offer {
|
|
733
|
+
border-bottom-color: var(--hive-line, #232b38);
|
|
734
|
+
background: var(--hive-surface);
|
|
735
|
+
color: var(--hive-fg-soft);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
.hive-queen-offer {
|
|
739
|
+
display: flex;
|
|
740
|
+
flex-wrap: wrap;
|
|
741
|
+
align-items: center;
|
|
742
|
+
gap: 8px;
|
|
743
|
+
max-width: 76ch;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
.hive-queen-offer.is-hidden,
|
|
747
|
+
.hive-queen-exit.is-hidden { display: none; }
|
|
748
|
+
|
|
749
|
+
.hive-queen-takeover {
|
|
750
|
+
border-color: color-mix(in srgb, var(--hive-accent, #58c4dc) 45%, var(--hive-line, #232b38));
|
|
751
|
+
background: var(--hive-accent-soft);
|
|
752
|
+
color: var(--hive-accent, #58c4dc);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.hive-queen-takeover:disabled {
|
|
756
|
+
opacity: 0.6;
|
|
757
|
+
cursor: wait;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
|
|
706
761
|
|
|
707
762
|
.hive-queen-text {
|
|
708
763
|
max-width: 76ch;
|
|
@@ -937,6 +992,23 @@ const PANEL_STYLES = `.hive { position: relative; }
|
|
|
937
992
|
line-height: 1.5;
|
|
938
993
|
}
|
|
939
994
|
|
|
995
|
+
.hive-oldest {
|
|
996
|
+
max-width: 100%;
|
|
997
|
+
overflow-wrap: anywhere;
|
|
998
|
+
white-space: normal;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
.hive-oldest-label { min-width: 0; }
|
|
1002
|
+
|
|
1003
|
+
.hive-oldest-sep { opacity: 0.65; }
|
|
1004
|
+
|
|
1005
|
+
.hive-oldest-id {
|
|
1006
|
+
font-family: var(--hive-mono);
|
|
1007
|
+
font-size: 9.5px;
|
|
1008
|
+
font-weight: 400;
|
|
1009
|
+
overflow-wrap: anywhere;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
940
1012
|
/* -------------------------------------------------------------------- spacing */
|
|
941
1013
|
.hive {
|
|
942
1014
|
gap: 8px;
|
|
@@ -1063,7 +1135,7 @@ export const messages = Object.freeze({
|
|
|
1063
1135
|
"action.modeTitle": "Toggle board mode",
|
|
1064
1136
|
"action.retry": "retry",
|
|
1065
1137
|
"action.unfreeze": "unfreeze",
|
|
1066
|
-
"pane.agents": "
|
|
1138
|
+
"pane.agents": "workers",
|
|
1067
1139
|
"pane.board": "board",
|
|
1068
1140
|
"pane.events": "events",
|
|
1069
1141
|
"board.hint": "5 lanes",
|
|
@@ -1085,11 +1157,18 @@ export const messages = Object.freeze({
|
|
|
1085
1157
|
"mode.title": "mode:",
|
|
1086
1158
|
"stats.cards": "tasks",
|
|
1087
1159
|
"stats.oldest": "oldest",
|
|
1160
|
+
"stats.duration.justNow": "just now",
|
|
1161
|
+
"stats.duration.minute": "{count} min",
|
|
1162
|
+
"stats.duration.minutes": "{count} min",
|
|
1163
|
+
"stats.duration.hour": "{count} hr",
|
|
1164
|
+
"stats.duration.hours": "{count} hr",
|
|
1165
|
+
"stats.duration.day": "{count} day",
|
|
1166
|
+
"stats.duration.days": "{count} days",
|
|
1088
1167
|
"stats.byRoleTitle": "by role: ",
|
|
1089
1168
|
"status.actionFailed": "action failed",
|
|
1090
1169
|
"status.disconnected": "disconnected",
|
|
1091
|
-
"agents.empty": "No
|
|
1092
|
-
"agents.openAria": "Open
|
|
1170
|
+
"agents.empty": "No workers in the background.",
|
|
1171
|
+
"agents.openAria": "Open worker",
|
|
1093
1172
|
"agent.idle": "idle",
|
|
1094
1173
|
"agent.task": "task",
|
|
1095
1174
|
"agent.unknown": "unknown",
|
|
@@ -1146,7 +1225,7 @@ export const messages = Object.freeze({
|
|
|
1146
1225
|
"prompt.after": "After task ids (comma separated, optional)",
|
|
1147
1226
|
"prompt.commitMessage": "Commit message",
|
|
1148
1227
|
"prompt.paths": "Paths (comma separated, optional)",
|
|
1149
|
-
"prompt.claimAgent": "Claim as
|
|
1228
|
+
"prompt.claimAgent": "Claim as worker",
|
|
1150
1229
|
"prompt.commitSha": "Commit sha (optional)",
|
|
1151
1230
|
"prompt.failReason": "Failure reason",
|
|
1152
1231
|
"action.plan": "Give the Queen a goal",
|
|
@@ -1163,7 +1242,7 @@ export const messages = Object.freeze({
|
|
|
1163
1242
|
"help.uninitialised": "Initialise Hive with the button in the main area before using board actions.",
|
|
1164
1243
|
"init.repo": "repository",
|
|
1165
1244
|
"init.title": "This repo hasn't been initialised for Hive.",
|
|
1166
|
-
"init.description": "Initialising writes the role files, hooks and task refs this board reads, and turns this session into the swarm: the
|
|
1245
|
+
"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.",
|
|
1167
1246
|
"init.button": "Initialise Hive",
|
|
1168
1247
|
"init.buttonAria": "Initialise Hive in this repository",
|
|
1169
1248
|
"init.busy": "Initialising Hive…",
|
|
@@ -1176,13 +1255,23 @@ export const messages = Object.freeze({
|
|
|
1176
1255
|
"init.queenExit": "Exit from the chat window:",
|
|
1177
1256
|
"init.queenCommand": "/queen off",
|
|
1178
1257
|
"init.queenOutput": "Initialisation output",
|
|
1258
|
+
"queen.status.active": "Queen active",
|
|
1259
|
+
"queen.status.inactive": "Queen not active",
|
|
1260
|
+
"queen.source.auto": "auto",
|
|
1261
|
+
"queen.source.manual": "manual",
|
|
1262
|
+
"queen.activeTitle": "Queen mode is active ({source})",
|
|
1263
|
+
"queen.inactiveTitle": "The Queen has not taken over this session",
|
|
1264
|
+
"queen.offer": "The Queen has not taken over this session.",
|
|
1265
|
+
"queen.takeover": "Let the Queen take over",
|
|
1266
|
+
"queen.takeoverAria": "Let the Queen take over this session",
|
|
1267
|
+
"queen.takeoverBusy": "Taking over...",
|
|
1179
1268
|
"help.hint": "Open a task to see the actions for that task.",
|
|
1180
1269
|
"help.action.freeze": "Freeze: nobody can claim new tasks except tasks tagged fix.",
|
|
1181
|
-
"help.action.unfreeze": "Unfreeze:
|
|
1270
|
+
"help.action.unfreeze": "Unfreeze: workers can claim pending tasks again.",
|
|
1182
1271
|
"help.action.add": "New task: create a pending task with a role and file scope.",
|
|
1183
1272
|
"help.action.plan": "Give the Queen a goal: split a goal into tasks, preview the plan, then write it to the board.",
|
|
1184
1273
|
"help.action.commit": "Commit: commit the selected paths with a message.",
|
|
1185
|
-
"help.action.claim": "Claim: lease a pending task for
|
|
1274
|
+
"help.action.claim": "Claim: lease a pending task for a worker.",
|
|
1186
1275
|
"help.action.done": "Done: mark a claimed task complete, optionally with a commit sha.",
|
|
1187
1276
|
"help.action.fail": "Fail: mark a claimed task failed and record the reason.",
|
|
1188
1277
|
"help.action.retry": "Retry: put a failed or blocked task back in the queue.",
|
|
@@ -1190,7 +1279,7 @@ export const messages = Object.freeze({
|
|
|
1190
1279
|
"help.params.add": "title, role, scope[], after[]",
|
|
1191
1280
|
"help.params.plan": "goal, maxCards",
|
|
1192
1281
|
"help.params.commit": "message, set[]",
|
|
1193
|
-
"help.params.claim": "id,
|
|
1282
|
+
"help.params.claim": "id, worker",
|
|
1194
1283
|
"help.params.done": "id, sha?",
|
|
1195
1284
|
"help.params.fail": "id, reason",
|
|
1196
1285
|
"help.params.retry": "id",
|
|
@@ -1241,7 +1330,7 @@ export const messages = Object.freeze({
|
|
|
1241
1330
|
"action.modeTitle": "切换看板模式",
|
|
1242
1331
|
"action.retry": "重试",
|
|
1243
1332
|
"action.unfreeze": "解冻",
|
|
1244
|
-
"pane.agents": "
|
|
1333
|
+
"pane.agents": "工蜂",
|
|
1245
1334
|
"pane.board": "任务",
|
|
1246
1335
|
"pane.events": "事件",
|
|
1247
1336
|
"board.hint": "5 条泳道",
|
|
@@ -1263,11 +1352,18 @@ export const messages = Object.freeze({
|
|
|
1263
1352
|
"mode.title": "模式:",
|
|
1264
1353
|
"stats.cards": "个任务",
|
|
1265
1354
|
"stats.oldest": "最久待办",
|
|
1355
|
+
"stats.duration.justNow": "刚刚",
|
|
1356
|
+
"stats.duration.minute": "{count} 分钟",
|
|
1357
|
+
"stats.duration.minutes": "{count} 分钟",
|
|
1358
|
+
"stats.duration.hour": "{count} 小时",
|
|
1359
|
+
"stats.duration.hours": "{count} 小时",
|
|
1360
|
+
"stats.duration.day": "{count} 天",
|
|
1361
|
+
"stats.duration.days": "{count} 天",
|
|
1266
1362
|
"stats.byRoleTitle": "按角色:",
|
|
1267
1363
|
"status.actionFailed": "操作失败",
|
|
1268
1364
|
"status.disconnected": "连接断开",
|
|
1269
|
-
"agents.empty": "
|
|
1270
|
-
"agents.openAria": "
|
|
1365
|
+
"agents.empty": "后台暂无工蜂。",
|
|
1366
|
+
"agents.openAria": "打开工蜂",
|
|
1271
1367
|
"agent.idle": "空闲",
|
|
1272
1368
|
"agent.task": "任务",
|
|
1273
1369
|
"agent.unknown": "未知",
|
|
@@ -1324,7 +1420,7 @@ export const messages = Object.freeze({
|
|
|
1324
1420
|
"prompt.after": "排在哪些任务之后(任务 ID,逗号分隔,可选)",
|
|
1325
1421
|
"prompt.commitMessage": "提交信息",
|
|
1326
1422
|
"prompt.paths": "路径(逗号分隔,可选)",
|
|
1327
|
-
"prompt.claimAgent": "
|
|
1423
|
+
"prompt.claimAgent": "以哪个工蜂认领",
|
|
1328
1424
|
"prompt.commitSha": "提交 SHA(可选)",
|
|
1329
1425
|
"prompt.failReason": "失败原因",
|
|
1330
1426
|
"action.plan": "给女王下目标",
|
|
@@ -1341,7 +1437,7 @@ export const messages = Object.freeze({
|
|
|
1341
1437
|
"help.uninitialised": "请先用主区的按钮初始化 Hive,再使用看板操作。",
|
|
1342
1438
|
"init.repo": "仓库",
|
|
1343
1439
|
"init.title": "这个仓库还没初始化 Hive。",
|
|
1344
|
-
"init.description": "初始化后,这块看板才能读数据,同时进入蜂群模式:Hive 会写入角色文件、hooks
|
|
1440
|
+
"init.description": "初始化后,这块看板才能读数据,同时进入蜂群模式:Hive 会写入角色文件、hooks 和任务引用,女王分解任务;只要 DSH 进程不退出,蜂群会一直执行任务直到完成。",
|
|
1345
1441
|
"init.button": "初始化 Hive",
|
|
1346
1442
|
"init.buttonAria": "在这个仓库初始化 Hive",
|
|
1347
1443
|
"init.busy": "正在初始化 Hive…",
|
|
@@ -1354,13 +1450,23 @@ export const messages = Object.freeze({
|
|
|
1354
1450
|
"init.queenExit": "退出请在聊天窗口输入:",
|
|
1355
1451
|
"init.queenCommand": "/queen off",
|
|
1356
1452
|
"init.queenOutput": "初始化输出",
|
|
1453
|
+
"queen.status.active": "女王已接管",
|
|
1454
|
+
"queen.status.inactive": "女王未接管",
|
|
1455
|
+
"queen.source.auto": "自动",
|
|
1456
|
+
"queen.source.manual": "手动",
|
|
1457
|
+
"queen.activeTitle": "女王模式已接管({source})",
|
|
1458
|
+
"queen.inactiveTitle": "女王尚未接管本会话",
|
|
1459
|
+
"queen.offer": "女王尚未接管本会话。",
|
|
1460
|
+
"queen.takeover": "让女王接管",
|
|
1461
|
+
"queen.takeoverAria": "让女王接管本会话",
|
|
1462
|
+
"queen.takeoverBusy": "正在接管…",
|
|
1357
1463
|
"help.hint": "点开任务可查看该任务自己的操作。",
|
|
1358
1464
|
"help.action.freeze": "冻结:除带 fix 标签的任务外,任何人都不再能认领新任务。",
|
|
1359
|
-
"help.action.unfreeze": "
|
|
1465
|
+
"help.action.unfreeze": "解冻:恢复认领,工蜂可以继续接取待办任务。",
|
|
1360
1466
|
"help.action.add": "新建任务:添加一条带角色和文件范围的待办任务。",
|
|
1361
|
-
"help.action.plan": "
|
|
1467
|
+
"help.action.plan": "给女王下目标:让女王把目标拆成任务计划,预览后再写入看板。",
|
|
1362
1468
|
"help.action.commit": "提交:按提交信息提交选中的路径。",
|
|
1363
|
-
"help.action.claim": "
|
|
1469
|
+
"help.action.claim": "认领:以某个工蜂的名义短期租下这条待办任务。",
|
|
1364
1470
|
"help.action.done": "完成:把已认领的任务标为完成,可选填写提交 SHA。",
|
|
1365
1471
|
"help.action.fail": "标记失败:把已认领的任务标为失败,并写明原因。",
|
|
1366
1472
|
"help.action.retry": "重试:把失败或受阻的任务放回队列。",
|
|
@@ -1368,7 +1474,7 @@ export const messages = Object.freeze({
|
|
|
1368
1474
|
"help.params.add": "title、role、scope[]、after[]",
|
|
1369
1475
|
"help.params.plan": "goal、maxCards",
|
|
1370
1476
|
"help.params.commit": "message、set[]",
|
|
1371
|
-
"help.params.claim": "id
|
|
1477
|
+
"help.params.claim": "id、工蜂",
|
|
1372
1478
|
"help.params.done": "id、sha?",
|
|
1373
1479
|
"help.params.fail": "id、reason",
|
|
1374
1480
|
"help.params.retry": "id",
|
|
@@ -1504,10 +1610,26 @@ function normalizeStats(stats, tasks) {
|
|
|
1504
1610
|
}
|
|
1505
1611
|
}
|
|
1506
1612
|
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1613
|
+
let oldestPending = null;
|
|
1614
|
+
const rawOldest = source.oldestPending;
|
|
1615
|
+
if (isRecord(rawOldest)) {
|
|
1616
|
+
const id =
|
|
1617
|
+
typeof rawOldest.id === "string" || typeof rawOldest.id === "number" ? String(rawOldest.id) : "";
|
|
1618
|
+
const createdValue =
|
|
1619
|
+
rawOldest.createdAt !== undefined && rawOldest.createdAt !== null
|
|
1620
|
+
? rawOldest.createdAt
|
|
1621
|
+
: rawOldest.created !== undefined && rawOldest.created !== null
|
|
1622
|
+
? rawOldest.created
|
|
1623
|
+
: rawOldest.at;
|
|
1624
|
+
const createdAt =
|
|
1625
|
+
typeof createdValue === "string" || typeof createdValue === "number" ? String(createdValue) : "";
|
|
1626
|
+
if (id || createdAt) oldestPending = { id, createdAt };
|
|
1627
|
+
} else if (typeof rawOldest === "string" || typeof rawOldest === "number") {
|
|
1628
|
+
const text = String(rawOldest);
|
|
1629
|
+
if (text) {
|
|
1630
|
+
oldestPending = parseDate(text) ? { id: "", createdAt: text } : { id: text, createdAt: "" };
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1511
1633
|
|
|
1512
1634
|
return { total, byState, byRole, oldestPending };
|
|
1513
1635
|
}
|
|
@@ -1582,9 +1704,10 @@ function helpGroups(mode) {
|
|
|
1582
1704
|
* @param {object} snapshot
|
|
1583
1705
|
* @returns {{
|
|
1584
1706
|
* at: string, repo: string, mode: string, initialised: boolean, writable: boolean,
|
|
1707
|
+
* queen: {active:boolean, source:"auto"|"manual"|null, repo:string}|null,
|
|
1585
1708
|
* lanes: Record<string, Array<{id:string,title:string,role:string,owner:string,scope:string[],reason:string}>>,
|
|
1586
1709
|
* laneOrder: string[],
|
|
1587
|
-
* stats: {total:number, byState:Record<string,number>, byRole:Record<string,number>, oldestPending:string|null},
|
|
1710
|
+
* stats: {total:number, byState:Record<string,number>, byRole:Record<string,number>, oldestPending:{id:string,createdAt:string}|null},
|
|
1588
1711
|
* agents: Array<{agent:string,state:string,task:string,files:string[],updatedAt:string}>,
|
|
1589
1712
|
* events: Array<{ts:string,kind:string,task:string,actor:string}>,
|
|
1590
1713
|
* actions: Array<{name:string,labelKey:string,body?:object}>
|
|
@@ -1612,12 +1735,26 @@ export function renderModel(snapshot) {
|
|
|
1612
1735
|
: "free";
|
|
1613
1736
|
const writable = source.writable === true;
|
|
1614
1737
|
const initialised = source.initialised !== false;
|
|
1738
|
+
const rawQueen = isRecord(source.queen) ? source.queen : null;
|
|
1739
|
+
const queenActive = rawQueen !== null && rawQueen.active === true;
|
|
1740
|
+
const queen =
|
|
1741
|
+
rawQueen === null
|
|
1742
|
+
? null
|
|
1743
|
+
: {
|
|
1744
|
+
active: queenActive,
|
|
1745
|
+
source:
|
|
1746
|
+
queenActive && (rawQueen.source === "auto" || rawQueen.source === "manual")
|
|
1747
|
+
? rawQueen.source
|
|
1748
|
+
: null,
|
|
1749
|
+
repo: typeof rawQueen.repo === "string" ? rawQueen.repo : "",
|
|
1750
|
+
};
|
|
1615
1751
|
|
|
1616
1752
|
return {
|
|
1617
1753
|
at: asString(source.at),
|
|
1618
1754
|
repo: asString(source.repo),
|
|
1619
1755
|
mode,
|
|
1620
1756
|
initialised,
|
|
1757
|
+
queen,
|
|
1621
1758
|
writable,
|
|
1622
1759
|
lanes,
|
|
1623
1760
|
laneOrder: [...LANE_ORDER],
|
|
@@ -2123,6 +2260,7 @@ export function mount(root, options = {}) {
|
|
|
2123
2260
|
let initErrorMessage = "";
|
|
2124
2261
|
let initRequestSeq = 0;
|
|
2125
2262
|
let queenNotice = false;
|
|
2263
|
+
let queenBusy = false;
|
|
2126
2264
|
let supervisorData = [];
|
|
2127
2265
|
let supervisorRequest = null;
|
|
2128
2266
|
let limitsOverlay = null;
|
|
@@ -2148,6 +2286,9 @@ export function mount(root, options = {}) {
|
|
|
2148
2286
|
const statsNode = element(doc, "div", "hive-stats");
|
|
2149
2287
|
bar.appendChild(statsNode);
|
|
2150
2288
|
|
|
2289
|
+
const queenBadge = element(doc, "span", "hive-queen-badge is-hidden", "");
|
|
2290
|
+
bar.appendChild(queenBadge);
|
|
2291
|
+
|
|
2151
2292
|
const statusNode = element(doc, "span", "hive-status", "");
|
|
2152
2293
|
bar.appendChild(statusNode);
|
|
2153
2294
|
|
|
@@ -2193,12 +2334,22 @@ export function mount(root, options = {}) {
|
|
|
2193
2334
|
const queenCommand = element(doc, "code", "hive-queen-command", "");
|
|
2194
2335
|
queenExit.appendChild(queenExitText);
|
|
2195
2336
|
queenExit.appendChild(queenCommand);
|
|
2337
|
+
const queenOffer = element(doc, "div", "hive-queen-offer is-hidden");
|
|
2338
|
+
const queenTakeoverButton = element(doc, "button", "hive-btn hive-queen-takeover", translate("queen.takeover"));
|
|
2339
|
+
setAttr(queenTakeoverButton, "type", "button");
|
|
2340
|
+
setAttr(queenTakeoverButton, "title", translate("queen.takeoverAria"));
|
|
2341
|
+
setAttr(queenTakeoverButton, "aria-label", translate("queen.takeoverAria"));
|
|
2342
|
+
queenTakeoverButton.addEventListener("click", () => {
|
|
2343
|
+
void runQueenOn(queenTakeoverButton);
|
|
2344
|
+
});
|
|
2345
|
+
queenOffer.appendChild(queenTakeoverButton);
|
|
2196
2346
|
const queenOutputDetails = element(doc, "details", "hive-init-output hive-queen-output is-hidden");
|
|
2197
2347
|
const queenOutputSummary = element(doc, "summary", "hive-output-summary", "");
|
|
2198
2348
|
const queenOutputPre = element(doc, "pre", "hive-output-pre", "");
|
|
2199
2349
|
queenOutputDetails.appendChild(queenOutputSummary);
|
|
2200
2350
|
queenOutputDetails.appendChild(queenOutputPre);
|
|
2201
2351
|
queenHint.appendChild(queenHintText);
|
|
2352
|
+
queenHint.appendChild(queenOffer);
|
|
2202
2353
|
queenHint.appendChild(queenExit);
|
|
2203
2354
|
queenHint.appendChild(queenOutputDetails);
|
|
2204
2355
|
|
|
@@ -3335,6 +3486,21 @@ export function mount(root, options = {}) {
|
|
|
3335
3486
|
return result.payload;
|
|
3336
3487
|
}
|
|
3337
3488
|
|
|
3489
|
+
async function runQueenOn(button) {
|
|
3490
|
+
if (destroyed || queenBusy) return;
|
|
3491
|
+
const model = lastModel;
|
|
3492
|
+
if (!model || model.initialised === false || (model.queen && model.queen.active)) return;
|
|
3493
|
+
queenBusy = true;
|
|
3494
|
+
renderQueenHint(model);
|
|
3495
|
+
try {
|
|
3496
|
+
await postAction("queen-on", {});
|
|
3497
|
+
} finally {
|
|
3498
|
+
queenBusy = false;
|
|
3499
|
+
if (!destroyed && lastModel) renderQueenHint(lastModel);
|
|
3500
|
+
else if (button && typeof button.focus === "function") button.focus();
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
|
|
3338
3504
|
async function runInitialise() {
|
|
3339
3505
|
if (destroyed || initBusy) return;
|
|
3340
3506
|
const model = lastModel;
|
|
@@ -3500,9 +3666,45 @@ export function mount(root, options = {}) {
|
|
|
3500
3666
|
}
|
|
3501
3667
|
|
|
3502
3668
|
function renderQueenHint(model) {
|
|
3503
|
-
const
|
|
3504
|
-
|
|
3505
|
-
|
|
3669
|
+
const initialised = Boolean(model && model.initialised !== false);
|
|
3670
|
+
const state = model && isRecord(model.queen) ? model.queen : null;
|
|
3671
|
+
const active = state ? state.active === true : Boolean(queenNotice);
|
|
3672
|
+
const show = initialised && Boolean(state || queenNotice);
|
|
3673
|
+
const offer = show && !active;
|
|
3674
|
+
|
|
3675
|
+
if (initialised && state) {
|
|
3676
|
+
const source =
|
|
3677
|
+
state.source === "auto"
|
|
3678
|
+
? translate("queen.source.auto")
|
|
3679
|
+
: state.source === "manual"
|
|
3680
|
+
? translate("queen.source.manual")
|
|
3681
|
+
: "";
|
|
3682
|
+
const title = active
|
|
3683
|
+
? source
|
|
3684
|
+
? translate("queen.activeTitle").replace("{source}", source)
|
|
3685
|
+
: translate("queen.status.active")
|
|
3686
|
+
: translate("queen.inactiveTitle");
|
|
3687
|
+
queenBadge.className = "hive-queen-badge " + (active ? "is-active" : "is-inactive");
|
|
3688
|
+
queenBadge.textContent = active ? translate("queen.status.active") : translate("queen.status.inactive");
|
|
3689
|
+
setAttr(queenBadge, "title", title);
|
|
3690
|
+
setAttr(queenBadge, "aria-label", title);
|
|
3691
|
+
} else {
|
|
3692
|
+
queenBadge.className = "hive-queen-badge is-hidden";
|
|
3693
|
+
queenBadge.textContent = "";
|
|
3694
|
+
setAttr(queenBadge, "title", "");
|
|
3695
|
+
setAttr(queenBadge, "aria-label", "");
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
queenHint.className = "hive-queen-hint" + (show ? " is-visible" : "") + (offer ? " is-offer" : "");
|
|
3699
|
+
queenHintText.textContent = active ? translate("init.queen") : translate("queen.offer");
|
|
3700
|
+
queenOffer.className = "hive-queen-offer" + (offer ? "" : " is-hidden");
|
|
3701
|
+
queenTakeoverButton.disabled = queenBusy;
|
|
3702
|
+
queenTakeoverButton.textContent = queenBusy ? translate("queen.takeoverBusy") : translate("queen.takeover");
|
|
3703
|
+
const takeoverAria = queenBusy ? translate("queen.takeoverBusy") : translate("queen.takeoverAria");
|
|
3704
|
+
setAttr(queenTakeoverButton, "title", takeoverAria);
|
|
3705
|
+
setAttr(queenTakeoverButton, "aria-label", takeoverAria);
|
|
3706
|
+
|
|
3707
|
+
queenExit.className = "hive-queen-exit" + (active ? "" : " is-hidden");
|
|
3506
3708
|
queenExitText.textContent = translate("init.queenExit");
|
|
3507
3709
|
queenCommand.textContent = translate("init.queenCommand");
|
|
3508
3710
|
queenOutputSummary.textContent = translate("init.queenOutput");
|
|
@@ -3510,7 +3712,7 @@ export function mount(root, options = {}) {
|
|
|
3510
3712
|
const output = initOutput && initOutput.stdout ? initOutput.stdout : translate("init.noOutput");
|
|
3511
3713
|
queenOutputPre.textContent = output;
|
|
3512
3714
|
queenOutputDetails.className =
|
|
3513
|
-
"hive-init-output hive-queen-output" + (show && initOutput ? "" : " is-hidden");
|
|
3715
|
+
"hive-init-output hive-queen-output" + (show && active && initOutput ? "" : " is-hidden");
|
|
3514
3716
|
}
|
|
3515
3717
|
|
|
3516
3718
|
function supervisorEndpoint(op) {
|
|
@@ -3658,6 +3860,23 @@ export function mount(root, options = {}) {
|
|
|
3658
3860
|
}
|
|
3659
3861
|
}
|
|
3660
3862
|
|
|
3863
|
+
function durationLabel(count, singularKey, pluralKey) {
|
|
3864
|
+
const key = count === 1 ? singularKey : pluralKey;
|
|
3865
|
+
return translate(key).replace("{count}", String(count));
|
|
3866
|
+
}
|
|
3867
|
+
|
|
3868
|
+
function elapsedLabel(createdAt) {
|
|
3869
|
+
const date = parseDate(createdAt);
|
|
3870
|
+
if (!date) return "";
|
|
3871
|
+
const seconds = Math.max(0, Math.floor((Date.now() - date.getTime()) / 1000));
|
|
3872
|
+
if (seconds < 60) return translate("stats.duration.justNow");
|
|
3873
|
+
const minutes = Math.floor(seconds / 60);
|
|
3874
|
+
if (minutes < 60) return durationLabel(minutes, "stats.duration.minute", "stats.duration.minutes");
|
|
3875
|
+
const hours = Math.floor(minutes / 60);
|
|
3876
|
+
if (hours < 24) return durationLabel(hours, "stats.duration.hour", "stats.duration.hours");
|
|
3877
|
+
return durationLabel(Math.floor(hours / 24), "stats.duration.day", "stats.duration.days");
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3661
3880
|
function renderStats(model) {
|
|
3662
3881
|
clearNode(statsNode);
|
|
3663
3882
|
const total = element(doc, "span", "hive-stat is-total");
|
|
@@ -3673,18 +3892,21 @@ export function mount(root, options = {}) {
|
|
|
3673
3892
|
}
|
|
3674
3893
|
|
|
3675
3894
|
if (model.stats.oldestPending) {
|
|
3676
|
-
const
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
)
|
|
3682
|
-
|
|
3895
|
+
const pending = model.stats.oldestPending;
|
|
3896
|
+
const duration = elapsedLabel(pending.createdAt);
|
|
3897
|
+
const label = translate("stats.oldest") + (duration ? " " + duration : "");
|
|
3898
|
+
const oldest = element(doc, "span", "hive-stat is-warn hive-oldest");
|
|
3899
|
+
oldest.appendChild(element(doc, "span", "hive-oldest-label", label));
|
|
3900
|
+
if (pending.id) {
|
|
3901
|
+
oldest.appendChild(element(doc, "span", "hive-oldest-sep", " · "));
|
|
3902
|
+
oldest.appendChild(element(doc, "code", "hive-oldest-id", pending.id));
|
|
3903
|
+
}
|
|
3904
|
+
setAttr(oldest, "title", label + (pending.id ? " · " + pending.id : ""));
|
|
3683
3905
|
statsNode.appendChild(oldest);
|
|
3684
3906
|
}
|
|
3685
3907
|
|
|
3686
3908
|
const roleSummary = Object.keys(model.stats.byRole)
|
|
3687
|
-
.map((role) => role + " " + model.stats.byRole[role])
|
|
3909
|
+
.map((role) => role + " " + asCount(model.stats.byRole[role], 0))
|
|
3688
3910
|
.join(" · ");
|
|
3689
3911
|
setAttr(statsNode, "title", roleSummary ? translate("stats.byRoleTitle") + roleSummary : "");
|
|
3690
3912
|
}
|
|
@@ -3976,6 +4198,7 @@ export function mount(root, options = {}) {
|
|
|
3976
4198
|
initOutput = null;
|
|
3977
4199
|
initErrorMessage = "";
|
|
3978
4200
|
queenNotice = false;
|
|
4201
|
+
queenBusy = false;
|
|
3979
4202
|
stageFilter = "all";
|
|
3980
4203
|
stageChipEntries = [];
|
|
3981
4204
|
eventsExpanded = false;
|