rvlib-shipkit 2.31.0 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/package.json +1 -1
  3. package/src/advisors/acts.ts +16 -15
  4. package/src/advisors/advice.ts +56 -102
  5. package/src/advisors/advisor-view.ts +98 -73
  6. package/src/advisors/app-graph.ts +1 -1
  7. package/src/advisors/app.ts +3 -11
  8. package/src/advisors/cf-api.ts +1 -1
  9. package/src/advisors/dir-bucket.ts +4 -3
  10. package/src/advisors/edge/api.ts +26 -198
  11. package/src/advisors/edge/bucket.ts +2 -2
  12. package/src/advisors/edge/handler.ts +13 -155
  13. package/src/advisors/edge/here.ts +5 -5
  14. package/src/advisors/edge/pages.ts +12 -9
  15. package/src/advisors/edge/shell.ts +6 -5
  16. package/src/advisors/edge/sign-in.ts +101 -36
  17. package/src/advisors/edge/status.ts +19 -6
  18. package/src/advisors/edge/types.ts +36 -60
  19. package/src/advisors/expose.ts +29 -29
  20. package/src/advisors/here.ts +12 -12
  21. package/src/advisors/invite-send.ts +79 -35
  22. package/src/advisors/invite.ts +31 -8
  23. package/src/advisors/job.ts +24 -16
  24. package/src/advisors/login.ts +40 -15
  25. package/src/advisors/owner-store.ts +46 -22
  26. package/src/advisors/photos.ts +3 -3
  27. package/src/advisors/project.ts +25 -23
  28. package/src/advisors/reach.ts +89 -0
  29. package/src/advisors/rights.ts +1 -1
  30. package/src/advisors/routes.ts +55 -74
  31. package/src/advisors/scan.ts +0 -4
  32. package/src/advisors/setup-run.ts +14 -14
  33. package/src/advisors/share-trace.ts +3 -3
  34. package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
  35. package/src/advisors/speaks.ts +29 -0
  36. package/src/advisors/sync.ts +92 -182
  37. package/src/advisors/tunnel.ts +6 -5
  38. package/src/advisors/users-listen.ts +92 -0
  39. package/src/advisors/users-router.ts +257 -85
  40. package/src/advisors/users-store.ts +81 -0
  41. package/src/agent-time/blocked-scan.ts +181 -0
  42. package/src/agent-time/registry.ts +12 -5
  43. package/src/agent-time/store.ts +9 -109
  44. package/src/asks/ask-bar-fold.ts +2 -1
  45. package/src/asks/ask-close.ts +2 -1
  46. package/src/asks/ask-doc.ts +2 -1
  47. package/src/asks/ask-migrate.ts +3 -2
  48. package/src/asks/ask-steps-fold.ts +2 -1
  49. package/src/asks/ask-store.ts +4 -3
  50. package/src/check.ts +3 -43
  51. package/src/checks/SK001-package-json-shape.check.ts +4 -55
  52. package/src/checks/SK004-gitignore-policy.check.ts +24 -69
  53. package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
  54. package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
  55. package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
  56. package/src/checks/SK020-self-spawning-check.check.ts +5 -7
  57. package/src/checks/SK035-public-clean.check.ts +1 -1
  58. package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
  59. package/src/checks/SK042-post-kinds.check.ts +5 -14
  60. package/src/checks/SK054-agent-allow-list.check.ts +5 -74
  61. package/src/checks/SK055-retired-config-keys.check.ts +45 -0
  62. package/src/cli/cmd_Advisors.ts +11 -45
  63. package/src/cli/cmd_Asks.ts +3 -10
  64. package/src/cli/cmd_Backup.ts +25 -127
  65. package/src/cli/cmd_BackupTargets.ts +1 -1
  66. package/src/cli/cmd_Checks.ts +0 -14
  67. package/src/cli/cmd_Db.ts +3 -82
  68. package/src/cli/cmd_Home.ts +4 -32
  69. package/src/cli/cmd_Hq.ts +0 -17
  70. package/src/cli/cmd_Releases.ts +57 -4
  71. package/src/cli/cmd_Review.ts +333 -354
  72. package/src/cli/cmd_SocialDrafts.ts +6 -13
  73. package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
  74. package/src/cli/cmd_Time.ts +1 -1
  75. package/src/cli/cmd_Trailer.ts +1 -1
  76. package/src/cli/inbox-hook-run.ts +5 -23
  77. package/src/cli/registry-heads.ts +5 -55
  78. package/src/cli/registry.ts +1 -5
  79. package/src/cli/review-here.ts +1 -1
  80. package/src/cli.ts +2 -2
  81. package/src/collections/collection-types.ts +1 -1
  82. package/src/collections/review.ts +5 -4
  83. package/src/core/agent-allow-policy.ts +32 -2
  84. package/src/core/agent-env.ts +8 -0
  85. package/src/core/allow-rows.ts +74 -0
  86. package/src/core/check-file-names.ts +19 -106
  87. package/src/core/footprint.ts +17 -13
  88. package/src/core/identities-root.ts +1 -4
  89. package/src/core/layout.ts +1 -2
  90. package/src/core/machine-db.ts +33 -208
  91. package/src/core/machine-layout.ts +14 -127
  92. package/src/core/mask-source.ts +60 -0
  93. package/src/core/memory-watch.ts +17 -14
  94. package/src/core/motherhome.ts +8 -35
  95. package/src/core/one-way-in-policy.ts +0 -3
  96. package/src/core/repo-walk.ts +0 -9
  97. package/src/core/retention.ts +1 -9
  98. package/src/core/retired-checks.ts +2 -0
  99. package/src/core/tmux-policy.ts +1 -1
  100. package/src/core/tree-watch.ts +2 -2
  101. package/src/core/when.ts +7 -45
  102. package/src/gate/discover-checks.ts +42 -32
  103. package/src/gate/gate-checks.ts +21 -131
  104. package/src/gate/pre-commit-discovery.ts +16 -25
  105. package/src/gate/run-check.ts +0 -4
  106. package/src/gate/run-fix.ts +5 -17
  107. package/src/gate/run-fixers.ts +6 -42
  108. package/src/home/app-sign.ts +2 -2
  109. package/src/home/backup-status.ts +52 -92
  110. package/src/home/backup-verdict.ts +2 -2
  111. package/src/home/daemon-jobs.ts +51 -95
  112. package/src/home/database-words.ts +1 -2
  113. package/src/home/databases.ts +9 -25
  114. package/src/home/home-launchd.ts +0 -6
  115. package/src/home/home-paths.ts +8 -4
  116. package/src/home/home-routes.ts +3 -10
  117. package/src/home/home-state.ts +2 -14
  118. package/src/home/inbox-shape.ts +14 -15
  119. package/src/home/inbox.ts +1 -1
  120. package/src/home/machine-repair.ts +102 -103
  121. package/src/home/resume.ts +1 -15
  122. package/src/home/run-daemon.ts +4 -11
  123. package/src/home/space-page.ts +3 -2
  124. package/src/home/supervise.ts +3 -7
  125. package/src/hooks/hook-config.ts +6 -7
  126. package/src/hooks/leak-guard.ts +1 -1
  127. package/src/hooks/run-hooks.ts +0 -5
  128. package/src/hq/daemon-db.ts +8 -8
  129. package/src/hq/door.ts +3 -16
  130. package/src/hq/hq-db.ts +4 -3
  131. package/src/hq/hq-local.ts +1 -2
  132. package/src/hq/hq-store.ts +0 -15
  133. package/src/hq/item-direct.ts +8 -10
  134. package/src/hq/item-fill.ts +37 -0
  135. package/src/hq/kinds/item-gone.ts +7 -10
  136. package/src/hq/kinds/item-msg.ts +12 -18
  137. package/src/hq/kinds/item.ts +13 -19
  138. package/src/hq/kinds/report.ts +3 -4
  139. package/src/hq/owner-switch.ts +3 -3
  140. package/src/hq/report.ts +5 -9
  141. package/src/hq/switch.ts +2 -11
  142. package/src/hq/thread-sync.ts +5 -17
  143. package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
  144. package/src/http/owner-word.ts +1 -1
  145. package/src/identities/machine.ts +16 -0
  146. package/src/init-repo.ts +0 -1
  147. package/src/ledger/check-stats.ts +6 -5
  148. package/src/ledger/db.ts +2 -4
  149. package/src/ledger/record-kept.ts +117 -48
  150. package/src/ledger/run-log.ts +21 -2
  151. package/src/ledger/slow-tests.ts +96 -0
  152. package/src/ledger/store.ts +3 -86
  153. package/src/ledger/suite-log.ts +8 -2
  154. package/src/media-store/backup/facts.ts +3 -37
  155. package/src/media-store/backup/keys.ts +1 -8
  156. package/src/media-store/backup/manifest.ts +6 -67
  157. package/src/media-store/backup/restore.ts +4 -13
  158. package/src/media-store/backup/retention.ts +13 -1
  159. package/src/media-store/backup/run.ts +6 -267
  160. package/src/media-store/backup/snapshot.ts +2 -38
  161. package/src/media-store/backup/sources.ts +3 -113
  162. package/src/media-store/backup/target-send.ts +5 -29
  163. package/src/media-store/db.ts +8 -7
  164. package/src/media-store/forget-one.ts +1 -1
  165. package/src/media-store/forget.ts +1 -80
  166. package/src/orchestrator/guards.ts +0 -1
  167. package/src/orchestrator/presence.ts +2 -2
  168. package/src/orchestrator/routes.ts +1 -1
  169. package/src/orchestrator/started.ts +0 -9
  170. package/src/orchestrator/talk-key.ts +3 -4
  171. package/src/orchestrator/unheard.ts +1 -1
  172. package/src/recordings/edit.ts +3 -3
  173. package/src/recordings/marks-draw.ts +17 -6
  174. package/src/recordings/marks.ts +120 -9
  175. package/src/reflections/reflections-queue.ts +3 -10
  176. package/src/release/notes.ts +1 -1
  177. package/src/release/public-clean.ts +66 -6
  178. package/src/release/run-bump.ts +11 -0
  179. package/src/release/run-release.ts +4 -0
  180. package/src/releases/from-thread.ts +3 -3
  181. package/src/releases/model.ts +186 -36
  182. package/src/releases/store.ts +13 -3
  183. package/src/releases/validate.ts +83 -0
  184. package/src/repo-config.ts +29 -64
  185. package/src/review/answer-kinds.ts +61 -4
  186. package/src/review/blocked-guard.ts +11 -0
  187. package/src/review/blocked-object.ts +298 -0
  188. package/src/review/cells.ts +116 -229
  189. package/src/review/close.ts +39 -1
  190. package/src/review/doc-save.ts +3 -2
  191. package/src/review/draft-item.ts +1 -1
  192. package/src/review/events.ts +3 -7
  193. package/src/review/expect.ts +23 -39
  194. package/src/review/format.ts +79 -46
  195. package/src/review/glyphs.ts +1 -0
  196. package/src/review/hand-over.ts +3 -3
  197. package/src/review/heard.ts +1 -1
  198. package/src/review/holds-sync.ts +2 -1
  199. package/src/review/inbox-hook.ts +2 -2
  200. package/src/review/inbox-read.ts +39 -33
  201. package/src/review/instruction-guards.ts +12 -0
  202. package/src/review/instructions.ts +0 -1
  203. package/src/review/item-db.ts +13 -43
  204. package/src/review/item-hq.ts +2 -2
  205. package/src/review/item-rows.ts +3 -14
  206. package/src/review/kind-catalog.ts +3 -1
  207. package/src/review/kinds.ts +18 -8
  208. package/src/review/live-view.ts +3 -0
  209. package/src/review/media-kind.ts +1 -1
  210. package/src/review/mentions.ts +1 -2
  211. package/src/review/model.ts +158 -114
  212. package/src/review/move.ts +149 -0
  213. package/src/review/need-threads.ts +3 -2
  214. package/src/review/object-card.ts +11 -0
  215. package/src/review/object-read.ts +6 -1
  216. package/src/review/one-block.ts +1 -1
  217. package/src/review/owner-read.ts +1 -1
  218. package/src/review/phone-push.ts +10 -9
  219. package/src/review/previews.ts +32 -4
  220. package/src/review/push.ts +2 -2
  221. package/src/review/recap.ts +129 -0
  222. package/src/review/referring.ts +6 -3
  223. package/src/review/reflection-object.ts +4 -3
  224. package/src/review/routes.ts +49 -19
  225. package/src/review/secret-route.ts +3 -2
  226. package/src/review/settle.ts +0 -6
  227. package/src/review/snooze.ts +5 -3
  228. package/src/review/speaker.ts +68 -0
  229. package/src/review/start-title.ts +19 -0
  230. package/src/review/store.ts +86 -59
  231. package/src/review/{wakes.ts → thread-events.ts} +92 -7
  232. package/src/review/thread-md.ts +35 -14
  233. package/src/review/thread-state.ts +798 -0
  234. package/src/review/threads.ts +29 -347
  235. package/src/review/traces.ts +104 -7
  236. package/src/review/trailer-item.ts +1 -1
  237. package/src/review/unit.ts +7 -9
  238. package/src/review/verdict-items.ts +12 -10
  239. package/src/review/view-layout.ts +25 -1
  240. package/src/review/watch-feed.ts +1 -2
  241. package/src/review/working-guards.ts +2 -3
  242. package/src/rules/untrack-generated.ts +1 -15
  243. package/src/secrets/lapse.ts +2 -1
  244. package/src/serve/hub-app/advisor-app.tsx +4 -4
  245. package/src/serve/hub-app/advisor-face.tsx +9 -3
  246. package/src/serve/hub-app/advisor-host.ts +27 -27
  247. package/src/serve/hub-app/advisors-model.ts +17 -8
  248. package/src/serve/hub-app/advisors-rights.tsx +1 -1
  249. package/src/serve/hub-app/advisors-st.ts +15 -14
  250. package/src/serve/hub-app/advisors-view.tsx +13 -11
  251. package/src/serve/hub-app/app-bridge.ts +23 -3
  252. package/src/serve/hub-app/asks-page.tsx +1 -1
  253. package/src/serve/hub-app/auto-text.tsx +71 -16
  254. package/src/serve/hub-app/check-view.tsx +0 -8
  255. package/src/serve/hub-app/controls.css +14 -3
  256. package/src/serve/hub-app/database-view.tsx +1 -2
  257. package/src/serve/hub-app/git-view.tsx +3 -1
  258. package/src/serve/hub-app/hub.css +12 -5
  259. package/src/serve/hub-app/icons.tsx +1 -1
  260. package/src/serve/hub-app/inbox-view.tsx +1 -2
  261. package/src/serve/hub-app/live-sources.ts +2 -2
  262. package/src/serve/hub-app/main-panel.tsx +2 -1
  263. package/src/serve/hub-app/panel-repo.ts +0 -9
  264. package/src/serve/hub-app/pic.tsx +29 -12
  265. package/src/serve/hub-app/polled.ts +16 -2
  266. package/src/serve/hub-app/recordings-st.ts +23 -2
  267. package/src/serve/hub-app/recordings-view.tsx +68 -10
  268. package/src/serve/hub-app/ref-pill.ts +1 -1
  269. package/src/serve/hub-app/repo-st.ts +1 -2
  270. package/src/serve/hub-app/review/advisor-add.tsx +1 -1
  271. package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
  272. package/src/serve/hub-app/review/draft-body.tsx +2 -2
  273. package/src/serve/hub-app/review/heard-line.tsx +1 -1
  274. package/src/serve/hub-app/review/instructions-view.tsx +1 -8
  275. package/src/serve/hub-app/review/kind-states.tsx +14 -9
  276. package/src/serve/hub-app/review/kit.tsx +4 -11
  277. package/src/serve/hub-app/review/lane-bar.tsx +3 -3
  278. package/src/serve/hub-app/review/lightbox.tsx +15 -11
  279. package/src/serve/hub-app/review/line-window.ts +4 -1
  280. package/src/serve/hub-app/review/live-bar-st.ts +2 -2
  281. package/src/serve/hub-app/review/live-view.tsx +57 -1
  282. package/src/serve/hub-app/review/object-panel.tsx +20 -8
  283. package/src/serve/hub-app/review/question-views.tsx +181 -54
  284. package/src/serve/hub-app/review/recap-bar.tsx +40 -0
  285. package/src/serve/hub-app/review/request-cell.tsx +48 -0
  286. package/src/serve/hub-app/review/review-cells.tsx +154 -96
  287. package/src/serve/hub-app/review/review-host.ts +2 -2
  288. package/src/serve/hub-app/review/review-kit.ts +17 -11
  289. package/src/serve/hub-app/review/review-list.tsx +23 -31
  290. package/src/serve/hub-app/review/review-st.ts +30 -40
  291. package/src/serve/hub-app/review/review-thread.tsx +139 -85
  292. package/src/serve/hub-app/review/review-views.tsx +124 -68
  293. package/src/serve/hub-app/review/share-lines.tsx +4 -4
  294. package/src/serve/hub-app/review/start-st.ts +2 -5
  295. package/src/serve/hub-app/review/superseded-runs.ts +4 -3
  296. package/src/serve/hub-app/review/thread-close.tsx +10 -7
  297. package/src/serve/hub-app/review/thread-st.ts +372 -201
  298. package/src/serve/hub-app/review/tone-bar.tsx +126 -0
  299. package/src/serve/hub-app/review/tones.ts +35 -0
  300. package/src/serve/hub-app/review/trailer-body.tsx +2 -2
  301. package/src/serve/hub-app/review/trailer-st.ts +3 -2
  302. package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
  303. package/src/serve/hub-app/review.css +180 -106
  304. package/src/serve/hub-app/search-view.tsx +1 -1
  305. package/src/serve/hub-app/social/social-model.ts +0 -4
  306. package/src/serve/hub-app/source-acts.ts +2 -1
  307. package/src/serve/hub-app/stores/stores-page.tsx +2 -2
  308. package/src/serve/hub-app/terminal-sources.tsx +2 -1
  309. package/src/serve/hub-app/thread-row.tsx +3 -4
  310. package/src/serve/hub-app/tree-build.ts +0 -4
  311. package/src/serve/hub-app/urls-view.tsx +2 -1
  312. package/src/serve/hub-app/view-layout.css +13 -3
  313. package/src/serve/hub-app/wikis-view.tsx +5 -2
  314. package/src/serve/hub-runtime.ts +7 -37
  315. package/src/serve/project-gutter-route.ts +6 -2
  316. package/src/serve/read-thread.ts +20 -2
  317. package/src/serve/read-worker.ts +9 -1
  318. package/src/serve/record-pages.ts +46 -0
  319. package/src/serve/serve-hub.ts +2 -2
  320. package/src/serve/terminal-host.ts +1 -1
  321. package/src/serve/terminal-route.ts +1 -3
  322. package/src/serve/tracked-watch.ts +1 -3
  323. package/src/setup-house.ts +2 -2
  324. package/src/shipkit-files.ts +1 -1
  325. package/src/shipkit.ts +1 -6
  326. package/src/shot/film-box.ts +0 -20
  327. package/src/social/drafts.ts +1 -1
  328. package/src/social/kinds.ts +6 -29
  329. package/src/social/load.ts +2 -2
  330. package/src/social/post-object.ts +3 -2
  331. package/src/social/release-stage.ts +1 -1
  332. package/src/social/stage.ts +2 -2
  333. package/src/stores/model.ts +4 -0
  334. package/src/stores/routes.ts +11 -3
  335. package/src/suite/judge-suites.ts +58 -0
  336. package/src/suite/red-alone.ts +54 -18
  337. package/src/suite/runner-shapes.ts +2 -2
  338. package/src/suite/suite-cli.ts +67 -14
  339. package/src/suite/test-units.ts +2 -1
  340. package/src/urls/fill.ts +1 -1
  341. package/src/urls/places.ts +1 -2
  342. package/src/vault/vault-config.ts +2 -2
  343. package/src/vault/vault-init.ts +1 -5
  344. package/src/wiki/graph-page.ts +14 -2
  345. package/src/advisors/copy-truth.ts +0 -49
  346. package/src/advisors/door-child.ts +0 -112
  347. package/src/advisors/door-serve.ts +0 -52
  348. package/src/advisors/door.ts +0 -118
  349. package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
  350. package/src/checks/SK029-explicit-check-files.check.ts +0 -112
  351. package/src/checks/SK048-one-local-file.check.ts +0 -36
  352. package/src/core/config-rewrite.ts +0 -111
  353. package/src/core/daemon-port.ts +0 -10
  354. package/src/core/legacy-shapes.ts +0 -263
  355. package/src/core/migrate-layout.ts +0 -638
  356. package/src/core/port-check-cli.ts +0 -52
  357. package/src/core/port-check-file.ts +0 -295
  358. package/src/core/port-check-files.ts +0 -31
  359. package/src/gate/discover-legacy-checks.ts +0 -26
  360. package/src/home/home-move.ts +0 -527
  361. package/src/home/machine-fold.ts +0 -810
  362. package/src/hq/item-shapes.ts +0 -54
  363. package/src/hq/kinds/items-read.ts +0 -4
  364. package/src/media-store/backup/daemon.ts +0 -220
  365. package/src/media-store/backup/kept.ts +0 -241
  366. package/src/media-store/backup/prune.ts +0 -359
  367. package/src/media-store/backup/secret.ts +0 -88
  368. package/src/media-store/backup/ssh-space.ts +0 -202
  369. package/src/media-store/backup/watch.ts +0 -117
  370. package/src/review/band.ts +0 -182
  371. package/src/review/folders.ts +0 -216
  372. package/src/review/hook-ask.ts +0 -58
  373. package/src/review/role.ts +0 -48
  374. package/src/review/thread-fold.ts +0 -64
  375. package/src/review/wait.ts +0 -91
  376. package/src/rules/rule.ts +0 -43
  377. package/src/serve/hook-thread.ts +0 -37
  378. package/src/serve/hook-work.ts +0 -92
  379. package/src/serve/hook-worker.ts +0 -57
  380. package/src/serve/hub-app/review/dock.tsx +0 -147
  381. package/src/serve/hub-app/review/faces.tsx +0 -18
  382. package/src/serve/hub-app/review/item-verdict.tsx +0 -112
  383. package/src/serve/hub-app/review/review-board.tsx +0 -48
  384. /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
