rvlib-shipkit 2.11.0 → 2.13.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 (298) hide show
  1. package/CHANGELOG.md +56 -12
  2. package/README.md +1 -1
  3. package/package.json +4 -2
  4. package/src/agent-time/store.ts +2 -2
  5. package/src/check.ts +1 -1
  6. package/src/checks/SK001-package-json-shape.check.ts +4 -0
  7. package/src/checks/SK003-claude-md-shape.check.ts +1 -1
  8. package/src/checks/SK004-gitignore-policy.check.ts +27 -2
  9. package/src/checks/SK005-rvlib-versions.check.ts +1 -1
  10. package/src/checks/SK008-reviewer-agent.check.ts +2 -2
  11. package/src/checks/SK012-config-barrel-import.check.ts +1 -1
  12. package/src/checks/SK015-nested-repo.check.ts +1 -1
  13. package/src/checks/SK035-public-clean.check.ts +46 -0
  14. package/src/checks/SK036-draft-media-size.check.ts +28 -0
  15. package/src/cli/cmd_Backup.ts +152 -0
  16. package/src/cli/cmd_Ci.ts +8 -11
  17. package/src/cli/cmd_Drill.ts +145 -0
  18. package/src/cli/cmd_Home.ts +50 -3
  19. package/src/cli/cmd_Media.ts +96 -5
  20. package/src/cli/cmd_Review.ts +8 -2
  21. package/src/cli/cmd_Shot.ts +5 -2
  22. package/src/cli/cmd_Smoke.ts +4 -1
  23. package/src/cli/cmd_Social.ts +226 -0
  24. package/src/cli/cmd_Start.ts +1 -1
  25. package/src/cli/cmd_Time.ts +1 -1
  26. package/src/cli/cmd_Trailer.ts +9 -2
  27. package/src/cli/cmd_Veille.ts +173 -0
  28. package/src/cli/family-pages.ts +3 -0
  29. package/src/cli/registry.ts +13 -2
  30. package/src/cli.ts +5 -2
  31. package/src/collections/actions.ts +1 -49
  32. package/src/collections/checks.ts +2 -1
  33. package/src/collections/collection-types.ts +11 -2
  34. package/src/collections/providers.ts +4 -4
  35. package/src/collections/review.ts +2 -1
  36. package/src/collections/tests.ts +19 -8
  37. package/src/contracts/apply-contracts.ts +1 -3
  38. package/src/contracts/contract-manifests.ts +2 -3
  39. package/src/contracts/contract-types.ts +0 -1
  40. package/src/contracts/contracts-engine.ts +0 -3
  41. package/src/core/app-icon.ts +9 -3
  42. package/src/core/bun-builtins.ts +2 -2
  43. package/src/core/discover-checks.ts +37 -5
  44. package/src/core/fix-scope.ts +4 -2
  45. package/src/core/floor-resolve.ts +68 -48
  46. package/src/core/floor.ts +9 -0
  47. package/src/core/git-root.ts +24 -0
  48. package/src/core/last-good.ts +3 -1
  49. package/src/core/layout.ts +8 -0
  50. package/src/core/log-stamp.ts +36 -0
  51. package/src/core/loop-watch.ts +93 -0
  52. package/src/core/machine-link.ts +134 -0
  53. package/src/core/memory-watch.ts +41 -0
  54. package/src/core/one-way-in-policy.ts +27 -19
  55. package/src/core/run-ci.ts +6 -8
  56. package/src/core/run-fixers.ts +9 -9
  57. package/src/core/slots.ts +21 -0
  58. package/src/core/tree-rev.ts +60 -0
  59. package/src/core/unit-files.ts +42 -0
  60. package/src/drill/render.ts +140 -0
  61. package/src/drill/run.ts +269 -0
  62. package/src/fleet/scan-fleet.ts +6 -5
  63. package/src/home/daemon-jobs.ts +201 -0
  64. package/src/home/global-context.ts +34 -1
  65. package/src/home/home-routes.ts +22 -15
  66. package/src/home/hubs.ts +10 -3
  67. package/src/home/inbox-shape.ts +61 -6
  68. package/src/home/inbox.ts +75 -4
  69. package/src/home/lib-watch.ts +10 -3
  70. package/src/home/machine-stores.ts +15 -29
  71. package/src/home/run-daemon.ts +15 -18
  72. package/src/home/run-pm.ts +2 -0
  73. package/src/home/serve-daemon.ts +4 -3
  74. package/src/home/serve-web.ts +110 -1
  75. package/src/hooks/commit-message.ts +28 -19
  76. package/src/hooks/leak-guard.ts +10 -3
  77. package/src/hooks/run-hooks.ts +2 -6
  78. package/src/identities/identities.ts +334 -0
  79. package/src/identities/machine-route.ts +126 -0
  80. package/src/identities/machine.ts +62 -0
  81. package/src/init-repo.ts +1 -1
  82. package/src/ledger/check-stats.ts +10 -9
  83. package/src/ledger/gate-checks.ts +32 -1
  84. package/src/ledger/record-kept.ts +112 -0
  85. package/src/ledger/repo-view.ts +10 -0
  86. package/src/ledger/run-log.ts +17 -12
  87. package/src/ledger/run-timeline.ts +8 -4
  88. package/src/ledger/store.ts +7 -0
  89. package/src/ledger/suite-log.ts +17 -13
  90. package/src/media-kinds.ts +9 -1
  91. package/src/media-store/backup/daemon.ts +73 -0
  92. package/src/media-store/backup/keys.ts +25 -0
  93. package/src/media-store/backup/manifest.ts +193 -0
  94. package/src/media-store/backup/restore.ts +192 -0
  95. package/src/media-store/backup/run.ts +278 -0
  96. package/src/media-store/backup/secret.ts +86 -0
  97. package/src/media-store/backup/snapshot.ts +64 -0
  98. package/src/media-store/backup/sources.ts +199 -0
  99. package/src/media-store/content.ts +11 -1
  100. package/src/media-store/daemon.ts +56 -70
  101. package/src/media-store/hand.ts +58 -0
  102. package/src/media-store/put.ts +122 -0
  103. package/src/media-store/space.ts +73 -11
  104. package/src/pages/forward.ts +35 -0
  105. package/src/pages/frame-client.ts +118 -0
  106. package/src/pages/routes.ts +29 -0
  107. package/src/pages/unit.ts +92 -0
  108. package/src/plan/planner.ts +12 -0
  109. package/src/plan/repo-source.ts +19 -5
  110. package/src/reflect/transcript.ts +35 -10
  111. package/src/release/public-clean.ts +301 -0
  112. package/src/release/published-here.ts +22 -0
  113. package/src/release/run-bump.ts +2 -1
  114. package/src/release/run-release.ts +4 -1
  115. package/src/repo-config.ts +53 -2
  116. package/src/review/http.ts +16 -2
  117. package/src/review/media-kind.ts +3 -3
  118. package/src/review/media-read.ts +3 -3
  119. package/src/review/model.ts +24 -5
  120. package/src/review/notes.ts +77 -0
  121. package/src/review/project.ts +6 -38
  122. package/src/review/routes.ts +8 -13
  123. package/src/review/store.ts +46 -4
  124. package/src/review/trailer-media.ts +24 -3
  125. package/src/review/trailer-shots.ts +106 -0
  126. package/src/review/unit.ts +1 -1
  127. package/src/scaffold/files/agent-handoff.md +3 -0
  128. package/src/scaffold/files/agent-index.md +4 -12
  129. package/src/scaffold/project-scaffold.ts +5 -4
  130. package/src/serve/embed.ts +1 -1
  131. package/src/serve/hub-app/col-card.tsx +3 -17
  132. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  133. package/src/serve/hub-app/cols-svc.ts +12 -14
  134. package/src/serve/hub-app/dock-st.ts +4 -2
  135. package/src/serve/hub-app/dock-view.tsx +2 -0
  136. package/src/serve/hub-app/frames-st.ts +35 -0
  137. package/src/serve/hub-app/hash-route.ts +64 -1
  138. package/src/serve/hub-app/home-st.ts +31 -7
  139. package/src/serve/hub-app/home-strip.css +9 -1
  140. package/src/serve/hub-app/home-strip.tsx +7 -6
  141. package/src/serve/hub-app/home.html +5 -0
  142. package/src/serve/hub-app/hub-app.tsx +49 -5
  143. package/src/serve/hub-app/hub.css +29 -11
  144. package/src/serve/hub-app/icons.tsx +16 -1
  145. package/src/serve/hub-app/identities-st.ts +210 -0
  146. package/src/serve/hub-app/identities-view.tsx +352 -0
  147. package/src/serve/hub-app/identities.css +48 -0
  148. package/src/serve/hub-app/identity-address.ts +52 -0
  149. package/src/serve/hub-app/inbox-st.ts +59 -6
  150. package/src/serve/hub-app/inbox-view.tsx +48 -6
  151. package/src/serve/hub-app/inbox.css +12 -1
  152. package/src/serve/hub-app/index.html +3 -0
  153. package/src/serve/hub-app/keys.ts +10 -2
  154. package/src/serve/hub-app/list-walk.ts +89 -0
  155. package/src/serve/hub-app/machine-st.ts +12 -0
  156. package/src/serve/hub-app/media-view.tsx +2 -1
  157. package/src/serve/hub-app/pages-frames.tsx +134 -0
  158. package/src/serve/hub-app/pages-svc.ts +111 -0
  159. package/src/serve/hub-app/palette-st.ts +18 -3
  160. package/src/serve/hub-app/palette-view.tsx +9 -2
  161. package/src/serve/hub-app/planned-view.tsx +2 -1
  162. package/src/serve/hub-app/project-list.css +18 -14
  163. package/src/serve/hub-app/project-list.tsx +88 -49
  164. package/src/serve/hub-app/projects-svc.ts +33 -3
  165. package/src/serve/hub-app/repo-sections.ts +19 -2
  166. package/src/serve/hub-app/repo-st.ts +75 -19
  167. package/src/serve/hub-app/review/review-cells.tsx +3 -3
  168. package/src/serve/hub-app/review/review-kit.ts +30 -7
  169. package/src/serve/hub-app/review/review-page.tsx +1 -1
  170. package/src/serve/hub-app/review/review-st.ts +33 -11
  171. package/src/serve/hub-app/review/review-thread.tsx +11 -9
  172. package/src/serve/hub-app/review/review-views.tsx +84 -19
  173. package/src/serve/hub-app/review/thread-st.ts +1 -10
  174. package/src/serve/hub-app/review/trailer-page.tsx +2 -1
  175. package/src/serve/hub-app/review.css +17 -8
  176. package/src/serve/hub-app/site/site-part.tsx +173 -0
  177. package/src/serve/hub-app/site/site-st.ts +157 -0
  178. package/src/serve/hub-app/site.css +35 -0
  179. package/src/serve/hub-app/social/calendar.tsx +182 -0
  180. package/src/serve/hub-app/social/comms-page.tsx +306 -0
  181. package/src/serve/hub-app/social/kit.tsx +244 -0
  182. package/src/serve/hub-app/social/post-card.tsx +456 -0
  183. package/src/serve/hub-app/social/problems.tsx +60 -0
  184. package/src/serve/hub-app/social/social-model.ts +154 -0
  185. package/src/serve/hub-app/social/social-page.tsx +674 -0
  186. package/src/serve/hub-app/social/social-st.ts +986 -0
  187. package/src/serve/hub-app/social.css +289 -0
  188. package/src/serve/hub-app/stores/stores-page.tsx +311 -0
  189. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  190. package/src/serve/hub-app/stores.css +54 -0
  191. package/src/serve/hub-app/test-view.tsx +9 -2
  192. package/src/serve/hub-app/tests-svc.ts +16 -1
  193. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  194. package/src/serve/hub-app/timeline-view.tsx +3 -2
  195. package/src/serve/hub-app/tree-build.ts +6 -0
  196. package/src/serve/hub-app/tree-row.tsx +27 -4
  197. package/src/serve/hub-app/tree-svc.ts +18 -49
  198. package/src/serve/hub-app/veille/veille-page.tsx +514 -0
  199. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  200. package/src/serve/hub-app/veille.css +84 -0
  201. package/src/serve/hub-runtime.ts +14 -9
  202. package/src/serve/project-gutter-route.ts +44 -12
  203. package/src/serve/resources-wire.ts +48 -0
  204. package/src/serve/run-lanes.ts +7 -4
  205. package/src/serve/same-origin.ts +1 -1
  206. package/src/serve/serve-hub.ts +27 -18
  207. package/src/serve/tracked-watch.ts +24 -3
  208. package/src/serve/warm-cell.ts +5 -1
  209. package/src/shipkit-files.ts +15 -4
  210. package/src/shipkit.ts +0 -1
  211. package/src/shot/box.ts +162 -0
  212. package/src/shot/browser-slot.ts +62 -0
  213. package/src/shot/client.ts +43 -7
  214. package/src/shot/clip-encoder.ts +93 -12
  215. package/src/shot/film-box.ts +188 -0
  216. package/src/shot/shooter.ts +50 -15
  217. package/src/shot/shot-ask.ts +10 -2
  218. package/src/shot/stepped-clip.ts +5 -4
  219. package/src/site/desk.ts +242 -0
  220. package/src/site/routes.ts +66 -0
  221. package/src/site/unit.ts +62 -0
  222. package/src/social/brands.ts +22 -0
  223. package/src/social/compose.ts +97 -0
  224. package/src/social/desk-index.ts +123 -0
  225. package/src/social/desk-wire.ts +64 -0
  226. package/src/social/drafts.ts +183 -0
  227. package/src/social/house.ts +24 -0
  228. package/src/social/load.ts +319 -0
  229. package/src/social/md.ts +70 -0
  230. package/src/social/media-facts.ts +53 -0
  231. package/src/social/media-kind.ts +189 -0
  232. package/src/social/media-limit.ts +42 -0
  233. package/src/social/media-of.ts +30 -0
  234. package/src/social/migrate.ts +123 -0
  235. package/src/social/open.ts +17 -0
  236. package/src/social/post-url.ts +158 -0
  237. package/src/social/presence.ts +332 -0
  238. package/src/social/public-read.ts +53 -0
  239. package/src/social/publish/bluesky.ts +168 -0
  240. package/src/social/publish/discord.ts +76 -0
  241. package/src/social/publish/index.ts +24 -0
  242. package/src/social/publish/secret.ts +13 -0
  243. package/src/social/push.ts +31 -0
  244. package/src/social/richtext.ts +37 -0
  245. package/src/social/routes.ts +180 -0
  246. package/src/social/stats.ts +134 -0
  247. package/src/social/text.ts +267 -0
  248. package/src/social/tracker-route.ts +39 -0
  249. package/src/social/tracker.ts +255 -0
  250. package/src/social/unit.ts +53 -0
  251. package/src/social/writes.ts +130 -0
  252. package/src/start-repo.ts +14 -9
  253. package/src/stores/collection.ts +27 -0
  254. package/src/stores/desk.ts +336 -0
  255. package/src/stores/model.ts +187 -0
  256. package/src/stores/routes.ts +126 -0
  257. package/src/stores/unit.ts +57 -0
  258. package/src/suite/calibrate.ts +127 -0
  259. package/src/suite/core-counters.ts +91 -0
  260. package/src/suite/judge-suites.ts +94 -34
  261. package/src/suite/suite-cli.ts +44 -10
  262. package/src/suite/suite-cpu-preload.ts +34 -9
  263. package/src/trailer/adapter.ts +4 -0
  264. package/src/trailer/build.ts +42 -11
  265. package/src/trailer/ffmpeg.ts +11 -0
  266. package/src/trailer/footage.ts +30 -13
  267. package/src/trailer/grammar.ts +18 -2
  268. package/src/trailer/graph.ts +28 -6
  269. package/src/trailer/passage.ts +21 -6
  270. package/src/trailer/plan.ts +74 -3
  271. package/src/trailer/shelf.ts +16 -0
  272. package/src/trailer/stitch.ts +67 -26
  273. package/src/trailer/url.ts +1 -1
  274. package/src/trailer/versions.ts +24 -0
  275. package/src/ts/gate-typecheck.ts +32 -0
  276. package/src/ts/typecheck-cli.ts +9 -11
  277. package/src/tui/tui-app.tsx +0 -1
  278. package/src/veille/asks.ts +155 -0
  279. package/src/veille/auto.ts +31 -0
  280. package/src/veille/batch.ts +27 -0
  281. package/src/veille/chrome.ts +127 -0
  282. package/src/veille/collection.ts +28 -0
  283. package/src/veille/desk.ts +242 -0
  284. package/src/veille/identity.ts +80 -0
  285. package/src/veille/import.ts +68 -0
  286. package/src/veille/log.ts +183 -0
  287. package/src/veille/platforms.ts +118 -0
  288. package/src/veille/reads.ts +66 -0
  289. package/src/veille/replied.ts +110 -0
  290. package/src/veille/routes.ts +185 -0
  291. package/src/veille/service.ts +81 -0
  292. package/src/veille/watch.ts +116 -0
  293. package/src/veille/worth.ts +46 -0
  294. package/src/wiki/scan-md.ts +18 -0
  295. package/src/collections/posts.ts +0 -142
  296. package/src/contracts/manifests/social.contract.ts +0 -20
  297. package/src/scaffold/files/agent-coding.md +0 -35
  298. package/src/ts/typecheck-cache.ts +0 -11
