rvlib-shipkit 2.9.0 → 2.11.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 (75) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/package.json +1 -1
  3. package/src/cli/cmd_Media.ts +164 -0
  4. package/src/cli/cmd_Review.ts +2 -1
  5. package/src/cli/family-pages.ts +1 -0
  6. package/src/cli/registry.ts +2 -0
  7. package/src/collections/pings.ts +6 -4
  8. package/src/core/app-icon.ts +17 -4
  9. package/src/core/scratch-objects.ts +56 -0
  10. package/src/core/trace-audit.ts +13 -1
  11. package/src/home/home-paths.ts +4 -0
  12. package/src/home/home-routes.ts +36 -2
  13. package/src/home/hubs.ts +5 -0
  14. package/src/home/inbox-shape.ts +182 -0
  15. package/src/home/inbox.ts +48 -0
  16. package/src/home/run-daemon.ts +12 -2
  17. package/src/home/serve-web.ts +155 -16
  18. package/src/ledger/git-scan.ts +73 -25
  19. package/src/ledger/repo-view.ts +2 -22
  20. package/src/media-kinds.ts +7 -0
  21. package/src/media-store/content.ts +51 -0
  22. package/src/media-store/daemon.ts +91 -0
  23. package/src/media-store/db.ts +74 -0
  24. package/src/media-store/fact.ts +9 -0
  25. package/src/media-store/kind.ts +44 -0
  26. package/src/media-store/purge.ts +139 -0
  27. package/src/media-store/remote.ts +93 -0
  28. package/src/media-store/space.ts +124 -0
  29. package/src/media-store/sync.ts +101 -0
  30. package/src/media-store/upload.ts +98 -0
  31. package/src/repo-config.ts +4 -0
  32. package/src/review/anim.ts +6 -5
  33. package/src/review/cells.ts +552 -0
  34. package/src/review/format.ts +1 -1
  35. package/src/review/media-kind.ts +84 -0
  36. package/src/review/media-read.ts +48 -0
  37. package/src/review/model.ts +43 -5
  38. package/src/review/previews.ts +153 -0
  39. package/src/review/routes.ts +105 -47
  40. package/src/review/store.ts +106 -45
  41. package/src/review/trailer-desk.ts +79 -46
  42. package/src/review/trailer-media.ts +163 -0
  43. package/src/review/trailer-routes.ts +5 -2
  44. package/src/serve/hub-app/home-st.ts +39 -9
  45. package/src/serve/hub-app/home.html +2 -1
  46. package/src/serve/hub-app/hub-app.tsx +7 -23
  47. package/src/serve/hub-app/icons.tsx +2 -0
  48. package/src/serve/hub-app/inbox-st.ts +144 -0
  49. package/src/serve/hub-app/inbox-view.tsx +205 -0
  50. package/src/serve/hub-app/inbox.css +73 -0
  51. package/src/serve/hub-app/item-view.tsx +19 -0
  52. package/src/serve/hub-app/keys.ts +4 -3
  53. package/src/serve/hub-app/palette-st.ts +2 -1
  54. package/src/serve/hub-app/project-list.tsx +1 -0
  55. package/src/serve/hub-app/projects-svc.ts +1 -1
  56. package/src/serve/hub-app/repo-st.ts +1 -1
  57. package/src/serve/hub-app/review/kind-view.tsx +21 -22
  58. package/src/serve/hub-app/review/kit.tsx +11 -12
  59. package/src/serve/hub-app/review/review-board.tsx +15 -13
  60. package/src/serve/hub-app/review/review-cells.tsx +241 -0
  61. package/src/serve/hub-app/review/review-kit.ts +79 -0
  62. package/src/serve/hub-app/review/review-list.tsx +87 -122
  63. package/src/serve/hub-app/review/review-page.tsx +22 -79
  64. package/src/serve/hub-app/review/review-st.ts +269 -698
  65. package/src/serve/hub-app/review/review-thread.tsx +302 -0
  66. package/src/serve/hub-app/review/review-views.tsx +322 -253
  67. package/src/serve/hub-app/review/thread-st.ts +770 -0
  68. package/src/serve/hub-app/review.css +235 -91
  69. package/src/serve/hub-runtime.ts +9 -4
  70. package/src/serve/serve-hub.ts +4 -1
  71. package/src/serve/warm-cell.ts +6 -1
  72. package/src/trailer/footage.ts +6 -2
  73. package/src/trailer/passage.ts +4 -2
  74. package/src/trailer/prune.ts +6 -10
  75. package/src/serve/hub-app/review/review-answer.tsx +0 -249
