@songsid/agend 2.4.0-beta.18 → 2.4.0-beta.19

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.
Files changed (377) hide show
  1. package/dist/agent-cli-instructions.md +13 -7
  2. package/dist/agent-cli.js +149 -49
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/agent-export.d.ts +3 -1
  5. package/dist/agent-export.js +18 -1
  6. package/dist/agent-export.js.map +1 -1
  7. package/dist/agent-whats-new.js +9 -0
  8. package/dist/agent-whats-new.js.map +1 -1
  9. package/dist/apply-job.d.ts +2 -2
  10. package/dist/auth-api.js +1 -1
  11. package/dist/auth-api.js.map +1 -1
  12. package/dist/backend/claude-code.d.ts +0 -6
  13. package/dist/backend/claude-code.js +23 -3
  14. package/dist/backend/claude-code.js.map +1 -1
  15. package/dist/backend/codex-precaution.js +3 -2
  16. package/dist/backend/codex-precaution.js.map +1 -1
  17. package/dist/backend/codex.js +1 -1
  18. package/dist/backend/codex.js.map +1 -1
  19. package/dist/backend/types.d.ts +6 -0
  20. package/dist/backend/types.js.map +1 -1
  21. package/dist/build-provenance.json +1 -1
  22. package/dist/channel/mcp-server.js +8 -2
  23. package/dist/channel/mcp-server.js.map +1 -1
  24. package/dist/channel/mcp-tools.d.ts +27 -1
  25. package/dist/channel/mcp-tools.js +77 -7
  26. package/dist/channel/mcp-tools.js.map +1 -1
  27. package/dist/chat-task-refs.d.ts +61 -0
  28. package/dist/chat-task-refs.js +112 -0
  29. package/dist/chat-task-refs.js.map +1 -0
  30. package/dist/classic-channel-manager.d.ts +1 -1
  31. package/dist/classic-channel-manager.js +6 -2
  32. package/dist/classic-channel-manager.js.map +1 -1
  33. package/dist/claude-credential-launch.d.ts +6 -0
  34. package/dist/claude-credential-launch.js +16 -3
  35. package/dist/claude-credential-launch.js.map +1 -1
  36. package/dist/claude-credential-runner.js +3 -1
  37. package/dist/claude-credential-runner.js.map +1 -1
  38. package/dist/claude-setup-token-transport.js +25 -3
  39. package/dist/claude-setup-token-transport.js.map +1 -1
  40. package/dist/cli-audited.js +5 -5
  41. package/dist/cli-audited.js.map +1 -1
  42. package/dist/composite-tools.d.ts +11 -0
  43. package/dist/composite-tools.js +29 -0
  44. package/dist/composite-tools.js.map +1 -0
  45. package/dist/config-validator.js +22 -1
  46. package/dist/config-validator.js.map +1 -1
  47. package/dist/config.js +11 -0
  48. package/dist/config.js.map +1 -1
  49. package/dist/contact-auth-policy.d.ts +1 -0
  50. package/dist/contact-auth-policy.js +2 -1
  51. package/dist/contact-auth-policy.js.map +1 -1
  52. package/dist/contact-auth-service.js +2 -0
  53. package/dist/contact-auth-service.js.map +1 -1
  54. package/dist/contact-auth-store.js +21 -6
  55. package/dist/contact-auth-store.js.map +1 -1
  56. package/dist/contact-auth-types.d.ts +2 -0
  57. package/dist/contact-auth-types.js.map +1 -1
  58. package/dist/daemon.js +4 -0
  59. package/dist/daemon.js.map +1 -1
  60. package/dist/darwin-memory.js +2 -1
  61. package/dist/darwin-memory.js.map +1 -1
  62. package/dist/dashboard-permissions.d.ts +1 -8
  63. package/dist/dashboard-permissions.js +8 -9
  64. package/dist/dashboard-permissions.js.map +1 -1
  65. package/dist/delivery-outbox.d.ts +0 -6
  66. package/dist/delivery-outbox.js +0 -25
  67. package/dist/delivery-outbox.js.map +1 -1
  68. package/dist/delivery-outbox.test.js +132 -96
  69. package/dist/delivery-outbox.test.js.map +1 -1
  70. package/dist/fleet-manager.d.ts +45 -7
  71. package/dist/fleet-manager.js +309 -99
  72. package/dist/fleet-manager.js.map +1 -1
  73. package/dist/fleet-windows-runtime.d.ts +1 -1
  74. package/dist/fleet-windows-runtime.js +8 -1
  75. package/dist/fleet-windows-runtime.js.map +1 -1
  76. package/dist/fleet-yaml-stringify.d.ts +1 -1
  77. package/dist/fleet-yaml-stringify.js +64 -11
  78. package/dist/fleet-yaml-stringify.js.map +1 -1
  79. package/dist/general-knowledge/skills/concepts/SKILL.md +53 -4
  80. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +4 -0
  81. package/dist/general-knowledge/skills/fleet-config/SKILL.md +21 -1
  82. package/dist/general-knowledge/skills/hub/SKILL.md +2 -0
  83. package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +5 -1
  84. package/dist/general-knowledge/skills/model-discovery/SKILL.md +3 -2
  85. package/dist/general-knowledge/skills/persona-emoji/SKILL.md +3 -0
  86. package/dist/general-knowledge/skills/task-board/SKILL.md +63 -0
  87. package/dist/general-knowledge/skills/web-appearance/SKILL.md +25 -2
  88. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +38 -9
  89. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +4 -0
  90. package/dist/general-knowledge/steering/core-rules.md +15 -78
  91. package/dist/general-role-block.d.ts +19 -0
  92. package/dist/general-role-block.js +56 -0
  93. package/dist/general-role-block.js.map +1 -0
  94. package/dist/general-role.d.ts +1 -1
  95. package/dist/general-role.js +1 -0
  96. package/dist/general-role.js.map +1 -1
  97. package/dist/host-memory.d.ts +3 -0
  98. package/dist/host-memory.js.map +1 -1
  99. package/dist/host-monitoring/darwin/collector.d.ts +18 -0
  100. package/dist/host-monitoring/darwin/collector.js +65 -0
  101. package/dist/host-monitoring/darwin/collector.js.map +1 -0
  102. package/dist/host-monitoring/darwin/defaults.d.ts +2 -0
  103. package/dist/host-monitoring/darwin/defaults.js +9 -0
  104. package/dist/host-monitoring/darwin/defaults.js.map +1 -0
  105. package/dist/host-monitoring/darwin/interpretation.d.ts +20 -0
  106. package/dist/host-monitoring/darwin/interpretation.js +73 -0
  107. package/dist/host-monitoring/darwin/interpretation.js.map +1 -0
  108. package/dist/host-monitoring/linux/collector.d.ts +17 -0
  109. package/dist/host-monitoring/linux/collector.js +55 -0
  110. package/dist/host-monitoring/linux/collector.js.map +1 -0
  111. package/dist/host-monitoring/linux/defaults.d.ts +2 -0
  112. package/dist/host-monitoring/linux/defaults.js +9 -0
  113. package/dist/host-monitoring/linux/defaults.js.map +1 -0
  114. package/dist/host-monitoring/linux/interpretation.d.ts +22 -0
  115. package/dist/host-monitoring/linux/interpretation.js +76 -0
  116. package/dist/host-monitoring/linux/interpretation.js.map +1 -0
  117. package/dist/host-monitoring/transport.d.ts +42 -0
  118. package/dist/host-monitoring/transport.js +101 -0
  119. package/dist/host-monitoring/transport.js.map +1 -0
  120. package/dist/host-monitoring/wsl/collector.d.ts +19 -0
  121. package/dist/host-monitoring/wsl/collector.js +72 -0
  122. package/dist/host-monitoring/wsl/collector.js.map +1 -0
  123. package/dist/host-monitoring/wsl/defaults.d.ts +2 -0
  124. package/dist/host-monitoring/wsl/defaults.js +9 -0
  125. package/dist/host-monitoring/wsl/defaults.js.map +1 -0
  126. package/dist/host-monitoring/wsl/interpretation.d.ts +22 -0
  127. package/dist/host-monitoring/wsl/interpretation.js +77 -0
  128. package/dist/host-monitoring/wsl/interpretation.js.map +1 -0
  129. package/dist/host-monitoring-alert-policy.d.ts +2 -0
  130. package/dist/host-monitoring-alert-policy.js +4 -2
  131. package/dist/host-monitoring-alert-policy.js.map +1 -1
  132. package/dist/host-monitoring-alert-settings.d.ts +3 -1
  133. package/dist/host-monitoring-alert-settings.js +7 -2
  134. package/dist/host-monitoring-alert-settings.js.map +1 -1
  135. package/dist/host-monitoring-alerts.d.ts +3 -0
  136. package/dist/host-monitoring-alerts.js +18 -3
  137. package/dist/host-monitoring-alerts.js.map +1 -1
  138. package/dist/host-monitoring-defaults.d.ts +19 -0
  139. package/dist/host-monitoring-defaults.js +10 -0
  140. package/dist/host-monitoring-defaults.js.map +1 -0
  141. package/dist/host-monitoring-platform.d.ts +18 -70
  142. package/dist/host-monitoring-platform.js +14 -269
  143. package/dist/host-monitoring-platform.js.map +1 -1
  144. package/dist/host-monitoring.d.ts +13 -0
  145. package/dist/host-monitoring.js.map +1 -1
  146. package/dist/hub/agent-catalog-model.d.ts +21 -0
  147. package/dist/hub/agent-catalog-model.js +9 -1
  148. package/dist/hub/agent-catalog-model.js.map +1 -1
  149. package/dist/hub/agent-catalog.d.ts +4 -1
  150. package/dist/hub/agent-catalog.js +11 -0
  151. package/dist/hub/agent-catalog.js.map +1 -1
  152. package/dist/hub/catalog.js +12 -0
  153. package/dist/hub/catalog.js.map +1 -1
  154. package/dist/hub/client.js +4 -1
  155. package/dist/hub/client.js.map +1 -1
  156. package/dist/hub/compose/member.d.ts +5 -0
  157. package/dist/hub/compose/member.js +25 -5
  158. package/dist/hub/compose/member.js.map +1 -1
  159. package/dist/hub/compose/server.d.ts +2 -0
  160. package/dist/hub/compose/server.js +4 -2
  161. package/dist/hub/compose/server.js.map +1 -1
  162. package/dist/hub/http/compose.d.ts +5 -0
  163. package/dist/hub/http/compose.js +25 -2
  164. package/dist/hub/http/compose.js.map +1 -1
  165. package/dist/hub/http/deps.d.ts +2 -0
  166. package/dist/hub/http/schema.js +4 -0
  167. package/dist/hub/http/schema.js.map +1 -1
  168. package/dist/hub/lapse-carry.d.ts +45 -0
  169. package/dist/hub/lapse-carry.js +62 -0
  170. package/dist/hub/lapse-carry.js.map +1 -0
  171. package/dist/hub/member/agent-catalog.d.ts +4 -1
  172. package/dist/hub/member/agent-catalog.js +15 -4
  173. package/dist/hub/member/agent-catalog.js.map +1 -1
  174. package/dist/hub/member/agent-intro.d.ts +4 -3
  175. package/dist/hub/member/agent-intro.js +7 -0
  176. package/dist/hub/member/agent-intro.js.map +1 -1
  177. package/dist/hub/member/exposure-api.d.ts +2 -0
  178. package/dist/hub/member/exposure-api.js +8 -1
  179. package/dist/hub/member/exposure-api.js.map +1 -1
  180. package/dist/hub/member/room-post.d.ts +34 -6
  181. package/dist/hub/member/room-post.js +30 -0
  182. package/dist/hub/member/room-post.js.map +1 -1
  183. package/dist/hub/member/sharing.d.ts +2 -0
  184. package/dist/hub/member/sharing.js +9 -2
  185. package/dist/hub/member/sharing.js.map +1 -1
  186. package/dist/hub/protocol.d.ts +2 -0
  187. package/dist/hub/room-brief-model.js +2 -1
  188. package/dist/hub/room-brief-model.js.map +1 -1
  189. package/dist/hub/rooms/agents.d.ts +2 -0
  190. package/dist/hub/rooms/agents.js +16 -2
  191. package/dist/hub/rooms/agents.js.map +1 -1
  192. package/dist/hub/rooms/office.d.ts +82 -0
  193. package/dist/hub/rooms/office.js +46 -0
  194. package/dist/hub/rooms/office.js.map +1 -0
  195. package/dist/hub/rooms/service.d.ts +66 -1
  196. package/dist/hub/rooms/service.js +67 -11
  197. package/dist/hub/rooms/service.js.map +1 -1
  198. package/dist/hub/rooms/types.d.ts +4 -0
  199. package/dist/hub/runtime.d.ts +1 -1
  200. package/dist/hub/server.js +9 -2
  201. package/dist/hub/server.js.map +1 -1
  202. package/dist/hub/sharing-requests.d.ts +5 -2
  203. package/dist/hub/sharing-requests.js +19 -4
  204. package/dist/hub/sharing-requests.js.map +1 -1
  205. package/dist/instance-config-impact.js +1 -1
  206. package/dist/instance-config-impact.js.map +1 -1
  207. package/dist/instance-lifecycle.js +6 -7
  208. package/dist/instance-lifecycle.js.map +1 -1
  209. package/dist/instruction-file-sizes.d.ts +46 -0
  210. package/dist/instruction-file-sizes.js +115 -0
  211. package/dist/instruction-file-sizes.js.map +1 -0
  212. package/dist/instructions.d.ts +35 -1
  213. package/dist/instructions.js +59 -33
  214. package/dist/instructions.js.map +1 -1
  215. package/dist/locale.js +16 -4
  216. package/dist/locale.js.map +1 -1
  217. package/dist/log-steps.d.ts +5 -0
  218. package/dist/log-steps.js +6 -2
  219. package/dist/log-steps.js.map +1 -1
  220. package/dist/memory-guidance.d.ts +5 -0
  221. package/dist/memory-guidance.js +14 -0
  222. package/dist/memory-guidance.js.map +1 -0
  223. package/dist/model-defaults.d.ts +5 -0
  224. package/dist/model-defaults.js +6 -0
  225. package/dist/model-defaults.js.map +1 -0
  226. package/dist/native-mcp.d.ts +2 -0
  227. package/dist/native-mcp.js +16 -6
  228. package/dist/native-mcp.js.map +1 -1
  229. package/dist/needs-you-hub.d.ts +2 -0
  230. package/dist/needs-you-hub.js +6 -1
  231. package/dist/needs-you-hub.js.map +1 -1
  232. package/dist/needs-you.d.ts +13 -1
  233. package/dist/needs-you.js +5 -0
  234. package/dist/needs-you.js.map +1 -1
  235. package/dist/outbound-handlers.d.ts +3 -3
  236. package/dist/outbound-schemas.d.ts +3 -0
  237. package/dist/outbound-schemas.js +27 -26
  238. package/dist/outbound-schemas.js.map +1 -1
  239. package/dist/quickstart.d.ts +1 -1
  240. package/dist/quickstart.js +2 -3
  241. package/dist/quickstart.js.map +1 -1
  242. package/dist/remote-card-prompt.d.ts +1 -0
  243. package/dist/remote-card-prompt.js +1 -1
  244. package/dist/remote-card-prompt.js.map +1 -1
  245. package/dist/runtime-build-info.js +1 -1
  246. package/dist/runtime-build-info.js.map +1 -1
  247. package/dist/runtime-cli-install.js +5 -5
  248. package/dist/runtime-cli-install.js.map +1 -1
  249. package/dist/runtime-pane-mcp.js +7 -3
  250. package/dist/runtime-pane-mcp.js.map +1 -1
  251. package/dist/runtime-pane-native.js +2 -1
  252. package/dist/runtime-pane-native.js.map +1 -1
  253. package/dist/scheduler/db.js +2 -0
  254. package/dist/scheduler/db.js.map +1 -1
  255. package/dist/scheduler/task-board-mentions.d.ts +32 -0
  256. package/dist/scheduler/task-board-mentions.js +97 -0
  257. package/dist/scheduler/task-board-mentions.js.map +1 -0
  258. package/dist/scheduler/task-board-text.js +3 -0
  259. package/dist/scheduler/task-board-text.js.map +1 -1
  260. package/dist/scheduler/task-board.d.ts +199 -3
  261. package/dist/scheduler/task-board.js +492 -7
  262. package/dist/scheduler/task-board.js.map +1 -1
  263. package/dist/settings-api.d.ts +3 -1
  264. package/dist/settings-api.js +23 -4
  265. package/dist/settings-api.js.map +1 -1
  266. package/dist/settings-change.js +4 -2
  267. package/dist/settings-change.js.map +1 -1
  268. package/dist/settings-effect.js +1 -1
  269. package/dist/settings-effect.js.map +1 -1
  270. package/dist/settings-instance-patch.js +3 -1
  271. package/dist/settings-instance-patch.js.map +1 -1
  272. package/dist/setup-host.d.ts +2 -3
  273. package/dist/setup-host.js +3 -5
  274. package/dist/setup-host.js.map +1 -1
  275. package/dist/setup-wizard.js +0 -2
  276. package/dist/setup-wizard.js.map +1 -1
  277. package/dist/shared-default-adoption.d.ts +24 -0
  278. package/dist/shared-default-adoption.js +73 -0
  279. package/dist/shared-default-adoption.js.map +1 -0
  280. package/dist/subagent-records.d.ts +2 -0
  281. package/dist/subagent-records.js +11 -1
  282. package/dist/subagent-records.js.map +1 -1
  283. package/dist/subagent-service.d.ts +3 -0
  284. package/dist/subagent-service.js +24 -4
  285. package/dist/subagent-service.js.map +1 -1
  286. package/dist/task-board-tool.d.ts +31 -0
  287. package/dist/task-board-tool.js +31 -0
  288. package/dist/task-board-tool.js.map +1 -1
  289. package/dist/task-board-waker.d.ts +23 -30
  290. package/dist/task-board-waker.js +136 -97
  291. package/dist/task-board-waker.js.map +1 -1
  292. package/dist/types.d.ts +23 -0
  293. package/dist/ui/agent-details-settings.js +2 -2
  294. package/dist/ui/agent-export-dialog.js +4 -3
  295. package/dist/ui/agent-export-strings.js +4 -4
  296. package/dist/ui/agent-page-strings.js +18 -0
  297. package/dist/ui/chat-activity-groups.js +1 -1
  298. package/dist/ui/chat-activity.js +17 -0
  299. package/dist/ui/chat-store.js +13 -4
  300. package/dist/ui/chat-task-ref-strings.js +24 -0
  301. package/dist/ui/chat-task-refs.js +129 -0
  302. package/dist/ui/claude-setup-token.js +3 -3
  303. package/dist/ui/contact-auth-strings.js +33 -3
  304. package/dist/ui/contact-authorizations.js +17 -24
  305. package/dist/ui/contact-grant-editor.js +50 -0
  306. package/dist/ui/contact-permissions.js +21 -8
  307. package/dist/ui/fleet-office-card.js +18 -14
  308. package/dist/ui/fleet-office.js +29 -17
  309. package/dist/ui/fleet-task-activity.js +362 -0
  310. package/dist/ui/fleet-task-card.js +317 -314
  311. package/dist/ui/fleet-task-common.js +99 -9
  312. package/dist/ui/fleet-task-create.js +67 -0
  313. package/dist/ui/fleet-task-edit.js +204 -0
  314. package/dist/ui/fleet-task-follow.js +123 -0
  315. package/dist/ui/fleet-task-menu.js +1 -1
  316. package/dist/ui/fleet-task-owner.js +252 -0
  317. package/dist/ui/fleet-task-run.js +257 -0
  318. package/dist/ui/fleet-task-view.js +178 -39
  319. package/dist/ui/fleet-task-work.js +2 -2
  320. package/dist/ui/fleet-tasks.js +258 -130
  321. package/dist/ui/host-health.js +9 -6
  322. package/dist/ui/host-monitoring-darwin.js +6 -0
  323. package/dist/ui/host-monitoring-help.js +7 -0
  324. package/dist/ui/host-monitoring-linux.js +6 -0
  325. package/dist/ui/host-monitoring-wsl.js +6 -0
  326. package/dist/ui/hub-agent-copy.js +2 -0
  327. package/dist/ui/hub-client.js +4 -0
  328. package/dist/ui/hub-my-agents-strings.js +2 -0
  329. package/dist/ui/hub-my-agents.js +17 -1
  330. package/dist/ui/hub-room-composer.js +108 -5
  331. package/dist/ui/hub-room-members-strings.js +9 -2
  332. package/dist/ui/hub-room-members.js +72 -15
  333. package/dist/ui/hub-room-office.js +191 -0
  334. package/dist/ui/hub-room-purpose.js +18 -2
  335. package/dist/ui/hub-room-settings.js +8 -1
  336. package/dist/ui/hub-room-strings.js +15 -0
  337. package/dist/ui/hub-room-thread.js +51 -15
  338. package/dist/ui/hub-strings.js +1 -1
  339. package/dist/ui/log-row.js +7 -5
  340. package/dist/ui/native-instance-settings.js +4 -2
  341. package/dist/ui/panel-chat.js +96 -17
  342. package/dist/ui/panel-details.js +17 -0
  343. package/dist/ui/panel-fleet.js +1 -1
  344. package/dist/ui/panel-hub.js +4 -1
  345. package/dist/ui/panel-needs.js +11 -2
  346. package/dist/ui/panel-settings.js +57 -13
  347. package/dist/ui/settings-apply.js +8 -3
  348. package/dist/ui/settings-default-model-scope.js +40 -0
  349. package/dist/ui/settings-default-model-strings.js +43 -0
  350. package/dist/ui/settings-dialogs.js +9 -5
  351. package/dist/ui/settings-host-alerts.js +4 -3
  352. package/dist/ui/settings-host-monitoring.js +2 -1
  353. package/dist/ui/settings-hub.js +1 -1
  354. package/dist/ui/settings-layout.js +7 -2
  355. package/dist/ui/settings-model.js +9 -5
  356. package/dist/ui/settings-quota-notice.js +3 -3
  357. package/dist/ui/settings-registry.js +3 -0
  358. package/dist/ui/settings-shared-strings.js +22 -0
  359. package/dist/ui/settings-shared.js +59 -12
  360. package/dist/ui/settings-strings.js +2 -4
  361. package/dist/ui/shared/app-i18n.js +2 -2
  362. package/dist/ui/shared/app.css +124 -46
  363. package/dist/ui/shared/chat-composer.js +7 -6
  364. package/dist/ui/shared/chat-render.js +39 -1
  365. package/dist/ui/shared/chat-thread.js +8 -3
  366. package/dist/ui/shared/composer-focus.js +21 -0
  367. package/dist/ui/shared/hub-chat.css +30 -2
  368. package/dist/ui/shared/hub-rooms-u2.css +17 -0
  369. package/dist/ui/shared/task-board.css +406 -8
  370. package/dist/ui/trigger-complete.js +71 -0
  371. package/dist/web-api.d.ts +9 -0
  372. package/dist/web-api.js +128 -13
  373. package/dist/web-api.js.map +1 -1
  374. package/dist/windows-native-mcp.js +5 -2
  375. package/dist/windows-native-mcp.js.map +1 -1
  376. package/dist/workflow-templates/default.md +4 -6
  377. package/package.json +1 -1