@@ -3,11 +3,10 @@
3
3
  // newest version (rectangles, reactions, stars, the pick, his word), each clip's clock. Made when a thread opens,
4
4
  // disposed when another one does. Only the newest version takes his marks: an older one shows what was said on it
5
5
  import { compareShallow, computed, computedStruct, makeAutoObservable, observableRef, runInAction } from 'mobx'
6
- import { bandOf, validatedOf } from '../../../review/band.ts'
7
- import { expectOf, waitLinesOf, type Expect } from '../../../review/expect.ts'
6
+ import { waitLinesOf } from '../../../review/expect.ts'
8
7
  import type { WordRefs } from '../word-refs.ts'
9
- import { waitsOnOwner, type Backlink, type Cell, type EventCell, type NoteCell, type ReplyCell, type ThreadView, type VerdictCell, type VersionCell } from '../../../review/cells.ts'
10
- import type { Trace } from '../../../review/traces.ts'
8
+ import { viewHolderOf, waitsOnOwner, type Backlink, type Cell, type EventCell, type NoteCell, type ReplyCell, type ThreadView, type VerdictCell, type VersionCell } from '../../../review/cells.ts'
9
+ import { foldQuiet, quietOf, type QuietPiece, type Trace } from '../../../review/traces.ts'
11
10
  import type { ShareEvent } from '../../../advisors/share-trace.ts'
