rvlib-shipkit 2.19.0 → 2.21.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 (196) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/package.json +1 -1
  3. package/src/annex/annex.ts +227 -0
  4. package/src/annex/offload.ts +279 -0
  5. package/src/checks/SK004-gitignore-policy.check.ts +6 -3
  6. package/src/checks/SK040-release-words.check.ts +43 -0
  7. package/src/checks/SK041-annex-links.check.ts +28 -0
  8. package/src/checks/SK042-post-kinds.check.ts +73 -0
  9. package/src/cli/cmd_Annex.ts +179 -0
  10. package/src/cli/cmd_Commands.ts +4 -1
  11. package/src/cli/cmd_GlobalProcesses.ts +2 -107
  12. package/src/cli/cmd_Home.ts +4 -3
  13. package/src/cli/cmd_Messages.ts +155 -0
  14. package/src/cli/cmd_Overview.ts +2 -1
  15. package/src/cli/cmd_Releases.ts +84 -0
  16. package/src/cli/cmd_Review.ts +176 -12
  17. package/src/cli/cmd_Shot.ts +4 -4
  18. package/src/cli/cmd_Social.ts +151 -8
  19. package/src/cli/cmd_Sound.ts +17 -4
  20. package/src/cli/cmd_Trailer.ts +67 -1
  21. package/src/cli/family-pages.ts +2 -0
  22. package/src/cli/kit/index.ts +1 -1
  23. package/src/cli/kit/verb.ts +11 -3
  24. package/src/cli/registry.ts +7 -1
  25. package/src/collections/collection-types.ts +8 -1
  26. package/src/collections/providers.ts +4 -1
  27. package/src/collections/review.ts +23 -4
  28. package/src/commands/model.ts +36 -0
  29. package/src/commands/registry.ts +49 -0
  30. package/src/commands/routes.ts +59 -0
  31. package/src/commands/runner.ts +35 -0
  32. package/src/commands/runs.ts +112 -0
  33. package/src/core/app-icon.ts +4 -3
  34. package/src/core/icon-type.ts +8 -0
  35. package/src/core/jobs.ts +4 -3
  36. package/src/core/layout.ts +11 -2
  37. package/src/core/squircle.ts +95 -0
  38. package/src/home/daemon-jobs.ts +26 -2
  39. package/src/home/global-units.ts +3 -0
  40. package/src/home/gui-app/ShipkitGui.swift +337 -5
  41. package/src/home/gui-app.ts +64 -33
  42. package/src/home/hmr-keep.ts +134 -0
  43. package/src/home/home-start.ts +2 -2
  44. package/src/home/lib-watch.ts +21 -11
  45. package/src/home/pm-switch.ts +112 -0
  46. package/src/home/pm.ts +1 -1
  47. package/src/home/process-apps.ts +181 -0
  48. package/src/home/resources.ts +3 -3
  49. package/src/home/run-web.ts +7 -4
  50. package/src/home/serve-web.ts +64 -14
  51. package/src/identities/collection.ts +49 -0
  52. package/src/identities/identities.ts +121 -14
  53. package/src/identities/machine.ts +4 -3
  54. package/src/identities/rating.ts +33 -0
  55. package/src/identities/shown.ts +170 -0
  56. package/src/identities/steps.ts +5 -0
  57. package/src/media-store/purge.ts +15 -1
  58. package/src/media-store/remote.ts +22 -6
  59. package/src/messages/brief.ts +117 -0
  60. package/src/messages/collection.ts +40 -0
  61. package/src/messages/model.ts +171 -0
  62. package/src/messages/routes.ts +15 -0
  63. package/src/messages/score.ts +182 -0
  64. package/src/messages/tabs.ts +13 -0
  65. package/src/release/notes.ts +130 -0
  66. package/src/release/run-bump.ts +41 -18
  67. package/src/release/run-release.ts +22 -4
  68. package/src/release/run-releases.ts +17 -15
  69. package/src/release/unit-resolve.ts +9 -0
  70. package/src/releases/add.ts +94 -0
  71. package/src/releases/before.ts +31 -0
  72. package/src/releases/collection.ts +36 -0
  73. package/src/releases/from-card.ts +151 -0
  74. package/src/releases/model.ts +327 -0
  75. package/src/releases/pictures.ts +110 -0
  76. package/src/releases/routes.ts +36 -0
  77. package/src/releases/store.ts +71 -0
  78. package/src/repo-config.ts +5 -0
  79. package/src/review/cells.ts +0 -11
  80. package/src/review/format.ts +10 -6
  81. package/src/review/http.ts +1 -1
  82. package/src/review/model.ts +102 -3
  83. package/src/review/notes.ts +2 -48
  84. package/src/review/routes.ts +28 -10
  85. package/src/review/stage-card.ts +197 -0
  86. package/src/review/stage-routes.ts +123 -0
  87. package/src/review/store.ts +47 -1
  88. package/src/review/trailer-card.ts +99 -0
  89. package/src/review/trailer-desk.ts +76 -4
  90. package/src/review/trailer-model.ts +106 -7
  91. package/src/review/trailer-notes.ts +45 -0
  92. package/src/review/trailer-routes.ts +119 -13
  93. package/src/review/trailer-voices.ts +144 -0
  94. package/src/review/watchers.ts +58 -1
  95. package/src/serve/hub-app/app-bridge.ts +71 -0
  96. package/src/serve/hub-app/benign-errors.ts +22 -0
  97. package/src/serve/hub-app/commands/commands-page.tsx +122 -0
  98. package/src/serve/hub-app/commands/commands-st.ts +177 -0
  99. package/src/serve/hub-app/commands.css +24 -0
  100. package/src/serve/hub-app/hash-route.ts +59 -8
  101. package/src/serve/hub-app/home-st.ts +19 -2
  102. package/src/serve/hub-app/home.html +3 -0
  103. package/src/serve/hub-app/hub-app.tsx +8 -0
  104. package/src/serve/hub-app/icons.tsx +5 -0
  105. package/src/serve/hub-app/identities-view.tsx +4 -1
  106. package/src/serve/hub-app/identities.css +1 -0
  107. package/src/serve/hub-app/index.html +3 -0
  108. package/src/serve/hub-app/keys.ts +2 -2
  109. package/src/serve/hub-app/machine-st.ts +41 -10
  110. package/src/serve/hub-app/messages/messages-page.tsx +354 -0
  111. package/src/serve/hub-app/messages/messages-st.ts +74 -0
  112. package/src/serve/hub-app/messages.css +35 -0
  113. package/src/serve/hub-app/project-list.css +7 -2
  114. package/src/serve/hub-app/project-list.tsx +9 -0
  115. package/src/serve/hub-app/projects-svc.ts +16 -6
  116. package/src/serve/hub-app/releases/releases-page.tsx +187 -0
  117. package/src/serve/hub-app/releases/releases-st.ts +111 -0
  118. package/src/serve/hub-app/releases.css +52 -0
  119. package/src/serve/hub-app/repo-sections.ts +16 -2
  120. package/src/serve/hub-app/repo-st.ts +66 -10
  121. package/src/serve/hub-app/review/clip-st.ts +34 -4
  122. package/src/serve/hub-app/review/kit.tsx +3 -3
  123. package/src/serve/hub-app/review/note-place.ts +31 -0
  124. package/src/serve/hub-app/review/review-cells.tsx +27 -3
  125. package/src/serve/hub-app/review/review-st.ts +77 -2
  126. package/src/serve/hub-app/review/review-thread.tsx +9 -31
  127. package/src/serve/hub-app/review/review-views.tsx +164 -58
  128. package/src/serve/hub-app/review/thread-st.ts +108 -41
  129. package/src/serve/hub-app/review/trailer-card.tsx +187 -0
  130. package/src/serve/hub-app/review/trailer-page.tsx +92 -36
  131. package/src/serve/hub-app/review/trailer-st.ts +306 -34
  132. package/src/serve/hub-app/review/trailer-timeline.tsx +68 -23
  133. package/src/serve/hub-app/review/trailer-voices-st.ts +370 -0
  134. package/src/serve/hub-app/review/trailer-voices.tsx +574 -0
  135. package/src/serve/hub-app/review.css +137 -6
  136. package/src/serve/hub-app/social/comms-page.tsx +65 -28
  137. package/src/serve/hub-app/social/identity-pictures.ts +46 -8
  138. package/src/serve/hub-app/social/kit.tsx +9 -6
  139. package/src/serve/hub-app/social/next-release.tsx +118 -0
  140. package/src/serve/hub-app/social/post-card.tsx +10 -2
  141. package/src/serve/hub-app/social/social-model.ts +39 -3
  142. package/src/serve/hub-app/social/social-page.tsx +179 -65
  143. package/src/serve/hub-app/social/social-st.ts +117 -27
  144. package/src/serve/hub-app/social/stage-popup.tsx +268 -0
  145. package/src/serve/hub-app/social/stage-st.ts +310 -0
  146. package/src/serve/hub-app/social/step-layout.ts +42 -0
  147. package/src/serve/hub-app/social.css +68 -1
  148. package/src/serve/hub-app/tree-build.ts +40 -1
  149. package/src/serve/hub-app/tree-svc.ts +10 -3
  150. package/src/serve/project-gutter-route.ts +12 -2
  151. package/src/serve/project-gutter.ts +4 -2
  152. package/src/serve/same-origin.ts +24 -1
  153. package/src/serve/serve-hub.ts +15 -1
  154. package/src/shipkit-files.ts +9 -7
  155. package/src/shot/box.ts +33 -12
  156. package/src/shot/client.ts +1 -1
  157. package/src/shot/shooter.ts +22 -12
  158. package/src/shot/shot-ask.ts +14 -3
  159. package/src/shot/shot.shipkit.ts +1 -1
  160. package/src/social/desk-index.ts +49 -8
  161. package/src/social/discord-layout.ts +54 -7
  162. package/src/social/drafts.ts +1 -1
  163. package/src/social/fit.ts +84 -0
  164. package/src/social/identity-words.ts +74 -0
  165. package/src/social/kind-pages.ts +41 -0
  166. package/src/social/kinds.ts +93 -0
  167. package/src/social/load.ts +125 -10
  168. package/src/social/media-limit.ts +63 -2
  169. package/src/social/presence.ts +1 -1
  170. package/src/social/publish/bluesky.ts +58 -19
  171. package/src/social/publish/index.ts +47 -6
  172. package/src/social/reach.ts +49 -0
  173. package/src/social/release-stage.ts +277 -0
  174. package/src/social/routes.ts +44 -8
  175. package/src/social/stage.ts +246 -0
  176. package/src/social/strip.ts +85 -0
  177. package/src/social/text.ts +6 -2
  178. package/src/social/unit.ts +57 -1
  179. package/src/social/writes.ts +11 -0
  180. package/src/trailer/bed.ts +111 -0
  181. package/src/trailer/build.ts +72 -40
  182. package/src/trailer/ffmpeg.ts +6 -0
  183. package/src/trailer/grammar.ts +37 -6
  184. package/src/trailer/graph.ts +12 -1
  185. package/src/trailer/public-words.ts +41 -0
  186. package/src/trailer/shot-plan.ts +75 -0
  187. package/src/trailer/shot-state.ts +191 -0
  188. package/src/trailer/sound/audio.ts +28 -0
  189. package/src/trailer/sound/brand.ts +53 -3
  190. package/src/trailer/sound/gen.ts +61 -2
  191. package/src/trailer/sound/index.ts +25 -11
  192. package/src/trailer/sound/presets.ts +86 -5
  193. package/src/trailer/sound/run.ts +1 -1
  194. package/src/trailer/sound/takes.ts +94 -0
  195. package/src/trailer/titles.ts +36 -0
  196. package/src/trailer/url.ts +1 -1