@@ -1,71 +1,102 @@
1
- // One card of the task board (Fleet › Tasks), in the app's dialog: every field editable in place, the checklist, the
2
- // moves the person makes (confirm, send back, answer, move, cancel, reopen), its sub tasks, and its comments, progress
3
- // log and history. Edits carry the version they started from, so saving over an agent's newer write is caught (409):
4
- // the dialog then shows the newer card with the draft still open, and saving again overwrites on purpose.
5
- import { html, useEffect, useLayoutEffect, useRef, useState } from "/assets/app-html.js";
1
+ // One card of the task board (Fleet › Tasks) as a page of its own: the main column holds what
2
+ // the card says (title, goal, scope, definition of done, context — a field nobody filled in is folded into a small "+ Add"
3
+ // button, not an empty block), what its agent wrote and does (state, result and the activity, one block: a single line while
4
+ // there is nothing to show), the sub tasks (a bordered list with its progress and a line to add one) and the card's activity —
5
+ // comments, progress log and history as one timeline, the comment box last. The side column holds the properties in three
6
+ // groups, each a chip that opens a menu (the choice saves at once). On a phone it is one column: title, spec, agent line,
7
+ // sub tasks, properties, activity. The card has an address of its own (`?card=M-3`, see fleet-tasks.js), so Back returns to
8
+ // the board or the list it was opened from.
9
+ // Edits carry the version they started from, so saving over an agent's newer write is caught (409): the page then shows
10
+ // the newer card with the draft still open, and saving again overwrites on purpose (fleet-task-edit.js).
11
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
6
12
  import { t, register } from "/assets/app-i18n.js";