@@ -0,0 +1,302 @@
1
+ // the open card as one chat (wiki build/shipkit/review.md, The review page): a bar on top (the title, where it stands,
2
+ // fold or unfold all, the contents), the cells in time order with the newest at the bottom, the contents strip beside
3
+ // them (every version, view, verdict and reply: a click scrolls there and unfolds it), and his answer box pinned under
4
+ // them: one word, sent with a verdict or as a reply. The column opens scrolled to the newest cell
5
+ import { observer } from 'mobx-react-lite'
6
+ import { useEffect, useRef } from 'react'
7
+ import { MOVE_LABEL, STATUS_LABEL, subjectLabel, viewName, viewTag } from '../../../review/model.ts'
8
+ import { AutoText } from '../auto-text.tsx'
9
+ import { Icon, ICON } from '../icons.tsx'
10
+ import { AutoTag, Empty, keepFocus, LaneTag, Listeners, Rework, toneOf, VERDICTS } from './kit.tsx'
11
+ import { CellFrame, EventsLine } from './review-cells.tsx'
12
+ import type { ReviewSt } from './review-st.ts'
13
+ import { cellDom, type ThreadSt, type ViewMark } from './thread-st.ts'
14
+
15
+ /** `back`: where the phone's ◂ goes, the cards when absent; null when the page around the column draws its own */
16
+ export const ThreadColumn = observer(({ rv, back }: { rv: ReviewSt; back?: (() => void) | null }) => {
17
+ const el = useRef<HTMLDivElement | null>(null)
18
+ useEffect(() => {
19
+ const node = el.current
20
+ if (node == null || typeof ResizeObserver === 'undefined') return
21
+ // the width lands on the next frame: a relayout inside the callback is the observer's loop error
22
+ let raf = 0
23
+ const ro = new ResizeObserver(([e]) => {
24
+ const w = e!.contentRect.width
25
+ cancelAnimationFrame(raf)
26
+ raf = requestAnimationFrame(() => rv.fit(w))
27
+ })
28
+ ro.observe(node)
29
+ return () => {
30
+ cancelAnimationFrame(raf)
31
+ ro.disconnect()
32
+ }
33
+ }, [rv])
34
+ const card = rv.card
35
+ return (
36
+ <div ref={el} className="rv-thread">
37
+ {card === null ? (
38
+ <Empty text={rv.page ? 'No card. An agent adds one with sk review add.' : 'Reading the cards…'} />
39
+ ) : (
40
+ <>
41
+ <TopBar rv={rv} card={card} back={back} />
42
+ <div className="rv-threadbody">
43
+ <Cells rv={rv} card={card} />
44
+ {rv.rail ? <Contents rv={rv} card={card} /> : rv.phone.on ? null : <Minimap rv={rv} card={card} dir="col" />}
45
+ {rv.sheet && !rv.rail ? (
46
+ <div className="rv-sheet" onClick={() => rv.closeSheet()}>
47
+ <div onClick={(e) => e.stopPropagation()}><Contents rv={rv} card={card} /></div>
48
+ </div>
49
+ ) : null}
50
+ </div>
51
+ <Composer rv={rv} card={card} />
52
+ </>
53
+ )}
54
+ </div>
55
+ )
56
+ })
57
+
58
+ /** the card's bar: its title, where it stands, its lane, who listens, the copy for an agent, fold or unfold all, the
59
+ * contents; on the phone a way back to the cards */
60
+ const TopBar = observer(({ rv, card, back }: { rv: ReviewSt; card: ThreadSt; back?: (() => void) | null }) => {
61
+ const v = card.data
62
+ const row = rv.openRow
63
+ return (
64
+ <div className="rv-top">
65
+ <div className="rv-topline">
66
+ {rv.phone.on && back !== null ? <button className="ghost rv-back" aria-label="back" onClick={() => (back != null ? back() : rv.phone.show('list'))}>◂</button> : null}
67
+ <h2 className="rv-title">{v?.title ?? row?.title ?? card.id}</h2>
68
+ {rv.phone.on ? null : <Waiting card={card} />}
69
+ <button className="rv-copyid ghost" title="copy this card for an agent (C): its title, its repo, sk review show, its link" aria-label="copy this card for an agent" onClick={() => void rv.copyCard()}>
70
+ <Icon d={ICON.copy} />
71
+ </button>
72
+ </div>
73
+ {rv.phone.on && v ? <Minimap rv={rv} card={card} dir="row" /> : null}
74
+ {v ? (
75
+ <div className="rv-meta">
76
+ <span className={`rv-badge ${toneOf(v.status)}`}>{STATUS_LABEL[v.status]}</span>
77
+ {v.lane ? <LaneTag lane={v.lane} /> : null}
78
+ {v.origin.by === 'auto' ? <AutoTag rule={v.origin.rule} /> : null}
79
+ <span>{v.versions > 1 ? `${v.versions} versions` : 'one version'} · {subjectLabel(v.subject.kind, rv.spec ?? undefined)}{v.move !== 'none' ? ` · ${MOVE_LABEL[v.move]}` : ''}</span>
80
+ {v.forks.length > 0 ? (
81
+ <span className="rv-forks" title="other cards answered the same older versions: each is its own thread">
82
+ · forks:
83
+ {v.forks.map((f) => (
84
+ <button key={f} className="rv-fork ghost" title={f} onMouseDown={keepFocus} onClick={() => rv.pick(f)}>⑂ {forkName(f)}</button>
85
+ ))}
86
+ </span>
87
+ ) : null}
88
+ <Rework r={v.rework} />
89
+ <span className="sp" />
90
+ <span className="seg">
91
+ <button title="fold every cell" onMouseDown={keepFocus} onClick={() => card.foldAll(false)}>fold all</button>
92
+ <button title="unfold every cell (it loads every image)" onMouseDown={keepFocus} onClick={() => card.foldAll(true)}>unfold all</button>
93
+ </span>
94
+ <button className={rv.rail || rv.sheet ? 'on' : ''} title="every item of the card: a click shows it" onMouseDown={keepFocus} onClick={() => rv.toggleRail()}>☰ contents</button>
95
+ </div>
96
+ ) : card.error ? null : (
97
+ <div className="rv-meta"><span className="spin" /> reading the thread…</div>
98
+ )}
99
+ </div>
100
+ )
101
+ })
102
+
103
+ /** the cells in time order; on the first load it lands on the newest one (or the one an old link names), and a click
104
+ * on the contents scrolls to its target */
105
+ const Cells = observer(({ rv, card }: { rv: ReviewSt; card: ThreadSt }) => {
106
+ const el = useRef<HTMLDivElement | null>(null)
107
+ const landing = card.landed ? null : card.landing
108
+ useEffect(() => {
109
+ const box = el.current
110
+ if (!landing || !box) return
111
+ const raf = requestAnimationFrame(() => {
112
+ const target = box.querySelector<HTMLElement>(`#${landing}`)
113
+ if (target) box.scrollTop = Math.min(target.offsetTop - 8, box.scrollHeight - box.clientHeight)
114
+ card.land()
115
+ })
116
+ return () => cancelAnimationFrame(raf)
117
+ }, [landing, card])
118
+ // an agent word goes read once it shows on his screen with the tab visible: never on open, never one not drawn
119
+ const unread = card.unreadCells.join(' ')
120
+ useEffect(() => {
121
+ const box = el.current
122
+ if (!box || !unread || typeof IntersectionObserver === 'undefined') return
123
+ const showing = new Set<string>()
124
+ const send = (): void => {
125
+ if (document.visibilityState === 'visible' && showing.size > 0) void card.seen([...showing])
126
+ }
127
+ const io = new IntersectionObserver(
128
+ (es) => {
129
+ for (const e of es) {
130
+ const id = (e.target as HTMLElement).dataset.unread
131
+ if (!id) continue
132
+ if (e.isIntersecting) showing.add(id)
133
+ else showing.delete(id)
134
+ }
135
+ send()
136
+ },
137
+ { root: box, threshold: 0.3 },
138
+ )
139
+ for (const n of box.querySelectorAll<HTMLElement>('[data-unread]')) io.observe(n)
140
+ document.addEventListener('visibilitychange', send)
141
+ return () => {
142
+ io.disconnect()
143
+ document.removeEventListener('visibilitychange', send)
144
+ }
145
+ }, [unread, card])
146
+ const jump = card.jump
147
+ useEffect(() => {
148
+ const box = el.current
149
+ if (!jump || !box) return
150
+ const raf = requestAnimationFrame(() => {
151
+ box.querySelector<HTMLElement>(`#${jump}`)?.scrollIntoView({ behavior: 'smooth', block: 'start' })
152
+ card.jumped()
153
+ })
154
+ return () => cancelAnimationFrame(raf)
155
+ }, [jump, card])
156
+ return (
157
+ <div ref={el} className="rv-cells">
158
+ {card.lines.map((l, k) =>
159
+ l.kind === 'day' ? (
160
+ <div key={`d${k}`} className="rv-day"><span>{l.day}</span></div>
161
+ ) : l.kind === 'events' ? (
162
+ <EventsLine key={l.cells[0]!.id} rv={rv} cells={l.cells} />
163
+ ) : (
164
+ <CellFrame key={l.cell.id} rv={rv} card={card} c={l.cell} />
165
+ ),
166
+ )}
167
+ {card.error ? <div className="rv-err rv-pre">{card.error}</div> : null}
168
+ </div>
169
+ )
170
+ })
171
+
172
+ /** every item of the card, in the thread's order: each version and its views, each verdict, reply and note. A click
173
+ * unfolds it and scrolls there; a folded one reads dim */
174
+ const Contents = observer(({ rv, card }: { rv: ReviewSt; card: ThreadSt }) => (
175
+ <nav className="rv-contents" aria-label="every item of the card">
176
+ <div className="rv-contentshead">
177
+ <b>contents</b>
178
+ <span className="rv-dim">{card.contents.length}</span>
179
+ <span className="sp" />
180
+ {rv.sheet ? <button className="ghost rv-x" aria-label="close" onClick={() => rv.closeSheet()}>✕</button> : null}
181
+ </div>
182
+ <Minimap rv={rv} card={card} dir="row" />
183
+ <ol>
184
+ {card.contents.map((e) => {
185
+ const c = card.cells.find((x) => x.id === e.cell)
186
+ const shown = c !== undefined && card.isOpen(c) && (e.view === undefined || card.viewOpen(e.cell, e.view))
187
+ return (
188
+ <li key={e.key} className={`rv-entry k-${e.kind}${shown ? '' : ' folded'}${e.head ? ' head' : ''}${e.tone ? ` ${e.tone}` : ''}`}>
189
+ <button title={e.label} onMouseDown={keepFocus} onClick={() => { card.reveal(e.cell, e.view); rv.closeSheet() }}>
190
+ <span className="rv-entrybadge">{e.badge}</span>
191
+ <span className="rv-entrylabel">{e.label}</span>
192
+ </button>
193
+ </li>
194
+ )
195
+ })}
196
+ </ol>
197
+ </nav>
198
+ ))
199
+
200
+ /** a fork's head named by its id's words: `20261012-111305-silhouette-des-femmes` → « silhouette des femmes » */
201
+ const forkName = (id: string): string => {
202
+ const words = id.replace(/^\d{8}-\d{6}-/, '').split('-')
203
+ return words.length > 4 ? `${words.slice(0, 4).join(' ')}…` : words.join(' ')
204
+ }
205
+
206
+ /** « 3 of 5 views waiting for you »: the views of the version his answer goes to that have no answer yet */
207
+ const Waiting = observer(({ card }: { card: ThreadSt }) => {
208
+ const w = card.waitingViews
209
+ if (w === null) return null
210
+ return (
211
+ <span className={`rv-waiting${w.waiting === 0 ? ' done' : ''}`} title="a view is answered by OK, fix or no on it (a choice: scored or picked), or by the verdict; a note alone goes with the verdict">
212
+ {w.waiting} of {w.of} view{w.of > 1 ? 's' : ''} waiting for you
213
+ </span>
214
+ )
215
+ })
216
+
217
+ const ANSWER_GLYPH: Record<ViewMark['answer'], string> = { none: '', approved: '✓', 'approved-with-fix': '⚒', rejected: '✕', archived: '▤', scored: '★', picked: '✓', sent: '' }
218
+
219
+ /** the minimap: every version as a pill, the one his answer goes to ringed, under it one mark per view coloured by his
220
+ * answer (none yet, OK, fix, no), each answer and reply as a dot; a click shows it. Beside the cells as a strip
221
+ * (`col`), or one row under the card's title on a phone and on top of the contents (`row`) */
222
+ export const Minimap = observer(({ rv, card, dir }: { rv: ReviewSt; card: ThreadSt; dir: 'col' | 'row' }) => {
223
+ const target = card.head?.id
224
+ const marks = card.viewMarks
225
+ return (
226
+ <nav className={`rv-mini ${dir}`} aria-label="the card's versions, the views of the one you answer, the answers">
227
+ {dir === 'col' ? <button className="rv-miniopen" title="every item of the card" onMouseDown={keepFocus} onClick={() => rv.toggleRail()}>☰</button> : null}
228
+ {dir === 'row' && rv.phone.on ? <Waiting card={card} /> : null}
229
+ {card.contents.filter((e) => e.kind !== 'view').map((e) => (
230
+ <span key={e.key} className="rv-minigroup">
231
+ <button className={`rv-minientry k-${e.kind}${e.cell === target && e.kind === 'version' ? ' head' : ''}${e.tone ? ` ${e.tone}` : ''}`} title={e.label} onMouseDown={keepFocus} onClick={() => card.reveal(e.cell)}>
232
+ {e.kind === 'version' ? e.badge : ''}
233
+ </button>
234
+ {e.kind === 'version' && e.cell === target && marks.length > 0 ? (
235
+ <span className="rv-minimarks">
236
+ {marks.map((m) => (
237
+ <button key={m.view} className={`rv-minimark a-${m.answer}${m.noted ? ' noted' : ''}`} title={`${m.tag}: ${m.answer === 'none' ? 'waiting for you' : m.answer}${m.noted ? ', a draft note on it' : ''}`}
238
+ onMouseDown={keepFocus} onClick={() => card.reveal(e.cell, m.view)}>
239
+ {m.tag.split('.')[1]}{ANSWER_GLYPH[m.answer] ? <small>{ANSWER_GLYPH[m.answer]}</small> : null}
240
+ </button>
241
+ ))}
242
+ </span>
243
+ ) : null}
244
+ </span>
245
+ ))}
246
+ </nav>
247
+ )
248
+ })
249
+
250
+ /** his answer, pinned under the cells: what goes with it (his notes, reactions, pick, each a click away), one word, then
251
+ * the verdicts and « reply ». A verdict sends the word with his notes; a reply sends the word alone (⌘Enter) */
252
+ const Composer = observer(({ rv, card }: { rv: ReviewSt; card: ThreadSt }) => {
253
+ const v = card.data
254
+ if (!v) return null
255
+ const d = card.draft
256
+ const h = card.head
257
+ const n = h?.kind === 'version' ? h.n : null
258
+ const views = card.headItem?.views ?? []
259
+ const reactions = card.outgoingReactions
260
+ const verdicts = card.takesVerdict
261
+ const sent = h?.kind === 'version' ? card.verdictsOn(h.id).findLast((x) => x.current)?.verdict : undefined
262
+ const newest = card.newest
263
+ return (
264
+ <div className="rv-composer">
265
+ {card.draftOn !== null && !card.keptOn && newest?.kind === 'version' && n !== null ? (
266
+ <div className="rv-moved" role="status">
267
+ <span>your draft is on v{n}; v{newest.n} landed while you wrote</span>
268
+ <button className="primary" onClick={() => card.moveDraft()}>move it to v{newest.n}</button>
269
+ <button onClick={() => card.keepDraftOn()}>keep it on v{n}</button>
270
+ </div>
271
+ ) : null}
272
+ <div className="rv-goes">
273
+ <span className="rv-dim">{verdicts ? `your answer goes to v${n}` : h?.kind === 'version' ? 'a draft card: a word goes in a reply' : 'your reply goes to this item'}</span>
274
+ {v.lane ? <LaneTag lane={v.lane} /> : null}
275
+ {rv.phone.on ? null : <Listeners rv={rv} heads={[{ lane: v.lane, session: v.origin.by === 'agent' ? v.origin.session : undefined }]} />}
276
+ {d.pick !== undefined && n !== null ? <button className="rv-chip re-approved" onClick={() => card.reveal(h?.id ?? v.head, d.pick)}>✓ picked {viewTag(n, d.pick)} {viewName(views[d.pick], d.pick)}</button> : null}
277
+ {d.rects.length > 0 ? <button className="rv-chip rect" title="your draft notes: the verdict sends them" onClick={() => card.reveal(h?.id ?? v.head, d.rects[0]?.view ?? 0)}>⬚ {d.rects.length} draft note{d.rects.length > 1 ? 's' : ''}, sent with your verdict</button> : null}
278
+ {reactions.length > 0 ? <button className="rv-chip" onClick={() => card.reveal(h?.id ?? v.head, reactions[0]?.view)}>{reactions.length} reaction{reactions.length > 1 ? 's' : ''}</button> : null}
279
+ {card.dirty ? <button className="ghost rv-chip" title="drop the draft: your notes and your word" onClick={() => card.dropDraft()}>clear</button> : null}
280
+ </div>
281
+ <AutoText className="rv-reply" placeholder={rv.phone.on ? 'your word' : verdicts ? 'your word: a verdict sends it with your notes, ⌘Enter sends it alone as a reply' : 'your word (⌘Enter sends it)'} value={d.comment}
282
+ onText={(t) => card.setComment(t)}
283
+ onKeyDown={(e) => {
284
+ if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
285
+ e.preventDefault()
286
+ void card.sendReply()
287
+ } else if (e.key === 'Escape') e.currentTarget.blur()
288
+ }} />
289
+ <div className="rv-acts">
290
+ {verdicts
291
+ ? VERDICTS.map((x) => (
292
+ <button key={x.status} className={`rv-verdict ${toneOf(x.status)}${sent === x.status ? ' chosen' : ''}`} disabled={card.busy} onClick={() => void card.submit(x.status)} title={`${x.label} (${x.key})`}>
293
+ {rv.phone.on ? x.short : <><span className="rv-vglyph">{x.glyph}</span> {x.short} ({x.key})</>}
294
+ </button>
295
+ ))
296
+ : null}
297
+ <span className="sp" />
298
+ <button className="primary rv-send" disabled={!d.comment.trim() || card.busy} title="send your word alone, as a reply (⌘Enter)" onClick={() => void card.sendReply()}>Reply</button>
299
+ </div>
300
+ </div>
301
+ )
302
+ })