@@ -0,0 +1,306 @@
1
+ // a repo's Communications page (`#page:comms`, wiki build/shipkit/social.md, The desks in the hub): the calendar on top,
2
+ // the drafts on the left (the family, the channel, the identity, the order), the draft picked in the middle (its angle,
3
+ // his notes, a card a heading), its article and media on the right. On a phone one pane at a time
4
+ import { observer } from 'mobx-react-lite'
5
+ import { Fragment, useEffect, useRef } from 'react'
6
+ import { Group, Panel, Separator } from 'react-resizable-panels'
7
+ import type { RepoSt } from '../repo-st.ts'
8
+ import { PANEL, PhoneTop } from '../review/review-page.tsx'
9
+ import { SocialCalendar } from './calendar.tsx'
10
+ import { CopyIcon, ErrorLine, Lightbox, NotesBox, Toast } from './kit.tsx'
11
+ import { AngleCards, Cards, Logos, MediaTile } from './post-card.tsx'
12
+ import { FAM_LABEL, madeOn, posting, STATUS, countsOf, type Draft, type Fam } from './social-model.ts'
13
+ import { Problems } from './problems.tsx'
14
+ import type { SocialSt } from './social-st.ts'
15
+ import { Caret } from '../icons.tsx'
16
+
17
+ export const CommsPage = observer(({ app }: { app: RepoSt }) => {
18
+ const so = app.social
19
+ useEffect(() => {
20
+ so.start()
21
+ return () => so.stop()
22
+ }, [so])
23
+ if (so.phone)
24
+ return (
25
+ <div className="so-phone">
26
+ {so.phonePane === 'list' ? (
27
+ <>
28
+ <PhoneTop app={app} />
29
+ <DraftsList so={so} />
30
+ </>
31
+ ) : (
32
+ <>
33
+ <div className="rv-phonetop">
34
+ <button className="ghost" onClick={() => so.showPhoneList()}>
35
+ ◂ drafts
36
+ </button>
37
+ <b className="so-ellip">{so.currentDraft?.title || so.currentDraft?.slug}</b>
38
+ </div>
39
+ <DraftPane so={so} />
40
+ <DraftSide so={so} />
41
+ </>
42
+ )}
43
+ <Lightbox so={so} />
44
+ <Toast so={so} />
45
+ </div>
46
+ )
47
+ return (
48
+ <div className="so-page">
49
+ <SocialCalendar so={so} />
50
+ <Group className="rv-cols" orientation="horizontal">
51
+ <Panel id="comms-list" defaultSize="22%" minSize={240} className="rv-pane" style={PANEL}>
52
+ <DraftsList so={so} />
53
+ </Panel>
54
+ <Separator className="rsep" />
55
+ <Panel id="comms-draft" defaultSize="46%" minSize={360} className="rv-pane" style={PANEL}>
56
+ <div className="rv-scroll so-ground">
57
+ <DraftPane so={so} />
58
+ </div>
59
+ </Panel>
60
+ <Separator className="rsep" />
61
+ <Panel id="comms-side" defaultSize="32%" minSize={280} className="rv-pane" style={PANEL}>
62
+ <div className="rv-scroll so-ground">
63
+ <DraftSide so={so} />
64
+ </div>
65
+ </Panel>
66
+ </Group>
67
+ <Lightbox so={so} />
68
+ <Toast so={so} />
69
+ </div>
70
+ )
71
+ })
72
+
73
+ const FAM_CHOICES: (Fam | null)[] = ['feed', 'vertical', null]
74
+
75
+ /** every draft in the order asked: its day, its title, its platforms (lit once posted there), its count */
76
+ const DraftsList = observer(({ so }: { so: SocialSt }) => {
77
+ const drafts = so.visibleDrafts
78
+ const t = so.listTotals
79
+ return (
80
+ <div className="so-listcol">
81
+ <div className="so-filters">
82
+ <input ref={(el) => { so.searchEl = el }} className="rv-search" placeholder="search the drafts" value={so.draftQuery} onChange={(e) => so.setDraftQuery(e.currentTarget.value)} />
83
+ <span className="seg so-fullseg">
84
+ {FAM_CHOICES.map((f) => (
85
+ <button key={f ?? 'all'} className={so.fam === f ? 'on' : ''} onClick={() => so.setView({ fam: f })} title={f === 'feed' ? 'the drafts with a message to the feed (X, Bluesky, Threads, Mastodon, Discord)' : f === 'vertical' ? 'the drafts with a message to the vertical (TikTok, Instagram, YouTube)' : 'every draft'}>
86
+ {f ? FAM_LABEL[f] : 'All'}
87
+ </button>
88
+ ))}
89
+ </span>
90
+ <div className="so-selects">
91
+ <select value={so.channel ?? ''} onChange={(e) => so.setView({ channel: e.currentTarget.value || null })} title="only the drafts that hold a message for one platform">
92
+ <option value="">every channel</option>
93
+ {so.channels.map((id) => (
94
+ <option key={id} value={id}>
95
+ {id}
96
+ </option>
97
+ ))}
98
+ </select>
99
+ <select value={so.who ?? ''} onChange={(e) => so.setView({ who: e.currentTarget.value || null })} title="only the drafts one identity speaks">
100
+ <option value="">every identity</option>
101
+ {so.speakers.map((s) => (
102
+ <option key={s.id} value={s.id}>
103
+ {s.name} · {s.n}
104
+ </option>
105
+ ))}
106
+ </select>
107
+ </div>
108
+ <div className="so-selects">
109
+ <button className="ghost" onClick={() => so.foldAll(!so.allFolded)} title={so.allFolded ? 'unfold every series' : 'fold every series'}>
110
+ {so.allFolded ? '⇕ unfold all' : '⇳ fold all'}
111
+ </button>
112
+ <button className="ghost" onClick={() => so.setView({ newestFirst: !so.newestFirst })}>
113
+ {so.newestFirst ? '↓ newest first' : '↑ oldest first'}
114
+ </button>
115
+ </div>
116
+ <span className="rv-count">
117
+ {drafts.length < t.drafts ? `${drafts.length} of ` : ''}
118
+ {t.drafts} drafts · {t.waiting} to post
119
+ </span>
120
+ </div>
121
+ <Problems so={so} lines={[...(so.loadError ? [so.loadError] : []), ...so.errors]} />
122
+ <div className="rv-listscroll so-rows">
123
+ {so.desk && so.desk.drafts.length === 0 ? <div className="rv-empty">no draft: write .shipkit/social/drafts/&lt;YYYYMMDD-HHMMSS&gt;-&lt;topic&gt;/draft.md</div> : null}
124
+ {drafts.map((d) => (
125
+ <Fragment key={d.slug}>
126
+ <DraftRow so={so} d={d} />
127
+ {so.shownParts(d).map((part) => (
128
+ <PartRow key={part} so={so} d={d} part={part} />
129
+ ))}
130
+ </Fragment>
131
+ ))}
132
+ </div>
133
+ </div>
134
+ )
135
+ })
136
+
137
+ /** the row picked stays in view, as the arrows walk the list */
138
+ function useInView(on: boolean) {
139
+ const ref = useRef<HTMLButtonElement>(null)
140
+ useEffect(() => {
141
+ if (on) ref.current?.scrollIntoView({ block: 'nearest' })
142
+ }, [on])
143
+ return ref
144
+ }
145
+
146
+ const DraftRow = observer(({ so, d }: { so: SocialSt; d: Draft }) => {
147
+ const c = so.listCounts(d)
148
+ const on = so.isDraft(d) && so.currentPart === null
149
+ const ref = useInView(on)
150
+ const other = so.desk?.speaksAs != null && d.identity !== so.desk.speaksAs
151
+ return (
152
+ <button ref={ref} className={`so-draftrow p-${posting(c)}${on ? ' on' : ''}${d.status === 'rejected' ? ' rejected' : ''}`} onClick={() => so.pickDraft(d.slug)} title={d.slug}>
153
+ {so.listParts(d).length > 0 ? (
154
+ <span
155
+ className="so-chev"
156
+ role="button"
157
+ aria-label={so.seriesFolded(d) ? 'unfold the messages' : 'fold the messages'}
158
+ onClick={(e) => {
159
+ // the fold alone: the row's own click would open the draft
160
+ e.stopPropagation()
161
+ so.flipSeries(d)
162
+ }}
163
+ >
164
+ <Caret open={!so.seriesFolded(d)} />
165
+ </span>
166
+ ) : null}
167
+ <span className="so-day">{madeOn(d.slug)}</span>
168
+ <span className="so-rowtitle">
169
+ {d.article ? <span className="so-art" title="an article: it holds a post.md">▤</span> : null}
170
+ {d.title || d.slug}
171
+ </span>
172
+ {other ? <span className="so-who" title={`spoken as ${so.identityOf(d.identity)?.name ?? d.identity}, not the repo's identity`}>{so.identityOf(d.identity)?.name ?? d.identity}</span> : null}
173
+ <Logos so={so} posts={so.familyPosts(d)} size={14} />
174
+ <span className={`so-frac${c.of > 0 && c.posted === c.of ? ' t-ok' : ''}`}>
175
+ {c.posted}/{c.of}
176
+ </span>
177
+ </button>
178
+ )
179
+ })
180
+
181
+ /** one message of a series under its draft's row: its name, its platforms, its count; a click opens it alone */
182
+ const PartRow = observer(({ so, d, part }: { so: SocialSt; d: Draft; part: string }) => {
183
+ const posts = so.familyPosts(d).filter((x) => x.name === part)
184
+ const c = so.listCounts(d, part)
185
+ const on = so.isDraft(d) && so.currentPart === part
186
+ const ref = useInView(on)
187
+ return (
188
+ <button ref={ref} className={`so-draftrow part p-${posting(c)}${on ? ' on' : ''}${d.status === 'rejected' ? ' rejected' : ''}`} onClick={() => so.pickDraft(d.slug, part)} title={posts[0]?.text}>
189
+ <span className="rv-dim">↳</span>
190
+ <span className="so-rowtitle small">{part}</span>
191
+ <Logos so={so} posts={posts} size={12} />
192
+ <span className={`so-frac${c.of > 0 && c.posted === c.of ? ' t-ok' : ''}`}>
193
+ {c.posted}/{c.of}
194
+ </span>
195
+ </button>
196
+ )
197
+ })
198
+
199
+ const DraftPane = observer(({ so }: { so: SocialSt }) => {
200
+ const d = so.currentDraft
201
+ if (!d) return <div className="rv-empty">{so.desk ? 'no draft here: the list keeps none' : so.loadError ?? so.waitText}</div>
202
+ return <DraftPage so={so} d={d} />
203
+ })
204
+
205
+ /** a draft picked: its title and state, its angle, his notes, then a card a message */
206
+ const DraftPage = observer(({ so, d }: { so: SocialSt; d: Draft }) => {
207
+ const c = countsOf(d.posts)
208
+ const all = c.posted === c.of && c.of > 0
209
+ const speaker = so.identityOf(d.identity)
210
+ const shown = so.shownMessages(d)
211
+ useEffect(() => void so.loadNotes(d.slug), [so, d.slug])
212
+ return (
213
+ <div className="so-colin">
214
+ <ErrorLine so={so} />
215
+ <div className="so-pagehead">
216
+ <h2 className="so-h">
217
+ {d.title || d.slug}
218
+ {d.kind ? <span className="rv-dim so-light"> · {d.kind}</span> : null}
219
+ </h2>
220
+ <span className={`so-badge ${all ? 't-ok' : d.status === 'picked' ? 't-warn' : 't-dim'}`}>{all ? 'posted everywhere' : `${STATUS[d.status] ?? d.status} · ${c.posted}/${c.of}`}</span>
221
+ </div>
222
+ <div className="so-meta">
223
+ {speaker ? (
224
+ <span className={`so-who${d.identity !== so.desk?.speaksAs ? '' : ' own'}`} title="the identity that speaks it">
225
+ {speaker.name}
226
+ </span>
227
+ ) : null}
228
+ <a href={so.editorUrl(d.path)}>open in VS Code ({d.file}) ↗</a>
229
+ </div>
230
+ {d.angle ? <AngleCards key={d.slug} angle={d.angle} /> : null}
231
+ <NotesBox so={so} notes={so.notes[d.slug] ?? []} placeholder="a note on this draft: it goes to the review page, an agent takes it" send={(text) => so.sendNote(d, text)} />
232
+ {so.currentPart !== null ? (
233
+ <div className="so-partline">
234
+ <span className="so-partchip">{so.currentPart}</span>
235
+ <button className="so-linkbtn" onClick={() => so.pickDraft(d.slug)}>
236
+ the whole draft
237
+ </button>
238
+ </div>
239
+ ) : null}
240
+ <Cards so={so} posts={shown.filter((x) => so.inFamilyPost(x))} />
241
+ {so.fam !== null && shown.some((x) => !so.inFamilyPost(x)) ? (
242
+ <>
243
+ <div className="rv-divider">outside {FAM_LABEL[so.fam]}</div>
244
+ <Cards so={so} posts={shown.filter((x) => !so.inFamilyPost(x))} />
245
+ </>
246
+ ) : null}
247
+ </div>
248
+ )
249
+ })
250
+
251
+ const DraftSide = observer(({ so }: { so: SocialSt }) => {
252
+ const d = so.currentDraft
253
+ return d ? <DraftMedia so={so} d={d} /> : null
254
+ })
255
+
256
+ /** the right of a draft: its article when it holds one, every media large, the picture's description */
257
+ const DraftMedia = observer(({ so, d }: { so: SocialSt; d: Draft }) => {
258
+ const art = d.article
259
+ return (
260
+ <div className="so-colin">
261
+ {art ? (
262
+ <div className="so-card so-article">
263
+ <div className="so-posthead">
264
+ <span className="so-art">▤</span>
265
+ <b className="so-grow">{art.title}</b>
266
+ <span className={`so-badge ${art.draft ? 't-dim' : 't-ok'}`}>{art.draft ? 'not online' : 'online'}</span>
267
+ </div>
268
+ <div className="rv-dim rv-small">
269
+ {art.date}
270
+ {art.url ? (
271
+ <>
272
+ {' · '}
273
+ <a href={art.url} target="_blank" rel="noreferrer">
274
+ {art.url}
275
+ </a>
276
+ </>
277
+ ) : null}
278
+ </div>
279
+ {art.description ? <div className="so-text">{art.description}</div> : null}
280
+ <div className="so-acts">
281
+ {so.desk?.article ? (
282
+ <a className="so-btn primary" href={so.previewUrl(d.slug)} target="_blank" rel="noreferrer" title="the page as the site renders it">
283
+ 👁 Preview
284
+ </a>
285
+ ) : null}
286
+ <a className="so-btn" href={so.editorUrl(d.path.replace(/draft\.md$/, 'post.md'))}>
287
+ ✎ post.md
288
+ </a>
289
+ </div>
290
+ </div>
291
+ ) : null}
292
+ <b>Media</b>
293
+ {d.media.length === 0 ? <div className="rv-dim rv-small">none: `media:` in the draft's front matter</div> : null}
294
+ {d.media.map((m) => (
295
+ <MediaTile key={m.name} so={so} slug={d.slug} m={m} size="large" />
296
+ ))}
297
+ {d.alt ? (
298
+ <div className="so-card so-row">
299
+ <span className="so-rowfield">description</span>
300
+ <span className="so-rowvalue">{d.alt}</span>
301
+ <CopyIcon so={so} text={d.alt} k={`${d.slug}/alt`} title="copy the description" />
302
+ </div>
303
+ ) : null}
304
+ </div>
305
+ )
306
+ })
@@ -0,0 +1,244 @@
1
+ // the desks' small parts (wiki build/shipkit/social.md, The desks in the hub): a platform's logo on its colour, the
2
+ // fold chevron and the card that folds, a count over its max, a frame of words with « Copy », a field's legend, his
3
+ // note box, the lightbox. A brand's hex is data: it rides as `--brand`, every other colour is a token of hub.css
4
+ import { observer } from 'mobx-react-lite'
5
+ import { useState, type CSSProperties, type ReactNode } from 'react'
6
+ import { BRANDS, brandHex } from '../../../social/brands.ts'
7
+ import { renderMd, renderMdInline } from '../md.ts'
8
+ import { plain } from './social-model.ts'
9
+ import type { DraftNote, SocialSt } from './social-st.ts'
10
+ import { Caret } from '../icons.tsx'
11
+
12
+ export const brandVar = (id: string): CSSProperties => ({ '--brand': brandHex(id) }) as CSSProperties
13
+
14
+ /** the platform's mark on its colour; a platform without one shows its initial */
15
+ export function Logo(p: { id: string; name: string; size: number; muted?: boolean }) {
16
+ const b = BRANDS[p.id]
17
+ const glyph = Math.round(p.size * 0.58)
18
+ const box = { ...brandVar(p.id), width: p.size, height: p.size, borderRadius: p.size * 0.28, fontSize: glyph } as CSSProperties
19
+ return (
20
+ <span className={`so-logo${p.muted ? ' muted' : ''}`} style={box} title={p.name}>
21
+ {b ? (
22
+ <svg viewBox="0 0 24 24" width={glyph} height={glyph} aria-hidden>
23
+ <path d={b.d} />
24
+ </svg>
25
+ ) : (
26
+ <b>{p.name.slice(0, 1)}</b>
27
+ )}
28
+ </span>
29
+ )
30
+ }
31
+
32
+ /** the chevron that folds a card to its top line */
33
+ export function Fold(p: { open: boolean; flip: () => void }) {
34
+ return (
35
+ <button className="so-fold" onClick={p.flip} aria-label={p.open ? 'fold' : 'unfold'} aria-expanded={p.open}>
36
+ <Caret open={p.open} />
37
+ </button>
38
+ )
39
+ }
40
+
41
+ export const Md = ({ text, className }: { text: string; className?: string }) => <div className={`so-md${className ? ` ${className}` : ''}`} dangerouslySetInnerHTML={{ __html: renderMd(text) }} />
42
+ export const MdInline = ({ text }: { text: string }) => <span className="so-md" dangerouslySetInnerHTML={{ __html: renderMdInline(text) }} />
43
+
44
+ /** a card a click on its title folds to its top line; `right` stays beside the title, `summary` shows while folded,
45
+ * `flush` draws the body edge to edge (rows split by a line) */
46
+ export function FoldCard(p: { title: string; open: boolean; flip: () => void; right?: ReactNode; summary?: string; flush?: boolean; tone?: string; children: ReactNode }) {
47
+ return (
48
+ <div className={`so-card so-foldcard${p.tone ? ` t-${p.tone}` : ''}`}>
49
+ <div className="so-foldhead">
50
+ <button className="so-foldtitle" onClick={p.flip} aria-expanded={p.open}>
51
+ <span className="so-chev"><Caret open={p.open} /></span>
52
+ <b>{p.title}</b>
53
+ {!p.open && p.summary ? <span className="so-summary">{plain(p.summary)}</span> : null}
54
+ </button>
55
+ {p.right}
56
+ </div>
57
+ {p.open ? p.flush ? p.children : <div className="so-foldbody">{p.children}</div> : null}
58
+ </div>
59
+ )
60
+ }
61
+
62
+ /** a card of a Social page, folded or opened as he last left that card; `open` before he ever did */
63
+ export const KeptFold = observer((p: { so: SocialSt; card: string; title: string; open?: boolean; right?: ReactNode; summary?: string; flush?: boolean; tone?: string; children: ReactNode }) => {
64
+ const init = p.open ?? true
65
+ return (
66
+ <FoldCard title={p.title} open={p.so.isOpen(p.card, init)} flip={() => p.so.flipFold(p.card, init)} right={p.right} summary={p.summary} flush={p.flush} tone={p.tone}>
67
+ {p.children}
68
+ </FoldCard>
69
+ )
70
+ })
71
+
72
+ /** a length over its max: small, green within, red past it */
73
+ export function Count(p: { n: number; max: number | null; title?: string }) {
74
+ const tone = p.max === null ? 'dim' : p.n > p.max ? 'red' : 'ok'
75
+ return (
76
+ <span className={`so-count t-${tone}`} title={p.title}>
77
+ {p.n}
78
+ {p.max !== null && `/${p.max}`}
79
+ </span>
80
+ )
81
+ }
82
+
83
+ /** a field he fills on the platform, its name a small legend on the field's top border, a note (a count) at its right */
84
+ export function Field(p: { label: string; note?: ReactNode; children: ReactNode }) {
85
+ return (
86
+ <div className={`so-field${p.label || p.note ? ' legend' : ''}`}>
87
+ {p.label || p.note ? (
88
+ <div className="so-legendrow">
89
+ {p.label ? <span className="so-legend">{p.label}</span> : <span />}
90
+ {p.note ? <span className="so-legendnote">{p.note}</span> : null}
91
+ </div>
92
+ ) : null}
93
+ {p.children}
94
+ </div>
95
+ )
96
+ }
97
+
98
+ /** words he pastes, in a clear frame, « Copy » in its corner (and « Edit » where the text is his to change) */
99
+ export const CopyFrame = observer((p: { so: SocialSt; text: string; k: string; title?: boolean; onEdit?: () => void; copy?: string }) => {
100
+ const done = p.so.copiedKey === p.k
101
+ return (
102
+ <div className={`so-copyframe${p.onEdit ? ' tall' : ''}`}>
103
+ <div className={`so-copytext rv-pre${p.title ? ' strong' : ''}`}>{p.text}</div>
104
+ <div className="so-corner">
105
+ <button className={done ? 'so-done' : ''} onClick={() => void p.so.copy(p.copy ?? p.text, p.k)}>
106
+ {done ? '✓ Copied' : '⧉ Copy'}
107
+ </button>
108
+ {p.onEdit ? (
109
+ <button className="primary" onClick={p.onEdit}>
110
+ ✎ Edit
111
+ </button>
112
+ ) : null}
113
+ </div>
114
+ </div>
115
+ )
116
+ })
117
+
118
+ /** a small copy button, a check while it is on the clipboard */
119
+ export const CopyIcon = observer((p: { so: SocialSt; text: string; k: string; title?: string }) => (
120
+ <button className="so-icon" onClick={() => void p.so.copy(p.text, p.k)} title={p.title ?? 'copy'} aria-label={p.title ?? 'copy'}>
121
+ {p.so.copiedKey === p.k ? '✓' : '⧉'}
122
+ </button>
123
+ ))
124
+
125
+ /** one row of a flush card: its field, its value with « copy » */
126
+ export const CopyRow = observer((p: { so: SocialSt; k: string; field: string; value: string; children?: ReactNode }) => (
127
+ <div className="so-row">
128
+ <span className="so-rowfield">{p.field}</span>
129
+ {p.children ?? (
130
+ <>
131
+ <span className="so-rowvalue rv-pre">{p.value}</span>
132
+ <CopyIcon so={p.so} text={p.value} k={p.k} title={`copy ${p.field}`} />
133
+ </>
134
+ )}
135
+ </div>
136
+ ))
137
+
138
+ /** his notes on one thing: « Send » or ⌘ Enter raises it in the review store, each note under it « in progress » or
139
+ * « taken up » with the agent's last word, a click opening it on the review page */
140
+ export const NotesBox = observer((p: { so: SocialSt; notes: readonly DraftNote[]; placeholder: string; send: (text: string) => Promise<boolean> }) => {
141
+ const [text, setText] = useState('')
142
+ const send = async (): Promise<void> => {
143
+ if (await p.send(text)) setText('')
144
+ }
145
+ return (
146
+ <div className="so-notes">
147
+ <div className="so-noteline">
148
+ <textarea
149
+ rows={1}
150
+ placeholder={p.placeholder}
151
+ value={text}
152
+ onChange={(e) => setText(e.currentTarget.value)}
153
+ onKeyDown={(e) => {
154
+ if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) void send()
155
+ }}
156
+ />
157
+ <button className="primary" disabled={p.so.busy || text.trim() === ''} onClick={() => void send()} title="⌘ Enter">
158
+ ➤ Send
159
+ </button>
160
+ </div>
161
+ {p.notes.map((n, i) => (
162
+ <button key={`${n.id}/${i}`} className={`so-said ${n.state === 'closed' ? 't-ok' : 't-warn'}`} onClick={() => p.so.openNote(n.id)} title="open it on the review page">
163
+ <span className="so-saidstate">{n.state === 'closed' ? 'taken up' : 'in progress'}</span> {n.text}
164
+ {n.answer ? <div className="rv-dim">→ {n.answer}</div> : null}
165
+ </button>
166
+ ))}
167
+ </div>
168
+ )
169
+ })
170
+
171
+ /** the small button that opens a media in the lightbox: shown on hover, always on the phone */
172
+ export function ExpandButton(p: { onClick: () => void; shown: boolean }) {
173
+ if (!p.shown) return null
174
+ return (
175
+ <button
176
+ className="so-expand"
177
+ onClick={(e) => {
178
+ e.stopPropagation()
179
+ p.onClick()
180
+ }}
181
+ title="look at it large: ← → step through the draft's media"
182
+ aria-label="look at it large"
183
+ >
184
+ ⤢
185
+ </button>
186
+ )
187
+ }
188
+
189
+ /** the draft's media over the whole page on a dark ground, as large as fits; Esc, a click outside or ✕ close it, ← →
190
+ * step through the draft's media (SocialSt.key). A clip plays with its controls and its sound */
191
+ export const Lightbox = observer(({ so }: { so: SocialSt }) => {
192
+ const lb = so.lightbox
193
+ const d = so.lightboxDraft
194
+ if (!lb || !d) return null
195
+ const at = Math.max(0, d.media.findIndex((m) => m.name === lb.name))
196
+ const m = d.media[at]
197
+ if (!m) return null
198
+ const url = so.mediaUrl(d.slug, m)
199
+ const n = d.media.length
200
+ return (
201
+ <div className="so-lightbox" onClick={() => so.closeLightbox()}>
202
+ <div className="so-lbbar" onClick={(e) => e.stopPropagation()}>
203
+ {n > 1 ? <button className="ghost" onClick={() => so.stepLightbox(-1)} title="the one before">‹</button> : null}
204
+ <span>
205
+ {m.name}
206
+ {n > 1 ? ` · ${at + 1}/${n}` : ''}
207
+ </span>
208
+ {n > 1 ? <button className="ghost" onClick={() => so.stepLightbox(1)} title="the next">›</button> : null}
209
+ <button className="ghost" onClick={() => so.closeLightbox()} title="close (Escape)">✕</button>
210
+ </div>
211
+ {/\.(mp4|webm|mov)$/i.test(m.name) ? (
212
+ <video key={url} src={url} autoPlay loop playsInline controls className="so-lbmedia" onClick={(e) => e.stopPropagation()} />
213
+ ) : (
214
+ <img key={url} src={url} alt={m.name} className="so-lbmedia" onClick={(e) => e.stopPropagation()} />
215
+ )}
216
+ </div>
217
+ )
218
+ })
219
+
220
+ export const Toast = observer(({ so }: { so: SocialSt }) => (so.toast ? <div className="rv-toast" role="status">{so.toast}</div> : null))
221
+
222
+ export const ErrorLine = observer(({ so }: { so: SocialSt }) =>
223
+ so.error ? (
224
+ <div className="so-error" onClick={() => so.clearError()} title="close">
225
+ {so.error} ✕
226
+ </div>
227
+ ) : null,
228
+ )
229
+
230
+ /** a button to one page of the platform, when the account names it */
231
+ export function Go(p: { href: string; label: string; icon: string; solid?: boolean }) {
232
+ if (p.href === '') return null
233
+ return (
234
+ <a className={`so-go${p.solid ? ' solid' : ''}`} href={p.href} target="_blank" rel="noreferrer">
235
+ {p.icon} {p.label}
236
+ </a>
237
+ )
238
+ }
239
+
240
+ /** a platform's page in a popup window of its own, its URL bar showing, the hub left where it is */
241
+ export const popup = (e: { preventDefault: () => void }, url: string, name: string): void => {
242
+ e.preventDefault()
243
+ window.open(url, name.replace(/[^a-z0-9]/gi, '-'), 'popup,width=1200,height=900')
244
+ }