7
13
  import { appStore, useStore } from "/assets/app-store.js";
8
- import { Dialog } from "/assets/ui-dialog.js";
14
+ import { Empty, Skeleton } from "/assets/ui-states.js";
9
15
  import { Icon } from "/assets/ui-icons.js";
16
+ import { Menu } from "/assets/ui-menu.js";
10
17
  import { toast } from "/assets/ui-toast.js";
11
- import { AssigneeOption, StatusPill, Who, answerBlocked, askText, boardApi, currentWork, errorText, followsSubs, moveCard, notesForPeople, relTime, wrapUpText } from "./fleet-task-common.js";
12
- import { StepButtons } from "./fleet-task-menu.js";
18
+ import { ProgressBar, StatusPill, Who, answerBlocked, askText, boardApi, errorText, followsSubs, hiddenWaits, moveCard, notesForPeople, relTime, scrollBox, wrapUpText, COLUMNS } from "./fleet-task-common.js";
19
+ import { StepButtons, movesFor } from "./fleet-task-menu.js";
20
+ import { Checklist, EditableText, InlineTitle, PropChip, QuickAdd } from "./fleet-task-edit.js";
21
+ import { Composer, Timeline } from "./fleet-task-activity.js";
22
+ import { AgentRun } from "./fleet-task-run.js";
23
+ import { LeaderRow, WatchersRow } from "./fleet-task-follow.js";
13
24
 
14
25
  register("taskcard", {
15
26
  en: {
16
27
  loading: "Loading…", missing: "There is no card {0}", version: "v{0}", copyLink: "Copy this card's link", linkCopied: "Link copied",
17
28
  conflict: "{0} changed while you were editing. The newer card is shown and your edit is still open — save again to overwrite it.",
18
- moveTo: "Move to…", moveLabel: "Change the status", followsSubs: "It has sub tasks: its status follows them",
19
- reopen: "Reopen", cancelCard: "Cancel this card", confirmMain: "Confirm the main task",
20
- assignee: "Assignee", nobody: "Unassigned", unassign: "(unassign)", other: "Other…", otherTitle: "Assign to another instance", otherLabel: "The instance's name",
21
- change: "Change…", project: "Project", priority: "Priority", size: "Size", review: "Your confirmation", reviewBox: "Stop at review for my confirmation",
29
+ followsSubs: "It has sub tasks: its status follows them",
30
+ reopen: "Reopen", cancelCard: "Cancel this card", confirmMain: "Confirm the main task", moreActions: "More actions",
31
+ assignee: "Assignee", nobody: "Unassigned", unassign: "Unassigned", other: "Other…", otherTitle: "Assign to another instance", otherLabel: "The instance's name",
32
+ status: "Status", project: "Project", priority: "Priority", size: "Size", review: "Needs my confirmation", reviewBox: "Stop at review for my confirmation", reviewShort: "Stops at review",
22
33
  reviewOn: "Stops at review for your confirmation", reviewOff: "Finishes without your confirmation",
23
34
  parent: "Main task", deps: "Waits for", none: "None", edit: "Edit", depsTitle: "What {0} waits for", depsLabel: "Card numbers to finish first, separated by commas or spaces (empty: nothing)",
24
35
  depWaiting: "Not done yet", depDone: "Done", opened: "Opened by {0} {1} · changed {2}",
25
36
  blockedReason: "Blocked on", goal: "Goal", goalHint: "Why, and what done looks like", scope: "Scope", scopeHint: "In: … / Out: …",
26
37
  definition: "Definition of done", acceptance: "Acceptance", context: "Context", contextHint: "Paths, related cards, decisions already made",
27
38
  state: "State", stateHint: "Done / next / watch out (the assignee keeps it current)", result: "Result", resultHint: "Which files changed and how it was checked",
28
- empty: "(empty — click to edit)", clickToEdit: "Click to edit", ctrlEnter: "Ctrl+Enter saves", save: "Save", cancel: "Cancel",
29
- checklistEmpty: "(none yet — click to add)", editList: "Edit the list", onePerLine: "One per line; an item whose text changes is unchecked again", items: "{0}/{1} items",
30
- subs: "Sub tasks ({0})", quickAdd: "New sub task: type a title and press Enter (small work needs no split)",
31
- tabComments: "Comments {0}", tabLog: "Progress log {0}", tabHistory: "History", noComments: "No comments yet", noLog: "No progress log yet",
32
- rejectTag: "Sent back", approveTag: "Confirmed", commentTo: "Comment to {0} (Ctrl+Enter sends)", commentHint: "Comment (Ctrl+Enter sends)", send: "Send",
33
- evCreated: "opened it", evMoved: "{0} → {1}", evAuto: " (automatic)", evAssigned: "assignee {0} → {1}", evUpdated: "changed {0}", evCommented: "commented", evLogged: "log: {0}",
39
+ empty: "(empty — click to edit)", clickToEdit: "Click to edit", editHint: "Click away or Ctrl+Enter saves · Esc drops the change",
40
+ saving: "Saving…", notSaved: "Not saved — click away or press Ctrl+Enter to try again",
41
+ conflictInline: "This changed meanwhile. Overwrite it with your text?", overwrite: "Overwrite", discard: "Discard my change",
42
+ checklistEmpty: "(none yet — click to add)", editList: "Edit the list", onePerLine: "One per line; an item whose text changes is unchecked again · click away or Ctrl+Enter saves", items: "{0}/{1} items",
43
+ subs: "Sub tasks", quickAdd: "New sub task: type a title and press Enter (small work needs no split)",
44
+ activity: "Activity", activityShow: "Show", "show.all": "All", "show.comments": "Comments", "show.log": "Progress", "show.history": "History",
45
+ noActivity: "Nothing yet — a comment, a progress note or a change shows here", nothingHere: "Nothing of this kind yet",
46
+ rejectTag: "Sent back", approveTag: "Confirmed", commentTo: "Comment to {0} — @ names an instance (Ctrl+Enter sends)", commentHint: "Comment — @ names an instance (Ctrl+Enter sends)", send: "Send",
47
+ mentionList: "Instances to mention", boardOffShort: "task board off",
48
+ rowMoved: "changed status from {0} to {1}", rowAssigned: "changed assignee from {0} to {1}", activities: "{0} activities", activity1: "1 activity",
49
+ logTip: "A one-line work note an agent or member wrote down — not a comment",
50
+ evCreated: "opened it", evMoved: "{0} → {1}", evAuto: " (automatic)", evAssigned: "assignee {0} → {1}", evUpdated: "changed {0}", evCommented: "commented", evLogged: "log: {0}", evWatchers: "changed watchers: {0}",
34
51
  fTitle: "title", fGoal: "goal", fScope: "scope", fContext: "context", fState: "state", fResult: "result", fBlockedReason: "blocked reason", fSize: "size",
35
52
  fPriority: "priority", fNeedsReview: "needs review", fDependsOn: "dependencies", fAcceptance: "acceptance", fProjectId: "project",
36
- position: "Position", moveUp: "Move up", moveDown: "Move down",
53
+ position: "Position", moveUp: "Move up", moveDown: "Move down", properties: "Properties", crumbs: "Where this card is", backBoard: "Back to the board", backList: "Back to the list",
37
54
  dispatcher: "Dispatched by", dispatcherHint: "A blocked card's question goes to them first", dispatcherMe: "Me", dispatcherNone: "Nobody",
38
- dispatcherPerson: "{0} (a person)", now: "Now", nowNone: "No sub task in progress", fDispatcher: "dispatcher",
55
+ dispatcherPerson: "{0} (a person)", fDispatcher: "dispatcher",
56
+ today: "Today", yesterday: "Yesterday", repeated: "The same, {0} times in a row",
57
+ groupCore: "Core", groupTeam: "Project and people", groupFlow: "Flow",
58
+ addGoal: "Add goal", addScope: "Add scope", addDefinition: "Add definition of done", addAcceptance: "Add acceptance", addContext: "Add context", addState: "Add state", addResult: "Add result",
59
+ subsDone: "{0} of {1} sub tasks done",
39
60
  },
40
61
  "zh-TW": {
41
62
  loading: "載入中…", missing: "找不到 {0}", version: "v{0}", copyLink: "複製這張卡的連結", linkCopied: "已複製連結",
42
63
  conflict: "{0} 在你編輯時被改過了。已載入最新內容,你的修改還在,再存一次就會覆蓋。",
43
- moveTo: "移到…", moveLabel: "改狀態", followsSubs: "有子任務,狀態會跟著子任務自動變化",
44
- reopen: "重新打開", cancelCard: "取消這張卡", confirmMain: "確認主任務",
45
- assignee: "負責人", nobody: "沒人負責", unassign: "(不指派)", other: "其他…", otherTitle: "指派給其他 Agent", otherLabel: "Agent 名稱",
46
- change: "改…", project: "專案", priority: "優先度", size: "大小", review: "你確認", reviewBox: "做完要停在待確認,等我確認",
64
+ followsSubs: "有子任務,狀態會跟著子任務自動變化",
65
+ reopen: "重新打開", cancelCard: "取消這張卡", confirmMain: "確認主任務", moreActions: "更多動作",
66
+ assignee: "負責人", nobody: "沒人負責", unassign: "沒人負責", other: "其他…", otherTitle: "指派給其他 Agent", otherLabel: "Agent 名稱",
67
+ status: "狀態", project: "專案", priority: "優先度", size: "大小", review: "待我確認", reviewBox: "做完要停在待確認,等我確認", reviewShort: "完成前停在待確認",
47
68
  reviewOn: "做完會停在待確認,等你確認", reviewOff: "做完直接完成,不等你確認",
48
- parent: "主任務", deps: "相依", none: "沒有", edit: "編輯", depsTitle: "{0} 的相依", depsLabel: "要先完成的卡號,用逗號或空白分開(留空=沒有相依)",
49
- depWaiting: "還沒完成", depDone: "已完成", opened: "{0} 開的・{1}・最後更新 {2}",
69
+ parent: "主任務", deps: "相依卡片", none: "沒有", edit: "編輯", depsTitle: "{0} 的相依", depsLabel: "要先完成的卡號,用逗號或空白分開(留空=沒有相依)",
70
+ depWaiting: "還沒完成", depDone: "已完成", opened: "{0} 開的 · {1} · 最後更新 {2}",
50
71
  blockedReason: "卡住原因", goal: "目標", goalHint: "為什麼做、做完是什麼樣子", scope: "範圍", scopeHint: "做:…/不做:…",
51
72
  definition: "完成定義", acceptance: "驗收條件", context: "背景", contextHint: "檔案路徑、相關卡號、已經做的決定",
52
73
  state: "目前狀態", stateHint: "已完成/下一步/注意(負責人會隨時覆寫)", result: "產出", resultHint: "改了哪些檔案、怎麼驗證",
53
- empty: "(未填,點一下編輯)", clickToEdit: "點一下編輯", ctrlEnter: "Ctrl+Enter 儲存", save: "儲存", cancel: "取消",
54
- checklistEmpty: "(還沒有,點一下新增)", editList: "編輯清單", onePerLine: "一行一項;改了文字的項目會變回沒勾", items: "{0}/{1} 項",
55
- subs: "子任務({0})", quickAdd: "新增子任務:輸入標題後按 Enter(小事可以不拆)",
56
- tabComments: "留言 {0}", tabLog: "進度紀錄 {0}", tabHistory: "變更歷史", noComments: "還沒有留言", noLog: "還沒有進度紀錄",
57
- rejectTag: "退回", approveTag: "確認", commentTo: "留言給 {0}(Ctrl+Enter 送出)", commentHint: "留言(Ctrl+Enter 送出)", send: "送出",
58
- evCreated: "開卡", evMoved: "{0}→{1}", evAuto: "(自動)", evAssigned: "負責人 {0}→{1}", evUpdated: "修改{0}", evCommented: "留言", evLogged: "紀錄:{0}",
74
+ empty: "(未填,點一下編輯)", clickToEdit: "點一下編輯", editHint: "點別處或按 Ctrl+Enter 儲存・Esc 放棄修改",
75
+ saving: "儲存中…", notSaved: "還沒存到 — 點別處或按 Ctrl+Enter 再試一次",
76
+ conflictInline: "這裡剛被別人改過。要用你的文字覆蓋嗎?", overwrite: "覆蓋", discard: "放棄我的修改",
77
+ checklistEmpty: "(還沒有,點一下新增)", editList: "編輯清單", onePerLine: "一行一項;改了文字的項目會變回沒勾・點別處或按 Ctrl+Enter 儲存", items: "{0}/{1} 項",
78
+ subs: "子任務", quickAdd: "新增子任務:輸入標題後按 Enter(小事可以不拆)",
79
+ activity: "動態", activityShow: "顯示", "show.all": "全部", "show.comments": "留言", "show.log": "進度", "show.history": "歷史",
80
+ noActivity: "還沒有動態 — 留言、進度紀錄與變更都會出現在這裡", nothingHere: "這類還沒有內容",
81
+ rejectTag: "退回", approveTag: "確認", commentTo: "留言給 {0} — 輸入 @ 可選 Agent(Ctrl+Enter 送出)", commentHint: "留言 — 輸入 @ 可選 Agent(Ctrl+Enter 送出)", send: "送出",
82
+ mentionList: "可提及的 Agent", boardOffShort: "任務板已關閉",
83
+ rowMoved: "把狀態從 {0} 改成 {1}", rowAssigned: "把負責人從 {0} 改成 {1}", activities: "{0} 項動態", activity1: "1 項動態",
84
+ logTip: "agent 或成員記下的一行工作紀錄,不是留言",
85
+ evCreated: "開卡", evMoved: "{0}→{1}", evAuto: "(自動)", evAssigned: "負責人 {0}→{1}", evUpdated: "修改{0}", evCommented: "留言", evLogged: "紀錄:{0}", evWatchers: "修改關注者:{0}",
59
86
  fTitle: "標題", fGoal: "目標", fScope: "範圍", fContext: "背景", fState: "目前狀態", fResult: "產出", fBlockedReason: "卡住原因", fSize: "大小",
60
87
  fPriority: "優先度", fNeedsReview: "需要確認", fDependsOn: "相依", fAcceptance: "驗收條件", fProjectId: "專案",
61
- position: "位置", moveUp: "往上移", moveDown: "往下移",
88
+ position: "位置", moveUp: "往上移", moveDown: "往下移", properties: "屬性", crumbs: "這張卡的位置", backBoard: "回到看板", backList: "回到清單",
62
89
  dispatcher: "派工", dispatcherHint: "卡住要決定的事會先通知派工者", dispatcherMe: "我", dispatcherNone: "(沒有)",
63
- dispatcherPerson: "{0}(人)", now: "目前", nowNone: "沒有正在進行的子任務", fDispatcher: "派工者",
90
+ dispatcherPerson: "{0}(人)", fDispatcher: "派工者",
91
+ today: "今天", yesterday: "昨天", repeated: "連續 {0} 次相同",
92
+ groupCore: "核心狀態", groupTeam: "專案與協作", groupFlow: "流程控制",
93
+ addGoal: "新增目標", addScope: "新增範圍", addDefinition: "完成定義", addAcceptance: "驗收條件", addContext: "補充背景", addState: "目前狀態", addResult: "產出",
94
+ subsDone: "{0}/{1} 個子任務已完成",
64
95
  },
65
96
  });