12
11
  import {
13
12
  asOptions,
@@ -36,19 +35,22 @@ import { MentionSt, partyJump } from './mention-st.ts'
36
35
  import type { RefBox } from '../auto-text.tsx'
37
36
  import { PicturesSt } from './pictures-st.ts'
38
37
  import { ClipSt } from './clip-st.ts'
39
- import { answeredAs, postJson, READ_MS } from './review-kit.ts'
38
+ import { answeredAs, movedOfError, postJson, READ_MS } from './review-kit.ts'
39
+ import { reach } from '../reach.ts'
40
40
  import type { ReviewSt } from './review-st.ts'
41
41
  import type { ThreadBarSt } from '../advisors-st.ts'
42
42
  import { ADVISOR_WHO, type ReviewAct } from './review-host.ts'
43
43
  import { TrailerSt } from './trailer-st.ts'
44
44
  import { laneNotes, notesNow, sortedDraft, type LaneNote } from '../../../review/trailer-notes.ts'
45
45
  import { ITEM_VERDICTS, type ItemVerdict } from '../../../review/verdict-items.ts'
46
+ import { toneOfStatus } from './tones.ts'
46
47
  import { versionActs } from '../../../review/settle.ts'
47
48
  import type { LaneMark } from '../../../review/trailer-model.ts'
48
49
  import { KeptFolds } from '../kept-folds.ts'
49
50
  import { foldSuperseded, runOf } from './superseded-runs.ts'
50
51
  import { fixReactions, spotWords, versionFix, versionObject, type ReplyOn, type Spot } from '../../../review/one-block.ts'
51
52
  import { findLast } from '../../../core/es2022.ts'
53
+ import { bandOf, mootAt } from '../../../review/thread-state.ts'
52
54
 
53
55
 
54
56
  /** what the object panel shows: the object a message links (its cell, its address), a loose picture, or a cell's
@@ -66,6 +68,8 @@ const EMPTY: Draft = { rects: [], comment: '' }
66
68
 
67
69
  /** a draft's marks, its words left out */
68
70
  type Marks = Pick<Draft, 'rects' | 'reactions' | 'pick'>
71
+ /** his click on a kind's action, on its way or answered: `why` the store's refusal */
72
+ export type ActState = { name: string; state: 'sending' | 'sent' | 'failed'; why?: string }
69
73
  const sameMarks = (a: Marks, b: Marks): boolean => a.rects === b.rects && a.reactions === b.reactions && a.pick === b.pick
70
74
 
71
75
  const isDirty = (d: Draft | undefined): boolean => d !== undefined && (d.rects.length > 0 || d.comment.trim() !== '' || (d.reactions ?? []).length > 0 || d.pick !== undefined)
@@ -82,8 +86,46 @@ export type TileFilter = (typeof TILE_FILTERS)[number]
82
86
  export type Traced = (EventCell | VerdictCell) & { trace: Trace; share?: ShareEvent; backlink?: Backlink }
83
87
 
84
88
  /** one line of the thread as drawn: a day's divider, a run of traces, a framed cell, or a run of items a newer one
85
- * superseded, one quiet line that opens to show them (superseded-runs.ts): `key` its first cell, `n` its items */
86
- export type Line = { kind: 'day'; day: string } | { kind: 'events'; cells: Traced[] } | { kind: 'cell'; cell: Framed } | { kind: 'superseded'; key: string; n: number; words: string; lines: Line[] }
89
+ * superseded, one quiet line that opens to show them (superseded-runs.ts): `key` its first cell, `n` its items;
90
+ * `recap`: the run is everything before the recap he accepted */
91
+ export type Line = { kind: 'day'; day: string } | { kind: 'events'; cells: Traced[] } | { kind: 'cell'; cell: Framed } | { kind: 'superseded'; key: string; n: number; words: string; recap?: true; lines: Line[] }
92
+
93
+ /** one trace line as drawn: the same trace in a row said once, `n` times, from `c` to `last` */
94
+ export interface TraceRun {
95
+ c: Traced
96
+ n: number
97
+ last: Traced
98
+ }
99
+
100
+ /** a run of traces as drawn (review-cells.tsx TraceLines): the same trace in a row one line, then two or more quiet lines
101
+ * in a row one fold, its key its first cell */
102
+ export function traceRunsOf(cells: readonly Traced[]): QuietPiece<TraceRun>[] {
103
+ const runs: TraceRun[] = []
104
+ for (const c of cells) {
105
+ const run = runs.at(-1)
106
+ if (run && run.c.summary === c.summary) {
107
+ run.n++
108
+ run.last = c
109
+ } else runs.push({ c, n: 1, last: c })
110
+ }
111
+ return foldQuiet(runs, (r) => quietOf(r.c.trace))
112
+ }
113
+
114
+ /** the key of a fold of quiet trace lines: its first cell */
115
+ export const quietKey = (first: TraceRun): string => `quiet:${first.c.id}`
116
+
117
+ /** the fold of quiet trace lines a cell sits in, by its key; null when it sits in none */
118
+ export function quietFoldOf(lines: readonly Line[], cell: string): string | null {
119
+ for (const l of lines) {
120
+ const inner = l.kind === 'superseded' ? quietFoldOf(l.lines, cell) : null
121
+ if (inner !== null) return inner
122
+ const at = l.kind === 'events' ? l.cells.findIndex((c) => c.id === cell) : -1
123
+ if (l.kind !== 'events' || at < 0) continue
124
+ // a fold's lines are its cells in a row, first to last
125
+ for (const p of traceRunsOf(l.cells)) if ('fold' in p && at >= l.cells.indexOf(p.fold[0]!.c) && at <= l.cells.indexOf(p.fold.at(-1)!.last)) return quietKey(p.fold[0]!)
126
+ }
127
+ return null
128
+ }
87
129
 
88
130
  /** one item of the contents strip: a cell, or one view of a version, and the key a click unfolds */
89
131
  export interface Entry {
@@ -117,52 +159,42 @@ export interface SaidNote {
117
159
 
118
160
  /** the dom id of a cell and of a view of a version: a message id carries a slash */
119
161
  export const cellDom = (id: string): string => `rvc-${id.replace(/[^A-Za-z0-9-]/g, '_')}`
120
- /** a step of an ask's instructions in the timeline, where the dock's reminder jumps */
162
+ /** a step of an ask's instructions in the timeline */
121
163
  export const stepDom = (cell: string, step: number): string => `${cellDom(cell)}-s${step}`
122
164
  export const viewDom = (id: string, view: number): string => `${cellDom(id)}-v${view}`
123
165
  export const viewKey = (id: string, view: number): string => `${id}#${view}`
124
166
  /** one message's block in a draft version */
125
167
  export const postDom = (id: string, key: string): string => `${cellDom(id)}-p-${key.replace(/[^a-z0-9-]/gi, '_')}`
126
- export const dockDom = (id: string): string => `rvd-${id.replace(/[^A-Za-z0-9-]/g, '_')}`
127
168
 
128
- const ASK_WORD: Record<NonNullable<NonNullable<ReplyCell['ask']>['kind']>, string> = { choice: 'question', checklist: 'checklist', confirm: 'a step to do', text: 'question', url: 'a link', secret: 'a secret', file: 'a file' }
129
-
130
- /** what kind of request a cell makes, in a word */
131
- export const requestWord = (c: ReplyCell): string => (c.propose ? 'proposed change' : c.ask === undefined && c.judge ? 'your verdict' : c.instructions ? 'steps' : ASK_WORD[c.ask?.kind ?? 'choice'])
132
-
133
- /** his answer on a question or a change, in one line; a secret says where it is stored, never a byte of it */
134
- /** where a question or a change stands in its cell: orange while it waits on the owner, green once answered, grey when
135
- * a newer one superseded it or the thread's close ended it unanswered */
136
- export const requestState = (c: ReplyCell, waiting: boolean): 'superseded' | 'waiting' | 'moot' | 'answered' =>
137
- c.superseded ? 'superseded' : waiting ? 'waiting' : c.moot ? 'moot' : 'answered'
169
+ /** where a question or a change stands in its cell: orange while it waits on the owner, green once answered, plain when
170
+ * a newer one superseded it, the thread's close ended it unanswered, or he left it unanswered (« no answer ») */
171
+ export const requestState = (c: ReplyCell, waiting: boolean): 'superseded' | 'waiting' | 'moot' | 'no-answer' | 'answered' =>
172
+ c.superseded ? 'superseded' : waiting ? 'waiting' : c.moot ? 'moot' : c.ask?.tone === 'no-answer' ? 'no-answer' : 'answered'
138
173
 
139
174
  /** the owner's answer on a choice's row: the option clicked, else the owner's words alone, one more option at the
140
175
  * row's end; null while none */
141
176
  export const ownerChoice = (a: NonNullable<ReplyCell['ask']>): { option: number } | { words: string } | null =>
142
177
  a.answered ? { option: a.answered.option } : a.none !== undefined ? { words: a.none } : null
143
178
 
144
- export function answeredWords(c: ReplyCell): string {
145
- const p = c.propose
146
- if (p) {
147
- const n = p.fields.filter((f) => f.applied).length
148
- return n === 0 ? 'with words' : n === p.fields.length ? (n === 1 ? `applied ${p.fields[0]!.key}` : `applied all ${n}`) : `applied ${n} of ${p.fields.length}, then words`
149
- }
150
- const a = c.ask
151
- if (!a) return ''
152
- if (a.answered) {
153
- // the answer's text is the option's label, then the owner's words after « : » when there are some
154
- const label = a.options[a.answered.option] ?? `option ${a.answered.option + 1}`
155
- const t = a.answered.text
156
- const words = t === label ? '' : t.startsWith(`${label}: `) ? t.slice(label.length + 2) : t
157
- return `${label}${words ? ` · « ${words} »` : ''}`
158
- }
159
- if (a.none !== undefined) return `« ${a.none} »`
160
- if (a.kind === 'secret') return a.secret?.stored ? `stored as ${a.secret.name}` : 'not given'
161
- if (a.kind === 'checklist') return `all ${a.lines?.length ?? 0} ${c.instructions ? 'steps ' : ''}done`
162
- if (a.kind === 'confirm') return 'done'
163
- if (a.kind === 'url' && a.value) return `${a.value.text}${a.value.opens ? '' : ' · did not open from this Mac'}`
164
- if (a.value) return a.kind === 'file' ? `his file, view ${(a.value.view ?? 0) + 1}` : a.value.text
165
- return 'yes'
179
+ /** cells in reading order: a divider when the day changes, the state changes in a row folded into one line, each run of
180
+ * superseded items folded into one line */
181
+ function linesOf(cells: readonly Cell[]): Line[] {
182
+ const out: Line[] = []
183
+ let day = ''
184
+ for (const c of cells) {
185
+ const d = dayOf(c.at)
186
+ if (d !== day) {
187
+ out.push({ kind: 'day', day: d })
188
+ day = d
189
+ }
190
+ const last = out.at(-1)
191
+ if (c.kind === 'event' || (c.kind === 'verdict' && c.trace !== undefined)) {
192
+ const t = c as Traced
193
+ if (last?.kind === 'events') last.cells.push(t)
194
+ else out.push({ kind: 'events', cells: [t] })
195
+ } else out.push({ kind: 'cell', cell: c })
196
+ }
197
+ return foldSuperseded(out)
166
198
  }
167
199
 
168
200
  /** a reaction is on that view, that tile of it, or that message of a draft version */
@@ -203,6 +235,8 @@ export class ThreadSt {
203
235
  folds: Record<string, boolean> = {}
204
236
  /** each run of superseded items he opened, by its first cell: kept in the browser, a run's cells belong to one thread */
205
237
  readonly runs = new KeptFolds('hub:superseded-runs')
238
+ /** each fold of quiet trace lines he opened, by its first cell (review/traces.ts foldQuiet) */
239
+ readonly quiets = new KeptFolds('hub:quiet-traces')
206
240
  /** a scroll asked of the thread column: it brings that dom id into view once, then clears it */
207
241
  jump: string | null = null
208
242
  /** the column scrolled to the newest cell once, on the first load */
@@ -211,9 +245,6 @@ export class ThreadSt {
211
245
  * gallery the one tile it shows large; or the page of a version of an object (`states`), framed live */
212
246
  boxed: { cell: string; view: number; tile?: number } | { cell: string; states: true } | null = null
213
247
  private drafts: Record<string, Draft> = {}
214
- /** the older version his answer goes to: a version landed while he wrote, or he chose to answer it. His first mark
215
- * on the newest version, or « answer v4 », brings his answer back to the newest */
216
- draftOn: string | null = null
217
248
  /** the newest version's active view: the one last drawn on or picked, whose clip the keys drive */
218
249
  view = 0
219
250
  /** a picked rectangle of his draft: its note box opens beside it */
@@ -245,8 +276,9 @@ export class ThreadSt {
245
276
  replyOn: ReplyOn | null = null
246
277
  /** each ask to put the caret in the reply box: the composer takes it once no lightbox covers it */
247
278
  replyAsk = 0
248
- /** the kind's action he sent on an item, by `<item>#<link>` */
249
- acted: Record<string, string> = {}
279
+ /** the kind's action he clicked on an item, by `<item>#<link>`: drawn chosen in the click's frame (« sending… »), then
280
+ * « sent », or the linked object as it was with one line why */
281
+ acting: Record<string, ActState> = {}
250
282
  /** the head's tag field: what he types in it, null while it is shut; « + tag » or « more » opens it */
251
283
  tagTyping: string | null = null
252
284
  busy = false
@@ -258,7 +290,7 @@ export class ThreadSt {
258
290
  /** the popup of a face clicked on a version (its id) or a message that asks a verdict (its cell's id): the verdict
259
291
  * `status` and its note as he types it; its send gives both in one answer, a bare send the plain verdict. `why`:
260
292
  * the store refused that send, the popup back with the words typed. Never the reply box's words, a comment of their own */
261
- note: { on: string; status: ItemVerdict; text: string; why?: string } | null = null
293
+ note: { on: string; status: ItemVerdict; text: string; why?: string; option?: number } | null = null
262
294
  /** the verdicts on their way, written in the order he clicked; the number of the newest */
263
295
  private saves: Promise<void> = Promise.resolve()
264
296
  private saved = 0
@@ -350,6 +382,9 @@ export class ThreadSt {
350
382
  this.error = null
351
383
  })
352
384
  } catch (e) {
385
+ // a thread moved to another repo: its old link opens it where it is now
386
+ const moved = movedOfError(e)
387
+ if (moved !== null && this.followMove(moved)) return
353
388
  runInAction(() => (this.error = (e as Error).message))
354
389
  // a pane with nothing drawn reads again by itself: under the live socket no poll would
355
390
  if (this.data === null && !this.gone && this.again === null) {
@@ -361,8 +396,9 @@ export class ThreadSt {
361
396
  }
362
397
  }
363
398
 
364
- /** a thread from the server: a cell he sees keeps its fold when a new answer changes the defaults; a version that
365
- * lands while he writes leaves his draft on the version he started it on */
399
+ /** a thread from the server: a cell he sees keeps its fold when a new answer changes the defaults; a draft on an
400
+ * older version (one that landed while he wrote, or one kept in the browser) goes to the newest, which his answer
401
+ * answers when sent */
366
402
  receive(v: ThreadView): void {
367
403
  // the same answer again (a 304) still settles a send that turned sent since: the read that drew its message may
368
404
  // have come before the send's own answer, and no later read changes
@@ -371,7 +407,6 @@ export class ThreadSt {
371
407
  // a cell a newer object just superseded folds even under the owner's eyes: that is the point of superseding it
372
408
  const gone = new Set(v.cells.flatMap((c) => (c.superseded ? [c.id] : [])))
373
409
  if (before) for (const c of before.cells) if (c.kind !== 'event' && !gone.has(c.id) && this.folds[c.id] === undefined && this.defaultOpen(c, before) !== this.defaultOpen(c, v)) this.folds = { ...this.folds, [c.id]: this.defaultOpen(c, before) }
374
- if (before && before.head !== v.head && this.draftOn === null && isDirty(this.drafts[before.head]) && v.members.includes(before.head)) this.draftOn = before.head
375
410
  this.data = v
376
411
  // an address's view on a link to an old version is that version's view, never the newest's
377
412
  if (!before && v.asked !== v.head && this.view > 0) {
@@ -379,14 +414,14 @@ export class ThreadSt {
379
414
  this.view = 0
380
415
  this.reveal(v.asked, at)
381
416
  }
382
- if (this.draftOn !== null && !v.members.includes(this.draftOn)) this.draftOn = null
383
- // every version's draft kept in the browser is found again: an older one stays on its version (`parked`)
417
+ // every version's draft kept in the browser is found again
384
418
  const found: Record<string, Draft> = {}
385
419
  for (const id of v.members) {
386
420
  const d = this.drafts[id] === undefined ? this.rv.storedDraft(id) : null
387
421
  if (d) found[id] = d
388
422
  }
389
423
  if (Object.keys(found).length > 0) this.drafts = { ...this.drafts, ...found }
424
+ for (const id of v.members) if (id !== v.head && isDirty(this.drafts[id])) this.carry(id, v.head)
390
425
  const ids = new Set(v.cells.map((c) => c.id))
391
426
  this.outbox.settle(v.cells.map((c) => ({ id: c.id, who: c.who, ...(c.kind === 'reply' ? { text: c.text } : {}) })))
392
427
  if (Object.keys(this.deleting).some((id) => !ids.has(id))) this.deleting = Object.fromEntries(Object.keys(this.deleting).filter((id) => ids.has(id)).map((id) => [id, true as const]))
@@ -404,10 +439,9 @@ export class ThreadSt {
404
439
  return this.data?.cells ?? []
405
440
  }
406
441
 
407
- /** the cell the owner's verdict and reply go to: the newest version, or the raised item no version answers; the older
408
- * version his draft sits on while a newer one landed */
442
+ /** the cell the owner's verdict and reply go to: the newest version, or the raised item no version answers */
409
443
  get head(): Framed | null {
410
- const h = this.draftOn ?? this.data?.head
444
+ const h = this.data?.head
411
445
  return (this.cells.find((c) => c.id === h && c.kind !== 'event') as Framed | undefined) ?? null
412
446
  }
413
447
 
@@ -417,68 +451,32 @@ export class ThreadSt {
417
451
  return (this.cells.find((c) => c.id === h && c.kind !== 'event') as Framed | undefined) ?? null
418
452
  }
419
453
 
420
- /** an unsent draft on an older version while his answer goes to the newest: found again when the thread opened, or
421
- * left there by a mark on the newest. Never taken, never lost: the box offers to move it, answer it, or drop it */
422
- get parked(): string | null {
423
- if (this.draftOn !== null || !this.data) return null
424
- const head = this.data.head
425
- return [...this.data.members].reverse().find((id) => id !== head && isDirty(this.drafts[id])) ?? null
426
- }
427
-
428
- /** the newest version takes his marks while his answer sits on an older one: his first mark brings it back */
429
- get claims(): boolean {
430
- const n = this.newest
431
- return this.draftOn !== null && n?.kind === 'version' && !n.item.wip
432
- }
433
-
434
- /** his answer goes to the newest version; the draft on the older one stays there, parked */
435
- answerNewest(): void {
436
- if (this.draftOn === null) return
437
- this.draftOn = null
438
- this.rect = null
439
- }
440
-
441
- /** his answer goes to the older version his parked draft is on */
442
- answerParked(): void {
443
- const p = this.parked
444
- if (p === null) return
445
- this.draftOn = p
446
- this.rect = null
447
- }
448
-
449
- /** the parked draft dropped: his notes and his word on the older version */
450
- dropParked(): void {
451
- const p = this.parked
452
- if (p !== null) this.put(p, null)
453
- }
454
-
455
- /** his draft moved onto the newest version: his word, and the marks whose view the newest has; what does not fit
456
- * stays on the older one */
457
- moveDraft(): void {
458
- const from = this.draftOn ?? this.parked
459
- const to = this.data?.head
460
- if (from === null || !to) return
454
+ /** a draft moved from an older version onto `to`: his word, and the marks whose view `to` has; what does not fit
455
+ * stays on the older one, never dropped */
456
+ private carry(from: string, to: string): void {
461
457
  const d = this.drafts[from] ?? EMPTY
462
458
  const toItem = this.versionOf(to)?.item
463
459
  const views = (toItem?.views ?? []).length
464
460
  const fits = (view: number | undefined): boolean => (view ?? 0) < views
465
461
  // a word on a message of a draft follows to a newer draft version, which holds no view
466
462
  const takes = (r: ReviewReaction): boolean => (r.post !== undefined ? toItem?.draft !== undefined : fits(r.view))
463
+ const rects = d.rects.filter((r) => fits(r.view))
464
+ const taken = (d.reactions ?? []).filter(takes)
465
+ if (d.comment.trim() === '' && rects.length === 0 && taken.length === 0) return
467
466
  const into = this.drafts[to] ?? EMPTY
468
467
  const moved: Draft = {
469
468
  comment: [into.comment, d.comment].filter((x) => x.trim() !== '').join('\n'),
470
- rects: [...into.rects, ...d.rects.filter((r) => fits(r.view))],
469
+ rects: [...into.rects, ...rects],
471
470
  ...(into.pick !== undefined ? { pick: into.pick } : {}),
472
471
  }
473
- const reactions = [...(into.reactions ?? []), ...(d.reactions ?? []).filter((r) => takes(r) && !(into.reactions ?? []).some((q) => sameSpot(q, r.view, r.tile, r.post)))]
472
+ const reactions = [...(into.reactions ?? []), ...taken.filter((r) => !(into.reactions ?? []).some((q) => sameSpot(q, r.view, r.tile, r.post)))]
474
473
  if (reactions.length > 0) moved.reactions = reactions
475
- const left: Draft = { comment: '', rects: d.rects.filter((r) => !fits(r.view)) }
474
+ // a pick names a view of the older version: it stays there with it
475
+ const left: Draft = { comment: '', rects: d.rects.filter((r) => !fits(r.view)), ...(d.pick !== undefined ? { pick: d.pick } : {}) }
476
476
  const leftReactions = (d.reactions ?? []).filter((r) => !takes(r))
477
477
  if (leftReactions.length > 0) left.reactions = leftReactions
478
478
  this.put(to, moved)
479
479
  this.put(from, isDirty(left) ? left : null)
480
- this.draftOn = null
481
- this.rect = null
482
480
  }
483
481
 
484
482
  get headItem(): Item | null {
@@ -491,18 +489,8 @@ export class ThreadSt {
491
489
  const h = this.head
492
490
  // a thread opened with words holds nothing to judge: its questions and changes take his answer in their cells;
493
491
  // his own save neither
494
- // a promised next version replaces it: no verdict needed (review/threads.ts nextVersionOf)
495
- return h?.kind === 'version' && !h.item.wip && !asksNoVerdict(h.item) && this.data?.next === undefined
496
- }
497
-
498
- /** what is expected of him now: the band of the list and the dock's own lines (review/expect.ts expectOf, the
499
- * function the cli's verbs print too); the dock draws it when nothing waits on his answer */
500
- get expect(): Expect | null {
501
- const v = this.data
502
- if (!v) return null
503
- const ver = this.verdictAbove
504
- const waiting = waitLinesOf(this.openRequests, ver ? { id: ver.id, n: ver.n } : null, v.ask ? { state: v.ask.state, title: v.ask.title, head: v.head } : undefined)
505
- return expectOf({ ...v, waiting, ...(v.aside ? { aside: v.aside } : {}), validated: validatedOf({ turn: v.turn, status: v.status, ...(v.ask ? { ask: v.ask.state } : {}) }) }, this.rv.parties, this.rv.bandNow)
492
+ // a promised next version replaces it: no verdict needed (review/thread-state.ts ThreadState next)
493
+ return h?.kind === 'version' && !h.item.wip && !asksNoVerdict(h.item) && this.data?.state.next == null
506
494
  }
507
495
 
508
496
  /** the version cell an item id names */
@@ -510,6 +498,55 @@ export class ThreadSt {
510
498
  return (this.cells.find((c) => c.kind === 'version' && c.id === id) as VersionCell | undefined) ?? null
511
499
  }
512
500
 
501
+ /** the cell whose item holds the views a message names: a version, or the item he raised (review/cells.ts viewHolderOf);
502
+ * every reader of a message's media goes through it */
503
+ get holders(): ReadonlyMap<string, VersionCell> {
504
+ const out = new Map<string, VersionCell>()
505
+ for (const c of this.cells) {
506
+ const h = viewHolderOf(c)
507
+ if (h !== null) out.set(c.id, h)
508
+ }
509
+ return out
510
+ }
511
+
512
+ holderOf(id: string): VersionCell | null {
513
+ return this.holders.get(id) ?? null
514
+ }
515
+
516
+ /** the house repos this thread may move to, every one but its own, as the move route takes them; null until read */
517
+ moveTargets: string[] | null = null
518
+
519
+ /** the house repos read once, when the head first draws its « move to project… » */
520
+ async readMoveTargets(): Promise<void> {
521
+ if (this.moveTargets !== null || this.rv.host.owner == null || !this.rv.can('move')) return
522
+ try {
523
+ const r = await (await reach(this.rv.url('/api/review/move-targets'), { cache: 'no-store' })).json() as { repos?: string[] }
524
+ runInAction(() => (this.moveTargets = r.repos ?? []))
525
+ } catch {
526
+ runInAction(() => (this.moveTargets = []))
527
+ }
528
+ }
529
+
530
+ /** his « move to project… »: the thread moves whole to `repo` (review/move.ts), then opens there */
531
+ async moveTo(repo: string): Promise<void> {
532
+ const head = this.data?.head
533
+ if (head === undefined) return
534
+ try {
535
+ const m = await postJson<{ repo: string; head: string }>(this.rv.url(`/api/review/${head}/move`), { repo })
536
+ this.followMove(m)
537
+ } catch (e) {
538
+ runInAction(() => (this.error = (e as Error).message))
539
+ }
540
+ }
541
+
542
+ /** the thread opened where it moved, in its repo's threads; false at the advisors' door, which has no other repo */
543
+ followMove(m: { repo: string; head: string }): boolean {
544
+ const o = this.rv.host.owner
545
+ if (o == null) return false
546
+ o.home.openReview(m.repo, m.head)
547
+ return true
548
+ }
549
+
513
550
  /** the thread's bar of advisors, where he may share: its shares' acts are lines of this timeline */
514
551
  get shareBar(): ThreadBarSt | null {
515
552
  const o = this.rv.host.owner
@@ -521,7 +558,7 @@ export class ThreadSt {
521
558
  /** each act of the thread's shares as a trace cell, at its own time (advisors/share-trace.ts) */
522
559
  get shareCells(): Traced[] {
523
560
  const head = this.data?.head ?? ''
524
- return (this.shareBar?.data?.trace ?? []).map((e) => ({ kind: 'event' as const, id: e.id, on: head, at: e.at, who: e.who, party: 'owner' as const, summary: e.words, open: false, trace: { act: 'share' as const, did: e.words }, share: e }))
561
+ return (this.shareBar?.data?.trace ?? []).map((e) => ({ kind: 'event' as const, id: e.id, on: head, at: e.at, who: e.who, party: 'owner' as const, summary: e.words, open: false, trace: { act: 'share' as const, did: e.words, ...(e.live === true ? { live: true as const } : {}) }, share: e }))
525
562
  }
526
563
 
527
564
  /** each message of another thread that names this one by its code, a quiet line of the timeline at its time */
@@ -538,7 +575,7 @@ export class ThreadSt {
538
575
  return {
539
576
  look: (c) => {
540
577
  const r = refs[c]
541
- return r === undefined ? null : { code: r.code, head: r.head, title: r.title, band: bandOf(r, parties, now) }
578
+ return r === undefined ? null : { code: r.code, head: r.head, title: r.title, band: bandOf(r.state, parties, now) }
542
579
  },
543
580
  open: this.openRef,
544
581
  }
@@ -550,26 +587,20 @@ export class ThreadSt {
550
587
  /** the thread in reading order: a divider when the day changes, the state changes in a row folded into one line,
551
588
  * each run of superseded items folded into one line; the shares' acts among them by their time */
552
589
  get lines(): Line[] {
553
- const out: Line[] = []
554
- let day = ''
555
590
  const shares = [...this.shareCells, ...this.backlinkCells]
556
591
  // the owner's words on their way stand last: the newest, whatever the clock of the store says
557
592
  const cells = Object.keys(this.deleting).length === 0 ? this.cells : this.cells.filter((c) => !this.deleting[c.id])
558
593
  const all: Cell[] = [...(shares.length === 0 ? cells : [...cells, ...shares].sort((a, b) => a.at.localeCompare(b.at))), ...this.outbox.cells]
559
- for (const c of all) {
560
- const d = dayOf(c.at)
561
- if (d !== day) {
562
- out.push({ kind: 'day', day: d })
563
- day = d
564
- }
565
- const last = out.at(-1)
566
- if (c.kind === 'event' || (c.kind === 'verdict' && c.trace !== undefined)) {
567
- const t = c as Traced
568
- if (last?.kind === 'events') last.cells.push(t)
569
- else out.push({ kind: 'events', cells: [t] })
570
- } else out.push({ kind: 'cell', cell: c })
571
- }
572
- return foldSuperseded(out)
594
+ // past a recap he accepted, what came before it is one quiet line that opens (review/cells.ts ThreadView recap)
595
+ const recap = this.data?.recap
596
+ if (recap === undefined) return linesOf(all)
597
+ const before = new Set(recap.before)
598
+ const own = new Set(cells)
599
+ // a share's act or a backlink before the recap folds with it
600
+ const fold = new Set(all.filter((c) => before.has(c.id) || (c.at < recap.at && !own.has(c))))
601
+ if (fold.size === 0) return linesOf(all)
602
+ const n = [...fold].filter((c) => c.kind !== 'event').length
603
+ return [{ kind: 'superseded', key: `recap:${recap.cell}`, n, words: `${n} message${n === 1 ? '' : 's'} before the recap`, recap: true, lines: linesOf(all.filter((c) => fold.has(c))) }, ...linesOf(all.filter((c) => !fold.has(c)))]
573
604
  }
574
605
 
575
606
  /** the run of superseded items is open: shut until he opens it */
@@ -581,42 +612,74 @@ export class ThreadSt {
581
612
  this.runs.flipFold(key, false)
582
613
  }
583
614
 
584
- /** a jump to a cell inside a shut run opens the run */
615
+ /** a fold of quiet trace lines is open: shut until he opens it */
616
+ quietOpen(key: string): boolean {
617
+ return this.quiets.isOpen(key, false)
618
+ }
619
+
620
+ toggleQuiet(key: string): void {
621
+ this.quiets.flipFold(key, false)
622
+ }
623
+
624
+ /** a jump to a cell inside a shut run opens the run, and the fold of quiet traces it sits in */
585
625
  private openRunOf(cell: string): void {
586
626
  const key = runOf(this.lines, cell)
587
627
  if (key !== null) this.runs.setFold(key, true)
628
+ const fold = quietFoldOf(this.lines, cell)
629
+ if (fold !== null) this.quiets.setFold(fold, true)
588
630
  }
589
631
 
590
- // ── the dock: what waits on his answer, above his reply box (wiki tools/shipkit/threads-page.md, The dock) ──
632
+ // ── what waits on his answer: the arrows at the column's top count it (wiki tools/shipkit/threads-page.md, The timeline) ──
591
633
 
592
634
  /** each question and proposed change of an agent that still waits on him, oldest first: the server closes a request
593
- * asked before his close, an ask's close too (review/cells.ts, moot), and one asked after it waits */
635
+ * asked before the close, whoever closed (review/cells.ts, moot), and one asked after it waits */
594
636
  get openRequests(): ReplyCell[] {
595
- return this.cells.filter(waitsOnOwner)
637
+ // a question with a row per thing waits as one, by its first row: the cell that draws every row
638
+ const seen = new Set<string>()
639
+ const out: ReplyCell[] = []
640
+ // what the thread's state says waits on him (review/thread-state.ts), its rows as one; an answer on its way
641
+ // already closes its cell here
642
+ const waits = new Set(this.data ? waitLinesOf(this.data.state).map((l) => l.id) : [])
643
+ const rowOf = (c: ReplyCell): ReplyCell => (c.ask?.row ? (this.rowsOf(c)[0] ?? c) : c)
644
+ for (const c of this.cells.filter((x): x is ReplyCell => waitsOnOwner(x) && (waits.has(x.id) || waits.has(rowOf(x).id)))) {
645
+ const g = c.ask?.row?.group
646
+ if (g === undefined) out.push(c)
647
+ else if (!seen.has(g)) {
648
+ seen.add(g)
649
+ out.push(this.rowsOf(c)[0] ?? c)
650
+ }
651
+ }
652
+ return out
653
+ }
654
+
655
+ /** the rows of the question with a row per thing that `c` is one row of, in row order; empty for any other cell */
656
+ rowsOf(c: ReplyCell): ReplyCell[] {
657
+ const g = c.ask?.row?.group
658
+ if (g === undefined) return []
659
+ return this.cells.filter((x): x is ReplyCell => x.kind === 'reply' && x.ask?.row?.group === g).sort((a, b) => a.ask!.row!.i - b.ask!.row!.i)
596
660
  }
597
661
 
598
- /** every cell the dock lists: the open requests, then the version that waits for the owner's verdict */
662
+ /** every cell that waits on him: the open requests, then the version that waits for the owner's verdict */
599
663
  get waiting(): string[] {
600
664
  const v = this.verdictAbove
601
665
  return [...this.openRequests.map((c) => c.id), ...(v ? [v.id] : [])]
602
666
  }
603
667
 
604
- /** when he closed the thread, null while it is open: the server's `closedAt` (review/threads.ts), the one function
605
- * every list reads. A request asked before it closes with it, one asked after it still waits */
668
+ /** when the close moots what was asked before it, whoever closed; null while it is open (review/thread-state.ts
669
+ * mootAt): a request asked before it closes with it, one asked after it still waits */
606
670
  get closedAt(): string | null {
607
- return this.data?.closedAt ?? null
671
+ return this.data ? mootAt(this.data.state) : null
608
672
  }
609
673
 
610
- /** the request still waits on him: its cell draws its controls live, the dock reminds of it */
674
+ /** the request still waits on him: its cell draws its controls live */
611
675
  waitsNow(id: string): boolean {
612
676
  return this.openRequests.some((c) => c.id === id)
613
677
  }
614
678
 
615
- /** the version that waits for the owner's verdict: its verdicts sit under it in the timeline (item-verdict.tsx), the
616
- * dock holds one line that reminds of it */
679
+ /** the version that waits for the owner's verdict: its answer bar sits at its foot (tone-bar.tsx) */
617
680
  get verdictAbove(): VersionCell | null {
618
681
  const h = this.head
619
- if (h?.kind !== 'version' || !this.takesVerdict || this.chosenOn(h.id) !== undefined || this.data?.state.state === 'closed') return null
682
+ if (h?.kind !== 'version' || !this.takesVerdict || this.chosenOn(h.id) !== undefined || this.data?.state.closed != null) return null
620
683
  return h
621
684
  }
622
685
 
@@ -626,10 +689,11 @@ export class ThreadSt {
626
689
  return this.save(c.id, status, () => postJson(this.rv.url(`/api/review/${c.on}/item-verdict`), { re: c.id.slice(c.on.length + 1), status, ...(text !== '' ? { text } : {}) }), false)
627
690
  }
628
691
 
629
- /** V F R, 1 2 3: the face on the newest open item that asks the owner's verdict, a message or the version; the version
630
- * when none waits. It opens that face's popup, as a click does: Enter sends */
692
+ /** 1 to 5, V F R X Y: the tone on the newest open item that asks the owner's answer, a message, a question or the
693
+ * version; the version when none waits. It opens that tone's box, ok and your call too: a key alone never sends,
694
+ * Enter does */
631
695
  judgeKey(status: ItemVerdict): Promise<void> | void {
632
- const c = [...this.openRequests].reverse().find((x) => x.judge?.open === true)
696
+ const c = [...this.openRequests].reverse().find((x) => x.judge?.open === true || this.questionCell(x.id) !== undefined)
633
697
  const v = this.verdictAbove
634
698
  if (c !== undefined && (v === null || c.at >= v.at)) return this.face(c.id, status)
635
699
  // a version answered by its kind's acts (a draft) takes no verdict, by key either
@@ -640,9 +704,86 @@ export class ThreadSt {
640
704
 
641
705
  /** a face clicked on `on` (a version's id, or a message's cell id): its popup opens there, its box empty; another
642
706
  * face of that item open swaps to this one and keeps the words typed; the same face again closes it. Nothing is sent */
643
- face(on: string, status: ItemVerdict): void {
644
- const n = this.note?.on === on ? this.note : null
645
- this.note = n?.status === status ? null : { on, status, text: n?.text ?? '' }
707
+ face(on: string, status: ItemVerdict, option?: number): void {
708
+ const n = this.note?.on === on && this.note.option === option ? this.note : null
709
+ this.note = n?.status === status ? null : { on, status, text: n?.text ?? '', ...(option !== undefined ? { option } : {}) }
710
+ }
711
+
712
+ /** a click on a tone of the bar (tone-bar.tsx): ok and your call send at once; one that takes words, or the one
713
+ * already given, opens its box (face). `option`: the bar of one option of a question (the lightbox's side panel),
714
+ * whose ok and fix take that option */
715
+ tone(on: string, status: ItemVerdict, option?: number): Promise<void> | void {
716
+ if (toneOfStatus(status)?.words === true || this.litOn(on, status, option)) return this.face(on, status, option)
717
+ this.note = { on, status, text: '', ...(option !== undefined ? { option } : {}) }
718
+ return this.sendNote()
719
+ }
720
+
721
+ /** the tone given on `on`, read for the bar of one option: its ok and fix are lit on the option he picked alone */
722
+ litOn(on: string, status: ItemVerdict, option?: number): boolean {
723
+ if (this.givenOn(on) !== status) return false
724
+ if (option === undefined || (status !== 'approved' && status !== 'approved-with-fix')) return true
725
+ const q = this.questionCell(on)
726
+ return q !== undefined && this.yours(q) === option
727
+ }
728
+
729
+ /** the option of a question marked as the reader's: their click on its way, else their own pick (the owner's, on his hub) */
730
+ yours(c: ReplyCell): number | undefined {
731
+ const ask = c.ask
732
+ if (ask === undefined) return undefined
733
+ const local = this.picking[c.id]
734
+ if (local !== undefined && local.state !== 'failed') return local.option
735
+ if (this.rv.host.role === 'advisor') return ask.people?.find((p) => p.you === true)?.option
736
+ const his = ownerChoice(ask)
737
+ return ask.ownerPick ?? (ask.answered?.by === undefined && his !== null && 'option' in his ? his.option : undefined)
738
+ }
739
+
740
+ /** the reader's remark with their pick (« pick with a remark »): their click on its way, else the answer's; '' with none */
741
+ yourRemark(c: ReplyCell): string {
742
+ const local = this.picking[c.id]
743
+ if (local !== undefined && local.state !== 'failed') return local.remark ?? ''
744
+ const yours = this.yours(c)
745
+ return yours !== undefined && c.ask?.answered?.option === yours ? (c.ask.answered.remark ?? '') : ''
746
+ }
747
+
748
+ /** the question and its option a view of version `cell` draws (an option's picture), the newest question first; the
749
+ * lightbox opened on it steps through that question's options (a row question's, its row's) */
750
+ optionAt(cell: string, view: number): { c: ReplyCell; i: number; order: number[] } | null {
751
+ for (const c of [...this.cells].reverse()) {
752
+ if (c.kind !== 'reply' || c.ask?.views === undefined || c.on !== cell) continue
753
+ const i = c.ask.views.indexOf(view)
754
+ if (i < 0) continue
755
+ return { c, i, order: c.ask.views.flatMap((v, k) => (v === null ? [] : [k])) }
756
+ }
757
+ return null
758
+ }
759
+
760
+ /** the question `on` names when the bar answers it: a choice of one thing, no step of an ask's instructions */
761
+ questionCell(on: string): ReplyCell | undefined {
762
+ const c = this.askingCell(on)
763
+ return c?.ask !== undefined && (c.ask.kind === undefined || c.ask.kind === 'choice') && c.step === undefined && c.judge === undefined ? c : undefined
764
+ }
765
+
766
+ /** the tone the owner's answer to a question gives, the one on its way first: a pick ok, a pick with the owner's words a fix, words
767
+ * alone a rework unless he named another tone */
768
+ private questionTone(c: ReplyCell): ItemVerdict | undefined {
769
+ const a = c.ask!
770
+ const local = this.picking[c.id]
771
+ if (local !== undefined && local.state !== 'failed') return local.remark ? 'approved-with-fix' : 'approved'
772
+ if (a.tone !== undefined && (ITEM_VERDICTS as readonly string[]).includes(a.tone)) return a.tone as ItemVerdict
773
+ if (a.answered !== undefined) return a.answered.remark ? 'approved-with-fix' : 'approved'
774
+ return a.none !== undefined ? 'rework' : undefined
775
+ }
776
+
777
+ /** the owner's tone on a question (sendNote): ok takes the agent's pick, a fix the pick with the owner's words; a rework, a wrong
778
+ * direction or your call goes as his answer in that tone (store.ts answerAsk `tone`) */
779
+ private answerTone(c: ReplyCell, status: ItemVerdict, text: string, option?: number): Promise<void> {
780
+ const pick = option ?? c.ask?.pick
781
+ if ((status === 'approved' || status === 'approved-with-fix') && pick !== undefined) return this.pickOption(c, pick, status === 'approved' ? '' : text)
782
+ if (status === 'approved' || status === 'approved-with-fix') {
783
+ this.failed = { on: c.id, why: 'the agent named no pick: click an option above' }
784
+ return Promise.resolve()
785
+ }
786
+ return this.save(c.id, status, () => postJson(this.rv.url(`/api/review/${c.on}/answer`), { re: c.id.slice(c.on.length + 1), tone: status, ...(text !== '' ? { text } : {}) }), false)
646
787
  }
647
788
 
648
789
  setNote(text: string): void {
@@ -655,8 +796,8 @@ export class ThreadSt {
655
796
  }
656
797
 
657
798
  /** the verdict already given is the one the popup holds and nothing new goes with it: a bare send changes nothing */
658
- private sameAsGiven(n: { on: string; status: ItemVerdict; text: string }): boolean {
659
- return n.text.trim() === '' && this.givenOn(n.on) === n.status && (this.askingCell(n.on) !== undefined || !this.marked)
799
+ private sameAsGiven(n: { on: string; status: ItemVerdict; text: string; option?: number }): boolean {
800
+ return n.text.trim() === '' && this.litOn(n.on, n.status, n.option) && (this.askingCell(n.on) !== undefined || !this.marked)
660
801
  }
661
802
 
662
803
  /** « take it back » in the popup of a version's lit face: the version waits for the owner's verdict again */
@@ -667,7 +808,8 @@ export class ThreadSt {
667
808
 
668
809
  /** the verdict given on `on` (a version's id or a message's cell id), the one on its way first */
669
810
  givenOn(on: string): ItemVerdict | undefined {
670
- const s = this.chosenOn(on) ?? this.askingCell(on)?.judge?.verdict?.status
811
+ const q = this.questionCell(on)
812
+ const s = this.chosenOn(on) ?? (q !== undefined ? this.questionTone(q) : this.askingCell(on)?.judge?.verdict?.status)
671
813
  return s !== undefined && (ITEM_VERDICTS as readonly string[]).includes(s) ? (s as ItemVerdict) : undefined
672
814
  }
673
815
 
@@ -685,13 +827,14 @@ export class ThreadSt {
685
827
  this.note = null
686
828
  if (this.sameAsGiven(n)) return
687
829
  const text = n.text.trim()
830
+ const q = this.questionCell(n.on)
688
831
  const c = this.askingCell(n.on)
689
832
  this.error = null
690
- await (c !== undefined ? this.judge(c, n.status, text) : this.submit(n.status, text))
833
+ await (q !== undefined ? this.answerTone(q, n.status, text, n.option) : c !== undefined ? this.judge(c, n.status, text) : this.submit(n.status, text))
691
834
  runInAction(() => {
692
835
  const why = this.failed?.on === n.on ? this.failed.why : this.error
693
836
  if (why === null || this.note !== null) return
694
- this.note = { on: n.on, status: n.status, text: n.text, why }
837
+ this.note = { on: n.on, status: n.status, text: n.text, why, ...(n.option !== undefined ? { option: n.option } : {}) }
695
838
  if (this.failed?.on === n.on) this.failed = null
696
839
  this.error = null
697
840
  })
@@ -739,13 +882,6 @@ export class ThreadSt {
739
882
  if (view !== undefined && cell === this.target) this.setView(view)
740
883
  }
741
884
 
742
- /** the dock's reminder of an ask's instructions: the column scrolls to that step and lights it */
743
- revealStep(cell: string, step: number): void {
744
- this.openRunOf(cell)
745
- this.folds = { ...this.folds, [cell]: true }
746
- this.jump = stepDom(cell, step)
747
- }
748
-
749
885
  jumped(): void {
750
886
  this.jump = null
751
887
  }
@@ -875,7 +1011,7 @@ export class ThreadSt {
875
1011
  const r = own ?? given
876
1012
  const picked = this.pickShown(h) === i
877
1013
  // a gallery is answered tile by tile: one tile scored or marked answers the view
878
- const tiles = isGallery(v) && [...(this.marks.reactions ?? []), ...(sent?.reactions ?? [])].some((q) => q.view === i && q.tile !== undefined && (q.status || q.stars || q.picked))
1014
+ const tiles = isGallery(v) && [...(this.marks.reactions ?? []), ...(sent?.reactions ?? [])].some((q) => q.view === i && q.tile !== undefined && (q.status || q.stars))
879
1015
  const answer: ViewMark['answer'] = picked ? 'picked' : r?.status ? r.status : (choice && r?.stars) || tiles ? 'scored' : sent ? 'sent' : 'none'
880
1016
  const noted = this.marks.rects.some((q) => (q.view ?? 0) === i) || (own?.comment ?? '').trim() !== ''
881
1017
  return { view: i, tag: viewTag(h.n, i), answer, noted }
@@ -972,7 +1108,7 @@ export class ThreadSt {
972
1108
 
973
1109
  /** the id his draft and his answer go to */
974
1110
  get target(): string | null {
975
- return this.draftOn ?? this.data?.head ?? null
1111
+ return this.data?.head ?? null
976
1112
  }
977
1113
 
978
1114
  get draft(): Draft {
@@ -1020,7 +1156,6 @@ export class ThreadSt {
1020
1156
  const h = this.target
1021
1157
  if (!h) return
1022
1158
  this.put(h, null)
1023
- if (this.draftOn === h) this.draftOn = null
1024
1159
  this.rect = null
1025
1160
  this.attach.follow('')
1026
1161
  }
@@ -1041,7 +1176,6 @@ export class ThreadSt {
1041
1176
  if (reactions.length > 0) left.reactions = reactions
1042
1177
  this.put(on, isDirty(left) ? left : null)
1043
1178
  }
1044
- if (this.draftOn === on) this.draftOn = null
1045
1179
  if (this.target !== on) this.rect = null
1046
1180
  }
1047
1181
 
@@ -1207,9 +1341,9 @@ export class ThreadSt {
1207
1341
  this.putReaction(view, tile, { comment: '' })
1208
1342
  }
1209
1343
 
1210
- private putReaction(view: number, tile: number | undefined, r: { status?: ReviewStatus | undefined; comment: string; stars?: number | undefined; picked?: true | undefined }, post?: string): void {
1211
- const next: ReviewReaction = { view, ...(tile !== undefined ? { tile } : {}), ...(post !== undefined ? { post } : {}), ...(r.status ? { status: r.status } : {}), comment: r.comment, ...(r.stars ? { stars: r.stars } : {}), ...(r.picked ? { picked: true as const } : {}) }
1212
- const empty = !r.status && r.comment === '' && !r.stars && !r.picked
1344
+ private putReaction(view: number, tile: number | undefined, r: { status?: ReviewStatus | undefined; comment: string; stars?: number | undefined }, post?: string): void {
1345
+ const next: ReviewReaction = { view, ...(tile !== undefined ? { tile } : {}), ...(post !== undefined ? { post } : {}), ...(r.status ? { status: r.status } : {}), comment: r.comment, ...(r.stars ? { stars: r.stars } : {}) }
1346
+ const empty = !r.status && r.comment === '' && !r.stars
1213
1347
  this.edit((d) => {
1214
1348
  const rest = (d.reactions ?? []).filter((q) => !sameSpot(q, view, tile, post))
1215
1349
  return { ...d, reactions: empty ? rest : [...rest, next] }
@@ -1291,23 +1425,9 @@ export class ThreadSt {
1291
1425
  tileShown(r: ReviewReaction | null): boolean {
1292
1426
  const f = this.tileFilter
1293
1427
  if (f === 'all') return true
1294
- if (f === 'unrated') return !r?.stars && !r?.status && !r?.picked
1428
+ if (f === 'unrated') return !r?.stars && !r?.status
1295
1429
  if (f === 'low') return r?.stars !== undefined && r.stars < 3
1296
- return r?.status === 'approved-with-fix' || r?.status === 'rejected'
1297
- }
1298
-
1299
- /** a variant kept for its row: the row's other pick clears; the same tile again clears it */
1300
- pickTile(view: number, tile: number, group: string, tiles: readonly { group?: string }[]): void {
1301
- const was = this.reactionOf(view, tile)?.picked === true
1302
- tiles.forEach((t, k) => {
1303
- if (t.group !== group) return
1304
- const cur = this.reactionOf(view, k)
1305
- if (cur?.picked) this.putReaction(view, k, { ...cur, picked: undefined })
1306
- })
1307
- if (!was) {
1308
- const cur = this.reactionOf(view, tile)
1309
- this.putReaction(view, tile, { ...cur, comment: cur?.comment ?? '', picked: true })
1310
- }
1430
+ return r?.status === 'approved-with-fix' || r?.status === 'rework'
1311
1431
  }
1312
1432
 
1313
1433
  /** a version as thin option rows: a choice, or views that each play alone, unless he asked them full */
@@ -1455,22 +1575,26 @@ export class ThreadSt {
1455
1575
  })
1456
1576
  }
1457
1577
 
1458
- /** a kind's action on item `id` with its words; `re` the link it acts on. True once the store took it */
1578
+ /** what his click on a kind's action on item `id` (`re` the link it acts on) is doing now, if he clicked one */
1579
+ actOn(id: string, re?: string): ActState | undefined {
1580
+ return this.acting[`${id}#${re ?? ''}`]
1581
+ }
1582
+
1583
+ /** a kind's action on item `id` with its words; `re` the link it acts on: drawn chosen at once, the store's write
1584
+ * behind it; a click on that object while one is on its way does nothing. True once the store took it */
1459
1585
  async act(id: string, name: string, text: string, re?: string): Promise<boolean> {
1460
- if (this.busy) return false
1461
- this.busy = true
1462
- this.error = null
1586
+ const key = `${id}#${re ?? ''}`
1587
+ if (this.acting[key]?.state === 'sending') return false
1588
+ this.acting = { ...this.acting, [key]: { name, state: 'sending' } }
1463
1589
  try {
1464
1590
  await postJson(this.rv.url(`/api/review/${id}/action`), { name, ...(text !== '' ? { text } : {}), ...(re ? { re } : {}) })
1465
- runInAction(() => (this.acted = { ...this.acted, [`${id}#${re ?? ''}`]: name }))
1591
+ runInAction(() => (this.acting = { ...this.acting, [key]: { name, state: 'sent' } }))
1466
1592
  await this.refresh()
1467
1593
  await this.answeredHere()
1468
1594
  return true
1469
1595
  } catch (e) {
1470
- runInAction(() => (this.error = (e as Error).message))
1596
+ runInAction(() => (this.acting = { ...this.acting, [key]: { name, state: 'failed', why: (e as Error).message } }))
1471
1597
  return false
1472
- } finally {
1473
- runInAction(() => (this.busy = false))
1474
1598
  }
1475
1599
  }
1476
1600
 
@@ -1639,7 +1763,17 @@ export class ThreadSt {
1639
1763
  private acts: Promise<void> = Promise.resolve()
1640
1764
  /** a click on a question's option, by cell: drawn on its question at once (« sending… »), then « sent » or why not with
1641
1765
  * « retry »; the next read of the thread draws the answer itself */
1642
- picking: Record<string, { option: number; state: 'sending' | 'sent' | 'failed'; why?: string }> = {}
1766
+ picking: Record<string, { option: number; state: 'sending' | 'sent' | 'failed'; why?: string; remark?: string }> = {}
1767
+ /** the option whose « pick with a remark » box is open, by question cell: one box a question at a time */
1768
+ remarking: Record<string, number> = {}
1769
+
1770
+ setRemarking(cell: string, option: number | null): void {
1771
+ const { [cell]: _, ...rest } = this.remarking
1772
+ this.remarking = option === null ? rest : { ...rest, [cell]: option }
1773
+ }
1774
+
1775
+ /** the key of the box that holds his remark with a pick, apart from the « none of these » words (`hints[c.id]`) */
1776
+ remarkBox = (c: { id: string }): string => `${c.id}#remark`
1643
1777
  /** the questions he chose to answer again (« change it » on an answer a person's pick gave), by cell */
1644
1778
  changing: Record<string, true> = {}
1645
1779
 
@@ -1648,24 +1782,31 @@ export class ThreadSt {
1648
1782
  this.changing = on ? { ...rest, [cell]: true } : rest
1649
1783
  }
1650
1784
 
1651
- /** one click on an option: shown taken at once, queued behind any act still on its way, never silently dropped */
1652
- pickOption(c: { id: string; on: string }, option: number): Promise<void> {
1653
- const sent = (this.hints[c.id] ?? '').trim()
1785
+ /** one click on an option, `remark` the owner's words with it (« pick with a remark »; none for a plain pick): shown taken at
1786
+ * once, queued behind any act still on its way, never silently dropped */
1787
+ pickOption(c: { id: string; on: string }, option: number, remark = ''): Promise<void> {
1788
+ const sent = remark.trim()
1654
1789
  const re = c.id.slice(c.on.length + 1)
1655
- this.picking = { ...this.picking, [c.id]: { option, state: 'sending' } }
1790
+ const words = sent !== '' ? { remark: sent } : {}
1791
+ this.picking = { ...this.picking, [c.id]: { option, state: 'sending', ...words } }
1656
1792
  this.error = null
1657
1793
  const run = async (): Promise<void> => {
1658
1794
  try {
1659
- await postJson(this.rv.url(`/api/review/${c.on}/answer`), { re, option, ...(sent !== '' ? { text: sent } : {}) })
1795
+ const r = await postJson<{ moved?: { repo: string; head: string } }>(this.rv.url(`/api/review/${c.on}/answer`), { re, option, ...(sent !== '' ? { text: sent } : {}) })
1796
+ // his « move to <repo> » moved the thread: it opens there
1797
+ if (r.moved !== undefined && this.followMove(r.moved)) return
1660
1798
  runInAction(() => {
1661
- if (this.picking[c.id]?.option === option) this.picking = { ...this.picking, [c.id]: { option, state: 'sent' } }
1799
+ if (this.picking[c.id]?.option === option) this.picking = { ...this.picking, [c.id]: { option, state: 'sent', ...words } }
1662
1800
  this.setChanging(c.id, false)
1663
- if ((this.hints[c.id] ?? '').trim() === sent) delete this.hints[c.id]
1801
+ if (sent !== '') {
1802
+ if (this.remarking[c.id] === option) this.setRemarking(c.id, null)
1803
+ if ((this.hints[this.remarkBox(c)] ?? '').trim() === sent) delete this.hints[this.remarkBox(c)]
1804
+ }
1664
1805
  })
1665
1806
  await this.answeredHere()
1666
1807
  } catch (e) {
1667
1808
  runInAction(() => {
1668
- if (this.picking[c.id]?.option === option) this.picking = { ...this.picking, [c.id]: { option, state: 'failed', why: (e as Error).message } }
1809
+ if (this.picking[c.id]?.option === option) this.picking = { ...this.picking, [c.id]: { option, state: 'failed', why: (e as Error).message, ...words } }
1669
1810
  })
1670
1811
  }
1671
1812
  }
@@ -1687,6 +1828,36 @@ export class ThreadSt {
1687
1828
  /** the key of the box that holds the owner's edit of one field's value */
1688
1829
  fieldBox = (c: { id: string }, key: string): string => `${c.id}#${key}`
1689
1830
 
1831
+ /** a text or a url he gave, by cell: drawn given at his click while the store writes it (a url after the hub tried
1832
+ * it, up to 4 s), or his value back in its field with why it was not sent */
1833
+ giving: Record<string, { value: string; state: 'sending' | 'failed'; why?: string }> = {}
1834
+
1835
+ /** his « send » on a text or a url question: given at once, queued behind any act on its way, never dropped */
1836
+ give(c: { id: string; on: string }, value: string): Promise<void> {
1837
+ const sent = value.trim()
1838
+ if (sent === '') return this.acts
1839
+ this.giving = { ...this.giving, [c.id]: { value: sent, state: 'sending' } }
1840
+ this.error = null
1841
+ const box = this.fieldBox(c, 'value')
1842
+ const run = async (): Promise<void> => {
1843
+ try {
1844
+ await postJson(this.rv.url(`/api/review/${c.on}/answer`), { re: c.id.slice(c.on.length + 1), value: sent })
1845
+ runInAction(() => {
1846
+ if ((this.hints[box] ?? '').trim() === sent) delete this.hints[box]
1847
+ })
1848
+ await this.answeredHere()
1849
+ runInAction(() => {
1850
+ const { [c.id]: _, ...rest } = this.giving
1851
+ this.giving = rest
1852
+ })
1853
+ } catch (e) {
1854
+ runInAction(() => (this.giving = { ...this.giving, [c.id]: { value: sent, state: 'failed', why: (e as Error).message } }))
1855
+ }
1856
+ }
1857
+ this.acts = this.acts.then(run)
1858
+ return this.acts
1859
+ }
1860
+
1690
1861
  private async answering(c: { id: string; on: string }, all: readonly { option?: number; apply?: true; field?: string; tick?: boolean; value?: string }[]): Promise<void> {
1691
1862
  const sent = this.hints[c.id] ?? ''
1692
1863
  const re = c.id.slice(c.on.length + 1)