rvlib-shipkit 2.12.0 → 2.14.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 (378) hide show
  1. package/CHANGELOG.md +75 -21
  2. package/README.md +1 -1
  3. package/package.json +4 -2
  4. package/src/agent-time/store.ts +2 -2
  5. package/src/assets/run-assets.ts +2 -2
  6. package/src/assets/server/studio-server.ts +27 -23
  7. package/src/check.ts +4 -4
  8. package/src/checks/SK001-package-json-shape.check.ts +8 -4
  9. package/src/checks/SK002-contracts-fulfillness.check.ts +2 -2
  10. package/src/checks/SK003-claude-md-shape.check.ts +20 -13
  11. package/src/checks/SK004-gitignore-policy.check.ts +45 -6
  12. package/src/checks/SK005-rvlib-versions.check.ts +2 -2
  13. package/src/checks/SK006-npm-publish-safety.check.ts +3 -3
  14. package/src/checks/SK007-github-visibility.check.ts +2 -2
  15. package/src/checks/SK008-reviewer-agent.check.ts +3 -3
  16. package/src/checks/SK010-undeclared-unit.check.ts +2 -2
  17. package/src/checks/SK011-sibling-unit-ranges.check.ts +2 -2
  18. package/src/checks/SK012-config-barrel-import.check.ts +2 -2
  19. package/src/checks/SK013-one-way-in-policy.check.ts +2 -2
  20. package/src/checks/SK015-nested-repo.check.ts +3 -3
  21. package/src/checks/SK016-legacy-check-shapes.check.ts +2 -2
  22. package/src/checks/SK017-vscode-hub-task.check.ts +2 -2
  23. package/src/checks/SK018-test-files-run.check.ts +2 -2
  24. package/src/checks/SK019-tests-run-in-units.check.ts +2 -2
  25. package/src/checks/SK020-self-spawning-check.check.ts +2 -2
  26. package/src/checks/SK022-machine-runs-the-pin.check.ts +2 -2
  27. package/src/checks/SK024-identity-colors.check.ts +1 -1
  28. package/src/checks/SK025-release-drift.check.ts +2 -2
  29. package/src/checks/SK026-asks-autoclose.check.ts +2 -2
  30. package/src/checks/SK027-agent-wiki-links.check.ts +8 -2
  31. package/src/checks/SK028-readme.check.ts +2 -2
  32. package/src/checks/SK029-explicit-check-files.check.ts +3 -3
  33. package/src/checks/SK030-cache-audit.check.ts +7 -5
  34. package/src/checks/SK031-trace-audit.check.ts +7 -7
  35. package/src/checks/SK032-ignored-inputs.check.ts +3 -3
  36. package/src/checks/SK033-global-contribution.check.ts +11 -4
  37. package/src/checks/SK034-commit-gates-armed.check.ts +2 -2
  38. package/src/checks/SK035-public-clean.check.ts +46 -0
  39. package/src/checks/SK036-draft-media-size.check.ts +28 -0
  40. package/src/checks/SK037-keyword-additions.check.ts +43 -0
  41. package/src/cli/cmd_Backup.ts +152 -0
  42. package/src/cli/cmd_Ci.ts +8 -11
  43. package/src/cli/cmd_Commands.ts +4 -4
  44. package/src/cli/cmd_ConfigKeys.ts +2 -2
  45. package/src/cli/cmd_Drill.ts +145 -0
  46. package/src/cli/cmd_Home.ts +50 -3
  47. package/src/cli/cmd_Init.ts +1 -1
  48. package/src/cli/cmd_Media.ts +10 -8
  49. package/src/cli/cmd_Mv.ts +14 -7
  50. package/src/cli/cmd_Review.ts +6 -4
  51. package/src/cli/cmd_Shot.ts +5 -2
  52. package/src/cli/cmd_Smoke.ts +5 -2
  53. package/src/cli/cmd_Social.ts +226 -0
  54. package/src/cli/cmd_Sound.ts +1 -1
  55. package/src/cli/cmd_Start.ts +1 -1
  56. package/src/cli/cmd_Time.ts +1 -1
  57. package/src/cli/cmd_TraceAudit.ts +6 -6
  58. package/src/cli/cmd_Trailer.ts +7 -4
  59. package/src/cli/cmd_Veille.ts +173 -0
  60. package/src/cli/cmd_When.ts +2 -2
  61. package/src/cli/family-pages.ts +19 -16
  62. package/src/cli/registry.ts +13 -2
  63. package/src/cli.ts +5 -2
  64. package/src/collections/actions.ts +1 -49
  65. package/src/collections/checks.ts +2 -1
  66. package/src/collections/collection-types.ts +12 -3
  67. package/src/collections/providers.ts +4 -4
  68. package/src/collections/review.ts +3 -2
  69. package/src/collections/tests.ts +19 -8
  70. package/src/comfy/comfy-panel.ts +2 -2
  71. package/src/contracts/apply-contracts.ts +1 -3
  72. package/src/contracts/contract-manifests.ts +2 -3
  73. package/src/contracts/contract-types.ts +0 -1
  74. package/src/contracts/contracts-engine.ts +0 -3
  75. package/src/contracts/manifests/discord.contract.ts +1 -1
  76. package/src/contracts/manifests/identity.contract.ts +1 -1
  77. package/src/contracts/manifests/itch.contract.ts +1 -1
  78. package/src/contracts/manifests/steam.contract.ts +1 -1
  79. package/src/core/agent-dir-at.ts +12 -0
  80. package/src/core/agent-dir.ts +16 -0
  81. package/src/core/app-icon.ts +9 -3
  82. package/src/core/budget.ts +1 -1
  83. package/src/core/bun-builtins.ts +2 -2
  84. package/src/core/canonical-scripts.ts +2 -2
  85. package/src/core/discover-checks.ts +38 -6
  86. package/src/core/fix-scope.ts +4 -2
  87. package/src/core/floor-resolve.ts +68 -48
  88. package/src/core/floor.ts +9 -0
  89. package/src/core/git-root.ts +24 -0
  90. package/src/core/global-contribution.ts +4 -1
  91. package/src/core/ignored-block.ts +1 -1
  92. package/src/core/ignored-inputs.ts +3 -2
  93. package/src/core/last-good.ts +3 -1
  94. package/src/core/layout.ts +8 -0
  95. package/src/core/log-stamp.ts +36 -0
  96. package/src/core/loop-watch.ts +93 -0
  97. package/src/core/machine-link.ts +134 -0
  98. package/src/core/memory-watch.ts +41 -0
  99. package/src/core/motherhome.ts +2 -2
  100. package/src/core/one-way-in-policy.ts +34 -26
  101. package/src/core/run-ci.ts +9 -11
  102. package/src/core/run-fixers.ts +9 -9
  103. package/src/core/runs-matrix.ts +1 -1
  104. package/src/core/slots.ts +30 -0
  105. package/src/core/trace-audit.ts +50 -9
  106. package/src/core/tree-rev.ts +60 -0
  107. package/src/core/unit-files.ts +42 -0
  108. package/src/drill/render.ts +140 -0
  109. package/src/drill/run.ts +269 -0
  110. package/src/fleet/scan-fleet.ts +6 -5
  111. package/src/home/daemon-jobs.ts +201 -0
  112. package/src/home/global-context.ts +44 -8
  113. package/src/home/gui-app/ShipkitGui.swift +91 -2
  114. package/src/home/home-routes.ts +22 -15
  115. package/src/home/hubs.ts +10 -3
  116. package/src/home/inbox-shape.ts +54 -5
  117. package/src/home/inbox.ts +17 -2
  118. package/src/home/lib-watch.ts +10 -3
  119. package/src/home/machine-stores.ts +15 -29
  120. package/src/home/pm-config.ts +4 -1
  121. package/src/home/pm-inputs.ts +2 -0
  122. package/src/home/resources.ts +7 -2
  123. package/src/home/run-daemon.ts +15 -18
  124. package/src/home/run-pm.ts +3 -1
  125. package/src/home/serve-daemon.ts +4 -3
  126. package/src/home/serve-web.ts +104 -1
  127. package/src/hooks/commit-message.ts +29 -20
  128. package/src/hooks/hook-gates.ts +1 -1
  129. package/src/hooks/leak-guard.ts +69 -9
  130. package/src/hooks/run-hooks.ts +18 -22
  131. package/src/identities/identities.ts +334 -0
  132. package/src/identities/machine-route.ts +126 -0
  133. package/src/identities/machine.ts +62 -0
  134. package/src/init-repo.ts +3 -3
  135. package/src/ledger/check-stats.ts +10 -9
  136. package/src/ledger/gate-checks.ts +32 -1
  137. package/src/ledger/record-kept.ts +112 -0
  138. package/src/ledger/repo-view.ts +10 -0
  139. package/src/ledger/run-log.ts +17 -12
  140. package/src/ledger/run-timeline.ts +8 -4
  141. package/src/ledger/store.ts +7 -0
  142. package/src/ledger/suite-log.ts +17 -13
  143. package/src/media-kinds.ts +3 -2
  144. package/src/media-store/backup/daemon.ts +73 -0
  145. package/src/media-store/backup/keys.ts +25 -0
  146. package/src/media-store/backup/manifest.ts +193 -0
  147. package/src/media-store/backup/restore.ts +192 -0
  148. package/src/media-store/backup/run.ts +278 -0
  149. package/src/media-store/backup/secret.ts +86 -0
  150. package/src/media-store/backup/snapshot.ts +64 -0
  151. package/src/media-store/backup/sources.ts +199 -0
  152. package/src/media-store/content.ts +1 -1
  153. package/src/media-store/daemon.ts +56 -70
  154. package/src/media-store/db.ts +1 -1
  155. package/src/media-store/fact.ts +1 -1
  156. package/src/media-store/hand.ts +1 -1
  157. package/src/media-store/kind.ts +1 -1
  158. package/src/media-store/purge.ts +1 -1
  159. package/src/media-store/put.ts +5 -3
  160. package/src/media-store/remote.ts +1 -1
  161. package/src/media-store/space.ts +24 -5
  162. package/src/mv/mv-md.ts +63 -22
  163. package/src/pages/forward.ts +35 -0
  164. package/src/pages/frame-client.ts +118 -0
  165. package/src/pages/routes.ts +29 -0
  166. package/src/pages/unit.ts +92 -0
  167. package/src/plan/planner.ts +12 -0
  168. package/src/plan/repo-source.ts +19 -5
  169. package/src/reflect/transcript.ts +35 -10
  170. package/src/release/public-clean.ts +319 -0
  171. package/src/release/published-here.ts +22 -0
  172. package/src/release/run-bump.ts +3 -2
  173. package/src/release/run-release.ts +7 -4
  174. package/src/repo-config.ts +71 -13
  175. package/src/review/anim.ts +1 -1
  176. package/src/review/auto.ts +1 -1
  177. package/src/review/cells.ts +15 -1
  178. package/src/review/format.ts +2 -2
  179. package/src/review/http.ts +16 -2
  180. package/src/review/marks.ts +1 -1
  181. package/src/review/media-kind.ts +1 -1
  182. package/src/review/media-read.ts +1 -1
  183. package/src/review/model.ts +27 -6
  184. package/src/review/notes.ts +125 -0
  185. package/src/review/previews.ts +1 -1
  186. package/src/review/project.ts +7 -39
  187. package/src/review/role.ts +1 -1
  188. package/src/review/routes.ts +18 -14
  189. package/src/review/store.ts +42 -2
  190. package/src/review/threads.ts +1 -1
  191. package/src/review/trailer-desk.ts +3 -3
  192. package/src/review/trailer-media.ts +8 -5
  193. package/src/review/trailer-model.ts +1 -1
  194. package/src/review/trailer-routes.ts +1 -1
  195. package/src/review/trailer-shots.ts +22 -5
  196. package/src/review/unit.ts +2 -2
  197. package/src/scaffold/files/agent-handoff.md +3 -0
  198. package/src/scaffold/files/agent-index.md +4 -12
  199. package/src/scaffold/files/tsconfig.json +1 -1
  200. package/src/scaffold/project-scaffold.ts +6 -5
  201. package/src/serve/embed.ts +2 -2
  202. package/src/serve/hub-app/check-words.ts +1 -1
  203. package/src/serve/hub-app/col-card.tsx +3 -17
  204. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  205. package/src/serve/hub-app/cols-svc.ts +0 -13
  206. package/src/serve/hub-app/dock-st.ts +4 -2
  207. package/src/serve/hub-app/dock-view.tsx +2 -0
  208. package/src/serve/hub-app/frames-st.ts +35 -0
  209. package/src/serve/hub-app/hash-route.ts +64 -1
  210. package/src/serve/hub-app/home-st.ts +32 -8
  211. package/src/serve/hub-app/home-strip.css +9 -1
  212. package/src/serve/hub-app/home-strip.tsx +7 -6
  213. package/src/serve/hub-app/home.html +5 -0
  214. package/src/serve/hub-app/hub-app.tsx +51 -7
  215. package/src/serve/hub-app/hub.css +29 -11
  216. package/src/serve/hub-app/icons.tsx +16 -1
  217. package/src/serve/hub-app/identities-st.ts +210 -0
  218. package/src/serve/hub-app/identities-view.tsx +353 -0
  219. package/src/serve/hub-app/identities.css +48 -0
  220. package/src/serve/hub-app/identity-address.ts +52 -0
  221. package/src/serve/hub-app/inbox-st.ts +60 -7
  222. package/src/serve/hub-app/inbox-view.tsx +49 -7
  223. package/src/serve/hub-app/inbox.css +12 -1
  224. package/src/serve/hub-app/index.html +3 -0
  225. package/src/serve/hub-app/kept-cols.tsx +30 -0
  226. package/src/serve/hub-app/keys.ts +10 -2
  227. package/src/serve/hub-app/list-walk.ts +89 -0
  228. package/src/serve/hub-app/machine-st.ts +12 -0
  229. package/src/serve/hub-app/media-svc.ts +1 -1
  230. package/src/serve/hub-app/media-view.tsx +2 -1
  231. package/src/serve/hub-app/pages-frames.tsx +134 -0
  232. package/src/serve/hub-app/pages-svc.ts +111 -0
  233. package/src/serve/hub-app/palette-st.ts +18 -3
  234. package/src/serve/hub-app/palette-view.tsx +9 -2
  235. package/src/serve/hub-app/planned-view.tsx +2 -1
  236. package/src/serve/hub-app/project-list.css +18 -14
  237. package/src/serve/hub-app/project-list.tsx +88 -49
  238. package/src/serve/hub-app/projects-svc.ts +33 -3
  239. package/src/serve/hub-app/repo-sections.ts +19 -2
  240. package/src/serve/hub-app/repo-st.ts +76 -20
  241. package/src/serve/hub-app/review/review-board.tsx +1 -1
  242. package/src/serve/hub-app/review/review-cells.tsx +6 -5
  243. package/src/serve/hub-app/review/review-kit.ts +30 -7
  244. package/src/serve/hub-app/review/review-page.tsx +6 -5
  245. package/src/serve/hub-app/review/review-st.ts +34 -15
  246. package/src/serve/hub-app/review/review-thread.tsx +63 -14
  247. package/src/serve/hub-app/review/review-views.tsx +133 -51
  248. package/src/serve/hub-app/review/thread-st.ts +80 -37
  249. package/src/serve/hub-app/review/trailer-page.tsx +7 -5
  250. package/src/serve/hub-app/review/trailer-st.ts +1 -1
  251. package/src/serve/hub-app/review.css +26 -9
  252. package/src/serve/hub-app/site/site-part.tsx +173 -0
  253. package/src/serve/hub-app/site/site-st.ts +157 -0
  254. package/src/serve/hub-app/site.css +35 -0
  255. package/src/serve/hub-app/social/calendar.tsx +182 -0
  256. package/src/serve/hub-app/social/comms-page.tsx +330 -0
  257. package/src/serve/hub-app/social/kit.tsx +244 -0
  258. package/src/serve/hub-app/social/post-card.tsx +456 -0
  259. package/src/serve/hub-app/social/problems.tsx +60 -0
  260. package/src/serve/hub-app/social/social-model.ts +154 -0
  261. package/src/serve/hub-app/social/social-page.tsx +681 -0
  262. package/src/serve/hub-app/social/social-st.ts +1014 -0
  263. package/src/serve/hub-app/social.css +289 -0
  264. package/src/serve/hub-app/stores/stores-page.tsx +312 -0
  265. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  266. package/src/serve/hub-app/stores.css +54 -0
  267. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  268. package/src/serve/hub-app/timeline-view.tsx +3 -2
  269. package/src/serve/hub-app/tree-build.ts +6 -0
  270. package/src/serve/hub-app/tree-row.tsx +27 -4
  271. package/src/serve/hub-app/tree-svc.ts +18 -49
  272. package/src/serve/hub-app/veille/veille-page.tsx +515 -0
  273. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  274. package/src/serve/hub-app/veille.css +84 -0
  275. package/src/serve/hub-runtime.ts +20 -11
  276. package/src/serve/project-gutter-route.ts +44 -12
  277. package/src/serve/run-lanes.ts +7 -4
  278. package/src/serve/same-origin.ts +1 -1
  279. package/src/serve/serve-hub.ts +20 -12
  280. package/src/serve/tracked-watch.ts +24 -3
  281. package/src/serve/warm-cell.ts +5 -1
  282. package/src/shipkit-files.ts +15 -4
  283. package/src/shipkit.ts +0 -1
  284. package/src/shot/box.ts +160 -0
  285. package/src/shot/browser-slot.ts +74 -0
  286. package/src/shot/client.ts +42 -7
  287. package/src/shot/clip-encoder.ts +108 -24
  288. package/src/shot/film-box.ts +292 -0
  289. package/src/shot/shooter.ts +71 -17
  290. package/src/shot/shot-ask.ts +10 -2
  291. package/src/shot/stepped-clip.ts +5 -4
  292. package/src/site/desk.ts +242 -0
  293. package/src/site/routes.ts +66 -0
  294. package/src/site/unit.ts +62 -0
  295. package/src/social/brands.ts +22 -0
  296. package/src/social/card-drafts.ts +24 -0
  297. package/src/social/compose.ts +97 -0
  298. package/src/social/desk-index.ts +123 -0
  299. package/src/social/desk-wire.ts +64 -0
  300. package/src/social/drafts.ts +183 -0
  301. package/src/social/house.ts +24 -0
  302. package/src/social/load.ts +332 -0
  303. package/src/social/md.ts +70 -0
  304. package/src/social/media-facts.ts +53 -0
  305. package/src/social/media-kind.ts +189 -0
  306. package/src/social/media-limit.ts +42 -0
  307. package/src/social/media-of.ts +30 -0
  308. package/src/social/migrate.ts +123 -0
  309. package/src/social/open.ts +17 -0
  310. package/src/social/post-url.ts +158 -0
  311. package/src/social/presence.ts +332 -0
  312. package/src/social/public-read.ts +53 -0
  313. package/src/social/publish/bluesky.ts +168 -0
  314. package/src/social/publish/discord.ts +76 -0
  315. package/src/social/publish/index.ts +24 -0
  316. package/src/social/publish/secret.ts +13 -0
  317. package/src/social/push.ts +37 -0
  318. package/src/social/richtext.ts +37 -0
  319. package/src/social/routes.ts +186 -0
  320. package/src/social/stats.ts +134 -0
  321. package/src/social/text.ts +267 -0
  322. package/src/social/tracker-route.ts +39 -0
  323. package/src/social/tracker.ts +255 -0
  324. package/src/social/unit.ts +53 -0
  325. package/src/social/writes.ts +130 -0
  326. package/src/start-repo.ts +14 -9
  327. package/src/stores/collection.ts +27 -0
  328. package/src/stores/desk.ts +336 -0
  329. package/src/stores/model.ts +187 -0
  330. package/src/stores/routes.ts +126 -0
  331. package/src/stores/unit.ts +57 -0
  332. package/src/suite/calibrate.ts +127 -0
  333. package/src/suite/core-counters.ts +91 -0
  334. package/src/suite/judge-suites.ts +95 -35
  335. package/src/suite/suite-cli.ts +44 -10
  336. package/src/suite/suite-cpu-preload.ts +34 -9
  337. package/src/trace/tracer.ts +12 -5
  338. package/src/trailer/adapter.ts +5 -1
  339. package/src/trailer/build.ts +45 -12
  340. package/src/trailer/ffmpeg.ts +11 -0
  341. package/src/trailer/footage.ts +30 -13
  342. package/src/trailer/grammar.ts +18 -2
  343. package/src/trailer/graph.ts +28 -6
  344. package/src/trailer/holes.ts +1 -1
  345. package/src/trailer/passage.ts +18 -6
  346. package/src/trailer/plan.ts +74 -3
  347. package/src/trailer/prune.ts +1 -1
  348. package/src/trailer/states.ts +1 -1
  349. package/src/trailer/stitch.ts +67 -26
  350. package/src/trailer/url.ts +1 -1
  351. package/src/trailer/versions.ts +24 -0
  352. package/src/trailer/words.ts +1 -1
  353. package/src/ts/gate-typecheck.ts +32 -0
  354. package/src/ts/typecheck-cli.ts +9 -11
  355. package/src/tui/run-tui.ts +1 -1
  356. package/src/tui/tui-app.tsx +0 -1
  357. package/src/tui/tui-store.ts +1 -1
  358. package/src/veille/asks.ts +155 -0
  359. package/src/veille/auto.ts +31 -0
  360. package/src/veille/batch.ts +27 -0
  361. package/src/veille/chrome.ts +127 -0
  362. package/src/veille/collection.ts +28 -0
  363. package/src/veille/desk.ts +242 -0
  364. package/src/veille/identity.ts +80 -0
  365. package/src/veille/import.ts +68 -0
  366. package/src/veille/log.ts +183 -0
  367. package/src/veille/platforms.ts +118 -0
  368. package/src/veille/reads.ts +66 -0
  369. package/src/veille/replied.ts +110 -0
  370. package/src/veille/routes.ts +185 -0
  371. package/src/veille/service.ts +81 -0
  372. package/src/veille/watch.ts +116 -0
  373. package/src/veille/worth.ts +46 -0
  374. package/src/wiki/scan-md.ts +18 -0
  375. package/src/collections/posts.ts +0 -142
  376. package/src/contracts/manifests/social.contract.ts +0 -20
  377. package/src/scaffold/files/agent-coding.md +0 -35
  378. package/src/ts/typecheck-cache.ts +0 -11