66
97
 
67
- const MOVES = ["open", "claimed", "blocked", "review", "done"];
68
98
  const LIMIT = { title: 100, goal: 300, scope: 600, context: 1000, state: 500, result: 1000, blockedReason: 400, acceptanceItems: 10 };
99
+ const PRIORITY_CHOICES = ["urgent", "high", "normal", "low"];
69
100
 
70
101
  /** One history line, without who and when. */
71
102
  export function describeEvent(ev) {
@@ -76,29 +107,102 @@ export function describeEvent(ev) {
76
107
  case "assigned": return t("taskcard.evAssigned", d.from || "—", d.to || "—");
77
108
  case "updated": return t("taskcard.evUpdated", Object.keys(d.changes || {}).map((k) => fieldName(k)).join(", "));
78
109
  case "commented": return t("taskcard.evCommented");
79
- case "logged": return t("taskcard.evLogged", d.text || "");
110
+ case "logged": return d.watchers ? t("taskcard.evWatchers", watcherChange(d)) : t("taskcard.evLogged", d.text || "");
80
111
  default: return ev.type;
81
112
  }
82
113
  }
114
+ /**
115
+ * A history line as the activity stream's thin row says it, without who and when: a sentence the name leads —
116
+ * "dev-a changed status from To do to In progress" — for a move and a change of assignee; every other line as `describeEvent`.
117
+ */
118
+ export function describeRow(ev) {
119
+ const d = ev.data || {};
120
+ if (ev.type === "moved") return `${t("taskcard.rowMoved", t(`tasks.${d.from}`), t(`tasks.${d.to}`))}${d.auto ? t("taskcard.evAuto") : ""}${d.reason ? `: ${d.reason}` : ""}`;
121
+ if (ev.type === "assigned") return t("taskcard.rowAssigned", d.from || "—", d.to || "—");
122
+ return describeEvent(ev);
123
+ }
124
+ /**
125
+ * A watcher change as the board wrote it (`data.watchers`: { added, removed }): "+ops, −dev-b" — the true minus sign, not a hyphen,
126
+ * so a narrow line never breaks between the sign and the name; the event's own text when the lists are not there.
127
+ */
128
+ const watcherChange = (d) => {
129
+ const w = d.watchers || {};
130
+ const names = (list) => (Array.isArray(list) ? list.filter((n) => typeof n === "string") : []);
131
+ const parts = [...names(w.added).map((n) => `+${n}`), ...names(w.removed).map((n) => `\u2212${n}`)];
132
+ return parts.length ? parts.join(", ") : String(d.text || "").replace(/^watchers:\s*/, "");
133
+ };
83
134
  const fieldName = (k) => { const key = `taskcard.f${k[0].toUpperCase()}${k.slice(1)}`; const s = t(key); return s === key ? k : s; };
84
135
 
136
+ // ── What each chip offers (pure: tests import these) ────────
137
+
85
138
  /**
86
- * `writable`: false over the public link (the card is shown, nothing on it changes). `place`: up and down in its column,
87
- * for touch and keyboard (null when it cannot move). `steps`: the previous and next card the page showed, and where
88
- * this one is among them (null: nowhere to step).
139
+ * The statuses a card's chip lists: every column, the card's own ticked; those a person may not move it to by hand (a
140
+ * main task that follows its sub tasks) are listed too, disabled and saying why — `act(to)` runs a choice.
89
141
  */
