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
@@ -0,0 +1,52 @@
1
+ // the address of the home's identity view (wiki tools/shipkit/social.md, Identities): `/identities#<id>[/<part>[/<place>]]`,
2
+ // the part a section (`@legal`, `@veille`, `@site`) or an account, the place one of that account's; no part, the profile.
3
+ // And the rows of its list, in the order the arrows walk them
4
+ import type { MachineIdentity } from '../../identities/machine-route.ts'
5
+
6
+ const IDENTITIES_PATH = '/identities'
7
+
8
+ /** the sections of an identity beside its accounts; the profile is the identity alone */
9
+ const SECTIONS = ['@legal', '@veille', '@site'] as const
10
+ type Section = (typeof SECTIONS)[number]
11
+ const LEGAL_PART: Section = '@legal'
12
+
13
+ export type IdentitySel = { id: string | null; part: string | null; place: string | null }
14
+
15
+ export const isSection = (part: string | null): part is Section => SECTIONS.includes(part as Section)
16
+
17
+ /** the hash of a pick, empty for the view with nothing picked */
18
+ export function identityHash(s: IdentitySel): string {
19
+ if (s.id == null) return ''
20
+ const parts = [s.id, ...(s.part == null ? [] : [s.part]), ...(s.part != null && !isSection(s.part) && s.place != null ? [s.place] : [])]
21
+ return `#${parts.join('/')}`
22
+ }
23
+
24
+ /** a hash read back; a word the view does not know is left to the view, which shows it is gone */
25
+ export function parseIdentityHash(hash: string): IdentitySel {
26
+ const [id = '', part = '', place = ''] = hash.replace(/^#/, '').split('/').map((x) => decodeURIComponent(x))
27
+ return { id: id === '' ? null : id, part: id === '' || part === '' ? null : part, place: part === '' || place === '' || isSection(part) ? null : place }
28
+ }
29
+
30
+ export const identityAddress = (s: IdentitySel): string => `${IDENTITIES_PATH}${identityHash(s)}`
31
+
32
+ /** a row of the view's list, in the order the arrows walk it (list-walk.ts): the sections, each account, each repo.
33
+ * A row opens its part in place, a repo row leaves for that repo's Social page */
34
+ export type IdentityRow = { key: string; depth: 0; dir: false; block: 'sections' | 'accounts' | 'repos'; part: string | null; repo: string | null; words: string }
35
+
36
+ type Listed = Pick<MachineIdentity, 'site' | 'repos'> & { accounts: readonly Pick<MachineIdentity['accounts'][number], 'id' | 'name' | 'handle'>[] }
37
+
38
+ /** every row of an identity, the company only when it has one; `q` keeps the rows whose words hold it, as the repo
39
+ * tree's filter does */
40
+ export function identityRows(i: Listed, company: boolean, q = ''): IdentityRow[] {
41
+ const row = (block: IdentityRow['block'], key: string, part: string | null, repo: string | null, words: string): IdentityRow => ({ key, depth: 0, dir: false, block, part, repo, words: words.toLowerCase() })
42
+ const all = [
43
+ row('sections', 's:profile', null, null, 'profile'),
44
+ ...(company ? [row('sections', `s:${LEGAL_PART}`, LEGAL_PART, null, 'company legal')] : []),
45
+ row('sections', 's:@veille', '@veille', null, 'veille'),
46
+ row('sections', 's:@site', '@site', null, `site ${i.site}`),
47
+ ...i.accounts.map((a) => row('accounts', `a:${a.id}`, a.id, null, `${a.id} ${a.name} ${a.handle}`)),
48
+ ...i.repos.map((r) => row('repos', `r:${r}`, null, r, r)),
49
+ ]
50
+ const k = q.trim().toLowerCase()
51
+ return k === '' ? all : all.filter((r) => r.words.includes(k))
52
+ }
@@ -1,4 +1,4 @@
1
- // the inbox page as state (wiki build/shipkit/home.md, The inbox), a node of the root (home-st.ts): the main list in
1
+ // the inbox page as state (wiki tools/shipkit/home.md, The inbox), a node of the root (home-st.ts): the main list in
2
2
  // pages of `GET /api/inbox`, the folded yellow list read once it unfolds, and the item open in place. Polled every few
3
3
  // seconds while the page shows and the tab is visible, 304 when nothing moved. An item opens in its repo's own state
4
4
  // (RepoSt): a card in that repo's review thread, an ask or a need in its item view, the same components as its hub
@@ -6,13 +6,14 @@
6
6
  // the one constraint a reader breaks first: the address and the open item move together, through HomeSt.show; `open`
7
7
  // only says which item the address names
8
8
  import { makeAutoObservable, observableRef, runInAction } from 'mobx'
9
- import { INBOX_PAGE, openOf, type InboxAnswer, type InboxRow } from '../../home/inbox-shape.ts'
10
- import { etagLoader } from './review/review-kit.ts'
9
+ import { groupRows, INBOX_GROUPS, INBOX_PAGE, openOf, type InboxAnswer, type InboxGroup, type InboxGroupNode, type InboxRow, type InboxShow } from '../../home/inbox-shape.ts'
10
+ import { etagLoader, kept, type EtagLoader } from './review/review-kit.ts'
11
11
  import { ownTrouble } from './reach.ts'
12
12
  import { ClockSvc } from './clock-svc.ts'
13
13
  import type { HomeSt } from './home-st.ts'
14
14
 
15
15
  const POLL_MS = 4000
16
+ const PREFS = 'shipkit.inbox.prefs'
16
17
 
17
18
  /** below this width the inbox is the phone's: one pane at a time, the list or the item */
18
19
  export const INBOX_PHONE_PX = 768
@@ -23,6 +24,10 @@ export class InboxSt {
23
24
  error = ''
24
25
  /** the rows asked of the main list: a page more on « more » */
25
26
  shown = INBOX_PAGE
27
+ /** the review cards only, or every kind */
28
+ show: InboxShow = 'cards'
29
+ /** what the rows group by, each on its own */
30
+ groupBy: InboxGroup[] = []
26
31
  /** the folded list unfolded: read while it is */
27
32
  yellowOpen = false
28
33
  /** the item the address names */
@@ -32,15 +37,25 @@ export class InboxSt {
32
37
  /** every row's age reads it, ticking while the page shows */
33
38
  readonly clock = new ClockSvc()
34
39
  private timer: ReturnType<typeof setInterval> | null = null
35
- private readonly loadMain: () => Promise<InboxAnswer>
36
- private readonly loadYellow: () => Promise<InboxAnswer>
40
+ private readonly loadMain: EtagLoader<InboxAnswer>
41
+ private readonly loadYellow: EtagLoader<InboxAnswer>
37
42
  private readonly onVisible = (): void => {
38
43
  if (document.visibilityState === 'visible' && this.timer != null) void this.poll()
39
44
  }
40
45
 
41
46
  constructor(private readonly home: HomeSt) {
42
- this.loadMain = etagLoader(() => `/api/inbox?limit=${this.shown}`)
43
- this.loadYellow = etagLoader(() => '/api/inbox?list=yellow&limit=500')
47
+ try {
48
+ const p = JSON.parse(kept.get(PREFS) ?? '{}') as { show?: string; groupBy?: string[] }
49
+ if (p.show === 'all') this.show = 'all'
50
+ this.groupBy = INBOX_GROUPS.filter((g) => p.groupBy?.includes(g))
51
+ } catch {
52
+ // a broken pref is the default
53
+ }
54
+ // the last lists drawn in the first frame: the daemon answers after, and only what moved draws again
55
+ this.loadMain = etagLoader(() => `/api/inbox?show=${this.show}&limit=${this.shown}`, { keep: 'inbox.main' })
56
+ this.loadYellow = etagLoader(() => `/api/inbox?show=${this.show}&list=yellow&limit=500`, { keep: 'inbox.yellow' })
57
+ this.page = this.loadMain.held()
58
+ this.yellowPage = this.loadYellow.held()
44
59
  makeAutoObservable<this, 'home' | 'timer' | 'loadMain' | 'loadYellow' | 'onVisible'>(this, { home: false, timer: false, loadMain: false, loadYellow: false, onVisible: false, clock: false, page: observableRef, yellowPage: observableRef })
45
60
  if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
46
61
  const mq = window.matchMedia(`(max-width: ${INBOX_PHONE_PX - 1}px)`)
@@ -57,6 +72,24 @@ export class InboxSt {
57
72
  return this.yellowPage?.rows ?? []
58
73
  }
59
74
 
75
+ /** the main list as it draws: one group of every row, or nested by what is on */
76
+ get groups(): InboxGroupNode[] {
77
+ return groupRows(this.rows, this.groupBy)
78
+ }
79
+
80
+ get yellowGroups(): InboxGroupNode[] {
81
+ return groupRows(this.yellowRows, this.groupBy)
82
+ }
83
+
84
+ /** what « all » would show beside the cards, both lists */
85
+ get allCount(): number {
86
+ return (this.page?.all?.main ?? 0) + (this.page?.all?.yellow ?? 0)
87
+ }
88
+
89
+ get cardCount(): number {
90
+ return this.show === 'cards' ? this.count + this.yellowCount : 0
91
+ }
92
+
60
93
  get count(): number {
61
94
  return this.page?.counts.main ?? 0
62
95
  }
@@ -120,6 +153,26 @@ export class InboxSt {
120
153
  ])
121
154
  }
122
155
 
156
+ setShow(s: InboxShow): void {
157
+ if (this.show === s) return
158
+ this.show = s
159
+ this.shown = INBOX_PAGE
160
+ // the kept answer of the other mode, if any, draws at once
161
+ this.page = this.loadMain.held()
162
+ this.yellowPage = this.loadYellow.held()
163
+ this.save()
164
+ void this.poll()
165
+ }
166
+
167
+ toggleGroup(g: InboxGroup): void {
168
+ this.groupBy = this.groupBy.includes(g) ? this.groupBy.filter((x) => x !== g) : INBOX_GROUPS.filter((x) => x === g || this.groupBy.includes(x))
169
+ this.save()
170
+ }
171
+
172
+ private save(): void {
173
+ kept.put(PREFS, JSON.stringify({ show: this.show, groupBy: this.groupBy }))
174
+ }
175
+
123
176
  showMore(): void {
124
177
  if (this.more === 0) return
125
178
  this.shown += INBOX_PAGE
@@ -1,14 +1,14 @@
1
- // the inbox page (wiki build/shipkit/home.md, The inbox): every repo's items that wait on the owner, newest first, each
1
+ // the inbox page (wiki tools/shipkit/home.md, The inbox): every repo's items that wait on the owner, newest first, each
2
2
  // row with its repo's icon, its kind, its title, its age and a thumb; what can wait folded at the bottom. A row opens
3
3
  // its item in place with its repo's own views: a card in the review thread (review-thread.tsx), an ask or a need in
4
4
  // its item view (item-view.tsx). On the desktop the list and the item side by side; on a phone one pane at a time,
5
5
  // the list kept under the item so back finds it where it was
6
6
  import { observer } from 'mobx-react-lite'
7
7
  import { useLayoutEffect } from 'react'
8
- import { isReviewId, type InboxRow } from '../../home/inbox-shape.ts'
8
+ import { INBOX_GROUPS, isReviewId, type InboxGroup, type InboxGroupNode, type InboxRow } from '../../home/inbox-shape.ts'
9
9
  import { hashFor } from './hash-route.ts'
10
10
  import { plainClick, repoPage, type HomeSt } from './home-st.ts'
11
- import { Icon, ICON } from './icons.tsx'
11
+ import { Caret, Icon, ICON } from './icons.tsx'
12
12
  import type { InboxSt } from './inbox-st.ts'
13
13
  import { ItemView } from './item-view.tsx'
14
14
  import { Face } from './project-list.tsx'
@@ -36,6 +36,7 @@ export const InboxView = observer(({ app }: { app: HomeSt }) => {
36
36
  <h1>inbox</h1>
37
37
  <Counts ib={ib} />
38
38
  </div>
39
+ <Bar ib={ib} />
39
40
  <InboxList app={app} />
40
41
  </div>
41
42
  {open != null ? <OpenItem app={app} item={open} /> : null}
@@ -48,6 +49,7 @@ export const InboxView = observer(({ app }: { app: HomeSt }) => {
48
49
  <h1>inbox</h1>
49
50
  <Counts ib={ib} />
50
51
  </div>
52
+ <Bar ib={ib} />
51
53
  <InboxList app={app} />
52
54
  </div>
53
55
  <div className="ib-itemcol">{open != null ? <OpenItem app={app} item={open} /> : <div className="ph">{ib.count > 0 ? 'pick a row: it opens here' : ''}</div>}</div>
@@ -64,6 +66,46 @@ const Counts = observer(({ ib }: { ib: InboxSt }) =>
64
66
  ),
65
67
  )
66
68
 
69
+ const GROUP_WORDS: Record<InboxGroup, string> = { repo: 'project', kind: 'type', lane: 'lane' }
70
+
71
+ /** what the list shows (the review cards, or every kind) and what it groups by, each axis on its own */
72
+ const Bar = observer(({ ib }: { ib: InboxSt }) => (
73
+ <div className="ib-bar">
74
+ <span className="seg" title="the review cards only, or every kind: checks, asks and needs too">
75
+ <button className={ib.show === 'cards' ? 'on' : ''} onClick={() => ib.setShow('cards')}>cards</button>
76
+ <button className={ib.show === 'all' ? 'on' : ''} onClick={() => ib.setShow('all')}>all{ib.show === 'cards' && ib.allCount > ib.cardCount ? <span className="ib-dim"> · {ib.allCount}</span> : null}</button>
77
+ </span>
78
+ <span className="sp" />
79
+ <span className="ib-groupby">
80
+ <span className="ib-dim">group by</span>
81
+ <span className="seg">
82
+ {INBOX_GROUPS.map((g) => (
83
+ <button key={g} className={ib.groupBy.includes(g) ? 'on' : ''} aria-pressed={ib.groupBy.includes(g)} onClick={() => ib.toggleGroup(g)}>{GROUP_WORDS[g]}</button>
84
+ ))}
85
+ </span>
86
+ </span>
87
+ </div>
88
+ ))
89
+
90
+ /** the rows as their groups nest: a group's head says what it is and how many, then its rows or its inner groups */
91
+ const Groups = observer(({ app, gs, depth = 0 }: { app: HomeSt; gs: InboxGroupNode[]; depth?: number }) => (
92
+ <>
93
+ {gs.map((g) =>
94
+ g.label === '' ? (
95
+ g.rows.map((r) => <Row key={r.key} app={app} r={r} />)
96
+ ) : (
97
+ <section key={g.key} className={`ib-group d${depth}`}>
98
+ <div className="ib-grouphead">
99
+ <span className="ib-glabel">{g.label}</span>
100
+ <span className="ib-gn">{g.n}</span>
101
+ </div>
102
+ {g.groups != null ? <Groups app={app} gs={g.groups} depth={depth + 1} /> : g.rows.map((r) => <Row key={r.key} app={app} r={r} />)}
103
+ </section>
104
+ ),
105
+ )}
106
+ </>
107
+ ))
108
+
67
109
  const InboxList = observer(({ app }: { app: HomeSt }) => {
68
110
  const ib = app.inbox
69
111
  const p = ib.page
@@ -73,19 +115,19 @@ const InboxList = observer(({ app }: { app: HomeSt }) => {
73
115
  {p == null ? (
74
116
  ib.error === '' ? <div className="ib-wait"><span className="spin" />reading every repo…</div> : null
75
117
  ) : ib.rows.length === 0 ? (
76
- <div className="ib-clear">nothing waits on you ✨</div>
118
+ <div className="ib-clear">{ib.show === 'cards' ? 'no card waits on you ✨' : 'nothing waits on you ✨'}</div>
77
119
  ) : (
78
- ib.rows.map((r) => <Row key={r.key} app={app} r={r} />)
120
+ <Groups app={app} gs={ib.groups} />
79
121
  )}
80
122
  {ib.more > 0 ? <button className="ib-more" onClick={() => ib.showMore()}>{ib.more} more</button> : null}
81
123
  {ib.yellowCount > 0 ? (
82
124
  <div className={`ib-fold${ib.yellowOpen ? ' on' : ''}`}>
83
125
  <button className="ib-foldhead" aria-expanded={ib.yellowOpen} onClick={() => ib.toggleYellow()}>
84
- <span className="ib-caret">{ib.yellowOpen ? '▾' : '▸'}</span>
126
+ <span className="ib-caret"><Caret open={ib.yellowOpen} /></span>
85
127
  <span>can wait</span>
86
128
  <span className="ib-n">{ib.yellowCount}</span>
87
129
  </button>
88
- {ib.yellowOpen ? ib.yellowRows.map((r) => <Row key={r.key} app={app} r={r} />) : null}
130
+ {ib.yellowOpen ? <Groups app={app} gs={ib.yellowGroups} /> : null}
89
131
  </div>
90
132
  ) : null}
91
133
  {p != null && p.missing.length > 0 ? (
@@ -39,13 +39,24 @@ a.ib-row.t-yellow{border-left-color:var(--warn)}
39
39
  .ib-l2 .ago{flex:none;margin-left:auto}
40
40
  .ib-thumb{flex:none;width:64px;height:48px;object-fit:cover;border-radius:4px;border:1px solid var(--line);background:var(--panel2)}
41
41
 
42
+ /* what the list shows and groups by, under the title */
43
+ .ib-bar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--s2);padding:0 var(--s4) var(--s2)}
44
+ .ib-bar .sp{flex:1}
45
+ .ib-bar .seg button{font-size:12px;padding:0 var(--s2);line-height:22px}
46
+ .ib-groupby{display:flex;align-items:center;gap:var(--s2);font-size:12px}
47
+ /* a group: its head, then its rows; an inner group steps in */
48
+ .ib-grouphead{display:flex;align-items:baseline;gap:var(--s2);padding:var(--s3) var(--s4) var(--s1);font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--dim);border-top:1px solid var(--line)}
49
+ .ib-group .ib-group > .ib-grouphead{margin-left:var(--s4);padding-top:var(--s2);border-top:0;font-size:10.5px}
50
+ .ib-glabel{text-transform:none;letter-spacing:0;font-size:12.5px;color:var(--ink)}
51
+ .ib-gn{font-variant-numeric:tabular-nums}
52
+
42
53
  /* the folded list and the repos it could not read */
43
54
  button.ib-more{margin:var(--s3) var(--s4) 0;min-height:44px;font-size:14px}
44
55
  .ib-fold{margin-top:var(--s4);border-top:1px solid var(--line)}
45
56
  button.ib-foldhead{display:flex;align-items:center;gap:var(--s2);width:100%;min-height:48px;padding:0 var(--s4);border:0;border-radius:0;
46
57
  background:transparent;color:var(--dim);font-size:14px;text-align:left}
47
58
  button.ib-foldhead:hover{color:var(--ink)}
48
- .ib-caret{width:12px}
59
+ .ib-caret{display:inline-flex;width:14px}
49
60
  .ib-n{color:var(--warn);font-weight:700}
50
61
  .ib-fold.on a.ib-row{opacity:.85}
51
62
  .ib-missing{padding:var(--s3) var(--s4);color:var(--dim);font-size:12.5px;display:flex;flex-direction:column;gap:var(--s1)}
@@ -15,6 +15,9 @@
15
15
  <link rel="stylesheet" href="./dock.css" />
16
16
  <link rel="stylesheet" href="./controls.css" />
17
17
  <link rel="stylesheet" href="./review.css" />
18
+ <link rel="stylesheet" href="./stores.css" />
19
+ <link rel="stylesheet" href="./veille.css" />
20
+ <link rel="stylesheet" href="./social.css" />
18
21
  </head>
19
22
  <body>
20
23
  <div id="root"></div>
@@ -0,0 +1,30 @@
1
+ // a page's columns (the identities, social, comms, stores, Veille, review and trailer pages): the widths his drags
2
+ // leave are kept per browser and page, so a reload draws them as he left them from the first paint. One group per
3
+ // page id; the panel ids inside must stay the same for a kept layout to apply (useDefaultLayout's own rule).
4
+ import type { ReactNode } from 'react'
5
+ import { Group, useDefaultLayout, type LayoutStorage } from 'react-resizable-panels'
6
+
7
+ /** the browser's storage, or nothing: a private window or blocked site data keeps the layout for the tab only */
8
+ const STORE: LayoutStorage = {
9
+ getItem: (k) => {
10
+ try {
11
+ return globalThis.localStorage?.getItem(k) ?? null
12
+ } catch {
13
+ return null
14
+ }
15
+ },
16
+ setItem: (k, v) => {
17
+ try {
18
+ globalThis.localStorage?.setItem(k, v)
19
+ } catch { /* the layout lasts the tab */ }
20
+ },
21
+ }
22
+
23
+ export const KeptCols = ({ id, children }: { id: string; children: ReactNode }) => {
24
+ const kept = useDefaultLayout({ id: `hub:cols:${id}`, storage: STORE, onlySaveAfterUserInteractions: true })
25
+ return (
26
+ <Group className="rv-cols" orientation="horizontal" defaultLayout={kept.defaultLayout} onLayoutChanged={kept.onLayoutChanged}>
27
+ {children}
28
+ </Group>
29
+ )
30
+ }
@@ -59,8 +59,8 @@ export function isSearchKey(e: Pick<KeyLike, 'key' | 'metaKey' | 'ctrlKey' | 'al
59
59
  * plus a letter only types a character inside a text field, where the page
60
60
  * leaves the key alone. Read from the physical key (`code`): on a Mac ⌥C
61
61
  * types ç, and AZERTY moves the letters */
62
- export type SectionId = 'readme' | 'contracts' | 'shipkit' | 'repo' | 'secrets' | 'when' | 'runs' | 'plan' | 'processes' | 'git' | 'asks' | 'review' | 'reflections' | 'tests' | 'media' | 'trailer' | 'wikis' | 'admin'
63
- export const SECTION_LETTER: Record<SectionId, string> = { readme: 'E', review: 'V', trailer: 'L', contracts: 'K', shipkit: 'S', repo: 'C', secrets: 'X', when: 'O', runs: 'R', plan: 'N', processes: 'P', git: 'G', asks: 'A', reflections: 'F', tests: 'T', media: 'M', wikis: 'W', admin: 'D' }
62
+ export type SectionId = 'readme' | 'contracts' | 'shipkit' | 'repo' | 'secrets' | 'when' | 'runs' | 'plan' | 'processes' | 'git' | 'asks' | 'review' | 'reflections' | 'tests' | 'media' | 'trailer' | 'stores' | 'veille' | 'comms' | 'social' | 'wikis' | 'admin'
63
+ export const SECTION_LETTER: Record<SectionId, string> = { readme: 'E', review: 'V', trailer: 'L', stores: 'B', veille: 'Y', comms: 'U', social: 'I', contracts: 'K', shipkit: 'S', repo: 'C', secrets: 'X', when: 'O', runs: 'R', plan: 'N', processes: 'P', git: 'G', asks: 'A', reflections: 'F', tests: 'T', media: 'M', wikis: 'W', admin: 'D' }
64
64
  /** a section's words on its row, where the id alone would not say it */
65
65
  export const SECTION_LABEL: Partial<Record<SectionId, string>> = { shipkit: 'shipkit checks', repo: 'repo checks' }
66
66
  export const sectionLabel = (id: SectionId): string => SECTION_LABEL[id] ?? id
@@ -74,3 +74,11 @@ export function sectionKey(e: KeyLike): SectionId | null {
74
74
  const hit = Object.entries(SECTION_LETTER).find(([, l]) => l === m[1])
75
75
  return hit == null ? null : (hit[0] as SectionId)
76
76
  }
77
+
78
+ /** a repo's own page on ⌥⇧ and its letter (wiki tools/shipkit/project-pages.md, Keys): shipkit's ⌥ letters stay its
79
+ * own. The letter, read from the physical key, or null */
80
+ export function pageLetterKey(e: KeyLike): string | null {
81
+ if (!e.altKey || !e.shiftKey || e.metaKey || e.ctrlKey) return null
82
+ return /^Key([A-Z])$/.exec(e.code)?.[1] ?? null
83
+ }
84
+ export const pageKeyLabel = (letter: string): string => `⌥⇧${letter}`
@@ -0,0 +1,89 @@
1
+ // the arrows over a list of rows: the one keyboard model of the hub's lists, the repo tree (tree-svc.ts) and the
2
+ // identity view (identities-st.ts). ↑ ↓ land on the row above or below, stepping over inert ones; → unfolds a folded
3
+ // row, else steps down; ← folds an unfolded row, else climbs to its parent; Enter and space open the row. What landing
4
+ // and opening do is the host's
5
+ export type WalkRow = { key: string; depth: number; dir: boolean }
6
+
7
+ export type WalkHost<R extends WalkRow> = {
8
+ readonly rows: readonly R[]
9
+ /** the row under the keyboard cursor */
10
+ cursor: string | null
11
+ /** where the arrows start with no cursor: the row of the page shown, -1 for none */
12
+ home(rows: readonly R[]): number
13
+ /** a row the arrows step over */
14
+ inert(row: R): boolean
15
+ /** an arrow landed on it */
16
+ land(row: R): void
17
+ /** Enter or space on it */
18
+ activate(row: R): void
19
+ isOpen(key: string): boolean
20
+ toggle(key: string): void
21
+ }
22
+
23
+ function from<R extends WalkRow>(h: WalkHost<R>): number {
24
+ const rows = h.rows
25
+ const i = rows.findIndex((r) => r.key === h.cursor)
26
+ return i !== -1 ? i : h.home(rows)
27
+ }
28
+
29
+ function move<R extends WalkRow>(h: WalkHost<R>, d: number): void {
30
+ const rows = h.rows
31
+ if (rows.length === 0) return
32
+ const i = from(h)
33
+ let next = i === -1 ? (d > 0 ? 0 : rows.length - 1) : i + d
34
+ while (next >= 0 && next < rows.length && h.inert(rows[next]!)) next += d
35
+ if (next < 0 || next >= rows.length || next === i) return
36
+ h.land(rows[next]!)
37
+ }
38
+
39
+ const cur = <R extends WalkRow>(h: WalkHost<R>): R | null => h.rows.find((r) => r.key === h.cursor) ?? null
40
+
41
+ function right<R extends WalkRow>(h: WalkHost<R>): void {
42
+ const r = cur(h)
43
+ if (r != null && r.dir && !h.isOpen(r.key)) h.toggle(r.key)
44
+ else move(h, 1)
45
+ }
46
+
47
+ function left<R extends WalkRow>(h: WalkHost<R>): void {
48
+ const r = cur(h)
49
+ if (r == null) return move(h, -1)
50
+ if (r.dir && h.isOpen(r.key)) return h.toggle(r.key)
51
+ const rows = h.rows
52
+ const i = rows.findIndex((x) => x.key === r.key)
53
+ for (let n = i - 1; n >= 0; n--) if (rows[n]!.depth < r.depth) return h.land(rows[n]!)
54
+ }
55
+
56
+ /** one key on the list; true = it was the list's, so the page must not also scroll */
57
+ export function walkKey<R extends WalkRow>(h: WalkHost<R>, k: string): boolean {
58
+ if (k === 'ArrowDown') move(h, 1)
59
+ else if (k === 'ArrowUp') move(h, -1)
60
+ else if (k === 'ArrowRight') right(h)
61
+ else if (k === 'ArrowLeft') left(h)
62
+ else if (k === 'Enter' || k === ' ') {
63
+ const r = cur(h)
64
+ if (r != null) h.activate(r)
65
+ } else return false
66
+ return true
67
+ }
68
+
69
+ /** a walk with the arrows is one history entry: its first step pushes, every next one rewrites it, so back returns to
70
+ * where the walk started. A held arrow opens ~30 pages a second, and the browser throws past 100 pushState calls per
71
+ * 10 seconds */
72
+ export class WalkEntry {
73
+ private walking = false
74
+ private walked = false
75
+ run(open: () => void): void {
76
+ this.walking = true
77
+ try {
78
+ open()
79
+ } finally {
80
+ this.walking = false
81
+ }
82
+ }
83
+ /** the history verb of a new address, asked once per address written */
84
+ how(): 'push' | 'replace' {
85
+ const h = this.walking && this.walked ? 'replace' : 'push'
86
+ this.walked = this.walking
87
+ return h
88
+ }
89
+ }
@@ -44,6 +44,10 @@ function loadKept(): Kept | null {
44
44
  export const webDownText = (why: string): string =>
45
45
  `the shipkit web does not answer on ${globalThis.location?.origin ?? 'this page\'s origin'} (${why}). \`shipkit pm\` runs it; this page comes back by itself once it answers`
46
46
 
47
+ /** the daemon restarting, as the machine card says it: the page keeps working on the web's copies */
48
+ export const restartingText = (at: number): string =>
49
+ `the daemon restarts: the page shows the last answers it gave${Number.isFinite(at) && at > 0 ? `, from ${new Date(at).toLocaleTimeString()}` : ''}, and comes back by itself`
50
+
47
51
  export type MachineOpts = { reload?: () => void; timeoutMs?: number }
48
52
 
49
53
  export class MachineSt {
@@ -62,6 +66,8 @@ export class MachineSt {
62
66
  * shipkit app window */
63
67
  /** why the daemon did not answer the last poll, or '' while it does */
64
68
  down = ''
69
+ /** the daemon restarts: the web answered the last answers it kept (serve-web.ts LastGood), '' while it answers */
70
+ restarting = ''
65
71
  /** which one did not answer: the web itself, or the daemon behind it */
66
72
  downWho: 'web' | 'daemon' = 'daemon'
67
73
  /** the daemon answered once since the load: until then data, pm and
@@ -191,6 +197,12 @@ export class MachineSt {
191
197
  const r = await reach('/api/home.json', { signal: AbortSignal.timeout(this.o.timeoutMs ?? MACHINE_TIMEOUT_MS) })
192
198
  if (!r.ok) throw new Error(`/api/home.json answered ${r.status}: ${await r.text()}`)
193
199
  const j = (await r.json()) as HomeAnswer
200
+ const stale = r.headers.get('x-shipkit-daemon') === 'restarting'
201
+ runInAction(() => {
202
+ this.restarting = stale ? restartingText(Number(r.headers.get('x-shipkit-daemon-at'))) : ''
203
+ if (stale) this.down = ''
204
+ })
205
+ if (stale) return
194
206
  const back = this.wasDown
195
207
  const cleared = this.pollError
196
208
  this.wasDown = false
@@ -1,4 +1,4 @@
1
- // Media (atelier) service — the studio state, per build/app-state-tree:
1
+ // Media (atelier) service — the studio state, per patterns/app-state-tree:
2
2
  // observable state + actions + computeds live HERE; components read and
3
3
  // call. Talks to the media API the hub mounts at /media/*. Kind/asset
4
4
  // structure is read-only (kit.ts is code-reviewed); this edits WORKSPACE
@@ -10,6 +10,7 @@ import { AutoText } from './auto-text.tsx'
10
10
  import { isAud, type MediaSvc } from './media-svc.ts'
11
11
  import { GeometryLayer, Rectbar, measureBox, type Box } from './geometry-view.tsx'
12
12
  import type { CatRow, CustomPanelRef } from './hub-types.ts'
13
+ import { Caret } from './icons.tsx'
13
14
 
14
15
  const TEX = 1024
15
16
  const MIX_UNIT = 24
@@ -26,7 +27,7 @@ export const MediaTopbar = observer(({ app }: { app: RepoSt }) => {
26
27
  folded (default) = one ellipsized line, click to expand */}
27
28
  <div className="promptrow">
28
29
  <button className="fold" title={m.promptOpen ? 'fold the prompt' : 'expand the prompt'}
29
- onClick={() => m.togglePrompt()}>{m.promptOpen ? '▾' : '▸'}</button>
30
+ onClick={() => m.togglePrompt()}><Caret open={m.promptOpen} /></button>
30
31
  {m.promptOpen
31
32
  // it grows on every prompt change, a selection's included; the css max-height caps it near 14 lines
32
33
  ? <AutoText className="prompt" value={m.prompt} placeholder="select an asset ←" onText={(t) => m.setPrompt(t)} />
@@ -0,0 +1,134 @@
1
+ // the hub side of a repo page's frame (wiki tools/shipkit/project-pages.md, The frame contract): every kept frame of
2
+ // this repo, the shown one displayed, the others hidden but alive (frames-st.ts). A frame loads through the hub's
3
+ // proxy, on this origin, and speaks `{ shipkit: <verb> }` messages, checked by source and origin. Its process down,
4
+ // the pane shows the start button, never a blank frame
5
+ import { reaction } from 'mobx'
6
+ import { observer } from 'mobx-react-lite'
7
+ import { useEffect, useRef, useState } from 'react'
8
+ import type { RepoSt } from './repo-st.ts'
9
+
10
+ type Msg = { shipkit?: unknown; keys?: unknown; title?: unknown; badge?: unknown; hash?: unknown; key?: unknown; code?: unknown; altKey?: unknown; shiftKey?: unknown; metaKey?: unknown; ctrlKey?: unknown }
11
+
12
+ /** the keys a frame passes up as typed on the hub: ⌥ letters, ⌥⇧ letters, the home's ⌘ keys */
13
+ function replayKey(m: Msg): void {
14
+ if (typeof m.key !== 'string' || typeof m.code !== 'string') return
15
+ document.body.dispatchEvent(new KeyboardEvent('keydown', { key: m.key, code: m.code, altKey: m.altKey === true, shiftKey: m.shiftKey === true, metaKey: m.metaKey === true, ctrlKey: m.ctrlKey === true, bubbles: true, cancelable: true }))
16
+ }
17
+
18
+ /** the page's process, as pm reports it: null when none is declared or pm does not say */
19
+ const processOf = (app: RepoSt, id: string) => {
20
+ const p = app.pages.find(id)
21
+ return p?.process == null ? null : (app.globalProcesses.find((r) => r.id === p.process) ?? null)
22
+ }
23
+
24
+ const DownCard = observer(({ app, id, text }: { app: RepoSt; id: string; text: string | null }) => {
25
+ const p = app.pages.find(id)
26
+ const proc = processOf(app, id)
27
+ const m = app.home.machine
28
+ const starting = proc?.dot === 'starting'
29
+ return (
30
+ <div className="stagewrap">
31
+ <div className="colcard checkcard">
32
+ <div className="chead"><span className="tid">page</span><h3 className="ctitle">{app.pages.title(id)}</h3></div>
33
+ <div className="usays">{text ?? (proc == null ? `the page does not answer on ${p?.url ?? id}` : `${proc.label} is ${proc.dot}: it serves this page`)}</div>
34
+ {proc != null && m != null ? (
35
+ <button disabled={starting} onClick={() => void m.processAct(proc.id, 'start')}>{starting ? `starting ${proc.label}…` : `start ${proc.label}`}</button>
36
+ ) : null}
37
+ </div>
38
+ </div>
39
+ )
40
+ })
41
+
42
+ const PageFrame = observer(({ app, id, on }: { app: RepoSt; id: string; on: boolean }) => {
43
+ const ref = useRef<HTMLIFrameElement>(null)
44
+ /** the keys the frame holds now: what it posted, or what the hub last sent it */
45
+ const held = useRef<string>(app.sel?.t === 'page' && app.sel.id === id ? (app.sel.q ?? '') : (app.pages.keys.get(id) ?? ''))
46
+ const onNow = useRef(on)
47
+ onNow.current = on
48
+ const [downText, setDownText] = useState<string | null>(null)
49
+ const [epoch, setEpoch] = useState(0)
50
+ const proc = processOf(app, id)
51
+ const down = proc != null && proc.dot !== 'up' && proc.dot !== 'unknown'
52
+ const missing = app.pages.loaded && app.pages.find(id) == null
53
+ const mounted = !down && !missing && downText == null
54
+ // the process came back: a frame that showed the down text loads again
55
+ useEffect(() => {
56
+ if (!down && downText != null && proc?.dot === 'up') {
57
+ setDownText(null)
58
+ setEpoch((n) => n + 1)
59
+ }
60
+ }, [down, downText, proc?.dot])
61
+ useEffect(() => {
62
+ if (!mounted) return
63
+ const post = (m: Record<string, unknown>): void => ref.current?.contentWindow?.postMessage({ ...m }, location.origin)
64
+ /** the identity the repo speaks as (its row's `speaksAs`, the default already folded in), null with none */
65
+ const identity = (): string | null => app.home.projects.list.find((p) => p.name === app.key)?.speaksAs ?? null
66
+ const hello = (): void => post({ shipkit: 'hello', keys: held.current, theme: app.home.theme.resolved, identity: identity(), on: onNow.current })
67
+ const onMessage = (e: MessageEvent): void => {
68
+ if (e.source !== ref.current?.contentWindow || e.origin !== location.origin) return
69
+ const m = (e.data ?? {}) as Msg
70
+ switch (m.shipkit) {
71
+ case 'ready': return hello()
72
+ case 'keys':
73
+ if (typeof m.keys !== 'string') return
74
+ held.current = m.keys
75
+ return app.pageMoved(id, m.keys)
76
+ case 'title': return app.pages.post(id, m)
77
+ case 'open':
78
+ if (typeof m.hash === 'string' && m.hash.startsWith('#')) location.hash = m.hash
79
+ return
80
+ case 'key': return replayKey(m)
81
+ }
82
+ }
83
+ window.addEventListener('message', onMessage)
84
+ const theme = reaction(() => app.home.theme.resolved, (t) => post({ shipkit: 'theme', theme: t }))
85
+ const speaker = reaction(identity, (i) => post({ shipkit: 'identity', identity: i }))
86
+ // the address moved from outside (back, a pasted link): the frame takes it
87
+ const keys = reaction(
88
+ () => (app.sel?.t === 'page' && app.sel.id === id ? (app.sel.q ?? '') : null),
89
+ (q) => {
90
+ if (q == null || q === held.current) return
91
+ held.current = q
92
+ post({ shipkit: 'keys', keys: q })
93
+ },
94
+ )
95
+ return () => {
96
+ window.removeEventListener('message', onMessage)
97
+ theme()
98
+ speaker()
99
+ keys()
100
+ }
101
+ }, [app, id, mounted, epoch])
102
+ // shown or hidden: the page decides what stops; shown, it takes the keyboard
103
+ useEffect(() => {
104
+ ref.current?.contentWindow?.postMessage({ shipkit: 'focus', on }, location.origin)
105
+ if (on) ref.current?.contentWindow?.focus()
106
+ }, [on])
107
+ /** the proxy's answer when the process does not: its text, in the down card */
108
+ const onLoad = (): void => {
109
+ try {
110
+ const d = ref.current?.contentDocument
111
+ if (d?.contentType === 'text/plain') setDownText(d.body.innerText.trim())
112
+ else if (on) ref.current?.contentWindow?.focus()
113
+ } catch {
114
+ // another origin cannot be read: never the case behind the proxy
115
+ }
116
+ }
117
+ return (
118
+ <div className="pframe" hidden={!on}>
119
+ {mounted ? <iframe key={epoch} ref={ref} src={app.pages.src(id)} title={app.pages.title(id)} onLoad={onLoad} /> : <DownCard app={app} id={id} text={missing ? (app.pages.problem ?? `this repo declares no page ${id}: a page({...}) unit adds one`) : downText} />}
120
+ </div>
121
+ )
122
+ })
123
+
124
+ /** every kept frame of this repo: under the main pane, shown when the page is */
125
+ export const PageFrames = observer(({ app }: { app: RepoSt }) => {
126
+ const ids = app.home.frames.of(app.key)
127
+ const shown = app.sel?.t === 'page' ? app.sel.id : null
128
+ if (ids.length === 0) return null
129
+ return (
130
+ <div className="pframes" hidden={shown == null}>
131
+ {ids.map((id) => <PageFrame key={id} app={app} id={id} on={id === shown && app.isShown} />)}
132
+ </div>
133
+ )
134
+ })