@@ -1,6 +1,6 @@
1
1
  // the views of one version, each its own numbered sub cell (`3.2`): a big title and its kind, drawn by kind (an image,
2
- // a pair side by side, as a curtain, an onion skin or the after alone, a clip on its own clock, a sound, a gallery), then
3
- // what was said on it right under it. Images come at the column's size (a 1600 px preview), the full file only on zoom.
2
+ // a pair side by side, as a curtain, an onion skin, the after alone or only its changes, a clip on its own clock, a sound,
3
+ // a gallery), with what was said on it and his word above the view. Images come at the column's size (a 1600 px preview), the full file only on zoom.
4
4
  // The newest version takes his marks: a drag on an image draws a rectangle whose note box opens beside it, a clip pauses
5
5
  // and keeps the frame's time. A choice, or views that each play alone, read as option rows, each image and clip full
6
6
  // under its row
@@ -14,19 +14,29 @@ import { blurOnEscape, FIT_ROOM, keepFocus, PAIR_NAMES, REACTIONS, secs, SIDE_LA
14
14
  import { ZOOMS, type Zoom } from './review-kit.ts'
15
15
  import { COMPARE_MODES, drawnSide, type CompareMode, type CompareSt, type PairSide, type ReviewSt } from './review-st.ts'
16
16
  import { viewDom, viewKind, viewKey, type ThreadSt } from './thread-st.ts'
17
+ import { Caret } from '../icons.tsx'
17
18
 
18
19
  const ZOOM_LABEL: Record<Zoom, string> = { fit: 'Fit', '1': '100 %', '1.5': '150 %', '2': '200 %' }
19
20
  const toneClass = (s: string | undefined): string => (s ? ` re-${s}` : '')
20
21
 
21
- /** one version as its views draw it: `live` when it takes his marks (the newest version of an agent's card, no draft) */
22
+ /** one version as its views draw it: `live` when his answer goes to it and it draws his draft; `claim` when it is the
23
+ * newest while his answer sits on an older version: it takes his marks, and the first one brings his answer here */
22
24
  export interface Ver {
23
25
  rv: ReviewSt
24
26
  card: ThreadSt
25
27
  cell: VersionCell
26
28
  live: boolean
29
+ claim: boolean
27
30
  }
28
31
 
29
32
  const itemOf = (ver: Ver): Item => ver.cell.item
33
+ /** the version takes his marks: OK, Fix, No, a rectangle, a word, a star, a pick */
34
+ const takes = (ver: Ver): boolean => ver.live || ver.claim
35
+ /** a mark on a claiming version: his answer comes to it first, then the mark lands in its own draft */
36
+ const mark = (ver: Ver, f: () => void): void => {
37
+ if (ver.claim) ver.card.answerNewest()
38
+ f()
39
+ }
30
40
 
31
41
  /** a version's views: its bar (rows or full, « Circle » on a phone, the zoom), then each view as a sub cell or a row */
32
42
  export const VersionViews = observer(({ ver }: { ver: Ver }) => {
@@ -34,7 +44,7 @@ export const VersionViews = observer(({ ver }: { ver: Ver }) => {
34
44
  const item = itemOf(ver)
35
45
  const views = item.views
36
46
  const rows = card.rows(item)
37
- const drawable = ver.live && views.some((v) => !isGallery(v) && !v.clip && !v.audio)
47
+ const drawable = takes(ver) && views.some((v) => !isGallery(v) && !v.clip && !v.audio)
38
48
  // a draft card's history is no view of its own: its frames cycle in place over the live one
39
49
  const history = item.wip ? views.find(isGallery) : undefined
40
50
  const options = rows || (card.full[item.id] === true)
@@ -49,7 +59,7 @@ export const VersionViews = observer(({ ver }: { ver: Ver }) => {
49
59
  ) : null}
50
60
  {rv.phone.on && drawable ? <button className={rv.phone.draw ? 'primary' : ''} onClick={() => rv.phone.toggleDraw()}>Circle</button> : null}
51
61
  <span className="sp" />
52
- <span className="seg" title="the zoom every view starts at">
62
+ <span className="seg" title="the zoom of every view of every card">
53
63
  {ZOOMS.map((z) => <button key={z} className={rv.zoom === z ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setZoom(z)}>{ZOOM_LABEL[z]}</button>)}
54
64
  </span>
55
65
  </div>
@@ -62,33 +72,30 @@ export const VersionViews = observer(({ ver }: { ver: Ver }) => {
62
72
  )
63
73
  })
64
74
 
65
- /** one view as a sub cell: its number and title, its kind, the owner's reaction, its tools, the view, then what was said on it */
75
+ /** one view as a sub cell: its number and title, its kind, the owner's reaction, its tools, what was said on it and his word, then the view */
66
76
  const ViewCell = observer(({ ver, v: live, i, frames }: { ver: Ver; v: ReviewView; i: number; frames?: GalleryView }) => {
67
77
  const { rv, card, cell } = ver
68
78
  const past = frames && card.frame !== null ? frames.gallery[card.frame] : undefined
69
79
  const v: ReviewView = past && !isGallery(live) ? { ...live, files: { image: past.file }, size: past.size } : live
70
80
  const media = isGallery(v) ? null : v
71
81
  const open = card.viewOpen(cell.id, i)
72
- const zoom = card.zoomOf(cell.id, i)
82
+ const zoom = rv.zoom
73
83
  const shown = card.reactionShown(cell, i)
74
84
  const active = ver.live && card.view === i
75
85
  const gone = goneOf(ver, v)
76
86
  return (
77
87
  <section id={viewDom(cell.id, i)} className={`rv-view${toneClass(shown?.status)}${active ? ' active' : ''}${open ? '' : ' folded'}`}>
78
88
  <header className="rv-viewhead">
79
- <button className="rv-foldbtn" aria-label={open ? 'fold this view' : 'unfold this view'} aria-expanded={open} onMouseDown={keepFocus} onClick={() => card.toggleView(cell.id, i)}>{open ? '▾' : '▸'}</button>
89
+ <button className="rv-foldbtn" aria-label={open ? 'fold this view' : 'unfold this view'} aria-expanded={open} onMouseDown={keepFocus} onClick={() => card.toggleView(cell.id, i)}><Caret open={open} /></button>
80
90
  <span className="rv-viewn">{viewTag(cell.n, i)}</span>
81
91
  <h4 className="rv-viewname" onClick={() => card.toggleView(cell.id, i)}>{v.label || <span className="rv-dim">{viewName(v, i)}</span>}</h4>
82
92
  <span className="rv-kind">{viewKind(v, false)}</span>
83
- {ver.live ? <ReactionToggles card={card} view={i} /> : shown?.status ? <SentReaction status={shown.status} /> : null}
93
+ {takes(ver) ? <ReactionToggles ver={ver} view={i} /> : shown?.status ? <SentReaction status={shown.status} /> : null}
84
94
  <span className="sp" />
85
95
  {open && media?.marks && media.marks.length > 0 ? <button className={rv.marksOn ? 'primary' : ''} onMouseDown={keepFocus} onClick={() => rv.toggleMarks()}>marks · M</button> : null}
86
96
  {open && media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} /> : null}
87
- {open && media && !media.audio ? (
88
- <button title={zoom === 'fit' ? 'see this image at its own size, the full file' : 'fit this image to the column'} onMouseDown={keepFocus}
89
- onClick={() => card.setViewZoom(cell.id, i, zoom === 'fit' ? '1' : 'fit')}>{zoom === 'fit' ? '100 %' : 'Fit'}</button>
90
- ) : null}
91
97
  </header>
98
+ <ViewNotes ver={ver} i={i} gallery={isGallery(v)} />
92
99
  {open ? (
93
100
  <div className="rv-viewbody">
94
101
  {frames ? <FrameSlider card={card} frames={frames} /> : null}
@@ -96,12 +103,11 @@ const ViewCell = observer(({ ver, v: live, i, frames }: { ver: Ver; v: ReviewVie
96
103
  {media?.note ? <div className="rv-viewnote">{media.note}</div> : null}
97
104
  </div>
98
105
  ) : null}
99
- <ViewNotes ver={ver} i={i} gallery={isGallery(v)} />
100
106
  </section>
101
107
  )
102
108
  })
103
109
 
104
- /** what was said on one view, under it: each answer's rectangles and reactions (a click shows the rectangle), then on
110
+ /** what was said on one view, above it: each answer's rectangles and reactions (a click shows the rectangle), then on
105
111
  * the newest version his draft: each rectangle's word, his word on the view */
106
112
  const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: number; gallery: boolean; word?: boolean }) => {
107
113
  const { card, cell } = ver
@@ -109,7 +115,7 @@ const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: num
109
115
  const views = itemOf(ver).views
110
116
  const draft = ver.live ? card.draft.rects.map((r, k) => [r, k] as const).filter(([r]) => (r.view ?? 0) === i) : []
111
117
  const reaction = ver.live ? card.reactionOf(i) : null
112
- if (said.length === 0 && draft.length === 0 && !(ver.live && word)) return null
118
+ if (said.length === 0 && draft.length === 0 && !(takes(ver) && word)) return null
113
119
  return (
114
120
  <div className="rv-viewnotes">
115
121
  {said.map((s, k) => {
@@ -142,9 +148,9 @@ const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: num
142
148
  <button className="ghost rv-x" title="delete this note" aria-label="delete this note" onClick={() => card.removeRect(k)}>✕</button>
143
149
  </div>
144
150
  ))}
145
- {ver.live && word ? (
151
+ {takes(ver) && word ? (
146
152
  <AutoText className="rv-word" placeholder={gallery ? 'a word on these images' : 'a word on this view'} value={reaction?.comment ?? ''}
147
- onKeyDown={blurOnEscape} onText={(t) => card.setReactionComment(i, undefined, t)} />
153
+ onKeyDown={blurOnEscape} onText={(t) => mark(ver, () => card.setReactionComment(i, undefined, t))} />
148
154
  ) : null}
149
155
  </div>
150
156
  )
@@ -175,7 +181,7 @@ const OptionRow = observer(({ ver, v, i }: { ver: Ver; v: ReviewView; i: number
175
181
  const unfolded = card.rowOpen(item, i)
176
182
  const file = playable ? ('video' in playable.files ? playable.files.video : 'audio' in playable.files ? playable.files.audio : '') : ''
177
183
  const duration = playable?.clip?.duration ?? playable?.audio?.duration ?? 0
178
- const showWord = ver.live && (word || (reaction?.comment ?? '') !== '')
184
+ const showWord = takes(ver) && (word || (reaction?.comment ?? '') !== '')
179
185
  const active = ver.live && card.view === i
180
186
  // an unfolded clip plays under its own bar: the row keeps no second clock
181
187
  const clock2 = c !== null && !(unfolded && playable?.clip)
@@ -202,14 +208,14 @@ const OptionRow = observer(({ ver, v, i }: { ver: Ver; v: ReviewView; i: number
202
208
  )}
203
209
  {c && clock2 ? <span className="rv-mono rv-opttime">{clock(c.time)} / {clock(duration)}</span> : null}
204
210
  <span className="rv-optacts">
205
- {choice ? <Stars card={card} view={i} live={ver.live} given={reaction?.stars} /> : ver.live ? <ReactionToggles card={card} view={i} /> : reaction?.status ? <SentReaction status={reaction.status} /> : null}
206
- {ver.live ? <button className={`rv-optword${showWord ? ' on' : ''}`} title="a word on this one" onMouseDown={keepFocus} onClick={() => setWord(!word)}>✎ word</button> : null}
211
+ {choice ? <Stars ver={ver} view={i} given={reaction?.stars} /> : takes(ver) ? <ReactionToggles ver={ver} view={i} /> : reaction?.status ? <SentReaction status={reaction.status} /> : null}
212
+ {takes(ver) ? <button className={`rv-optword${showWord ? ' on' : ''}`} title="a word on this one" onMouseDown={keepFocus} onClick={() => setWord(!word)}>✎ word</button> : null}
207
213
  {playable?.clip || !playable ? (
208
- <button className={unfolded ? 'on' : ''} title={unfolded ? 'fold it back to its row' : 'show it full under its row'} onMouseDown={keepFocus} onClick={() => card.toggleRow(item, i)}>{unfolded ? '▴ fold' : '▾ show'}</button>
214
+ <button className={unfolded ? 'on' : ''} title={unfolded ? 'fold it back to its row' : 'show it full under its row'} onMouseDown={keepFocus} onClick={() => card.toggleRow(item, i)}><Caret v open={unfolded} /> {unfolded ? 'fold' : 'show'}</button>
209
215
  ) : null}
210
216
  {playable?.audio ? <a className="rv-dl" href={rv.fileUrl(id, file)} download={`${id}-${file}`} title="download the sound">⤓</a> : null}
211
- {choice && ver.live ? (
212
- <button className={`rv-pick${picked ? ' on' : ''}`} title="pick this one: it is your answer (P)" disabled={card.busy} onClick={() => void card.choose(i)}>
217
+ {choice && takes(ver) ? (
218
+ <button className={`rv-pick${picked ? ' on' : ''}`} title="pick this one: it is your answer (P)" disabled={card.busy} onClick={() => mark(ver, () => void card.choose(i))}>
213
219
  {picked ? '✓ picked' : 'pick'}
214
220
  </button>
215
221
  ) : choice && picked ? <span className="rv-pick on">✓ picked</span> : null}
@@ -219,12 +225,12 @@ const OptionRow = observer(({ ver, v, i }: { ver: Ver; v: ReviewView; i: number
219
225
  {!ver.live && reaction?.comment ? <div className="rv-optnote rv-saidtext">« {reaction.comment} »</div> : null}
220
226
  {showWord ? (
221
227
  <AutoText className="rv-word" placeholder="a word on this one" value={reaction?.comment ?? ''} autoFocus={word && !reaction?.comment}
222
- onKeyDown={blurOnEscape} onText={(t) => card.setReactionComment(i, undefined, t)} />
228
+ onKeyDown={blurOnEscape} onText={(t) => mark(ver, () => card.setReactionComment(i, undefined, t))} />
223
229
  ) : null}
224
230
  {c && playable?.audio ? <SoundEl clip={c} src={rv.fileUrl(id, file)} /> : null}
225
231
  {unfolded ? (
226
232
  <div className="rv-optbody">
227
- {gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} /> : <MediaBody ver={ver} v={v} i={i} zoom={card.zoomOf(id, i)} />}
233
+ {gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} /> : <MediaBody ver={ver} v={v} i={i} zoom={ver.rv.zoom} />}
228
234
  </div>
229
235
  ) : null}
230
236
  <ViewNotes ver={ver} i={i} gallery={isGallery(v)} word={false} />
@@ -252,12 +258,14 @@ const Gone = ({ files }: { files: readonly string[] }) => (
252
258
  const clock = (t: number): string => `${Math.floor(t / 60)}:${String(Math.floor(t % 60)).padStart(2, '0')}`
253
259
 
254
260
  /** an option's score: STARS stars, a click on the one given clears it; an older version's stars as he gave them */
255
- const Stars = observer(({ card, view, live, given }: { card: ThreadSt; view: number; live: boolean; given: number | undefined }) => {
261
+ const Stars = observer(({ ver, view, given }: { ver: Ver; view: number; given: number | undefined }) => {
262
+ const { card } = ver
263
+ const live = takes(ver)
256
264
  const n = given ?? 0
257
265
  return (
258
266
  <span className="rv-stars" title={live ? `your score (⇧1 to ⇧${STARS} on the row playing)` : 'your score'}>
259
267
  {Array.from({ length: STARS }, (_, k) => (
260
- <button key={k} className={k < n ? 'on' : ''} disabled={!live} aria-label={`${k + 1} of ${STARS}`} onMouseDown={keepFocus} onClick={() => card.setStars(view, k + 1)}>{k < n ? '★' : '☆'}</button>
268
+ <button key={k} className={k < n ? 'on' : ''} disabled={!live} aria-label={`${k + 1} of ${STARS}`} onMouseDown={keepFocus} onClick={() => mark(ver, () => card.setStars(view, k + 1))}>{k < n ? '★' : '☆'}</button>
261
269
  ))}
262
270
  </span>
263
271
  )
@@ -323,13 +331,14 @@ const FrameSlider = observer(({ card, frames }: { card: ThreadSt; frames: Galler
323
331
  })
324
332
 
325
333
  /** the owner's reaction to one view or tile of the newest version: OK, fix or no; a click on the chosen one clears it */
326
- const ReactionToggles = observer(({ card, view, tile, small }: { card: ThreadSt; view: number; tile?: number; small?: boolean }) => {
327
- const cur = card.reactionOf(view, tile)?.status
334
+ const ReactionToggles = observer(({ ver, view, tile, small }: { ver: Ver; view: number; tile?: number; small?: boolean }) => {
335
+ const { card } = ver
336
+ const cur = ver.claim ? undefined : card.reactionOf(view, tile)?.status
328
337
  return (
329
338
  <span className="rv-reacts">
330
339
  {REACTIONS.map((o) => (
331
340
  <button key={o.status} title={o.tip} className={`rv-react re-${o.status}${small ? '' : ' big'}${cur === o.status ? ' on' : ''}${cur && cur !== o.status ? ' off' : ''}`}
332
- onMouseDown={keepFocus} onClick={() => card.react(view, tile, o.status)}>
341
+ onMouseDown={keepFocus} onClick={() => mark(ver, () => card.react(view, tile, o.status))}>
333
342
  {o.glyph} {o.label}
334
343
  </button>
335
344
  ))}
@@ -359,10 +368,10 @@ const Gallery = observer(({ ver, v, view }: { ver: Ver; v: GalleryView; view: nu
359
368
  <img src={big ? rv.fitUrl(id, t.file) : rv.thumbUrl(id, t.file)} alt={t.label} draggable={false} loading="lazy" />
360
369
  </div>
361
370
  <div className="rv-tilelabel" title={t.label}>{t.label}</div>
362
- {ver.live ? (
371
+ {takes(ver) ? (
363
372
  <>
364
- <ReactionToggles card={card} view={view} tile={k} small />
365
- <AutoText className="rv-word" placeholder="a word" value={r?.comment ?? ''} onKeyDown={blurOnEscape} onText={(t) => card.setReactionComment(view, k, t)} />
373
+ <ReactionToggles ver={ver} view={view} tile={k} small />
374
+ <AutoText className="rv-word" placeholder="a word" value={r?.comment ?? ''} onKeyDown={blurOnEscape} onText={(t) => mark(ver, () => card.setReactionComment(view, k, t))} />
366
375
  </>
367
376
  ) : r?.status ? <SentReaction status={r.status} /> : null}
368
377
  </div>
@@ -393,7 +402,7 @@ const MediaBody = observer(({ ver, v, i, zoom }: { ver: Ver; v: MediaView; i: nu
393
402
  <div style={scroll}>
394
403
  <div style={{ width: scale ? `${v.size.w * scale}px` : `min(100%, calc((100vh - ${room}px) * ${ratio}))`, margin: '0 auto' }}>
395
404
  <Compare c={rv.compare} base={src(name)} mod={undefined} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={undefined} view={i} />}
396
- over={() => (ver.live ? <RectNote card={card} view={i} sides={[undefined]} /> : null)} />
405
+ over={() => (ver.live ? <RectNote ver={ver} view={i} sides={[undefined]} /> : null)} />
397
406
  {bar}
398
407
  <Downloads rv={rv} item={item} files={[{ file: name }]} />
399
408
  </div>
@@ -418,8 +427,8 @@ const MediaBody = observer(({ ver, v, i, zoom }: { ver: Ver; v: MediaView; i: nu
418
427
  <div style={scroll}>
419
428
  <div className="rv-pairgrid" style={{ width: scale ? `${v.size.w * scale * cols + 8 * (cols - 1)}px` : fitW, gridTemplateColumns: `repeat(${cols}, 1fr)` }}>
420
429
  <Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect}
421
- draw={(s) => <Marks ver={ver} src={s} side={drawnSide(c.mode, s === before ? 'before' : 'after')} view={i} />}
422
- over={(srcs) => (ver.live ? <RectNote card={card} view={i} sides={srcs.map((s) => drawnSide(c.mode, s === before ? 'before' : 'after'))} /> : null)} />
430
+ draw={(s, face) => <Marks ver={ver} src={s} side={drawnSide(c.mode, s === before ? 'before' : 'after')} view={i} face={face} />}
431
+ over={(srcs) => (ver.live ? <RectNote ver={ver} view={i} sides={srcs.map((s) => drawnSide(c.mode, s === before ? 'before' : 'after'))} /> : null)} />
423
432
  </div>
424
433
  </div>
425
434
  {bar ? <div style={{ width: fitW, margin: '0 auto' }}>{bar}</div> : null}
@@ -484,7 +493,7 @@ const PhonePair = observer(({ ver, view, bar, before, after, aspect, size, scale
484
493
  size: { w: number; h: number }
485
494
  scale: number | null
486
495
  }) => {
487
- const { rv, card } = ver
496
+ const { rv } = ver
488
497
  const ph = rv.phone
489
498
  const c = rv.compare
490
499
  const side = ph.pair === 'swipe' && c.mode !== 'swipe' ? 'after' : ph.pair
@@ -500,10 +509,10 @@ const PhonePair = observer(({ ver, view, bar, before, after, aspect, size, scale
500
509
  <div style={{ width: scale ? `${size.w * scale}px` : '100%' }}>
501
510
  {side === 'swipe' ? (
502
511
  <Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={s === before ? 'before' : 'after'} view={view} />}
503
- over={(srcs) => (ver.live ? <RectNote card={card} view={view} sides={srcs.map((s) => (s === before ? 'before' : 'after'))} /> : null)} />
512
+ over={(srcs) => (ver.live ? <RectNote ver={ver} view={view} sides={srcs.map((s) => (s === before ? 'before' : 'after'))} /> : null)} />
504
513
  ) : (
505
514
  <Compare key={side} c={c} base={one} mod={undefined} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={side} view={view} />}
506
- over={() => (ver.live ? <RectNote card={card} view={view} sides={[side]} /> : null)} />
515
+ over={() => (ver.live ? <RectNote ver={ver} view={view} sides={[side]} /> : null)} />
507
516
  )}
508
517
  {bar}
509
518
  </div>
@@ -519,6 +528,7 @@ const MODES: { mode: CompareMode; glyph: string; tip: string }[] = [
519
528
  { mode: 'swipe', glyph: '⇹', tip: 'curtain: drag the line, the before on the left, the after on the right' },
520
529
  { mode: 'onion', glyph: '◐', tip: 'onion skin: the after over the before' },
521
530
  { mode: 'mod', glyph: '▣', tip: 'the after alone: hovering the image shows the before' },
531
+ { mode: 'diff', glyph: '≠', tip: 'only what changed: the after\'s changed pixels in colour, the rest faded' },
522
532
  ]
523
533
 
524
534
  /** the compare modes as tiny buttons, the onion's opacity floating under them */
@@ -527,7 +537,7 @@ const CompareModes = observer(({ c }: { c: CompareSt }) => (
527
537
  <span className="seg">
528
538
  {COMPARE_MODES.map((m) => {
529
539
  const o = MODES.find((x) => x.mode === m)!
530
- return <button key={m} title={o.tip} className={c.mode === m ? 'on' : ''} onMouseDown={keepFocus} onClick={() => c.setMode(m)}>{o.glyph}</button>
540
+ return <button key={m} title={`${o.tip} (D cycles, ⇧D back)`} className={c.mode === m ? 'on' : ''} onMouseDown={keepFocus} onClick={() => c.setMode(m)}>{o.glyph}</button>
531
541
  })}
532
542
  </span>
533
543
  {c.mode === 'onion' ? (
@@ -536,6 +546,65 @@ const CompareModes = observer(({ c }: { c: CompareSt }) => (
536
546
  </span>
537
547
  ))
538
548
 
549
+ /** a channel sum under this is the encoder's noise, never a change */
550
+ const DIFF_NOISE = 24
551
+
552
+ /** the share of the pixels that changed, as the caption says it */
553
+ const changesWords = (share: number | null | undefined): string =>
554
+ share === undefined ? 'reading…' : share === null ? 'could not be read' : share === 0 ? 'none: no pixel differs' : `${share < 0.001 ? '< 0.1' : (share * 100).toFixed(1)} % of the pixels`
555
+
556
+ /** the after, only where it changed from the before: each changed pixel in its own colour, every other pixel a pale
557
+ * gray of it, so what moved is all that stands out. Read in the browser from the two previews; `say` gets the share
558
+ * that changed, undefined while it reads, null when an image cannot be read */
559
+ const DiffCanvas = ({ base, mod, say }: { base: string; mod: string; say: (share: number | null | undefined) => void }) => {
560
+ const ref = useRef<HTMLCanvasElement>(null)
561
+ useEffect(() => {
562
+ let gone = false
563
+ const load = (src: string): Promise<HTMLImageElement> =>
564
+ new Promise((ok, no) => {
565
+ const img = new Image()
566
+ img.onload = () => ok(img)
567
+ img.onerror = () => no(new Error(src))
568
+ img.src = src
569
+ })
570
+ say(undefined)
571
+ Promise.all([load(base), load(mod)]).then(([a, b]) => {
572
+ const cv = ref.current
573
+ if (gone || cv == null) return
574
+ const w = b.naturalWidth
575
+ const h = b.naturalHeight
576
+ cv.width = w
577
+ cv.height = h
578
+ const ctx = cv.getContext('2d', { willReadFrequently: true })
579
+ if (ctx == null) return say(null)
580
+ ctx.drawImage(a, 0, 0, w, h)
581
+ const pa = ctx.getImageData(0, 0, w, h).data
582
+ ctx.drawImage(b, 0, 0, w, h)
583
+ const out = ctx.getImageData(0, 0, w, h)
584
+ const pb = out.data
585
+ let changed = 0
586
+ for (let i = 0; i < pb.length; i += 4) {
587
+ if (Math.abs(pa[i]! - pb[i]!) + Math.abs(pa[i + 1]! - pb[i + 1]!) + Math.abs(pa[i + 2]! - pb[i + 2]!) > DIFF_NOISE) {
588
+ changed++
589
+ continue
590
+ }
591
+ const v = 228 + (pb[i]! * 0.3 + pb[i + 1]! * 0.59 + pb[i + 2]! * 0.11) * 0.1
592
+ pb[i] = v
593
+ pb[i + 1] = v
594
+ pb[i + 2] = v
595
+ }
596
+ ctx.putImageData(out, 0, 0)
597
+ say(changed / (w * h))
598
+ }, () => {
599
+ if (!gone) say(null)
600
+ })
601
+ return () => {
602
+ gone = true
603
+ }
604
+ }, [base, mod, say])
605
+ return <canvas ref={ref} className="rv-diff" />
606
+ }
607
+
539
608
  /** follows the pointer until it is released */
540
609
  function track(move: (e: PointerEvent) => void): void {
541
610
  const up = (): void => {
@@ -549,8 +618,9 @@ function track(move: (e: PointerEvent) => void): void {
549
618
  /** THE pair: side by side, the curtain clipping both images, the after over the before as an onion skin, or the
550
619
  * after alone (the before while the pointer is over it). One image alone when `mod` is undefined. `over` draws what
551
620
  * sits over a frame unclipped (the picked rectangle's note box), given the images that frame shows */
552
- const Compare = observer(({ c, base, mod, names, aspect, draw, over }: { c: CompareSt; base: string; mod: string | undefined; names?: { base: string; mod: string }; aspect: string; draw: (src: string) => ReactNode; over?: (srcs: string[]) => ReactNode }) => {
621
+ const Compare = observer(({ c, base, mod, names, aspect, draw, over }: { c: CompareSt; base: string; mod: string | undefined; names?: { base: string; mod: string }; aspect: string; draw: (src: string, face?: ReactNode) => ReactNode; over?: (srcs: string[]) => ReactNode }) => {
553
622
  const [peek, setPeek] = useState(false)
623
+ const [share, setShare] = useState<number | null | undefined>(undefined)
554
624
  if (mod === undefined) return <Frame aspect={aspect} caption={null} over={over?.([base])}><div className="rv-fill">{draw(base)}</div></Frame>
555
625
  const n = names ?? PAIR_NAMES
556
626
  if (c.mode === 'side')
@@ -560,6 +630,12 @@ const Compare = observer(({ c, base, mod, names, aspect, draw, over }: { c: Comp
560
630
  <Frame aspect={aspect} caption={n.mod} modCap over={over?.([mod])}><div className="rv-fill">{draw(mod)}</div></Frame>
561
631
  </>
562
632
  )
633
+ if (c.mode === 'diff')
634
+ return (
635
+ <Frame aspect={aspect} caption={<>changes <span className="rv-modcap">{changesWords(share)}</span></>} over={over?.([mod])}>
636
+ <div className="rv-fill">{draw(mod, <DiffCanvas base={base} mod={mod} say={setShare} />)}</div>
637
+ </Frame>
638
+ )
563
639
  if (c.mode === 'mod')
564
640
  return (
565
641
  <Frame aspect={aspect} caption={peek ? n.base : n.mod} modCap={!peek} onPeek={setPeek} over={over?.([peek ? base : mod])}>
@@ -612,10 +688,12 @@ const clamp01 = (v: number): number => Math.max(0, Math.min(1, v))
612
688
  /** a drag shorter than this, on either axis, is a click: it picks nothing */
613
689
  const MIN_DRAG = 0.01
614
690
 
615
- /** one image of view `view` and its rectangles: the ones his answers sent (still), and on the newest version his
616
- * draft's, a drag drawing one (never in the curtain, whose drag moves the line). A clip view of the newest version that
617
- * is not the active one loops on its own: a click makes it active */
618
- const Marks = observer(({ ver, src, side, view }: { ver: Ver; src: string; side: Side | undefined; view: number }) => {
691
+ /** one image or clip of view `view` and its rectangles: the ones his answers sent (still), and on the version his
692
+ * answer goes to his draft's, a drag drawing one (never in the curtain, whose drag moves the line). A clip view of
693
+ * that version that is not the active one loops on its own: a click makes it active. On a claiming version (the newest,
694
+ * his answer on an older one) a drag draws at once and brings his answer here. `face` takes the image's place (the
695
+ * changes of a pair) */
696
+ const Marks = observer(({ ver, src, side, view, face }: { ver: Ver; src: string; side: Side | undefined; view: number; face?: ReactNode }) => {
619
697
  const { rv, card, cell } = ver
620
698
  const el = useRef<HTMLDivElement>(null)
621
699
  const [drag, setDrag] = useState<{ x0: number; y0: number; x1: number; y1: number } | null>(null)
@@ -624,7 +702,7 @@ const Marks = observer(({ ver, src, side, view }: { ver: Ver; src: string; side:
624
702
  const shown = any && !isGallery(any) ? any : undefined
625
703
  const clip = shown?.clip
626
704
  const active = card.view === view
627
- const drawing = ver.live && (phone.on ? phone.draw && (side === undefined || phone.pair !== 'swipe' || rv.compare.mode !== 'swipe') : side === undefined || rv.compare.mode !== 'swipe')
705
+ const drawing = takes(ver) && (phone.on ? phone.draw && (side === undefined || phone.pair !== 'swipe' || rv.compare.mode !== 'swipe') : side === undefined || rv.compare.mode !== 'swipe')
628
706
  const c = clip ? card.clipOf(cell.id, view) : null
629
707
  const at = (e: { clientX: number; clientY: number }): { x: number; y: number } => {
630
708
  const b = el.current?.getBoundingClientRect()
@@ -641,6 +719,7 @@ const Marks = observer(({ ver, src, side, view }: { ver: Ver; src: string; side:
641
719
  if (!drawing) return
642
720
  e.preventDefault()
643
721
  e.stopPropagation()
722
+ if (ver.claim) card.answerNewest()
644
723
  // he draws on the paused frame: the rectangle keeps its time
645
724
  if (c && !c.paused) c.pause()
646
725
  const a = at(e)
@@ -671,7 +750,7 @@ const Marks = observer(({ ver, src, side, view }: { ver: Ver; src: string; side:
671
750
  const live = drawing || (clip !== undefined && ver.live && !active)
672
751
  return (
673
752
  <div ref={el} className={`rv-marks${clip && ver.live && !active ? ' pick' : drawing ? ' draw' : ''}`} onPointerDown={down} style={{ pointerEvents: live ? 'auto' : 'none', touchAction: drawing ? 'none' : undefined }}>
674
- {c ? <ClipVideo key={src} clip={c} src={src} poster={shown?.clip ? rv.fitUrl(cell.id, shown.clip.poster) : undefined} preload={ver.live ? 'auto' : 'none'} /> : <img src={src} alt="" draggable={false} className="rv-markimg" loading="lazy" decoding="async" />}
753
+ {face ?? (c ? <ClipVideo key={src} clip={c} src={src} poster={shown?.clip ? rv.fitUrl(cell.id, shown.clip.poster) : undefined} preload={ver.live ? 'auto' : 'none'} /> : <img src={src} alt="" draggable={false} className="rv-markimg" loading="lazy" decoding="async" />)}
675
754
  {shown && rings.length > 0 ? <Rings marks={rings} w={shown.size.w} h={shown.size.h} /> : null}
676
755
  {sent.map(({ r, n }, k) => <div key={`s${k}`} className={`rv-rect sent${onIts(r) ? '' : ' faint'}`} style={pct(r)} title={r.comment || `rectangle ${n}`}><span className="rv-rectn">{n}</span></div>)}
677
756
  {rects.map(([r, i]) => (
@@ -710,8 +789,10 @@ const firstWords = (s: string): string => {
710
789
 
711
790
  /** the picked rectangle's note box, beside it on the image: under it, or over it when it sits low, focused once drawn
712
791
  * or clicked. Enter or Escape closes it (the rectangle stays), Shift Enter is a new line; `sides` are the sides the
713
- * frame shows */
714
- const RectNote = observer(({ card, view, sides }: { card: ThreadSt; view: number; sides: readonly (Side | undefined)[] }) => {
792
+ * frame shows. Its tag names the side it marks (before or after), and a second row repeats the view's OK, Fix and No
793
+ * under the hand that drew it (ReactionToggles, the head's own) */
794
+ const RectNote = observer(({ ver, view, sides }: { ver: Ver; view: number; sides: readonly (Side | undefined)[] }) => {
795
+ const { card } = ver
715
796
  const box = useRef<HTMLTextAreaElement | null>(null)
716
797
  const i = card.rect
717
798
  const r = i === null ? undefined : card.draft.rects[i]
@@ -727,7 +808,7 @@ const RectNote = observer(({ card, view, sides }: { card: ThreadSt; view: number
727
808
  const place = below ? { top: `${(r.y + r.h) * 100}%` } : { bottom: `${(1 - r.y) * 100}%` }
728
809
  return (
729
810
  <div className={`rv-note${below ? ' below' : ' above'}`} style={{ ...place, ['--nx' as string]: `${r.x * 100}%` }} onPointerDown={(e) => e.stopPropagation()}>
730
- <span className="rv-noten">{i + 1}{r.t !== undefined ? ` · ${secs(r.t)}` : ''}</span>
811
+ <span className={`rv-noten${r.side ? ` ${r.side}` : ''}`}>{i + 1}{r.side ? ` · ${r.side}` : ''}{r.t !== undefined ? ` · ${secs(r.t)}` : ''}</span>
731
812
  <AutoText el={(t) => (box.current = t)} placeholder="what is wrong here · Enter closes" value={r.comment}
732
813
  onText={(t) => card.setRectComment(i, t)}
733
814
  onKeyDown={(e) => {
@@ -737,6 +818,7 @@ const RectNote = observer(({ card, view, sides }: { card: ThreadSt; view: number
737
818
  }
738
819
  }} />
739
820
  <button className="ghost rv-x" title="delete this rectangle" aria-label="delete this rectangle" onMouseDown={keepFocus} onClick={() => card.removeRect(i)}>✕</button>
821
+ <span className="rv-notereacts"><ReactionToggles ver={ver} view={view} small /></span>
740
822
  </div>
741
823
  )
742
824
  })
@@ -1,4 +1,4 @@
1
- // one open card of the review page read as a thread (wiki build/shipkit/review.md, The review page): its cells from
1
+ // one open card of the review page read as a thread (wiki tools/shipkit/review.md, The review page): its cells from
2
2
  // `GET /api/review/threads/<id>`, what he folded, the contents strip and where a click on it lands, his draft on the
3
3
  // newest version (rectangles, reactions, stars, the pick, his word), each clip's clock. Made when a card opens,
4
4
  // disposed when another one does. Only the newest version takes his marks: an older one shows what was said on it
@@ -21,7 +21,7 @@ import {
21
21
  type Side,
22
22
  } from '../../../review/model.ts'
23
23
  import { ClipSt } from './clip-st.ts'
24
- import { etagLoader, postJson, type Zoom } from './review-kit.ts'
24
+ import { etagLoader, postJson } from './review-kit.ts'
25
25
  import type { ReviewSt } from './review-st.ts'
26
26
 
27
27
  export interface Draft {
@@ -105,17 +105,15 @@ export class ThreadSt {
105
105
  /** the column scrolled to the newest cell once, on the first load */
106
106
  landed = false
107
107
  private drafts: Record<string, Draft> = {}
108
- /** the older version his draft sits on: a version landed while he wrote. His answer goes there until he moves it */
108
+ /** the older version his answer goes to: a version landed while he wrote, or he chose to answer it. His first mark
109
+ * on the newest version, or « answer v4 », brings his answer back to the newest */
109
110
  draftOn: string | null = null
110
- /** he chose to keep his draft on the older version: the banner that offers the move is gone */
111
- keptOn = false
112
111
  /** the newest version's active view: the one last drawn on or picked, whose clip the keys drive */
113
112
  view = 0
114
113
  /** a picked rectangle of his draft: its note box opens beside it */
115
114
  rect: number | null = null
116
115
  /** the rectangle whose note box takes the focus once it shows */
117
116
  noteFocus: number | null = null
118
- viewZoom: Record<string, Zoom> = {}
119
117
  /** the gallery tile shown large, `<item>#<view>/<tile>` */
120
118
  bigTile: string | null = null
121
119
  /** a draft card's past frame shown in place of its live one; null is now */
@@ -125,6 +123,8 @@ export class ThreadSt {
125
123
  /** an option row folded or unfolded by hand, by `<item>#<view>` */
126
124
  openRows: Record<string, boolean> = {}
127
125
  busy = false
126
+ /** « 📣 post »'s box: his word while it is open, null when shut */
127
+ postBox: string | null = null
128
128
  private readonly clips = new Map<string, ClipSt>()
129
129
  /** the agent words already sent as read, by message id */
130
130
  private readonly reading = new Set<string>()
@@ -173,19 +173,13 @@ export class ThreadSt {
173
173
  this.reveal(v.asked, at)
174
174
  }
175
175
  if (this.draftOn !== null && !v.members.includes(this.draftOn)) this.draftOn = null
176
- if (this.drafts[v.head] === undefined) {
177
- const d = this.rv.storedDraft(v.head)
178
- if (d) this.drafts = { ...this.drafts, [v.head]: d }
179
- }
180
- // a draft left under an older version of this thread (a version landed after the page closed) is found again
181
- if (this.draftOn === null && !isDirty(this.drafts[v.head])) {
182
- const older = [...v.members].reverse().find((id) => id !== v.head && (isDirty(this.drafts[id]) || isDirty(this.rv.storedDraft(id) ?? undefined)))
183
- if (older) {
184
- const d = this.drafts[older] ?? this.rv.storedDraft(older)
185
- if (d) this.drafts = { ...this.drafts, [older]: d }
186
- this.draftOn = older
187
- }
176
+ // every version's draft kept in the browser is found again: an older one stays on its version (`parked`)
177
+ const found: Record<string, Draft> = {}
178
+ for (const id of v.members) {
179
+ const d = this.drafts[id] === undefined ? this.rv.storedDraft(id) : null
180
+ if (d) found[id] = d
188
181
  }
182
+ if (Object.keys(found).length > 0) this.drafts = { ...this.drafts, ...found }
189
183
  }
190
184
 
191
185
  private defaultOpen(c: Cell, v: ThreadView): boolean {
@@ -211,10 +205,45 @@ export class ThreadSt {
211
205
  return (this.cells.find((c) => c.id === h && c.kind !== 'event') as Framed | undefined) ?? null
212
206
  }
213
207
 
208
+ /** an unsent draft on an older version while his answer goes to the newest: found again when the card opened, or
209
+ * left there by a mark on the newest. Never taken, never lost: the box offers to move it, answer it, or drop it */
210
+ get parked(): string | null {
211
+ if (this.draftOn !== null || !this.data) return null
212
+ const head = this.data.head
213
+ return [...this.data.members].reverse().find((id) => id !== head && isDirty(this.drafts[id])) ?? null
214
+ }
215
+
216
+ /** the newest version takes his marks while his answer sits on an older one: his first mark brings it back */
217
+ get claims(): boolean {
218
+ const n = this.newest
219
+ return this.draftOn !== null && n?.kind === 'version' && !n.item.wip
220
+ }
221
+
222
+ /** his answer goes to the newest version; the draft on the older one stays there, parked */
223
+ answerNewest(): void {
224
+ if (this.draftOn === null) return
225
+ this.draftOn = null
226
+ this.rect = null
227
+ }
228
+
229
+ /** his answer goes to the older version his parked draft is on */
230
+ answerParked(): void {
231
+ const p = this.parked
232
+ if (p === null) return
233
+ this.draftOn = p
234
+ this.rect = null
235
+ }
236
+
237
+ /** the parked draft dropped: his notes and his word on the older version */
238
+ dropParked(): void {
239
+ const p = this.parked
240
+ if (p !== null) this.put(p, null)
241
+ }
242
+
214
243
  /** his draft moved onto the newest version: his word, and the marks whose view the newest has; what does not fit
215
244
  * stays on the older one */
216
245
  moveDraft(): void {
217
- const from = this.draftOn
246
+ const from = this.draftOn ?? this.parked
218
247
  const to = this.data?.head
219
248
  if (from === null || !to) return
220
249
  const d = this.drafts[from] ?? EMPTY
@@ -234,15 +263,9 @@ export class ThreadSt {
234
263
  this.put(to, moved)
235
264
  this.put(from, isDirty(left) ? left : null)
236
265
  this.draftOn = null
237
- this.keptOn = false
238
266
  this.rect = null
239
267
  }
240
268
 
241
- /** he keeps his draft on the older version: his answer goes there */
242
- keepDraftOn(): void {
243
- this.keptOn = true
244
- }
245
-
246
269
  get headItem(): Item | null {
247
270
  const h = this.head
248
271
  return h?.kind === 'version' ? h.item : (h?.kind === 'note' ? (h.item ?? null) : null)
@@ -485,10 +508,7 @@ export class ThreadSt {
485
508
  if (reactions.length > 0) left.reactions = reactions
486
509
  this.put(on, isDirty(left) ? left : null)
487
510
  }
488
- if (this.draftOn === on) {
489
- this.draftOn = null
490
- this.keptOn = false
491
- }
511
+ if (this.draftOn === on) this.draftOn = null
492
512
  if (this.target !== on) this.rect = null
493
513
  }
494
514
 
@@ -582,14 +602,6 @@ export class ThreadSt {
582
602
  this.rect = null
583
603
  }
584
604
 
585
- zoomOf(id: string, i: number): Zoom {
586
- return this.viewZoom[viewKey(id, i)] ?? this.rv.zoom
587
- }
588
-
589
- setViewZoom(id: string, i: number, z: Zoom): void {
590
- this.viewZoom = { ...this.viewZoom, [viewKey(id, i)]: z }
591
- }
592
-
593
605
  setFrame(f: number | null): void {
594
606
  this.frame = f
595
607
  }
@@ -695,6 +707,37 @@ export class ThreadSt {
695
707
  }
696
708
  }
697
709
 
710
+ openPost(): void {
711
+ this.postBox = ''
712
+ }
713
+
714
+ setPost(text: string): void {
715
+ this.postBox = text
716
+ }
717
+
718
+ closePost(): void {
719
+ this.postBox = null
720
+ }
721
+
722
+ /** « 📣 post »: this card deserves its own public post, his word the angle; an agent writes the draft */
723
+ async askPost(): Promise<void> {
724
+ const text = this.postBox
725
+ const card = this.data?.head
726
+ if (text === null || !card || this.busy) return
727
+ this.busy = true
728
+ this.error = null
729
+ try {
730
+ await postJson(this.rv.url(`/api/review/${card}/post`), { text })
731
+ runInAction(() => (this.postBox = null))
732
+ this.rv.say('post asked: an agent writes the draft')
733
+ await this.rv.answered()
734
+ } catch (e) {
735
+ runInAction(() => (this.error = (e as Error).message))
736
+ } finally {
737
+ runInAction(() => (this.busy = false))
738
+ }
739
+ }
740
+
698
741
  /** ⌘Enter or « reply »: his word goes to the thread's head as a reply; his marks stay in the draft */
699
742
  async sendReply(): Promise<void> {
700
743
  const h = this.target