@@ -21,6 +21,7 @@ import { ErrorLine, KeptFold, Lightbox, Logo, Toast } from './social/kit.tsx'
21
21
  import { Problems } from './social/problems.tsx'
22
22
  import { AccountProfile, IdentityMedia, IdentityPage, LegalPage, LegalPlatforms, Messages, PlacePane, PlatformHeader } from './social/social-page.tsx'
23
23
  import { LEGAL, ME, type DeskAccount, type DeskIdentity } from './social/social-model.ts'
24
+ import { staleBadge } from './social/identity-pictures.ts'
24
25
  import type { SocialSt } from './social/social-st.ts'
25
26
 
26
27
  const Mark = ({ i, px }: { i: MachineIdentity; px: number }) => {
@@ -186,12 +187,14 @@ const AccountRow = observer(({ app, i, d, r }: { app: HomeSt; i: MachineIdentity
186
187
  const c = a == null || so == null ? null : so.counts(a)
187
188
  const stat = a == null ? undefined : so?.statOf(a)
188
189
  const live = m.live !== ''
190
+ const stale = a == null ? null : staleBadge(a)
189
191
  return (
190
192
  <Go app={app} to={{ part: m.id }} cls={rowCls(app, r, live ? '' : ' off')} lit={app.identities.lit === r.key}
191
- title={[`${m.name}${m.handle === '' ? '' : ` ${m.handle}`}`, live ? 'online' : 'still to create', stat, c != null && c.waiting > 0 ? `${c.waiting} messages to post` : ''].filter(Boolean).join(' · ')}>
193
+ title={[`${m.name}${m.handle === '' ? '' : ` ${m.handle}`}`, live ? 'online' : 'still to create', stale == null ? '' : `${a!.uploads.filter((u) => u.stale).map((u) => u.field).join(', ')}: out of date on ${m.name}, the folder holds them changed`, stat, c != null && c.waiting > 0 ? `${c.waiting} messages to post` : ''].filter(Boolean).join(' · ')}>
192
194
  <Logo id={m.id} name={m.name} size={16} muted={!live} />
193
195
  <span className="idname">{m.name}</span>
194
196
  <span className="iddim idgrow so-ellip">{m.handle}</span>
197
+ {stale == null ? null : <span className="so-badge solid t-warn idstale">{stale}</span>}
195
198
  {c != null && c.waiting > 0 ? <b className="idnum">{c.waiting}</b> : null}
196
199
  <i className={`iddot${live ? ' live' : ''}`} />
197
200
  </Go>
@@ -32,6 +32,7 @@
32
32
  .idgrow{flex:1;min-width:0}
33
33
  /* an account's messages to post, the tree's count badge; its state a dot: green online, a ring still to create */
34
34
  .idnum{flex:none;min-width:16px;height:16px;padding:0 var(--s1);border-radius:8px;font-size:10px;line-height:16px;text-align:center;color:var(--dim);background:var(--panel2)}
35
+ .idstale{flex:none;white-space:nowrap;text-transform:none;letter-spacing:0}
35
36
  .iddot{flex:none;width:7px;height:7px;border-radius:50%;box-shadow:inset 0 0 0 1px var(--dim)}
36
37
  .iddot.live{background:var(--ok);box-shadow:none}
37
38
  .idpage{display:flex;flex-direction:column;gap:var(--s3)}
@@ -16,6 +16,9 @@
16
16
  <link rel="stylesheet" href="./controls.css" />
17
17
  <link rel="stylesheet" href="./review.css" />
18
18
  <link rel="stylesheet" href="./stores.css" />
19
+ <link rel="stylesheet" href="./messages.css" />
20
+ <link rel="stylesheet" href="./releases.css" />
21
+ <link rel="stylesheet" href="./commands.css" />
19
22
  <link rel="stylesheet" href="./veille.css" />
20
23
  <link rel="stylesheet" href="./social.css" />
21
24
  </head>
@@ -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' | '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' }
62
+ export type SectionId = 'readme' | 'contracts' | 'shipkit' | 'repo' | 'secrets' | 'when' | 'runs' | 'plan' | 'processes' | 'git' | 'commands' | 'asks' | 'review' | 'reflections' | 'tests' | 'media' | 'trailer' | 'stores' | 'releases' | 'messages' | 'veille' | 'comms' | 'social' | 'wikis' | 'admin'
63
+ export const SECTION_LETTER: Record<SectionId, string> = { readme: 'E', review: 'V', trailer: 'L', stores: 'B', releases: 'H', messages: 'J', veille: 'Y', comms: 'U', social: 'I', contracts: 'K', shipkit: 'S', repo: 'C', secrets: 'X', when: 'O', runs: 'R', plan: 'N', processes: 'P', git: 'G', commands: 'Q', 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
@@ -48,7 +48,26 @@ export const webDownText = (why: string): string =>
48
48
  export const restartingText = (at: number): string =>
49
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
50
 
51
- export type MachineOpts = { reload?: () => void; timeoutMs?: number }
51
+ /** a machine card waits out a restart: a role away for less than this is a restart the page rides through unseen, its
52
+ * last answers kept and asked again by the next poll (wiki tools/shipkit/home-staying-up.md) */
53
+ export const QUIET_MS = 15_000
54
+
55
+ /** one trouble's start, so its card shows only once it lasted the quiet time */
56
+ class Lasting {
57
+ private at: number | null = null
58
+ constructor(private ms: number) {}
59
+ /** the words to show now: '' while there is no trouble, or it has not lasted the quiet time yet */
60
+ show(words: string): string {
61
+ if (words === '') {
62
+ this.at = null
63
+ return ''
64
+ }
65
+ this.at ??= Date.now()
66
+ return Date.now() - this.at >= this.ms ? words : ''
67
+ }
68
+ }
69
+
70
+ export type MachineOpts = { reload?: () => void; timeoutMs?: number; quietMs?: number }
52
71
 
53
72
  export class MachineSt {
54
73
  data: HomeAnswer | null = null
@@ -86,16 +105,22 @@ export class MachineSt {
86
105
  private widgetsPolling = false
87
106
  /** `error` holds a poll's error, which the next good poll clears */
88
107
  private pollError = false
108
+ private downFor: Lasting
109
+ private pmDownFor: Lasting
110
+ private restartingFor: Lasting
89
111
 
90
112
  constructor(private st: HomeSt, private o: MachineOpts = {}) {
91
113
  this.clock = new ClockSvc()
114
+ this.downFor = new Lasting(o.quietMs ?? QUIET_MS)
115
+ this.pmDownFor = new Lasting(o.quietMs ?? QUIET_MS)
116
+ this.restartingFor = new Lasting(o.quietMs ?? QUIET_MS)
92
117
  const k = loadKept()
93
118
  if (k != null) {
94
119
  this.data = k.data
95
120
  this.pm = k.pm
96
121
  this.widgets = k.widgets
97
122
  }
98
- makeAutoObservable<this, 'st' | 'timer' | 'copiedTimer' | 'wasDown' | 'polling' | 'widgetsPolling' | 'pollError' | 'o' | 'kept' | 'keep'>(this, { st: false, clock: false, timer: false, copiedTimer: false, wasDown: false, polling: false, widgetsPolling: false, pollError: false, o: false, kept: false, keep: false, data: observableRef, pm: observableRef, widgets: observableRef })
123
+ makeAutoObservable<this, 'st' | 'timer' | 'copiedTimer' | 'wasDown' | 'polling' | 'widgetsPolling' | 'pollError' | 'o' | 'kept' | 'keep' | 'downFor' | 'pmDownFor' | 'restartingFor'>(this, { st: false, clock: false, timer: false, copiedTimer: false, wasDown: false, polling: false, widgetsPolling: false, pollError: false, o: false, kept: false, keep: false, downFor: false, pmDownFor: false, restartingFor: false, data: observableRef, pm: observableRef, widgets: observableRef })
99
124
  }
100
125
 
101
126
  /** the repo the page shows, null on the overview and the plan */
@@ -160,11 +185,12 @@ export class MachineSt {
160
185
  const j = (await r.json()) as PmAnswer
161
186
  runInAction(() => {
162
187
  this.pm = j
163
- this.pmDown = ''
188
+ this.pmDown = this.pmDownFor.show('')
164
189
  })
165
190
  } catch (e) {
166
191
  // the last answer stays, its rows unknown (processGroups): the table keeps its lines
167
- runInAction(() => { this.pmDown = (e as Error).message })
192
+ const shown = this.pmDownFor.show((e as Error).message)
193
+ runInAction(() => { this.pmDown = shown })
168
194
  }
169
195
  }
170
196
 
@@ -198,9 +224,11 @@ export class MachineSt {
198
224
  if (!r.ok) throw new Error(`/api/home.json answered ${r.status}: ${await r.text()}`)
199
225
  const j = (await r.json()) as HomeAnswer
200
226
  const stale = r.headers.get('x-shipkit-daemon') === 'restarting'
227
+ const restarting = this.restartingFor.show(stale ? restartingText(Number(r.headers.get('x-shipkit-daemon-at'))) : '')
228
+ const down = this.downFor.show('')
201
229
  runInAction(() => {
202
- this.restarting = stale ? restartingText(Number(r.headers.get('x-shipkit-daemon-at'))) : ''
203
- if (stale) this.down = ''
230
+ this.restarting = restarting
231
+ if (stale) this.down = down
204
232
  })
205
233
  if (stale) return
206
234
  const back = this.wasDown
@@ -209,7 +237,7 @@ export class MachineSt {
209
237
  this.pollError = false
210
238
  runInAction(() => {
211
239
  this.data = j
212
- this.down = ''
240
+ this.down = down
213
241
  this.fresh = true
214
242
  if (cleared) this.error = ''
215
243
  })
@@ -217,18 +245,21 @@ export class MachineSt {
217
245
  this.st.wake()
218
246
  // and every other one is read ahead behind it
219
247
  void this.st.prefetch()
220
- // what the page loaded while the daemon was away failed: start over
248
+ // what the page loaded during an outage it showed failed: start over. A restart it rode through unseen
249
+ // left every surface on what it last read, and their next poll reads again
221
250
  if (back) this.reload()
222
251
  } catch (e) {
223
252
  const msg = (e as Error).message
224
253
  if (e instanceof Unreachable) {
225
- this.wasDown = true
226
254
  const who = e.who === 'web' ? 'web' : 'daemon'
255
+ const shown = this.downFor.show(who === 'web' ? webDownText(msg) : msg)
256
+ if (shown !== '') this.wasDown = true
227
257
  runInAction(() => {
228
- this.down = who === 'web' ? webDownText(msg) : msg
258
+ this.down = shown
229
259
  this.downWho = who
230
260
  })
231
261
  } else {
262
+ this.downFor.show('')
232
263
  this.pollError = true
233
264
  runInAction(() => {
234
265
  this.down = ''
@@ -0,0 +1,354 @@
1
+ // a repo's messages page (`#page:messages`, wiki tools/shipkit/messages.md, The page): every message by family with its
2
+ // meaning and value, each phrasing scored by each reader of a run, the value for its cost, the personas, the page tops,
3
+ // the readers' notes. Read only: the store is edited as text in .shipkit/messages/
4
+ import { observer } from 'mobx-react-lite'
5
+ import { useEffect, type CSSProperties } from 'react'
6
+ import { PASS, VETO } from '../../../messages/score.ts'
7
+ import { MESSAGES_TABS } from '../../../messages/tabs.ts'
8
+ import type { RepoSt } from '../repo-st.ts'
9
+ import type { MessagesSt, RunView, StoreView } from './messages-st.ts'
10
+
11
+ type Msg = StoreView['messages'][number]
12
+
13
+ /** a phrasing's mean over the readers who scored it, or undefined */
14
+ const meanOf = (run: RunView | undefined, id: string): number | undefined => {
15
+ const cs = Object.values(run?.cells[id] ?? {})
16
+ return cs.length ? Math.round(cs.reduce((a, c) => a + c.score, 0) / cs.length) : undefined
17
+ }
18
+ /** a score's wash: green above 50, red below, deeper the further from it */
19
+ const heat = (s: number | undefined): CSSProperties | undefined =>
20
+ s === undefined ? undefined : { background: `color-mix(in srgb, var(${s >= 50 ? '--ok' : '--red'}) ${Math.round((Math.abs(s - 50) / 50) * 55 + 5)}%, transparent)` }
21
+
22
+ const Flags = ({ run, id }: { run: RunView | undefined; id: string }) => (
23
+ <>
24
+ {Object.entries(run?.verdicts[id] ?? {})
25
+ .filter(([, v]) => !PASS.test(v.verdict))
26
+ .map(([g, v]) => (
27
+ <span key={g} className={`msg-tag${VETO.test(v.verdict) ? ' veto' : ''}`} title={v.words}>
28
+ {g} {v.verdict}
29
+ </span>
30
+ ))}
31
+ </>
32
+ )
33
+
34
+ const MessageCard = observer(({ ms, m }: { ms: MessagesSt; m: Msg }) => {
35
+ const run = ms.current
36
+ const readers = run?.readers ?? []
37
+ const rows = [...m.candidates].sort((a, b) => (meanOf(run, b.id) ?? -1) - (meanOf(run, a.id) ?? -1))
38
+ return (
39
+ <section className="msg-card">
40
+ <h3>
41
+ {m.title}
42
+ <small>{m.id}</small>
43
+ </h3>
44
+ <dl>
45
+ {(['meaning', 'value', 'truth', 'never'] as const).map((k) =>
46
+ m.fields[k] ? (
47
+ <div key={k} className="msg-field">
48
+ <dt>{k}</dt>
49
+ <dd>{m.fields[k]}</dd>
50
+ </div>
51
+ ) : null,
52
+ )}
53
+ </dl>
54
+ <div className="msg-scroll">
55
+ <table>
56
+ <thead>
57
+ <tr>
58
+ <th>phrasing</th>
59
+ <th className="num">all</th>
60
+ {readers.map((r) => (
61
+ <th key={r} className="num">
62
+ {r}
63
+ </th>
64
+ ))}
65
+ <th className="num">words</th>
66
+ <th className="num">s</th>
67
+ <th>gatekeepers</th>
68
+ </tr>
69
+ </thead>
70
+ <tbody>
71
+ {rows.map((c) => (
72
+ <tr key={c.id}>
73
+ <td className="line">
74
+ <span className="msg-id">{c.id}</span> {c.text} <span className="msg-src">{c.source}</span>
75
+ </td>
76
+ <td className="cell" style={heat(meanOf(run, c.id))}>
77
+ <b>{meanOf(run, c.id) ?? ''}</b>
78
+ </td>
79
+ {readers.map((r) => {
80
+ const x = run?.cells[c.id]?.[r]
81
+ const tip = x ? `${r}: "${x.said}"\ngain: ${x.gain}\nunderstood ${x.understood}/2, value ${x.value}/2, appeal ${x.appeal}/5, believes ${x.believe}/2${x.friction ? `\nbothered by: ${x.friction}` : ''}` : `${r}: not in this run`
82
+ return (
83
+ <td key={r} className="cell" style={heat(x?.score)} title={tip}>
84
+ {x?.score ?? ''}
85
+ </td>
86
+ )
87
+ })}
88
+ <td className="num">{c.words}</td>
89
+ <td className="num">{c.seconds}</td>
90
+ <td>
91
+ <Flags run={run} id={c.id} />
92
+ </td>
93
+ </tr>
94
+ ))}
95
+ </tbody>
96
+ </table>
97
+ </div>
98
+ </section>
99
+ )
100
+ })
101
+
102
+ const Messages = observer(({ ms }: { ms: MessagesSt }) => {
103
+ const families = new Map<string, Msg[]>()
104
+ for (const m of ms.view?.messages ?? []) families.set(m.fields.family ?? 'other', [...(families.get(m.fields.family ?? 'other') ?? []), m])
105
+ return (
106
+ <>
107
+ <p className="msg-hint">Each cell is one reader, 0 to 100: understood 40 %, the value landed 30 %, appeal 20 %, belief 10 %. Rest on a cell for what that reader said. The store is text: .shipkit/messages/messages.md.</p>
108
+ {[...families].map(([f, list]) => (
109
+ <div key={f} className="msg-family">
110
+ <h2>{f}</h2>
111
+ {list.map((m) => (
112
+ <MessageCard key={m.id} ms={ms} m={m} />
113
+ ))}
114
+ </div>
115
+ ))}
116
+ </>
117
+ )
118
+ })
119
+
120
+ const Value = observer(({ ms }: { ms: MessagesSt }) => {
121
+ const rows = (ms.view?.messages ?? [])
122
+ .map((m) => {
123
+ const best = [...m.candidates].sort((a, b) => (meanOf(ms.current, b.id) ?? -1) - (meanOf(ms.current, a.id) ?? -1))[0]
124
+ const score = best ? meanOf(ms.current, best.id) : undefined
125
+ return best && score !== undefined ? { m, best, score, rate: Math.round(score / Math.max(best.seconds, 0.4)) } : null
126
+ })
127
+ .filter((x) => x !== null)
128
+ .sort((a, b) => b.rate - a.rate)
129
+ return (
130
+ <section className="msg-card">
131
+ <p className="msg-hint">Each message's best phrasing, ranked by its score for each second spoken: a small gain said in a second can beat a big one that needs a sentence.</p>
132
+ <div className="msg-scroll">
133
+ <table>
134
+ <thead>
135
+ <tr>
136
+ <th>message</th>
137
+ <th>best phrasing</th>
138
+ <th className="num">score</th>
139
+ <th className="num">words</th>
140
+ <th className="num">s</th>
141
+ <th className="num">score a second</th>
142
+ </tr>
143
+ </thead>
144
+ <tbody>
145
+ {rows.map((r) => (
146
+ <tr key={r.m.id}>
147
+ <td>{r.m.title}</td>
148
+ <td className="line">{r.best.text}</td>
149
+ <td className="cell" style={heat(r.score)}>
150
+ {r.score}
151
+ </td>
152
+ <td className="num">{r.best.words}</td>
153
+ <td className="num">{r.best.seconds}</td>
154
+ <td className="num">
155
+ <b>{r.rate}</b>
156
+ </td>
157
+ </tr>
158
+ ))}
159
+ </tbody>
160
+ </table>
161
+ </div>
162
+ </section>
163
+ )
164
+ })
165
+
166
+ const Personas = observer(({ ms }: { ms: MessagesSt }) => {
167
+ const run = ms.current
168
+ const text = new Map((ms.view?.messages ?? []).flatMap((m) => m.candidates.map((c) => [c.id, c.text] as const)))
169
+ return (
170
+ <div className="msg-grid">
171
+ {(ms.view?.personas ?? []).map((p) => {
172
+ const mine = Object.entries(run?.cells ?? {})
173
+ .map(([id, byReader]) => ({ id, x: byReader[p.id] }))
174
+ .filter((r) => r.x)
175
+ .sort((a, b) => b.x!.score - a.x!.score)
176
+ const flagged = Object.entries(run?.verdicts ?? {}).filter(([, v]) => v[p.id] && !PASS.test(v[p.id]!.verdict))
177
+ return (
178
+ <section key={p.id} className="msg-card">
179
+ <h3>
180
+ {p.id}
181
+ <span className="msg-kind">{p.kind}</span>
182
+ </h3>
183
+ <p className="msg-hint">{p.who}</p>
184
+ {p.kind === 'reader' && mine.length ? (
185
+ <table>
186
+ <tbody>
187
+ {[...mine.slice(0, 5), ...mine.slice(-3)].map((r, i) => (
188
+ <tr key={r.id} className={i === 5 ? 'msg-worst' : undefined}>
189
+ <td className="cell" style={heat(r.x!.score)} title={`"${r.x!.said}"\ngain: ${r.x!.gain}`}>
190
+ {r.x!.score}
191
+ </td>
192
+ <td>{text.get(r.id)}</td>
193
+ </tr>
194
+ ))}
195
+ </tbody>
196
+ </table>
197
+ ) : null}
198
+ {p.kind === 'gatekeeper' ? (
199
+ flagged.length ? (
200
+ <table>
201
+ <tbody>
202
+ {flagged.map(([id, v]) => (
203
+ <tr key={id}>
204
+ <td>
205
+ <span className={`msg-tag${VETO.test(v[p.id]!.verdict) ? ' veto' : ''}`}>{v[p.id]!.verdict}</span>
206
+ </td>
207
+ <td>
208
+ {text.get(id)} <span className="msg-src">{v[p.id]!.words}</span>
209
+ </td>
210
+ </tr>
211
+ ))}
212
+ </tbody>
213
+ </table>
214
+ ) : (
215
+ <p className="msg-hint">Allows every line of this run.</p>
216
+ )
217
+ ) : null}
218
+ </section>
219
+ )
220
+ })}
221
+ </div>
222
+ )
223
+ })
224
+
225
+ const Surfaces = observer(({ ms }: { ms: MessagesSt }) => {
226
+ const run = ms.surfaceRun
227
+ const took = ms.view?.takeaways ?? []
228
+ const share = took.length ? Math.round(40 / took.length) : 0
229
+ return (
230
+ <>
231
+ {(ms.view?.surfaces ?? []).map((sf) => (
232
+ <section key={sf.id} className="msg-card">
233
+ <h3>
234
+ {sf.title}
235
+ <small>{run ? `run ${run.id}, ${run.readers.length} readers` : 'not run yet'}</small>
236
+ </h3>
237
+ <p className="msg-hint">
238
+ Score: the headline alone {took.length ? 30 : 50} % (a link preview shows only it), the whole {took.length ? 30 : 50} %{took.map((t) => `, ${t.label} understood ${share} %`).join('')}, minus 10 for each reader who saw the lines repeat.
239
+ </p>
240
+ <div className="msg-scroll">
241
+ <table>
242
+ <thead>
243
+ <tr>
244
+ <th>option</th>
245
+ <th className="num">score</th>
246
+ <th className="num">alone</th>
247
+ <th className="num">whole</th>
248
+ {took.map((t) => (
249
+ <th key={t.id} className="num" title={t.text}>
250
+ {t.label}
251
+ </th>
252
+ ))}
253
+ <th className="num">repeats</th>
254
+ <th>gatekeepers, friction</th>
255
+ </tr>
256
+ </thead>
257
+ <tbody>
258
+ {[...sf.options]
259
+ .map((o) => ({ o, r: run?.surface.find((x) => x.option === o.id) }))
260
+ .sort((a, b) => (b.r?.score ?? -1) - (a.r?.score ?? -1))
261
+ .map(({ o, r }) => (
262
+ <tr key={o.id}>
263
+ <td className="line">
264
+ <span className="msg-id">{o.id}</span> <b>{o.headline}</b>
265
+ <br />
266
+ {o.second}
267
+ </td>
268
+ <td className="cell" style={heat(r?.score)}>
269
+ {r ? (r.veto ? '⛔' : r.score) : ''}
270
+ </td>
271
+ <td className="num">{r?.alone.toFixed(1)}</td>
272
+ <td className="num">{r?.whole.toFixed(1)}</td>
273
+ {took.map((t) => (
274
+ <td key={t.id} className="num">
275
+ {r ? `${r.took[t.id] ?? 0}/${r.n}` : ''}
276
+ </td>
277
+ ))}
278
+ <td className="num">{r?.repeats}</td>
279
+ <td>
280
+ {r?.gatekeepers.map((g) => (
281
+ <span key={g} className="msg-tag">
282
+ {g}
283
+ </span>
284
+ ))}{' '}
285
+ <span className="msg-src">{r?.friction.join('; ')}</span>
286
+ </td>
287
+ </tr>
288
+ ))}
289
+ </tbody>
290
+ </table>
291
+ </div>
292
+ </section>
293
+ ))}
294
+ </>
295
+ )
296
+ })
297
+
298
+ const Notes = observer(({ ms }: { ms: MessagesSt }) => {
299
+ const notes = Object.entries(ms.current?.notes ?? {})
300
+ return notes.length ? (
301
+ <div className="msg-grid">
302
+ {notes.map(([p, text]) => (
303
+ <section key={p} className="msg-card">
304
+ <h3>{p}</h3>
305
+ <pre>{text}</pre>
306
+ </section>
307
+ ))}
308
+ </div>
309
+ ) : (
310
+ <p className="msg-hint">This run kept no notes.</p>
311
+ )
312
+ })
313
+
314
+ export const MessagesPage = observer(({ app }: { app: RepoSt }) => {
315
+ const ms = app.messages
316
+ useEffect(() => {
317
+ ms.start()
318
+ return () => ms.stop()
319
+ }, [ms])
320
+ const v = ms.view
321
+ const count = v ? v.messages.reduce((a, m) => a + m.candidates.length, 0) : 0
322
+ return (
323
+ <div className="msg-page">
324
+ <header>
325
+ <h1>Messages</h1>
326
+ <p className="msg-lede">{v ? `${v.messages.length} messages, ${count} phrasings, ${v.personas.length} personas, ${v.runs.length} runs` : 'loading…'}</p>
327
+ {ms.runs.length > 1 ? (
328
+ <select value={ms.current?.id ?? ''} onChange={(e) => ms.show(ms.tab, e.target.value)}>
329
+ {ms.runs.map((r) => (
330
+ <option key={r.id} value={r.id}>
331
+ {r.id}
332
+ </option>
333
+ ))}
334
+ </select>
335
+ ) : (
336
+ <span className="msg-hint">run {ms.current?.id ?? 'none'}</span>
337
+ )}
338
+ </header>
339
+ <nav>
340
+ {MESSAGES_TABS.map(([t, label]) => (
341
+ <button key={t} type="button" className={ms.tab === t ? 'on' : ''} onClick={() => ms.show(t)}>
342
+ {label}
343
+ </button>
344
+ ))}
345
+ </nav>
346
+ {ms.error ? <p className="msg-error">{ms.error}</p> : null}
347
+ {ms.tab === 'messages' ? <Messages ms={ms} /> : null}
348
+ {ms.tab === 'value' ? <Value ms={ms} /> : null}
349
+ {ms.tab === 'personas' ? <Personas ms={ms} /> : null}
350
+ {ms.tab === 'surfaces' ? <Surfaces ms={ms} /> : null}
351
+ {ms.tab === 'notes' ? <Notes ms={ms} /> : null}
352
+ </div>
353
+ )
354
+ })
@@ -0,0 +1,74 @@
1
+ // a repo's messages page as state (wiki tools/shipkit/messages.md, The page): the store read whole from the hub, the
2
+ // tab shown and the run it scores by, both in the address. Read when the page opens and when the window comes back;
3
+ // the store is edited as text, so the page never writes
4
+ import { makeAutoObservable, runInAction } from 'mobx'
5
+ import type { RunView, StoreView } from '../../../messages/score.ts'
6
+ import type { MessagesTab } from '../../../messages/tabs.ts'
7
+ import { reach } from '../reach.ts'
8
+ import type { RepoSt } from '../repo-st.ts'
9
+
10
+ export type { RunView, StoreView }
11
+
12
+ export class MessagesSt {
13
+ view: StoreView | null = null
14
+ error: string | null = null
15
+ tab: MessagesTab = 'messages'
16
+ /** the run picked, '' for the newest messages run */
17
+ picked = ''
18
+ private started = 0
19
+
20
+ constructor(private readonly st: RepoSt) {
21
+ makeAutoObservable<this, 'st' | 'started' | 'onBack'>(this, { st: false, started: false, onBack: false })
22
+ }
23
+
24
+ /** the messages runs, newest first: the run picker lists them */
25
+ get runs(): RunView[] {
26
+ return this.view?.runs.filter((r) => r.kind === 'messages') ?? []
27
+ }
28
+
29
+ /** the run the cells score by: the one picked, else the newest */
30
+ get current(): RunView | undefined {
31
+ return this.runs.find((r) => r.id === this.picked) ?? this.runs[0]
32
+ }
33
+
34
+ /** the newest page top run: the Page tops tab scores by it */
35
+ get surfaceRun(): RunView | undefined {
36
+ return this.view?.runs.find((r) => r.kind === 'surface')
37
+ }
38
+
39
+ start(): void {
40
+ if (this.started++ === 0) window.addEventListener('focus', this.onBack)
41
+ void this.load()
42
+ }
43
+
44
+ stop(): void {
45
+ if (--this.started === 0) window.removeEventListener('focus', this.onBack)
46
+ }
47
+
48
+ private readonly onBack = (): void => void this.load()
49
+
50
+ async load(): Promise<void> {
51
+ try {
52
+ const r = await reach(this.st.url('/api/messages'))
53
+ const body = (await r.json()) as StoreView & { error?: string }
54
+ if (!r.ok) throw new Error(body.error ?? `HTTP ${r.status}`)
55
+ runInAction(() => {
56
+ this.view = body
57
+ this.error = null
58
+ })
59
+ } catch (e) {
60
+ runInAction(() => (this.error = (e as Error).message))
61
+ }
62
+ }
63
+
64
+ /** what the address says: the tab, and the run when one is picked */
65
+ select(tab: MessagesTab, run: string | null): void {
66
+ this.tab = tab
67
+ this.picked = run ?? ''
68
+ }
69
+
70
+ /** a click on a tab or the run picker: the address follows */
71
+ show(tab: MessagesTab, run: string = this.picked): void {
72
+ this.st.showMessages(tab, run || null)
73
+ }
74
+ }
@@ -0,0 +1,35 @@
1
+ /* the messages page (hub-app/messages/, wiki tools/shipkit/messages.md, The page): white cards on the gray ground, the
2
+ hub's tokens; a score's wash is the one colour the page picks, mixed from --ok and --red in the page's code */
3
+ .msg-page{flex:1;min-width:0;max-width:1280px;display:flex;flex-direction:column;gap:var(--s4);font-size:14px;line-height:1.45}
4
+ .msg-page header{display:flex;flex-wrap:wrap;gap:var(--s3);align-items:center}
5
+ .msg-page h1{font-size:20px;margin:0}
6
+ .msg-lede{color:var(--dim);margin:0;flex:1}
7
+ .msg-page nav{display:flex;gap:var(--s1);flex-wrap:wrap}
8
+ .msg-page nav button,.msg-page select{font:inherit;padding:var(--s1) var(--s3);border-radius:7px;border:1px solid var(--line);background:var(--panel);color:var(--ink);cursor:pointer}
9
+ .msg-page nav button.on{background:var(--accent);border-color:var(--accent);color:var(--panel)}
10
+ .msg-family{display:grid;gap:var(--s3)}
11
+ .msg-family h2{font-size:13px;text-transform:uppercase;letter-spacing:.08em;color:var(--dim);margin:var(--s3) 0 0}
12
+ .msg-card{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:var(--s3) var(--s4);display:grid;gap:var(--s2);min-width:0}
13
+ .msg-card h3{margin:0;font-size:15px}
14
+ .msg-card h3 small{color:var(--dim);font-weight:400;margin-left:var(--s2)}
15
+ .msg-card dl{display:grid;grid-template-columns:max-content 1fr;gap:var(--s0) var(--s3);margin:0;font-size:13px}
16
+ .msg-field{display:contents}
17
+ .msg-card dt{color:var(--dim)}
18
+ .msg-card dd{margin:0}
19
+ .msg-scroll{overflow-x:auto}
20
+ .msg-page table{border-collapse:collapse;width:100%;font-size:13px}
21
+ .msg-page th,.msg-page td{padding:var(--s1) var(--s2);border-top:1px solid var(--line);text-align:left;vertical-align:top}
22
+ .msg-page th{color:var(--dim);font-weight:500;white-space:nowrap;border-top:none}
23
+ .msg-page td.num,.msg-page th.num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
24
+ .msg-page td.cell{text-align:center;font-variant-numeric:tabular-nums;min-width:34px;cursor:help}
25
+ .msg-page td.line{min-width:260px;width:44%}
26
+ .msg-page tr.msg-worst td{border-top:2px solid var(--line)}
27
+ .msg-id{font-family:ui-monospace,Menlo,monospace;color:var(--dim);font-size:12px}
28
+ .msg-src{color:var(--dim);font-size:12px}
29
+ .msg-tag{display:inline-block;font-size:11.5px;padding:var(--s0) var(--s2);border-radius:999px;margin:0 var(--s0) 0 0;border:1px solid var(--warn);color:var(--warn)}
30
+ .msg-tag.veto{border-color:var(--red);color:var(--red)}
31
+ .msg-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:var(--s3)}
32
+ .msg-kind{font-size:11.5px;color:var(--dim);border:1px solid var(--line);border-radius:999px;padding:0 var(--s2);margin-left:var(--s2);font-weight:400}
33
+ .msg-page pre{margin:0;white-space:pre-wrap;font:12.5px/1.5 ui-monospace,Menlo,monospace}
34
+ .msg-error{color:var(--errink);background:var(--errbg);border:1px solid var(--errline);border-radius:7px;padding:var(--s2) var(--s3);margin:0}
35
+ .msg-hint{color:var(--dim);margin:0;font-size:13px}