90
- export function CardDialog({ id, tick, projects, boardOff = [], writable = true, place = null, steps = null, onClose, onOpen, reloadBoard }) {
142
+ export function statusItems(card, act) {
143
+ if (card.status === "cancelled") return [];
144
+ const allowed = movesFor(card);
145
+ return COLUMNS.map((to) => ({
146
+ key: to, label: t(`tasks.${to}`), checked: to === card.status, disabled: to !== card.status && !allowed.includes(to),
147
+ title: to !== card.status && !allowed.includes(to) ? t("tasks.derivedMove") : undefined, onSelect: () => act(to),
148
+ }));
149
+ }
150
+
151
+ /** Who a card can go to: nobody, each instance (one with the board off is listed, disabled), and Other… for any name. */
152
+ export function assigneeItems(card, names, boardOff, act) {
153
+ const all = [...new Set([...names, card.assignee].filter(Boolean))].sort((a, b) => a.localeCompare(b));
154
+ return [
155
+ { key: "none", label: t("taskcard.unassign"), checked: !card.assignee, onSelect: () => act(null) },
156
+ ...all.map((n) => {
157
+ const off = boardOff.includes(n) && n !== card.assignee;
158
+ return { key: `n:${n}`, label: off ? t("tasks.boardOff", n) : n, checked: card.assignee === n, disabled: off, title: off ? t("tasks.boardOffHint") : undefined, onSelect: () => act(n) };
159
+ }),
160
+ { key: "other", label: t("taskcard.other"), onSelect: () => act("\u0000other") },
161
+ ];
162
+ }
163
+
164
+ /** Who dispatched a card: a person (the one at the page), nobody, or an instance. */
165
+ export function dispatcherItems(card, names, act) {
166
+ const d = card.dispatcher;
167
+ const isMe = !!d && d.kind === "person", isNone = !d;
168
+ return [
169
+ { key: "me", label: t("taskcard.dispatcherMe"), checked: isMe, onSelect: () => act("\u0000me") },
170
+ { key: "none", label: t("taskcard.dispatcherNone"), checked: isNone, onSelect: () => act("\u0000none") },
171
+ ...names.map((n) => ({ key: `n:${n}`, label: n, checked: !!d && d.kind === "instance" && d.name === n, onSelect: () => act(n) })),
172
+ ];
173
+ }
174
+
175
+ /** The value the page sends for a dispatcher choice. */
176
+ export const dispatcherValue = (v) => (v === "\u0000none" ? null : v === "\u0000me" ? { kind: "person" } : { kind: "instance", name: v });
177
+
178
+ const radioItems = (list, current, label, act) => list.map((v) => ({ key: String(v), label: label(v), checked: current === v, onSelect: () => act(v) }));
179
+
180
+ // ── The page ──────────────────────────────────────────────
181
+
182
+ /**
183
+ * `writable`: false over a read-only link (the card is shown, nothing on it changes). `place`: up and down in its column,
184
+ * for touch and keyboard (null when it cannot move). `steps`: the previous and next card the page showed, and where this
185
+ * one is among them (null: nowhere to step). `where`: the project's name for the breadcrumb (null: none). `back`: what
186
+ * Back says. `onBack` returns to the board or list. `doing`: how many cards each instance has in progress (fleet-task-run.js).
187
+ */
188
+ export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing = new Map(), writable = true, place = null, steps = null, where = null, back, onBack, onOpen, onStep, reloadBoard }) {
91
189
  const { instances } = useStore(appStore);
92
190
  const [detail, setDetail] = useState(null);
93
191
  const [missing, setMissing] = useState(false);
94
- const [tab, setTab] = useState("comments");
95
192
  const seq = useRef(0);
193
+ const cardRef = useRef(null); // the card as last read: a chip's save sends its version, whatever was drawn since
194
+ const chain = useRef(Promise.resolve()); // saves go one after another, each on the version the one before left
195
+ // The empty fields a person opened with their "+ Add" button, for this card (another card starts with none).
196
+ const [opened, setOpened] = useState({ id, keys: [] });
197
+ const openKeys = opened.id === id ? opened.keys : [];
198
+ const openField = (key) => setOpened((o) => ({ id, keys: [...(o.id === id ? o.keys : []).filter((k) => k !== key), key] }));
199
+ const closeField = (key) => setOpened((o) => (o.id === id && o.keys.includes(key) ? { id, keys: o.keys.filter((k) => k !== key) } : o));
96
200
 
97
201
  async function load() {
98
202
  const mine = ++seq.current;
99
203
  try {
100
204
  const d = await boardApi.card(id);
101
- if (mine === seq.current) { setDetail(d); setMissing(false); }
205
+ if (mine === seq.current) { cardRef.current = d.card; setDetail(d); setMissing(false); }
102
206
  } catch (err) {
103
207
  if (mine !== seq.current) return;
104
208
  if (err.status === 404 || err.status === 400) setMissing(true);
@@ -106,23 +210,52 @@ export function CardDialog({ id, tick, projects, boardOff = [], writable = true,
106
210
  }
107
211
  }
108
212
  useEffect(() => { void load(); }, [id, tick]);
213
+ // The page takes the keyboard's place from the tile or row that opened it (once per card: later reads leave the focus be).
214
+ const head = useRef(null);
215
+ const focused = useRef(null);
216
+ useEffect(() => {
217
+ if (!detail || focused.current === id) return;
218
+ focused.current = id;
219
+ try { head.current?.focus({ preventScroll: true }); } catch { /* no focus API */ }
220
+ }, [detail, id]);
221
+ // A card's page starts at its top (the panel it sits in keeps its scroll from the board or the card before).
222
+ const root = useRef(null);
223
+ useEffect(() => { const box = scrollBox(root.current); if (box) box.scrollTop = 0; }, [id]);
109
224
 
110
- /** A write and what follows: its notes, the card and the board read again. Resolves "ok", "conflict" or "error". */
111
- async function run(fn) {
225
+ // Esc goes back to the board — unless a box, a menu or a dialog has it.
226
+ useEffect(() => {
227
+ const onKey = (e) => {
228
+ if (e.key !== "Escape" || e.defaultPrevented) return;
229
+ const el = e.target;
230
+ if (el && typeof el.closest === "function" && (el.closest("dialog, [role=menu], [role=listbox]") || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName || "") || el.isContentEditable)) return;
231
+ onBack();
232
+ };
233
+ document.addEventListener("keydown", onKey);
234
+ return () => document.removeEventListener("keydown", onKey);
235
+ }, [onBack]);
236
+
237
+ /**
238
+ * A write and what follows: its notes, the card and the board read again. Resolves "ok", "conflict" or "error" — or, with
239
+ * `detail`, `{ outcome, version }`, where `version` is the one the write's own answer gave the card (an edit kept open after
240
+ * its save is pinned to it).
241
+ */
242
+ async function run(fn, detail = false) {
243
+ const done = (outcome, version) => (detail ? { outcome, version } : outcome);
112
244
  try {
113
245
  const r = await fn();
246
+ const written = r && r.card && typeof r.card.version === "number" ? r.card.version : undefined;
114
247
  for (const n of notesForPeople(r && r.notes)) toast(n);
115
248
  await load();
116
249
  reloadBoard();
117
- return "ok";
250
+ return done("ok", written);
118
251
  } catch (err) {
119
252
  const conflict = err.status === 409;
120
253
  toast(conflict ? t("taskcard.conflict", id) : errorText(err), false);
121
254
  if (conflict) await load();
122
- return conflict ? "conflict" : "error";
255
+ return done(conflict ? "conflict" : "error");
123
256
  }
124
257
  }
125
- /** A move from this dialog: one at a time (claimed before the first await), then the card and the board read again. */
258
+ /** A move from this page: one at a time (claimed before the first await), then the card and the board read again. */
126
259
  const moving = useRef(false);
127
260
  const [busy, setBusy] = useState(false);
128
261
  async function moved(start) {
@@ -133,19 +266,37 @@ export function CardDialog({ id, tick, projects, boardOff = [], writable = true,
133
266
  finally { moving.current = false; setBusy(false); }
134
267
  }
135
268
 
136
- // Previous / Next: the page's cards (fleet-task-menu.js), in the header from the first frame (no jump once it loads).
137
- const tools = steps ? html`<${StepButtons} steps=${steps} onOpen=${onOpen} />` : null;
269
+ // Previous / Next: the page's cards (fleet-task-menu.js), from the first frame (no jump once the card loads).
270
+ const tools = steps ? html`<${StepButtons} steps=${steps} onOpen=${onStep || onOpen} />` : null;
271
+ const bar = (card) => html`<div class="tp-bar">
272
+ <button type="button" class="btn btn-ghost btn-sm tp-back" onClick=${onBack}><${Icon} name="back" size=${16} />${back}</button>
273
+ <nav class="tp-crumbs" aria-label=${t("taskcard.crumbs")}>${where ? html`<span class="tp-crumb">${where}</span>` : null}
274
+ ${card && card.parent ? html`<button type="button" class="tb-link tp-crumb" onClick=${() => onOpen(card.parent.id)}><span class="tb-code">${card.parent.id}</span> ${card.parent.title}</button>` : null}
275
+ <span class="tp-crumb tb-code">${id}</span></nav>
276
+ <span class="tp-tools">${tools}${card ? card.actions : null}</span>
277
+ </div>`;
138
278
  if (missing || !detail) {
139
- return html`<${Dialog} title=${id} onClose=${onClose} wide drawer tools=${tools}><p class="muted">${missing ? t("taskcard.missing", id) : t("taskcard.loading")}</p></${Dialog}>`;
279
+ return html`<div class="tp" ref=${root}>${bar(null)}${missing ? html`<${Empty} icon="tasks" title=${t("taskcard.missing", id)} />` : html`<${Skeleton} lines=${6} />`}</div>`;
140
280
  }
141
281
 
142
282
  const { card, parent, children } = detail;
143
283
  const isMain = card.kind === "main";
144
284
  const derived = followsSubs(card);
145
285
  const finished = card.status === "done" || card.status === "cancelled";
146
- /** `version` guards against overwriting a newer card; null skips it (text typed after a conflict was shown). */
147
- const save = (patch, version = card.version) => run(() => boardApi.update(card.id, version === null ? patch : { ...patch, version }));
148
- const names = [...new Set([...instances.map((i) => i.name), card.assignee].filter(Boolean))].sort();
286
+ /** `version` guards against overwriting a newer card; null skips it (text sent over a conflict on purpose). */
287
+ const save = (patch, version) => {
288
+ const job = chain.current.then(() => run(() => boardApi.update(card.id, version === null ? patch : { ...patch, version: version === undefined ? (cardRef.current || card).version : version }), true));
289
+ chain.current = job.catch(() => {});
290
+ return job;
291
+ };
292
+ const names = [...new Set([...instances.map((i) => i.name), card.assignee].filter(Boolean))].sort((a, b) => a.localeCompare(b));
293
+ // Only the fleet's instances can be mentioned (an assignee that has left the fleet, or a person, would wake nobody); the
294
+ // card's assignee comes first.
295
+ const fleet = instances.map((i) => i.name);
296
+ const mentionNames = [...(fleet.includes(card.assignee) ? [card.assignee] : []), ...fleet.filter((n) => n !== card.assignee)].map((name) => ({ name, off: boardOff.includes(name) }));
297
+
298
+ /** Who watches the card: no version (a watch is not an edit of the card), the card and the board read again after. */
299
+ const follow = (change) => run(() => boardApi.watchers(card.id, change));
149
300
 
150
301
  async function chooseAssignee(value) {
151
302
  if (value === "\u0000other") {
@@ -153,10 +304,7 @@ export function CardDialog({ id, tick, projects, boardOff = [], writable = true,
153
304
  if (name) await save({ assignee: name }, null);
154
305
  return;
155
306
  }
156
- await save({ assignee: value === "\u0000none" ? null : value });
157
- }
158
- async function chooseDispatcher(value) {
159
- await save({ dispatcher: value === "\u0000none" ? null : value === "\u0000me" ? { kind: "person" } : { kind: "instance", name: value } });
307
+ await save({ assignee: value });
160
308
  }
161
309
  async function editDeps() {
162
310
  const text = await askText({ title: t("taskcard.depsTitle", card.id), label: t("taskcard.depsLabel"), initial: card.dependsOn.join(", ") });
@@ -169,272 +317,127 @@ export function CardDialog({ id, tick, projects, boardOff = [], writable = true,
169
317
  void navigator.clipboard?.writeText(u.toString()).then(() => toast(t("taskcard.linkCopied")));
170
318
  } catch { /* no clipboard */ }
171
319
  }
320
+ const projectName = (pid) => (pid === null ? t("tasks.noProject") : (projects.find((p) => p.id === pid) || {}).name || "—");
321
+ const can = writable;
322
+ const row = (label, body, cls = "") => html`<div class=${`tp-row${cls ? ` ${cls}` : ""}`}><dt>${label}</dt><dd>${body}</dd></div>`;
323
+ const group = (key, title, rows) => html`<div class="tp-group" role="group" aria-labelledby=${`tpg-${key}`}><h4 class="tp-group-title" id=${`tpg-${key}`}>${title}</h4><dl class="tp-props">${rows}</dl></div>`;
172
324
 
173
- return html`<${Dialog} title=${`${card.id} · ${t(`tasks.${card.kind}`)}`} onClose=${onClose} wide drawer label=${`${card.id} ${card.title}`} tools=${tools}>
174
- <div class="tc">
175
- <div class="tc-head">
176
- ${writable ? html`<${InlineTitle} value=${card.title} version=${card.version} onSave=${(title, base) => save({ title }, base)} />` : html`<h3 class="tc-title">${card.title}</h3>`}
177
- <span class="muted tc-ver">${t("taskcard.version", card.version)}</span>
178
- <button type="button" class="icon-btn" title=${t("taskcard.copyLink")} aria-label=${t("taskcard.copyLink")} onClick=${copyLink}><${Icon} name="copy" size=${16} /></button>
179
- </div>
325
+ // The header toolbar: Previous / Next (above), the link, Mark blocked (by hand: a main task that follows its sub tasks only) and ⋯.
326
+ const copyBtn = html`<button type="button" class="icon-btn" title=${t("taskcard.copyLink")} aria-label=${t("taskcard.copyLink")} onClick=${copyLink}><${Icon} name="copy" size=${16} /></button>`;
327
+ const blockBtn = can && derived && !finished && card.status !== "blocked"
328
+ ? html`<button type="button" class="btn btn-sm tp-block-btn" disabled=${busy} onClick=${() => moved(() => moveCard(card, "blocked"))}>${t("tasks.block")}</button>` : null;
329
+ const more = can && !finished ? html`<${Menu} cls="tp-more" label=${t("taskcard.moreActions")} items=${[
330
+ { key: "cancel", label: t("taskcard.cancelCard"), icon: "trash", danger: true, onSelect: () => void moved(() => moveCard(card, "cancelled")) },
331
+ ]} />` : null;
180
332
 
181
- <div class="tc-actions">
182
- <${StatusPill} status=${card.status} card=${card} />
183
- ${writable ? html`
184
- ${card.status === "review" ? html`
185
- <button type="button" class="btn btn-primary btn-sm" disabled=${busy} onClick=${() => moved(() => moveCard(card, "done"))}><${Icon} name="check" size=${14} />${isMain ? t("taskcard.confirmMain") : t("tasks.confirm")}</button>
186
- <button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => moved(() => moveCard(card, "claimed"))}>${t("tasks.sendBack")}</button>
187
- ${wrapUpText(card) ? html`<span class="tc-hint wrapup">${t("tasks.wrapLine", wrapUpText(card))}</span>` : null}` : null}
188
- ${card.status === "blocked" ? html`<button type="button" class="btn btn-primary btn-sm" disabled=${busy} onClick=${() => moved(() => answerBlocked(card))}>${t("tasks.answer")}</button>` : null}
189
- ${!derived && !finished ? html`<select class="tb-select" value="" aria-label=${t("taskcard.moveLabel")} onChange=${(e) => { const to = e.target.value; e.target.value = ""; if (to) void moved(() => moveCard(card, to)); }} disabled=${busy}>
190
- <option value="">${t("taskcard.moveTo")}</option>
191
- ${MOVES.filter((s) => s !== card.status).map((s) => html`<option key=${s} value=${s}>${t(`tasks.${s}`)}</option>`)}</select>` : null}
192
- ${derived && !finished && card.status !== "blocked" ? html`<button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => moved(() => moveCard(card, "blocked"))}>${t("tasks.block")}</button>` : null}
193
- ${derived && !finished ? html`<span class="muted tc-hint">${t("taskcard.followsSubs")}</span>` : null}
194
- <span class="tb-grow"></span>
195
- ${finished
196
- ? html`<button type="button" class="btn btn-ghost btn-sm" disabled=${busy} onClick=${() => moved(() => moveCard(card, card.status === "done" ? "claimed" : "open"))}><${Icon} name="restart" size=${14} />${t("taskcard.reopen")}</button>`
197
- : html`<button type="button" class="btn btn-ghost btn-sm danger" disabled=${busy} onClick=${() => moved(() => moveCard(card, "cancelled"))}>${t("taskcard.cancelCard")}</button>`}` : null}
198
- </div>
333
+ // The text fields of the spec (goal, scope, definition of done, context) and of the agent's block (state, result): one
334
+ // that holds text is a field; an empty one is a "+ Add" button (a writer's way in) until it is opened, and folds back into
335
+ // its button when it is closed still empty. Over a read-only link an empty one is simply not there.
336
+ const textField = (key, field, title, hint, add, limit) => ({ key, title, add, has: !!card[field],
337
+ body: (open) => html`<${EditableText} readOnly=${!can} value=${card[field]} limit=${limit} version=${card.version} placeholder=${hint} open=${open} onClose=${() => closeField(key)}
338
+ onSave=${(v, base) => save({ [field]: v }, base)} />` });
339
+ const parts = (defs) => {
340
+ const shown = [], adders = [];
341
+ for (const d of defs) {
342
+ const isOpen = openKeys.includes(d.key);
343
+ if (d.has || isOpen) shown.push(html`<${Field} key=${d.key} title=${d.title}>${d.body(isOpen)}</${Field}>`);
344
+ else if (can) adders.push(html`<button key=${d.key} type="button" class="tp-add" data-add=${d.key} onClick=${() => openField(d.key)}><${Icon} name="plus" size=${14} />${t(d.add)}</button>`);
345
+ }
346
+ return { shown, adders };
347
+ };
348
+ const spec = parts([
349
+ textField("goal", "goal", t("taskcard.goal"), t("taskcard.goalHint"), "taskcard.addGoal", LIMIT.goal),
350
+ isMain ? textField("scope", "scope", t("taskcard.scope"), t("taskcard.scopeHint"), "taskcard.addScope", LIMIT.scope) : null,
351
+ { key: "definition", title: isMain ? t("taskcard.definition") : t("taskcard.acceptance"), add: isMain ? "taskcard.addDefinition" : "taskcard.addAcceptance", has: card.acceptance.length > 0,
352
+ body: (open) => html`<${Checklist} card=${card} readOnly=${!can} limit=${LIMIT.acceptanceItems} open=${open} onClose=${() => closeField("definition")}
353
+ onToggle=${(n, done) => save(done ? { check: [n] } : { uncheck: [n] })} onReplace=${(items, base) => save({ acceptance: items }, base)} />` },
354
+ textField("context", "context", t("taskcard.context"), t("taskcard.contextHint"), "taskcard.addContext", LIMIT.context),
355
+ ].filter(Boolean));
356
+ const handoff = parts([
357
+ textField("state", "state", t("taskcard.state"), t("taskcard.stateHint"), "taskcard.addState", LIMIT.state),
358
+ textField("result", "result", t("taskcard.result"), t("taskcard.resultHint"), "taskcard.addResult", LIMIT.result),
359
+ ]);
199
360
 
200
- <dl class="tc-meta">
201
- <dt>${t("taskcard.assignee")}</dt>
202
- <dd><${Who} name=${card.assignee} empty=${t("taskcard.nobody")} />
203
- ${writable ? html`<select class="tb-select" value="\u0000pick" aria-label=${t("taskcard.assignee")} onChange=${(e) => { const v = e.target.value; e.target.value = "\u0000pick"; void chooseAssignee(v); }}>
204
- <option value="\u0000pick" disabled hidden>${t("taskcard.change")}</option>
205
- ${card.assignee ? html`<option value="\u0000none">${t("taskcard.unassign")}</option>` : null}
206
- ${names.filter((n) => n !== card.assignee).map((n) => html`<${AssigneeOption} key=${n} name=${n} boardOff=${boardOff} />`)}
207
- <option value="\u0000other">${t("taskcard.other")}</option>
208
- </select>` : null}</dd>
209
- ${isMain && children.length ? html`<dt>${t("taskcard.now")}</dt><dd>${(() => {
210
- const now = currentWork(card, children);
211
- if (!now) return html`<span class="muted">${card.status === "review" ? t("tasks.review") : t("taskcard.nowNone")}</span>`;
212
- return now.cards.map((c) => html`<button key=${c.id} type="button" class="tc-now" onClick=${() => onOpen(c.id)} title=${c.title}>
213
- <span class=${`tb-now-label st-${now.tone}`}>${t(now.label)}</span><span class="tb-code">${c.id}</span><span class="tc-child-title">${c.title}</span>
214
- <${Who} name=${c.assignee} empty=${t("tasks.nobody")} /></button>`);
215
- })()}</dd>` : null}
216
- <dt>${t("taskcard.dispatcher")}</dt>
217
- <dd><span class="tb-who" title=${t("taskcard.dispatcherHint")}>${!card.dispatcher ? t("taskcard.dispatcherNone")
218
- : card.dispatcher.kind === "person" ? t("taskcard.dispatcherPerson", card.dispatcher.name) : card.dispatcher.name}</span>
219
- ${writable ? html`<select class="tb-select" value="\u0000pick" aria-label=${t("taskcard.dispatcher")} title=${t("taskcard.dispatcherHint")} onChange=${(e) => { const v = e.target.value; e.target.value = "\u0000pick"; void chooseDispatcher(v); }}>
220
- <option value="\u0000pick" disabled hidden>${t("taskcard.change")}</option>
221
- <option value="\u0000me">${t("taskcard.dispatcherMe")}</option>
222
- ${card.dispatcher ? html`<option value="\u0000none">${t("taskcard.dispatcherNone")}</option>` : null}
223
- ${names.filter((n) => !(card.dispatcher && card.dispatcher.kind === "instance" && card.dispatcher.name === n)).map((n) => html`<option key=${n} value=${n}>${n}</option>`)}
224
- </select>` : null}</dd>
225
- ${isMain ? html`<dt>${t("taskcard.project")}</dt>
226
- <dd>${writable ? html`<select class="tb-select" value=${card.projectId === null ? "" : String(card.projectId)} aria-label=${t("taskcard.project")}
227
- onChange=${(e) => void save({ projectId: e.target.value === "" ? null : Number(e.target.value) })}>
228
- <option value="">${t("tasks.noProject")}</option>
229
- ${projects.filter((p) => !p.archived || p.id === card.projectId).map((p) => html`<option key=${p.id} value=${String(p.id)}>${p.name}</option>`)}
230
- </select>` : html`<span class="tc-value">${card.projectId === null ? t("tasks.noProject") : (projects.find((p) => p.id === card.projectId) || {}).name || "—"}</span>`}</dd>` : null}
231
- <dt>${t("taskcard.priority")}</dt>
232
- <dd>${writable ? html`<select class="tb-select" value=${card.priority} aria-label=${t("taskcard.priority")} onChange=${(e) => void save({ priority: e.target.value })}>
233
- ${["urgent", "high", "normal", "low"].map((p) => html`<option key=${p} value=${p}>${t(`tasks.${p}`)}</option>`)}</select>`
234
- : html`<span class="tc-value">${t(`tasks.${card.priority}`)}</span>`}</dd>
235
- <dt>${t("taskcard.size")}</dt>
236
- <dd>${writable ? html`<select class="tb-select" value=${card.size || ""} aria-label=${t("taskcard.size")} onChange=${(e) => void save({ size: e.target.value || null })}>
237
- <option value="">${t("tasks.sizeNone")}</option>${["S", "M", "L"].map((s) => html`<option key=${s} value=${s}>${t(`tasks.size${s}`)}</option>`)}</select>`
238
- : html`<span class="tc-value">${card.size ? t(`tasks.size${card.size}`) : t("tasks.sizeNone")}</span>`}</dd>
239
- <dt>${t("taskcard.review")}</dt>
240
- <dd>${writable ? html`<label class="tb-check"><input type="checkbox" checked=${card.needsReview} onChange=${(e) => void save({ needsReview: e.target.checked })} />${t("taskcard.reviewBox")}</label>`
241
- // #2299: read-only (the public link): the values as text, not controls that look usable and are not.
242
- : html`<span class="tc-value">${t(card.needsReview ? "taskcard.reviewOn" : "taskcard.reviewOff")}</span>`}</dd>
243
- ${parent ? html`<dt>${t("taskcard.parent")}</dt><dd><button type="button" class="tb-link" onClick=${() => onOpen(parent.id)}><span class="tb-code">${parent.id}</span> ${parent.title}</button></dd>` : null}
244
- <dt>${t("taskcard.deps")}</dt>
245
- <dd>${card.dependsOn.length ? card.dependsOn.map((d) => html`<button key=${d} type="button" class=${`tc-dep${card.unmetDeps.includes(d) ? " waiting" : ""}`}
246
- title=${card.unmetDeps.includes(d) ? t("taskcard.depWaiting") : t("taskcard.depDone")} onClick=${() => onOpen(d)}>${d}</button>`) : html`<span class="muted">${t("taskcard.none")}</span>`}
247
- ${writable ? html`<button type="button" class="btn btn-ghost btn-sm" onClick=${editDeps}>${t("taskcard.edit")}</button>` : null}</dd>
248
- ${place && (place.up || place.down) ? html`<dt>${t("taskcard.position")}</dt>
249
- <dd><button type="button" class="btn btn-ghost btn-sm" disabled=${!place.up} aria-label=${t("taskcard.moveUp")} title=${t("taskcard.moveUp")} onClick=${place.up}><${Icon} name="up" size=${16} /></button>
250
- <button type="button" class="btn btn-ghost btn-sm" disabled=${!place.down} aria-label=${t("taskcard.moveDown")} title=${t("taskcard.moveDown")} onClick=${place.down}><${Icon} name="down" size=${16} /></button></dd>` : null}
251
- <dt></dt>
252
- <dd class="muted">${t("taskcard.opened", card.createdBy, relTime(card.createdAt), relTime(card.updatedAt))}</dd>
253
- </dl>
361
+ // The sub tasks: a bordered list — done / total and the bar on top, the sub tasks, a line to add one at the end.
362
+ const prog = card.progress && card.progress.total ? card.progress : null;
363
+ const subs = isMain ? html`<section class="tp-subs" aria-label=${t("taskcard.subs")}>
364
+ <h3>${t("taskcard.subs")}</h3>
365
+ <div class="tc-field-body">
366
+ ${prog ? html`<div class="tp-subs-head"><span class="tp-subs-count" title=${t("taskcard.subsDone", prog.done, prog.total)}>${prog.done} / ${prog.total}</span><${ProgressBar} progress=${prog} wide /></div>` : null}
367
+ ${children.length ? html`<ul class="tc-children">${children.map((c) => html`<li key=${c.id}><button type="button" onClick=${() => onOpen(c.id)}>
368
+ <${StatusPill} status=${c.status} card=${c} /><span class="tb-code">${c.id}</span><span class="tc-child-title">${c.title}</span><span class="tb-who">${c.assignee || ""}</span></button></li>`)}</ul>` : null}
369
+ ${finished || !can ? null : html`<${QuickAdd} placeholder=${t("taskcard.quickAdd")} limit=${LIMIT.title} onAdd=${(title) => run(() => boardApi.create({ parent: card.id, title }))} />`}
370
+ </div>
371
+ </section>` : null;
254
372
 
255
- ${card.status === "blocked" ? html`<${Field} title=${t("taskcard.blockedReason")} tone="blocked">
256
- <${EditableText} readOnly=${!writable} value=${card.blockedReason} limit=${LIMIT.blockedReason} version=${card.version} onSave=${(v, base) => save({ blockedReason: v }, base)} /></${Field}>` : null}
257
- <${Field} title=${t("taskcard.goal")}><${EditableText} readOnly=${!writable} value=${card.goal} limit=${LIMIT.goal} version=${card.version} placeholder=${t("taskcard.goalHint")} onSave=${(v, base) => save({ goal: v }, base)} /></${Field}>
258
- ${isMain ? html`<${Field} title=${t("taskcard.scope")}><${EditableText} readOnly=${!writable} value=${card.scope} limit=${LIMIT.scope} version=${card.version} placeholder=${t("taskcard.scopeHint")} onSave=${(v, base) => save({ scope: v }, base)} /></${Field}>` : null}
259
- <${Field} title=${isMain ? t("taskcard.definition") : t("taskcard.acceptance")}>
260
- <${Checklist} card=${card} readOnly=${!writable} onToggle=${(n, done) => save(done ? { check: [n] } : { uncheck: [n] })} onReplace=${(items, base) => save({ acceptance: items }, base)} /></${Field}>
261
- <${Field} title=${t("taskcard.context")}><${EditableText} readOnly=${!writable} value=${card.context} limit=${LIMIT.context} version=${card.version} placeholder=${t("taskcard.contextHint")} onSave=${(v, base) => save({ context: v }, base)} /></${Field}>
262
- <${Field} title=${t("taskcard.state")}><${EditableText} readOnly=${!writable} value=${card.state} limit=${LIMIT.state} version=${card.version} placeholder=${t("taskcard.stateHint")} onSave=${(v, base) => save({ state: v }, base)} /></${Field}>
263
- <${Field} title=${t("taskcard.result")}><${EditableText} readOnly=${!writable} value=${card.result} limit=${LIMIT.result} version=${card.version} placeholder=${t("taskcard.resultHint")} onSave=${(v, base) => save({ result: v }, base)} /></${Field}>
373
+ return html`<div class="tp" ref=${root} data-card=${card.id}>
374
+ ${bar({ parent, actions: html`${copyBtn}${blockBtn}${more}` })}
375
+ <div class="tp-grid">
376
+ <div class="tp-head">
377
+ <div class="tp-idrow"><span class="tb-code tp-code">${card.id}</span><${StatusPill} status=${card.status} card=${card} />
378
+ ${derived && !finished ? html`<span class="tp-derived">${t("taskcard.followsSubs")}</span>` : null}</div>
379
+ <div class="tc-head" ref=${head} tabindex="-1" role="heading" aria-level="2">
380
+ ${can ? html`<${InlineTitle} value=${card.title} version=${card.version} limit=${LIMIT.title} onSave=${(title, base) => save({ title }, base)} />` : html`<h2 class="tc-title">${card.title}</h2>`}
381
+ </div>
382
+ ${can ? html`<div class="tc-actions">
383
+ ${card.status === "review" ? html`
384
+ <button type="button" class="btn btn-primary btn-sm" disabled=${busy} onClick=${() => moved(() => moveCard(card, "done"))}><${Icon} name="check" size=${14} />${isMain ? t("taskcard.confirmMain") : t("tasks.confirm")}</button>
385
+ <button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => moved(() => moveCard(card, "claimed"))}>${t("tasks.sendBack")}</button>
386
+ ${wrapUpText(card) ? html`<span class="tc-hint wrapup">${t("tasks.wrapLine", wrapUpText(card))}</span>` : null}` : null}
387
+ ${card.status === "blocked" ? html`<button type="button" class="btn btn-primary btn-sm" disabled=${busy} onClick=${() => moved(() => answerBlocked(card))}>${t("tasks.answer")}</button>` : null}
388
+ ${finished ? html`<button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => moved(() => moveCard(card, card.status === "done" ? "claimed" : "open"))}><${Icon} name="restart" size=${14} />${t("taskcard.reopen")}</button>` : null}
389
+ </div>` : null}
390
+ </div>
264
391
 
265
- ${isMain ? html`<${Field} title=${t("taskcard.subs", children.length)}>
266
- ${children.length ? html`<ul class="tc-children">${children.map((c) => html`<li key=${c.id}><button type="button" onClick=${() => onOpen(c.id)}>
267
- <${StatusPill} status=${c.status} card=${c} /><span class="tb-code">${c.id}</span><span class="tc-child-title">${c.title}</span><span class="tb-who">${c.assignee || ""}</span></button></li>`)}</ul>` : null}
268
- ${finished || !writable ? null : html`<${QuickAdd} placeholder=${t("taskcard.quickAdd")} onAdd=${(title) => run(() => boardApi.create({ parent: card.id, title }))} />`}
269
- </${Field}>` : null}
392
+ <div class="tp-body">
393
+ ${card.status === "blocked" ? html`<${Field} title=${t("taskcard.blockedReason")} tone="blocked">
394
+ <${EditableText} readOnly=${!can} value=${card.blockedReason} limit=${LIMIT.blockedReason} version=${card.version} onSave=${(v, base) => save({ blockedReason: v }, base)} /></${Field}>` : null}
395
+ ${spec.shown.length ? html`<div class="tp-spec">${spec.shown}</div>` : null}
396
+ ${spec.adders.length ? html`<div class="tp-adders">${spec.adders}</div>` : null}
397
+ <${AgentRun} card=${card} detail=${detail} doing=${doing} derived=${derived} shown=${handoff.shown} adders=${handoff.adders} />
398
+ ${subs}
399
+ </div>
400
+
401
+ <aside class="card tp-side" aria-label=${t("taskcard.properties")}>
402
+ ${group("core", t("taskcard.groupCore"), html`
403
+ ${row(t("taskcard.status"), html`<${PropChip} label=${t("taskcard.status")} items=${can ? statusItems(card, (to) => moved(() => moveCard(card, to))) : null} value=${html`<${StatusPill} status=${card.status} card=${card} />`} />`)}
404
+ ${row(t("taskcard.assignee"), html`<${PropChip} label=${t("taskcard.assignee")} items=${can && !finished ? assigneeItems(card, names, boardOff, chooseAssignee) : null} value=${html`<${Who} name=${card.assignee} empty=${t("taskcard.nobody")} />`} />`)}
405
+ ${row(t("taskcard.priority"), html`<${PropChip} label=${t("taskcard.priority")} value=${html`<span class=${`tp-prio p-${card.priority}`}>${t(`tasks.${card.priority}`)}</span>`}
406
+ items=${can ? radioItems(PRIORITY_CHOICES, card.priority, (p) => t(`tasks.${p}`), (p) => save({ priority: p })) : null} />`)}
407
+ ${row(t("taskcard.size"), html`<${PropChip} label=${t("taskcard.size")} value=${card.size ? t(`tasks.size${card.size}`) : t("tasks.sizeNone")}
408
+ items=${can ? [{ key: "none", label: t("tasks.sizeNone"), checked: !card.size, onSelect: () => save({ size: null }) }, ...radioItems(["S", "M", "L"], card.size, (s) => t(`tasks.size${s}`), (s) => save({ size: s }))] : null} />`)}`)}
409
+ ${group("team", t("taskcard.groupTeam"), html`
410
+ ${isMain ? row(t("taskcard.project"), html`<${PropChip} label=${t("taskcard.project")} value=${projectName(card.projectId)}
411
+ items=${can ? [{ key: "none", label: t("tasks.noProject"), checked: card.projectId === null, onSelect: () => save({ projectId: null }) },
412
+ ...projects.filter((p) => !p.archived || p.id === card.projectId).map((p) => ({ key: String(p.id), label: p.name, checked: card.projectId === p.id, onSelect: () => save({ projectId: p.id }) }))] : null} />`) : null}
413
+ ${parent ? row(t("taskcard.parent"), html`<button type="button" class="tb-link" onClick=${() => onOpen(parent.id)}><span class="tb-code">${parent.id}</span> ${parent.title}</button>`) : null}
414
+ <${LeaderRow} detail=${detail} names=${fleet} boardOff=${boardOff} can=${can} follow=${follow} />
415
+ ${row(t("taskcard.dispatcher"), html`<${PropChip} label=${t("taskcard.dispatcher")} items=${can ? dispatcherItems(card, names, (v) => save({ dispatcher: dispatcherValue(v) })) : null}
416
+ value=${html`<span class="tb-who" title=${t("taskcard.dispatcherHint")}>${!card.dispatcher ? t("taskcard.dispatcherNone") : card.dispatcher.kind === "person" ? t("taskcard.dispatcherPerson", card.dispatcher.name) : card.dispatcher.name}</span>`} />`)}
417
+ <${WatchersRow} detail=${detail} names=${fleet} boardOff=${boardOff} can=${can} follow=${follow} />`)}
418
+ ${group("flow", t("taskcard.groupFlow"), html`
419
+ ${row(t("taskcard.review"), can ? html`<label class="tp-switch"><input type="checkbox" role="switch" class="s-ui-toggle" aria-label=${t("taskcard.reviewBox")} checked=${card.needsReview} onChange=${(e) => void save({ needsReview: e.target.checked })} /><span class="tc-hint muted">${t("taskcard.reviewShort")}</span></label>`
420
+ // #2299: read-only: the values as text, not controls that look usable and are not.
421
+ : html`<span class="tc-value">${t(card.needsReview ? "taskcard.reviewOn" : "taskcard.reviewOff")}</span>`, can ? "" : "tp-block")}
422
+ ${row(t("taskcard.deps"), html`${card.dependsOn.length ? card.dependsOn.map((d) => html`<button key=${d} type="button" class=${`tc-dep${card.unmetDeps.includes(d) ? " waiting" : ""}`}
423
+ title=${card.unmetDeps.includes(d) ? t("taskcard.depWaiting") : t("taskcard.depDone")} onClick=${() => onOpen(d)}>${d}</button>`) : hiddenWaits(card) ? null : html`<span class="muted">${t("taskcard.none")}</span>`}
424
+ ${hiddenWaits(card) ? html`<span class="muted" title=${t("taskcard.depWaiting")}>${hiddenWaits(card)}</span>` : null}
425
+ ${can ? html`<button type="button" class="btn btn-ghost btn-sm" onClick=${editDeps}>${t("taskcard.edit")}</button>` : null}`)}
426
+ ${place && (place.up || place.down) ? row(t("taskcard.position"), html`<button type="button" class="btn btn-ghost btn-sm" disabled=${!place.up} aria-label=${t("taskcard.moveUp")} title=${t("taskcard.moveUp")} onClick=${place.up}><${Icon} name="up" size=${16} /></button>
427
+ <button type="button" class="btn btn-ghost btn-sm" disabled=${!place.down} aria-label=${t("taskcard.moveDown")} title=${t("taskcard.moveDown")} onClick=${place.down}><${Icon} name="down" size=${16} /></button>`) : null}`)}
428
+ <p class="muted tp-opened">${t("taskcard.opened", card.createdBy, relTime(card.createdAt), relTime(card.updatedAt))} · ${t("taskcard.version", card.version)}</p>
429
+ </aside>
270
430
 
271
- <div class="seg tc-tabs" role="tablist">
272
- ${[["comments", t("taskcard.tabComments", detail.comments.length)], ["log", t("taskcard.tabLog", detail.logs.length)], ["history", t("taskcard.tabHistory")]].map(([k, label]) =>
273
- html`<button key=${k} type="button" role="tab" aria-selected=${tab === k ? "true" : "false"} class=${`seg-item${tab === k ? " active" : ""}`} onClick=${() => setTab(k)}>${label}</button>`)}
431
+ <div class="tp-activity">
432
+ <${Timeline} detail=${detail} describe=${describeRow} cards=${cards} lead=${((projects || []).find((x) => x.id === card.projectId) || {}).leadInstance || null} />
433
+ ${can ? html`<${Composer} names=${mentionNames} assignee=${card.assignee} placeholder=${card.assignee ? t("taskcard.commentTo", card.assignee) : t("taskcard.commentHint")}
434
+ onSend=${(text) => run(() => boardApi.update(card.id, { comment: text }))} />` : null}
274
435
  </div>
275
- ${tab === "comments" ? html`<${Comments} entries=${detail.comments} card=${card} writable=${writable} onSend=${(text) => run(() => boardApi.update(card.id, { comment: text }))} />` : null}
276
- ${tab === "log" ? html`<ul class="tc-feed">${detail.logs.length ? detail.logs.map((e) => html`<li key=${e.id}><span class="muted">${relTime(e.at)}</span> <b>${e.author}</b> ${e.text}</li>`)
277
- : html`<li class="muted">${t("taskcard.noLog")}</li>`}</ul>` : null}
278
- ${tab === "history" ? html`<ul class="tc-feed">${[...detail.history].reverse().map((ev) => html`<li key=${ev.id}><span class="muted">${relTime(ev.at)}</span> <b>${ev.actor}</b> ${describeEvent(ev)}</li>`)}</ul>` : null}
279
436
  </div>
280
- </${Dialog}>`;
437
+ </div>`;
281
438
  }
282
439
 
440
+ /** A labelled row of the page's grid: the label in the first column, whatever it holds (a text, a list, an editor) in the second. */
283
441
  function Field({ title, tone, children }) {
284
- return html`<section class=${`tc-field${tone ? ` tone-${tone}` : ""}`}><h3>${title}</h3>${children}</section>`;
285
- }
286
-
287
- /**
288
- * Which version an edit started from: a save sends it, so an agent's newer write is caught (409). After a conflict
289
- * the next save of the same draft overwrites on purpose (null: no check).
290
- */
291
- function useEditBase(version) {
292
- const [base, setBase] = useState(version);
293
- return {
294
- start: () => setBase(version),
295
- current: () => (base === undefined ? version : base),
296
- afterSave: (outcome) => { if (outcome === "conflict") setBase(null); },
297
- };
298
- }
299
-
300
- /** Focus moves into an edit box as it opens (before the next key: Esc must reach the box, not the dialog). */
301
- function useAutoFocus(open) {
302
- const ref = useRef(null);
303
- useLayoutEffect(() => { if (open && ref.current) ref.current.focus(); }, [open]);
304
- return ref;
305
- }
306
-
307
- /** Esc leaves the edit, not the dialog. */
308
- function escapeEdit(e, cancel) {
309
- if (e.key !== "Escape") return false;
310
- e.preventDefault();
311
- e.stopPropagation();
312
- cancel();
313
- return true;
314
- }
315
-
316
- function InlineTitle({ value, version, onSave }) {
317
- const [draft, setDraft] = useState(null);
318
- const base = useEditBase(version);
319
- const ref = useAutoFocus(draft !== null);
320
- if (draft === null) {
321
- return html`<button type="button" class="tc-title" title=${t("taskcard.clickToEdit")} onClick=${() => { setDraft(value); base.start(); }}>${value}</button>`;
322
- }
323
- const commit = async () => {
324
- const v = draft.trim();
325
- if (!v || v === value) { setDraft(null); return; }
326
- const outcome = await onSave(v, base.current());
327
- base.afterSave(outcome);
328
- if (outcome === "ok") setDraft(null);
329
- };
330
- return html`<input class="tc-title-input" value=${draft} maxlength=${LIMIT.title} ref=${ref}
331
- onInput=${(e) => setDraft(e.target.value)} onBlur=${() => void commit()}
332
- onKeyDown=${(e) => { if (escapeEdit(e, () => setDraft(null))) return; if (e.key === "Enter") { e.preventDefault(); void commit(); } }} />`;
333
- }
334
-
335
- function EditableText({ value, limit, placeholder, version, readOnly = false, onSave }) {
336
- const [draft, setDraft] = useState(null);
337
- const [saving, setSaving] = useState(false);
338
- const base = useEditBase(version);
339
- const ref = useAutoFocus(draft !== null);
340
- if (readOnly) return html`<p class=${`tc-text${value ? "" : " empty"}`}>${value || "—"}</p>`;
341
- if (draft === null) {
342
- return html`<button type="button" class=${`tc-text${value ? "" : " empty"}`} title=${t("taskcard.clickToEdit")} onClick=${() => { setDraft(value); base.start(); }}>${value || placeholder || t("taskcard.empty")}</button>`;
343
- }
344
- const length = [...draft].length;
345
- const submit = async () => {
346
- if (saving) return;
347
- setSaving(true);
348
- const outcome = await onSave(draft.trim(), base.current());
349
- setSaving(false);
350
- base.afterSave(outcome);
351
- if (outcome === "ok") setDraft(null);
352
- };
353
- return html`<div class="tc-edit">
354
- <textarea rows=${Math.min(10, Math.max(3, draft.split("\n").length + 1))} value=${draft} ref=${ref}
355
- onInput=${(e) => setDraft(e.target.value)}
356
- onKeyDown=${(e) => { if (escapeEdit(e, () => setDraft(null))) return; if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { e.preventDefault(); void submit(); } }}></textarea>
357
- <div class="tc-edit-bar">
358
- <span class=${`tc-counter${length > limit ? " over" : ""}`}>${length}/${limit}</span>
359
- <span class="muted">${t("taskcard.ctrlEnter")}</span>
360
- <span class="tb-grow"></span>
361
- <button type="button" class="btn btn-sm" onClick=${() => setDraft(null)}>${t("taskcard.cancel")}</button>
362
- <button type="button" class="btn btn-primary btn-sm" disabled=${saving || length > limit} onClick=${submit}>${t("taskcard.save")}</button>
363
- </div></div>`;
364
- }
365
-
366
- function Checklist({ card, readOnly = false, onToggle, onReplace }) {
367
- const [draft, setDraft] = useState(null);
368
- // One tick at a time: each sends the version it saw, so a second tick before the first is saved would be refused.
369
- // The tick being saved shows as asked meanwhile (the box does not flick back until the card is read again).
370
- const [ticking, setTicking] = useState(null);
371
- const tick = async (n, done) => { setTicking({ n, done }); try { await onToggle(n, done); } finally { setTicking(null); } };
372
- const base = useEditBase(card.version);
373
- const ref = useAutoFocus(draft !== null);
374
- const start = (text) => { setDraft(text); base.start(); };
375
- if (draft !== null) {
376
- const items = draft.split("\n").map((l) => l.trim()).filter(Boolean);
377
- const save = async () => {
378
- const outcome = await onReplace(items, base.current());
379
- base.afterSave(outcome);
380
- if (outcome === "ok") setDraft(null);
381
- };
382
- return html`<div class="tc-edit">
383
- <textarea rows=${Math.max(3, items.length + 1)} value=${draft} ref=${ref}
384
- onInput=${(e) => setDraft(e.target.value)}
385
- onKeyDown=${(e) => { if (escapeEdit(e, () => setDraft(null))) return; if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { e.preventDefault(); void save(); } }}></textarea>
386
- <div class="tc-edit-bar">
387
- <span class=${`tc-counter${items.length > LIMIT.acceptanceItems ? " over" : ""}`}>${t("taskcard.items", items.length, LIMIT.acceptanceItems)}</span>
388
- <span class="muted">${t("taskcard.onePerLine")}</span>
389
- <span class="tb-grow"></span>
390
- <button type="button" class="btn btn-sm" onClick=${() => setDraft(null)}>${t("taskcard.cancel")}</button>
391
- <button type="button" class="btn btn-primary btn-sm" disabled=${items.length > LIMIT.acceptanceItems} onClick=${save}>${t("taskcard.save")}</button>
392
- </div></div>`;
393
- }
394
- if (!card.acceptance.length) return readOnly ? html`<p class="tc-text empty">—</p>` : html`<button type="button" class="tc-text empty" onClick=${() => start("")}>${t("taskcard.checklistEmpty")}</button>`;
395
- return html`<ul class="tc-checklist">${card.acceptance.map((a, i) => html`<li key=${`${i}-${a.text}`}><label class="tb-check">
396
- <input type="checkbox" checked=${ticking && ticking.n === i + 1 ? ticking.done : a.done} disabled=${readOnly || !!ticking} onChange=${() => void tick(i + 1, !a.done)} /><span class=${a.done ? "done" : ""}>${a.text}</span></label></li>`)}</ul>
397
- ${readOnly ? null : html`<button type="button" class="btn btn-ghost btn-sm" onClick=${() => start(card.acceptance.map((a) => a.text).join("\n"))}>${t("taskcard.editList")}</button>`}`;
398
- }
399
-
400
- function QuickAdd({ placeholder, onAdd }) {
401
- const [title, setTitle] = useState("");
402
- const busy = useRef(false);
403
- return html`<input class="tc-quick-add" value=${title} placeholder=${placeholder} aria-label=${placeholder} maxlength=${LIMIT.title}
404
- onInput=${(e) => setTitle(e.target.value)}
405
- onKeyDown=${async (e) => {
406
- if (e.key !== "Enter" || !title.trim() || busy.current) return;
407
- e.preventDefault();
408
- busy.current = true;
409
- if ((await onAdd(title.trim())) === "ok") setTitle("");
410
- busy.current = false;
411
- }} />`;
412
- }
413
-
414
- function Comments({ entries, card, writable = true, onSend }) {
415
- const [text, setText] = useState("");
416
- const [sending, setSending] = useState(false);
417
- const busy = useRef(false);
418
- const send = async () => {
419
- if (!text.trim() || busy.current) return;
420
- busy.current = true;
421
- setSending(true);
422
- if ((await onSend(text.trim())) === "ok") setText("");
423
- setSending(false);
424
- busy.current = false;
425
- };
426
- return html`<div class="tc-comments">
427
- ${entries.length ? null : html`<p class="muted">${t("taskcard.noComments")}</p>`}
428
- ${entries.map((e) => html`<div key=${e.id} class=${`tc-comment${e.authorKind === "person" ? " person" : ""}`}>
429
- <div class="tc-comment-head"><b>${e.author}</b>
430
- ${e.kind === "reject" ? html`<span class="tb-tag st-blocked">${t("taskcard.rejectTag")}</span>` : null}
431
- ${e.kind === "approve" ? html`<span class="tb-tag st-done">${t("taskcard.approveTag")}</span>` : null}
432
- <span class="muted">${relTime(e.at)}</span></div>
433
- <div class="tc-comment-body">${e.text}</div></div>`)}
434
- ${writable ? html`<div class="tc-composer">
435
- <textarea rows="2" value=${text} placeholder=${card.assignee ? t("taskcard.commentTo", card.assignee) : t("taskcard.commentHint")} aria-label=${t("taskcard.commentHint")}
436
- onInput=${(e) => setText(e.target.value)}
437
- onKeyDown=${(e) => { if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); e.currentTarget.blur(); return; } if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { e.preventDefault(); void send(); } }}></textarea>
438
- <button type="button" class="btn btn-primary btn-sm" disabled=${sending || !text.trim()} onClick=${send}>${t("taskcard.send")}</button>
439
- </div>` : null}</div>`;
442
+ return html`<section class=${`tc-field${tone ? ` tone-${tone}` : ""}`}><h3>${title}</h3><div class="tc-field-body">${children}</div></section>`;
440
443
  }