rvlib-shipkit 2.22.1 → 2.24.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 (139) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/package.json +1 -1
  3. package/src/agent-time/render.ts +28 -14
  4. package/src/agent-time/report.ts +46 -25
  5. package/src/agent-time/store.ts +30 -10
  6. package/src/agent-time/timeline.ts +43 -15
  7. package/src/annex/annex.ts +3 -0
  8. package/src/annex/born.ts +464 -0
  9. package/src/annex/flush.ts +46 -0
  10. package/src/annex/offload.ts +171 -38
  11. package/src/annex/snapshots.ts +53 -0
  12. package/src/annex/tidy.ts +368 -0
  13. package/src/asks/asks-queue.ts +32 -11
  14. package/src/checks/SK041-annex-links.check.ts +4 -2
  15. package/src/checks/SK043-scratch-on-the-mac.check.ts +45 -0
  16. package/src/checks/SK044-behind-upstream.check.ts +38 -0
  17. package/src/cli/cmd_Annex.ts +60 -9
  18. package/src/cli/cmd_Asks.ts +2 -0
  19. package/src/cli/cmd_Backup.ts +7 -5
  20. package/src/cli/cmd_Bump.ts +1 -0
  21. package/src/cli/cmd_Capacity.ts +26 -0
  22. package/src/cli/cmd_Check.ts +1 -0
  23. package/src/cli/cmd_Checks.ts +1 -0
  24. package/src/cli/cmd_Ci.ts +1 -0
  25. package/src/cli/cmd_Commands.ts +50 -14
  26. package/src/cli/cmd_Home.ts +0 -1
  27. package/src/cli/cmd_Hooks.ts +1 -0
  28. package/src/cli/cmd_Mv.ts +1 -0
  29. package/src/cli/cmd_Rec.ts +17 -7
  30. package/src/cli/cmd_Reflect.ts +1 -0
  31. package/src/cli/cmd_Releases.ts +1 -0
  32. package/src/cli/cmd_Review.ts +124 -17
  33. package/src/cli/cmd_Secret.ts +41 -2
  34. package/src/cli/cmd_Shot.ts +1 -0
  35. package/src/cli/cmd_Status.ts +1 -0
  36. package/src/cli/cmd_Time.ts +3 -1
  37. package/src/cli/cmd_Tmp.ts +82 -0
  38. package/src/cli/cmd_Wiki.ts +1 -0
  39. package/src/cli/registry.ts +13 -1
  40. package/src/collections/pings.ts +1 -1
  41. package/src/core/capacity.ts +71 -0
  42. package/src/core/check-runner.ts +86 -15
  43. package/src/core/machine-db.ts +8 -0
  44. package/src/core/motherhome.ts +67 -9
  45. package/src/core/slots.ts +49 -12
  46. package/src/core/trace-audit.ts +4 -1
  47. package/src/drill/run.ts +5 -2
  48. package/src/home/daemon-jobs.ts +10 -3
  49. package/src/home/global-units.ts +3 -0
  50. package/src/home/gui-app/ShipkitGui.swift +1 -0
  51. package/src/home/home-launchd.ts +11 -3
  52. package/src/home/home-routes.ts +11 -4
  53. package/src/home/machine-host.ts +65 -0
  54. package/src/home/machine-stores.ts +30 -4
  55. package/src/home/machine-temp.ts +493 -0
  56. package/src/home/other-macs.ts +74 -0
  57. package/src/home/pm.ts +4 -1
  58. package/src/home/run-daemon.ts +10 -2
  59. package/src/home/run-pm.ts +1 -0
  60. package/src/home/serve-web.ts +2 -2
  61. package/src/home/via-hub.ts +6 -1
  62. package/src/identities/identities.ts +92 -24
  63. package/src/init-repo.ts +7 -3
  64. package/src/ledger/ledger.ts +6 -0
  65. package/src/ledger/store.ts +6 -0
  66. package/src/media-store/backup/keys.ts +21 -6
  67. package/src/media-store/backup/manifest.ts +52 -11
  68. package/src/media-store/backup/restore.ts +17 -10
  69. package/src/media-store/backup/run.ts +5 -2
  70. package/src/media-store/backup/sources.ts +2 -1
  71. package/src/media-store/daemon.ts +2 -2
  72. package/src/media-store/purge.ts +4 -0
  73. package/src/mv/mv-md.ts +121 -42
  74. package/src/recordings/load.ts +3 -3
  75. package/src/recordings/model.ts +7 -0
  76. package/src/recordings/open.ts +12 -0
  77. package/src/recordings/presets.ts +12 -5
  78. package/src/recordings/recorder-app/Capture.swift +34 -5
  79. package/src/recordings/recorder-app/Clip.swift +126 -17
  80. package/src/recordings/recorder-app/Editor.swift +177 -7
  81. package/src/recordings/recorder-app/Hud.swift +189 -0
  82. package/src/recordings/recorder-app/Tray.swift +179 -36
  83. package/src/recordings/recorder-app/icon.svg +16 -0
  84. package/src/recordings/recorder-app/main.swift +349 -18
  85. package/src/recordings/recorder-app.ts +8 -4
  86. package/src/recordings/recorder.shipkit.ts +2 -1
  87. package/src/recordings/routes.ts +52 -6
  88. package/src/recordings/run-recorder.ts +2 -1
  89. package/src/recordings/share.ts +27 -0
  90. package/src/recordings/take.ts +36 -4
  91. package/src/recordings/view.ts +11 -0
  92. package/src/reflect/transcript.ts +56 -11
  93. package/src/releases/from-card.ts +45 -3
  94. package/src/releases/model.ts +6 -0
  95. package/src/releases/store.ts +8 -1
  96. package/src/repo-config.ts +14 -4
  97. package/src/review/cells.ts +24 -3
  98. package/src/review/format.ts +33 -9
  99. package/src/review/media-kind.ts +14 -11
  100. package/src/review/media-read.ts +6 -5
  101. package/src/review/model.ts +104 -7
  102. package/src/review/paste.ts +2 -1
  103. package/src/review/previews.ts +123 -36
  104. package/src/review/routes.ts +29 -18
  105. package/src/review/store.ts +74 -12
  106. package/src/review/threads.ts +7 -5
  107. package/src/secrets/copy.ts +110 -0
  108. package/src/secrets/list.ts +17 -7
  109. package/src/serve/hub-app/home-strip.css +5 -0
  110. package/src/serve/hub-app/home-strip.tsx +18 -0
  111. package/src/serve/hub-app/hub-app.tsx +2 -1
  112. package/src/serve/hub-app/hub.css +18 -0
  113. package/src/serve/hub-app/inbox.css +1 -0
  114. package/src/serve/hub-app/pull-refresh.tsx +88 -0
  115. package/src/serve/hub-app/recordings-st.ts +135 -24
  116. package/src/serve/hub-app/recordings-view.tsx +293 -54
  117. package/src/serve/hub-app/recordings.css +77 -24
  118. package/src/serve/hub-app/review/review-cells.tsx +52 -13
  119. package/src/serve/hub-app/review/review-list.tsx +6 -1
  120. package/src/serve/hub-app/review/review-st.ts +6 -5
  121. package/src/serve/hub-app/review/review-thread.tsx +3 -1
  122. package/src/serve/hub-app/review/review-views.tsx +18 -11
  123. package/src/serve/hub-app/review/thread-st.ts +82 -14
  124. package/src/serve/hub-app/review.css +15 -2
  125. package/src/serve/hub-runtime.ts +2 -1
  126. package/src/serve/run-serve.ts +4 -2
  127. package/src/serve/serve-hub.ts +9 -2
  128. package/src/shipkit-files.ts +5 -0
  129. package/src/social/drafts.ts +4 -3
  130. package/src/social/load.ts +7 -2
  131. package/src/social/publish/discord.ts +10 -3
  132. package/src/suite/child-tools.ts +45 -0
  133. package/src/suite/judge-suites.ts +10 -22
  134. package/src/suite/select.ts +83 -8
  135. package/src/suite/suite-cli.ts +38 -14
  136. package/src/suite/suite-cores.ts +68 -0
  137. package/src/suite/suite-reads-preload.ts +8 -6
  138. package/src/ts/config.ts +44 -0
  139. package/src/ts/rename.ts +11 -1
@@ -7,13 +7,13 @@ import { dirname, extname, join } from 'node:path'
7
7
  import { isAnimFormat, isAnimLabels, isAnimMode, pairAnimation } from './anim.ts'
8
8
  import { startAuto } from './auto.ts'
9
9
  import { bad, KEEP, NO_STORE, ranged, tagged, TYPES } from './http.ts'
10
- import { viewFilesOf, type Rect, type ReviewItem, type Subject } from './model.ts'
10
+ import { verdictOf, viewFilesOf, type Rect, type ReviewItem, type ReviewStatus, type Subject } from './model.ts'
11
11
  import { stageGet, stagePost } from './stage-routes.ts'
12
12
  import { pasteHosts } from './paste.ts'
13
13
  import { openReview, partFile, viewOfItem } from './project.ts'
14
- import { isPreviewSize, previewOrRemote, warmPreviews } from './previews.ts'
14
+ import { CLIP, isPreviewSize, previewOrRemote, warmPreviews } from './previews.ts'
15
15
  import { roleOf } from './role.ts'
16
- import { addMessage, imageFile, itemOfRef, markRead, raiseItem, rateSubject, readAllCached, readItem, specOf, storeDir, storeStamp, threadImage, writeVerdict } from './store.ts'
16
+ import { addMessage, imageFile, itemOfRef, markRead, raiseItem, rateSubject, readAllCached, readItem, reopen, specOf, storeDir, storeStamp, threadImage, writeVerdict } from './store.ts'
17
17
  import { boardOf, pageOf, queryOf, threadIndex, threadOfId, threadView, type ThreadIndex } from './cells.ts'
18
18
  import { membersOf, threadsOf, type Thread } from './threads.ts'
19
19
  import { putMedia } from '../media-store/put.ts'
@@ -50,17 +50,15 @@ async function project(root: string): Promise<{ dir: string; unit: ReviewUnit |
50
50
  return { dir, unit }
51
51
  }
52
52
 
53
- /** an approved card's changelog line into next.md (releases/from-card.ts), after the verdict answered: a failure says so
54
- * on the card's thread and in the hub's log, so the change is never lost in silence */
55
- async function changeOnVerdict(dir: string, id: string): Promise<void> {
56
- try {
57
- const { onVerdict } = await import('../releases/from-card.ts')
58
- await onVerdict(dirname(dirname(dir)), id)
59
- } catch (e) {
60
- const why = (e as Error).message
61
- console.error(`FAIL: the release did not take the change of ${id}: ${why}`)
62
- addMessage(dir, id, 'releases', `the release did not take this change: ${why}. Run sk releases add --card ${id}`)
63
- }
53
+ /** next.md follows his answer (releases/from-card.ts), after the request answered; `was` the status before it */
54
+ async function releaseFollows(dir: string, id: string, was: ReviewStatus | null): Promise<void> {
55
+ const { followAnswer } = await import('../releases/from-card.ts')
56
+ await followAnswer(dirname(dirname(dir)), id, was)
57
+ }
58
+
59
+ const statusNow = (dir: string, id: string): ReviewStatus | null => {
60
+ const x = readItem(dir, id)
61
+ return x ? (verdictOf(x)?.status ?? null) : null
64
62
  }
65
63
 
66
64
  /** an image the page sent as a data url, written to a scratch file the caller removes */
@@ -230,14 +228,15 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
230
228
  const url = await remoteUrl(dir, t[1] ?? '', `thread/${t[2] ?? ''}`)
231
229
  return url ? toSpace(url) : bad('no such image', 404)
232
230
  }
233
- // a view's image at the size the page draws it; `thumb/<name>` is the preview's thumb size
231
+ // a view's image at the size the page draws it, a clip as the page plays it; `thumb/<name>` is the preview's thumb size
234
232
  const pv = /^\/api\/review\/([^/]+)\/(?:preview\/([^/]+)|thumb)\/([^/]+)$/.exec(path)
235
233
  if (pv && req.method === 'GET') {
236
234
  const size = pv[2] ?? 'thumb'
237
235
  if (!isPreviewSize(size)) return bad(`preview size ${size}: thumb or fit`, 404)
238
236
  const p = await previewOrRemote(dir, pv[1] ?? '', pv[3] ?? '', size)
239
237
  if (p && 'url' in p) return toSpace(p.url)
240
- return p ? new Response(Bun.file(p.file), { headers: { 'Content-Type': 'image/webp', ...KEEP } }) : bad('no such image', 404)
238
+ if (p && CLIP.test(p.file)) return ranged(req, p.file)
239
+ return p ? new Response(Bun.file(p.file), { headers: { 'Content-Type': 'image/webp', ...KEEP } }) : bad('no such image or clip', 404)
241
240
  }
242
241
  const m = /^\/api\/review\/([^/]+)\/([^/]+)$/.exec(path)
243
242
  if (!m) return null
@@ -245,12 +244,24 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
245
244
  if (req.method === 'POST') {
246
245
  try {
247
246
  if (name === 'feedback') {
247
+ const was = statusNow(dir, id)
248
248
  const r = writeVerdict(dir, id, await req.json())
249
- if (r.ok) void changeOnVerdict(dir, id)
249
+ if (r.ok) void releaseFollows(dir, id, was)
250
250
  return r.ok ? Response.json(r.message, { headers: NO_STORE }) : Response.json({ error: r.errors.join('\n'), errors: r.errors }, { status: 400, headers: NO_STORE })
251
251
  }
252
+ // a click on his lit verdict: he takes it back, the card waits for him again (the CLI's reopen, by the owner)
253
+ if (name === 'reopen') {
254
+ const v = reopen(dir, id, { who: 'owner' })
255
+ if (!v) return bad(`${id}: no such card, or no answer to take back`, 404)
256
+ void releaseFollows(dir, id, v.status)
257
+ return Response.json({ reopened: v.id }, { headers: NO_STORE })
258
+ }
252
259
  if (name === 'stage') return await stagePost(dirname(dirname(dir)), dir, id, unit, (await req.json().catch(() => ({}))) as Record<string, unknown>)
253
- if (name === 'reply') return Response.json(addMessage(dir, id, 'owner', ((await req.json()) as { text?: unknown }).text), { headers: NO_STORE })
260
+ if (name === 'reply') {
261
+ // `re`: the message his word answers, a hint on an agent's update
262
+ const b = (await req.json()) as { text?: unknown; re?: unknown }
263
+ return Response.json(addMessage(dir, id, 'owner', b.text, undefined, new Date(), b.re), { headers: NO_STORE })
264
+ }
254
265
  if (name === 'read') {
255
266
  // the page names the words it drew: a word that came after them stays unread
256
267
  const b = (await req.json().catch(() => ({}))) as { of?: unknown }
@@ -37,6 +37,11 @@ import {
37
37
  verdictOf,
38
38
  viewIndexOf,
39
39
  withdrawnOf,
40
+ inWork,
41
+ UPDATE_STATES,
42
+ UPDATE_WORDS,
43
+ updatesOf,
44
+ type UpdateState,
40
45
  type GalleryTile,
41
46
  type CardChangelog,
42
47
  type Item,
@@ -53,6 +58,7 @@ import {
53
58
  type TrailerCard,
54
59
  type Spec,
55
60
  type Subject,
61
+ type Verdict,
56
62
  viewFilesOf,
57
63
  mediaFilesOf,
58
64
  threadMediaOf,
@@ -418,11 +424,15 @@ function copyFiles(v: Loaded, n: number, into: string): void {
418
424
  }
419
425
  }
420
426
 
421
- /** another angle of an open card's subject, appended as its next view; refused once he answered */
422
- export async function addView(dir: string, id: string, v: ViewInput, o: { marks?: ReviewMark[]; light?: 'review' } = {}): Promise<Item> {
427
+ /** the command that posts an update, as a refusal names it */
428
+ const updateLine = (id: string): string => `sk review update ${id} <${UPDATE_STATES.join('|')}> "<one line>" <file> | <before> <after>`
429
+
430
+ /** another angle of an open card's subject, appended as its next view; refused once he answered, except the view of an
431
+ * update (`update`), which goes on at any time */
432
+ export async function addView(dir: string, id: string, v: ViewInput, o: { marks?: ReviewMark[]; light?: 'review'; update?: true } = {}): Promise<Item> {
423
433
  const x = readItem(dir, id)
424
434
  if (!x) throw new Error(`no card ${id}`)
425
- if (verdictOf(x)) throw new Error(`${id} has his answer already: a new version passes --supersedes ${id}`)
435
+ if (verdictOf(x) && !o.update) throw new Error(`${id} has his answer already: a picture of the work since goes on as an update, ${updateLine(id)}; a new version passes --supersedes ${id}`)
426
436
  if (v.note !== undefined && v.gallery) throw new Error(`"${v.label}": a note goes on an image, a clip or a sound, never a gallery`)
427
437
  if (!v.label.trim()) throw new Error('add-view: the view needs its label')
428
438
  const loaded = await loadView(v, `the view "${v.label}"`)
@@ -556,12 +566,56 @@ export function appendMessage(dir: string, id: string, m: Omit<Message, 'id' | '
556
566
  return out
557
567
  }
558
568
 
559
- /** a reply on an item from `who` (the owner, or an agent by its name), with an optional image; throws with the reason */
560
- export function addMessage(dir: string, id: string, who: string, text: unknown, image?: string, now = new Date()): Message {
561
- if (!readItem(dir, id)) throw new Error(`no card ${id}`)
569
+ /** a reply on an item from `who` (the owner, or an agent by its name), with an optional image; `re` the message of the
570
+ * item it answers (his hint on an update); throws with the reason */
571
+ export function addMessage(dir: string, id: string, who: string, text: unknown, image?: string, now = new Date(), re?: unknown): Message {
572
+ const x = readItem(dir, id)
573
+ if (!x) throw new Error(`no card ${id}`)
562
574
  const t = textOf(text)
563
575
  if ('error' in t) throw new Error(t.error)
564
- return appendMessage(dir, id, { who, text: t.text }, { ...(image !== undefined ? { image } : {}), now })
576
+ if (re !== undefined && !(typeof re === 'string' && x.thread.some((m) => m.id === re))) throw new Error(`re: ${String(re)} is no message of ${id}`)
577
+ return appendMessage(dir, id, { who, text: t.text, ...(typeof re === 'string' ? { re } : {}) }, { ...(image !== undefined ? { image } : {}), now })
578
+ }
579
+
580
+ /** a view of files as typed: one file an image, a clip or a sound (by its extension), two a before and an after; loadView
581
+ * checks them */
582
+ export function filesView(label: string, files: readonly string[], usage: string): ViewInput {
583
+ const [a, b] = files
584
+ if (files.length === 1 && a !== undefined) return { label, image: a }
585
+ if (files.length === 2 && a !== undefined && b !== undefined) return { label, before: a, after: b }
586
+ throw new Error(usage)
587
+ }
588
+
589
+ /** what an agent's update says: its state, its line, its media as it is, one file or a before and an after (none: the
590
+ * state alone) */
591
+ export interface UpdateInput {
592
+ who: string
593
+ state: string
594
+ text: unknown
595
+ files?: readonly string[]
596
+ now?: Date
597
+ }
598
+
599
+ /** an agent's update on its card, at any time, before or after his answer: its file, or its pair, becomes the card's next view
600
+ * (labelled `update <k>: <state>`, the line its note), then one message carries the state and the line. Still broken
601
+ * or better holds the card in work, fixed asks the owner's verdict again (model.ts stateOf) */
602
+ export async function postUpdate(dir: string, id: string, u: UpdateInput): Promise<{ item: Item; message: Message; tag: string; view: number | null }> {
603
+ const x = readItem(dir, id)
604
+ if (!x) throw new Error(`no card ${id}`)
605
+ if (x.item.origin.by !== 'agent') throw new Error(`${id} was raised, not sent by an agent: an update goes on the card that answers it`)
606
+ if (x.item.wip) throw new Error(`${id} is a draft on a live shot: its frame refreshes itself, sk review ready ${id} when it is done`)
607
+ if (!UPDATE_STATES.includes(u.state as UpdateState)) throw new Error(`the state: one of ${UPDATE_STATES.join(', ')}, not « ${u.state} »`)
608
+ const state = u.state as UpdateState
609
+ const t = textOf(u.text)
610
+ if ('error' in t) throw new Error(`the line: ${t.error.replace(/^text: /, '')}`)
611
+ const files = u.files ?? []
612
+ for (const f of files) if (!existsSync(f)) throw new Error(`${f}: no such file`)
613
+ const k = updatesOf(x).length + 1
614
+ const label = `update ${k}: ${UPDATE_WORDS[state]}`
615
+ const item = files.length === 0 ? x.item : await addView(dir, id, { ...filesView(label, files, `an update holds one file, or a before and an after: ${updateLine(id)}`), note: t.text }, { update: true })
616
+ const view = files.length === 0 ? null : item.views.length - 1
617
+ const message = appendMessage(dir, id, { who: u.who, text: t.text, update: { state, ...(view !== null ? { view } : {}) } }, u.now ? { now: u.now } : {})
618
+ return { item, message, tag: `update ${k} (${UPDATE_WORDS[state]})`, view }
565
619
  }
566
620
 
567
621
  /** `party` read what the other party wrote on an item: one `seen` message naming them; how many it read. `only`: the
@@ -748,12 +802,14 @@ export function withdraw(dir: string, id: string, why: string, now = new Date())
748
802
  return true
749
803
  }
750
804
 
751
- /** an answered card waits for his answer again: its verdict stays in the thread, before the reopen; false when it has none */
752
- export function reopen(dir: string, id: string, now = new Date()): boolean {
805
+ /** an answered card waits for his answer again: its verdict stays in the thread, before the reopen. `who`: an agent
806
+ * (the CLI), or the owner taking the verdict back (the hub). The verdict reopened, null when it has none */
807
+ export function reopen(dir: string, id: string, o: { who?: string; now?: Date } = {}): Verdict | null {
753
808
  const x = ID_RE.test(id) ? readItem(dir, id) : null
754
- if (!x || !verdictOf(x)) return false
755
- appendMessage(dir, id, { who: agentName(), op: 'reopen' }, { now })
756
- return true
809
+ const v = x ? verdictOf(x) : null
810
+ if (!v) return null
811
+ appendMessage(dir, id, { who: o.who ?? agentName(), op: 'reopen' }, { now: o.now ?? new Date() })
812
+ return v
757
813
  }
758
814
 
759
815
  /** the path of one image, clip or poster of an item, null for any other name */
@@ -1031,6 +1087,12 @@ export async function readyItem(dir: string, id: string, o: { image?: string; no
1031
1087
  const x = readItem(dir, id)
1032
1088
  if (!x) throw new Error(`no card ${id}`)
1033
1089
  const { wip, ...rest } = x.item
1090
+ if (!wip && inWork(x)) {
1091
+ // a card its updates hold in work: ready asks the owner's verdict, its newest picture goes on as an update
1092
+ if (o.image !== undefined) throw new Error(`${id} is in work by its updates: its new picture goes on as one, ${updateLine(id).replace('<broken|better|fixed>', 'fixed')}`)
1093
+ appendMessage(dir, id, { who: agentName(), op: 'ready' }, o.now ? { now: o.now } : {})
1094
+ return x.item
1095
+ }
1034
1096
  if (!wip) throw new Error(`${id} is not a draft card: it already takes a verdict`)
1035
1097
  let item: Item = rest
1036
1098
  if (o.image !== undefined) {
@@ -2,11 +2,13 @@
2
2
  // items (a report, his note) the card answers, read as one thread per bug; their status, conversation and order, and
3
3
  // the active thread a new card already covers. Pure, over the items of review/model.ts
4
4
  import {
5
+ inWork,
5
6
  isReply,
6
7
  partyOf,
7
8
  reworkOf,
8
9
  stateOf,
9
10
  subjectKey,
11
+ takenBackOf,
10
12
  unreadBy,
11
13
  verdictOf,
12
14
  withdrawnOf,
@@ -147,12 +149,12 @@ export function conversationOf(t: Thread): (Message & { on: string })[] {
147
149
  }
148
150
 
149
151
  /** a head waits for the owner's verdict: an agent's card, none yet, not withdrawn, not a draft */
150
- export const waits = (x: ReviewItem): boolean => x.item.origin.by === 'agent' && !x.item.wip && verdictOf(x) === null && withdrawnOf(x) === undefined
152
+ export const waits = (x: ReviewItem): boolean => x.item.origin.by === 'agent' && !inWork(x) && verdictOf(x) === null && withdrawnOf(x) === undefined
151
153
 
152
154
  /** the active pending heads first in the order they were sent, then every other thread, newest first */
153
155
  export function orderedThreads(items: readonly ReviewItem[]): Thread[] {
154
156
  const all = threadsOf(items)
155
- const first = (x: ReviewItem): boolean => waits(x) || (x.item.wip !== undefined && verdictOf(x) === null && withdrawnOf(x) === undefined)
157
+ const first = (x: ReviewItem): boolean => waits(x) || (x.item.origin.by === 'agent' && inWork(x))
156
158
  const pending = all.filter((t) => first(t.head)).sort((a, b) => oldest(a.head, b.head))
157
159
  const rest = all.filter((t) => !first(t.head)).sort((a, b) => newest(a.head, b.head))
158
160
  return [...pending, ...rest]
@@ -209,16 +211,16 @@ export function statusOf(x: ReviewItem, items: readonly ReviewItem[]): ShownStat
209
211
  const v = verdictOf(x)
210
212
  if (v) return v.status
211
213
  if (withdrawnOf(x) !== undefined) return 'withdrawn'
212
- if (x.item.wip) return 'wip'
214
+ if (inWork(x)) return 'wip'
213
215
  return supersederOf(x.item.id, items) ? 'superseded' : 'pending'
214
216
  }
215
217
 
216
- /** the latest thing on `x` the agent has not seen: its verdict or a reply of the owner */
218
+ /** the latest thing on `x` the agent has not seen: its verdict, a reply of the owner, or a verdict he took back */
217
219
  const lastUnseen = (x: ReviewItem, answered: boolean): string => {
218
220
  const v = verdictOf(x)
219
221
  const opening = answered || stateOf(x, false).state === 'closed' ? openingOf(x) : undefined
220
222
  const replies = unreadBy(x, 'agent').filter((m) => m !== opening)
221
- return [...(v && !v.seen ? [v.at] : []), ...replies.map((m) => m.at)].sort().at(-1) ?? ''
223
+ return [...(v && !v.seen ? [v.at] : []), ...replies.map((m) => m.at), ...takenBackOf(x).map((t) => t.m.at)].sort().at(-1) ?? ''
222
224
  }
223
225
 
224
226
  /** the items with a verdict or an owner reply the agent has not marked seen yet, oldest first */
@@ -0,0 +1,110 @@
1
+ // secrets copied to another Mac over ssh: each read through this house's manager and written by the peer's own
2
+ // `sk secret set`, from the house checkout at the same place under its home. A value only ever travels on ssh's
3
+ // stdin: never an argv, a file or a printed line. A secret the peer already answers is left as it is.
4
+ import { secretArgv } from '../smoke/run-smoke.ts'
5
+
6
+ export type Copied = { name: string; did: 'copied' | 'there' | 'not here' | 'failed'; why?: string }
7
+
8
+ /** what macOS's `security` says when the login keychain of an ssh session is locked */
9
+ export const LOCKED = /User interaction is not allowed/
10
+
11
+ type Ran = { code: number; out: string; err: string }
12
+ export type Run = (argv: string[], stdin?: string) => Promise<Ran>
13
+
14
+ const spawnRun: Run = async (argv, stdin) => {
15
+ const p = Bun.spawn(argv, { stdin: stdin == null ? 'ignore' : new Blob([stdin]), stdout: 'pipe', stderr: 'pipe' })
16
+ const [out, err] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text()])
17
+ return { code: await p.exited, out, err }
18
+ }
19
+
20
+ /** a word quoted for the peer's sh */
21
+ const q = (s: string): string => `'${s.replaceAll("'", `'\\''`)}'`
22
+
23
+ /** the line the peer's shell runs: an ssh command shell reads no rc file, so the tools' folders are named */
24
+ export const peerLine = (houseRel: string, args: string): string => `cd ~/${houseRel} && PATH="$HOME/.local/bin:$HOME/.bun/bin:$PATH" sk secret ${args}`
25
+
26
+ /** the unlock a locked peer needs, said once */
27
+ export const unlockHint = (to: string): string => `the login keychain of ${to} is locked to ssh, and an unlock holds for its own ssh session only: run \`sk secret copy --to ${to} --unlock\` from your terminal (it asks for that Mac's login password once)`
28
+
29
+ export async function copySecrets(o: { names: string[]; to: string; reader: string; houseRel: string; run?: Run }): Promise<{ copied: Copied[]; locked: boolean }> {
30
+ const run = o.run ?? spawnRun
31
+ const ssh = (args: string, stdin?: string): Promise<Ran> => run(['ssh', '-o', 'BatchMode=yes', o.to, peerLine(o.houseRel, args)], stdin)
32
+ const copied: Copied[] = []
33
+ for (const name of o.names) {
34
+ const value = await run(secretArgv(o.reader, name, 'get'))
35
+ if (value.code !== 0 || value.out.trim() === '') {
36
+ copied.push({ name, did: 'not here' })
37
+ continue
38
+ }
39
+ if ((await ssh(`get ${q(name)} > /dev/null 2>&1`)).code === 0) {
40
+ copied.push({ name, did: 'there' })
41
+ continue
42
+ }
43
+ const account = await run(secretArgv(o.reader, name, 'account'))
44
+ const who = account.code === 0 && account.out.trim() !== '' ? ` ${q(account.out.trim())}` : ''
45
+ const set = await ssh(`set ${q(name)}${who}`, value.out)
46
+ if (set.code === 0) {
47
+ copied.push({ name, did: 'copied' })
48
+ continue
49
+ }
50
+ const said = `${set.out}\n${set.err}`.replaceAll(value.out.trim(), '‹value›')
51
+ if (LOCKED.test(said)) return { copied: [...copied, { name, did: 'failed', why: unlockHint(o.to) }], locked: true }
52
+ copied.push({ name, did: 'failed', why: said.trim().split('\n').slice(-1)[0] ?? `exit ${set.code}` })
53
+ }
54
+ return { copied, locked: false }
55
+ }
56
+
57
+ /** one line a secret on the pipe to the peer: its name, then its account and its value in base64, so no byte of
58
+ * either can end a line or a word */
59
+ export const record = (name: string, account: string, value: string): string =>
60
+ `${name} ${Buffer.from(account).toString('base64')} ${Buffer.from(value).toString('base64')}\n`
61
+
62
+ /** what the peer runs in the ONE ssh session that unlocks its keychain (an unlock holds for its own session only):
63
+ * the unlock on the owner's terminal, then each line of the pipe stored by its own `sk secret set`, the value on
64
+ * stdin. `fifo` is relative to the peer's home. A failed unlock still drains the pipe, so the laptop's writer never hangs */
65
+ export const receiverScript = (fifo: string, houseRel: string): string =>
66
+ [
67
+ // the pipe is named from the home, where ssh starts, before the move into the house checkout
68
+ `f="$HOME"/${q(fifo)}; PATH="$HOME/.local/bin:$HOME/.bun/bin:$PATH"`,
69
+ `cd ~/${houseRel} || { cat "$f" > /dev/null; rm -f "$f"; exit 1; }`,
70
+ `if ! security unlock-keychain; then cat "$f" > /dev/null; rm -f "$f"; exit 1; fi`,
71
+ `while read -r name a64 v64; do`,
72
+ ` if sk secret get "$name" > /dev/null 2>&1; then echo "skip $name already there"; continue; fi`,
73
+ ` acct=$(printf %s "$a64" | base64 -d)`,
74
+ ` if printf %s "$v64" | base64 -d | sk secret set "$name" "$acct" > /dev/null 2>&1; then echo "ok $name copied"; else echo "FAIL $name not stored"; fi`,
75
+ `done < "$f"`,
76
+ `rm -f "$f"`,
77
+ ].join('\n')
78
+
79
+ /** the copy for a peer whose keychain ssh sees locked: run from the owner's terminal, since the unlock asks for that
80
+ * Mac's login password. Values ride a fifo on the peer (nothing at rest), filled by a second ssh session */
81
+ export async function copyWithUnlock(o: { names: string[]; to: string; reader: string; houseRel: string; say: (l: string) => void }): Promise<number> {
82
+ let lines = ''
83
+ for (const name of o.names) {
84
+ const value = await spawnRun(secretArgv(o.reader, name, 'get'))
85
+ if (value.code !== 0 || value.out.trim() === '') {
86
+ o.say(`skip ${name} not on this Mac`)
87
+ continue
88
+ }
89
+ const account = await spawnRun(secretArgv(o.reader, name, 'account'))
90
+ lines += record(name, account.code === 0 ? account.out.trim() : '', value.out.replace(/\n$/, ''))
91
+ }
92
+ if (lines === '') return 0
93
+ const fifo = `.shipkit-secret-copy-${process.pid}-${Date.now()}.fifo`
94
+ const made = await spawnRun(['ssh', '-o', 'BatchMode=yes', o.to, `mkfifo -m 600 ${q(fifo)}`])
95
+ if (made.code !== 0) {
96
+ o.say(`FAIL no pipe on ${o.to}: ${made.err.trim() || `exit ${made.code}`}`)
97
+ return 1
98
+ }
99
+ const writer = Bun.spawn(['ssh', '-o', 'BatchMode=yes', o.to, `cat > ${q(fifo)}`], { stdin: new Blob([lines]), stdout: 'ignore', stderr: 'pipe' })
100
+ o.say(`${o.to} asks for its login password once, to unlock its keychain for this session:`)
101
+ const receiver = Bun.spawn(['ssh', '-t', o.to, receiverScript(fifo, o.houseRel)], { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit' })
102
+ const code = await receiver.exited
103
+ // a receiver that never opened the pipe leaves the writer blocked on it
104
+ const done = await Promise.race([writer.exited, new Promise<null>((ok) => setTimeout(() => ok(null), 3000))])
105
+ if (done === null) {
106
+ writer.kill()
107
+ await spawnRun(['ssh', '-o', 'BatchMode=yes', o.to, `rm -f ${q(fifo)}`])
108
+ }
109
+ return code
110
+ }
@@ -1,9 +1,11 @@
1
1
  // the secrets one repo is for: the house's registry rows in its scope, plus the
2
2
  // repo's own `creds`. Presence reads each value through `credsReadCommand` and
3
- // keeps only whether it answered: a value is never printed, logged or returned.
3
+ // keeps only whether it answered, or that the keychain was locked to this session:
4
+ // a value is never printed, logged or returned.
4
5
  import { inScope, scopesAll, scopeText, type Asker } from '../core/scope.ts'
5
6
  import type { RepoConfig } from '../repo-config.ts'
6
7
  import { secretArgv } from '../smoke/run-smoke.ts'
8
+ import { LOCKED } from './copy.ts'
7
9
 
8
10
  export type Cred = NonNullable<RepoConfig['creds']>[number]
9
11
 
@@ -28,13 +30,21 @@ export function secretsFor(o: { asker: Asker; own: Cred[]; house: Cred[]; all?:
28
30
  .sort((a, b) => Number(b.mine) - Number(a.mine) || Number(b.inScope) - Number(a.inScope) || a.name.localeCompare(b.name))
29
31
  }
30
32
 
31
- /** whether each secret answers through the read command, all at once */
32
- export async function presence(reader: string, names: string[]): Promise<Map<string, boolean>> {
33
- const out = new Map<string, boolean>()
33
+ export type Presence = 'ok' | 'missing' | 'locked'
34
+
35
+ /** the exit of macOS's `security` for an item it found in a keychain locked to this session (an ssh one), with no
36
+ * message; an item it did not find exits 44, locked or not */
37
+ export const LOCKED_EXIT = 36
38
+
39
+ /** whether each secret answers through the read command, all at once. A secret in a keychain locked to this session
40
+ * is there but unread: locked, never missing */
41
+ export async function presence(reader: string, names: string[]): Promise<Map<string, Presence>> {
42
+ const out = new Map<string, Presence>()
34
43
  await Promise.all(names.map(async (name) => {
35
- const p = Bun.spawn(secretArgv(reader, name, 'get'), { stdout: 'pipe', stderr: 'ignore' })
36
- const answered = (await new Response(p.stdout).text()).trim() !== ''
37
- out.set(name, (await p.exited) === 0 && answered)
44
+ const p = Bun.spawn(secretArgv(reader, name, 'get'), { stdout: 'pipe', stderr: 'pipe' })
45
+ const [value, err] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text()])
46
+ const code = await p.exited
47
+ out.set(name, code === 0 && value.trim() !== '' ? 'ok' : code === LOCKED_EXIT || LOCKED.test(err) ? 'locked' : 'missing')
38
48
  }))
39
49
  return out
40
50
  }
@@ -3,6 +3,11 @@
3
3
  .hstrip{display:flex;align-items:center;flex-wrap:nowrap;gap:var(--s2);height:40px;flex:none;padding:0 var(--s3);border-bottom:1px solid var(--line);background:var(--bg-top);overflow:hidden;white-space:nowrap}
4
4
  .hstrip .sp{flex:1}
5
5
  .hplace{font-size:12px;font-weight:650;letter-spacing:.08em;text-transform:uppercase;color:var(--dim)}
6
+ /* the Mac this home runs on, and a link to each other Mac's home */
7
+ .hmacs{display:inline-flex;align-items:center;gap:var(--s1);flex:none}
8
+ .hmac{font-size:12px;font-weight:600;line-height:20px;padding:0 var(--s2);border:1px solid var(--line);border-radius:10px;color:var(--ink);text-decoration:none;white-space:nowrap}
9
+ .hmac.cur{color:var(--dim);border-color:transparent}
10
+ a.hmac:hover{border-color:var(--accent);color:var(--accent)}
6
11
  .hrepo{display:inline-flex;align-items:center;gap:var(--s2);min-width:0;flex:0 1 auto}
7
12
  .hrepo img,.hrico{flex:none;width:18px;height:18px;border-radius:4px;object-fit:contain}
8
13
  .hrname{font-size:13px;font-weight:650;letter-spacing:.04em;min-width:0;overflow:hidden;text-overflow:ellipsis}
@@ -344,6 +344,7 @@ export const HomeStrip = observer(({ app }: { app: HomeSt }) => {
344
344
  <div className="hstrip">
345
345
  <Places s={app.projects} />
346
346
  <Identities s={app.projects} />
347
+ <MacLinks m={m} />
347
348
  {name == null ? <span className="hplace">{app.page === 'overview' ? 'overview' : app.page}</span> : <ShownRepo app={app} name={name} />}
348
349
  {name == null ? null : <RepoProcesses m={m} name={name} />}
349
350
  <span className="sp" />
@@ -356,6 +357,23 @@ export const HomeStrip = observer(({ app }: { app: HomeSt }) => {
356
357
  )
357
358
  })
358
359
 
360
+ /** this Mac's name and a link to each other Mac's home: shown only while another Mac's home answers */
361
+ const MacLinks = observer(({ m }: { m: MachineSt }) => {
362
+ const macs = m.data?.otherMacs ?? []
363
+ if (macs.length === 0) return null
364
+ const here = m.data?.here
365
+ return (
366
+ <span className="hmacs" aria-label="the homes of this Mac and the others">
367
+ {here == null ? null : <span className="hmac cur" title="the Mac this home runs on">{here}</span>}
368
+ {macs.map((x) => (
369
+ <a key={x.url} className="hmac" href={x.url} target="_blank" rel="noopener" title={`the home on ${x.name}: ${x.url}`}>
370
+ {x.name} ↗
371
+ </a>
372
+ ))}
373
+ </span>
374
+ )
375
+ })
376
+
359
377
  /** archive the repo or bring it back: `archived` in its repo.config.ts, and
360
378
  * only that key. Archived, it stays listed and nothing runs there */
361
379
  export const ArchiveButton = observer(({ app, name }: { app: HomeSt; name: string }) => {
@@ -56,6 +56,7 @@ import { PageFrames } from './pages-frames.tsx'
56
56
  import { repoSections } from './repo-sections.ts'
57
57
  import { Dock } from './dock-view.tsx'
58
58
  import { DOCK } from './dock-st.ts'
59
+ import { PullRefresh } from './pull-refresh.tsx'
59
60
  import { animateDock } from './dock-anim.ts'
60
61
 
61
62
  // home.html marks the home's page; index.html is a hub serving on its own; `<base>/embed/?page=review` is one repo's
@@ -481,4 +482,4 @@ await Promise.race([home.shown?.cols.restore(), new Promise((ok) => setTimeout(o
481
482
  const solo = location.pathname.startsWith('/recordings') && new URLSearchParams(location.search).has('solo')
482
483
 
483
484
  quietBenignErrors(window)
484
- createRoot(document.getElementById('root')!).render(<StrictMode>{solo ? <main className="rcsolo"><RecordingsView app={home} solo /></main> : embed == null ? <App /> : <EmbedApp page={embed} />}</StrictMode>)
485
+ createRoot(document.getElementById('root')!).render(<StrictMode><PullRefresh />{solo ? <main className="rcsolo"><RecordingsView app={home} solo /></main> : embed == null ? <App /> : <EmbedApp page={embed} />}</StrictMode>)
@@ -12,6 +12,9 @@
12
12
  --accent:#6b8fb3;--sel:#1a2430;--chk1:#16181b;--chk2:#121417;
13
13
  /* state, and nothing else: red broken · orange taste pending · green measured passing */
14
14
  --red:#d2605c;--warn:#cf9a4e;--ok:#6faa86;--blue:#6f9bd1;
15
+ /* the recorder tray's copy buttons: a blue, a green and a purple dark enough for white text on them (5 to 1 at
16
+ least), the same in the tray, so a copy mode reads the same in both */
17
+ --recfile:#0b63ce;--recwebp:#1a7f43;--reclink:#8a3fc4;--recink:#ffffff;
15
18
  /* the colourless ones: scrims, shadows, masks and the ruler hairlines */
16
19
  --scrim:rgba(0,0,0,.6);--shadow:rgba(0,0,0,.62);--solid:#000;
17
20
  --hi1:rgba(255,255,255,.28);--hi2:rgba(255,255,255,.16);--hi3:rgba(255,255,255,.07);
@@ -38,6 +41,7 @@
38
41
  --bg-side:#e6e9ee;--bg-top:#eaedf1;--bg-dock:#e3e7ec;--panel2:#e3e7ec;--line:#bcc4ce;--ink:#16191d;--dim:#464b51;
39
42
  --accent:#355e87;--sel:#d2e0ef;--chk1:#e3e7ec;--chk2:#f7f8fa;
40
43
  --red:#a83733;--warn:#86550b;--ok:#256e45;--blue:#275fa0;
44
+ --recfile:#0b63ce;--recwebp:#1a7f43;--reclink:#8a3fc4;--recink:#ffffff;
41
45
  --scrim:rgba(20,24,30,.35);--shadow:rgba(20,24,30,.16);--solid:#000;
42
46
  --hi1:rgba(0,0,0,.2);--hi2:rgba(0,0,0,.11);--hi3:rgba(0,0,0,.045);
43
47
  --ground:#e3ede6;--groundline:#c6d6cb;--tag:#eef2f6;
@@ -53,6 +57,20 @@
53
57
  .idb{background:var(--idd)}
54
58
  :root[data-theme=light] .idb{background:var(--idl)}
55
59
  *{box-sizing:border-box}html,body,#root{height:100%}
60
+ /* react-resizable-panels writes touch-action pan-x or pan-y inline on every group and on the div inside every panel,
61
+ and they wrap the whole page: a phone could not pinch anywhere. Its separators keep their own none, so a drag still
62
+ resizes */
63
+ [data-group],[data-panel]>div{touch-action:manipulation!important}
64
+ /* the pull to refresh arrow (pull-refresh.tsx), over every sheet of the phone */
65
+ .ptr{position:fixed;top:env(safe-area-inset-top);left:50%;z-index:200;width:36px;height:36px;display:flex;align-items:center;
66
+ justify-content:center;border-radius:50%;background:var(--panel);border:1px solid var(--line);box-shadow:0 2px 10px var(--shadow);
67
+ color:var(--dim);font-size:20px;line-height:1;transform:translate(-50%,-48px);opacity:0;pointer-events:none;
68
+ transition:transform .2s,opacity .2s}
69
+ .ptr.drag{transition:none}
70
+ .ptr.armed{color:var(--accent);border-color:var(--accent)}
71
+ .ptr.go{animation:ptrspin .7s linear infinite}
72
+ @keyframes ptrspin{to{rotate:360deg}}
73
+ @media (prefers-reduced-motion:reduce){.ptr{transition:none}.ptr.go{animation:none}}
56
74
  body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.5 system-ui,sans-serif;overflow:hidden}
57
75
  /* a link with no class of its own: the browser default is dark blue on this dark page */
58
76
  a,a:visited{color:var(--accent)}
@@ -80,5 +80,6 @@ a.ib-hub svg{width:14px;height:14px}
80
80
  .ib-phone .rv-back{min-width:44px;min-height:44px}
81
81
  .ib-phone input,.ib-phone textarea,.ib-phone select{font-size:16px}
82
82
  .ib-phone .ib-pane button,.ib-sheet button{min-height:44px}
83
+ .ib-phone .ib-pane .seg,.ib-sheet .seg{height:auto}
83
84
  .ib-phone .stagewrap{padding:var(--s3)}
84
85
  .ib-phone .colcard input{min-width:0}
@@ -0,0 +1,88 @@
1
+ // pull to refresh on a touch screen. The page is an app shell (body overflow hidden, the panes scroll inside, hub.css),
2
+ // so the browser's own pull never starts, and the home installed on a phone (standalone) has none at all. One finger
3
+ // that pulls down where nothing under it is scrolled draws the arrow; let go past the mark and the page reloads.
4
+ // Mounted once for every page (hub-app.tsx); a mouse first screen renders nothing
5
+ import { useEffect, useRef } from 'react'
6
+
7
+ /** finger travel before a drag counts as a pull, so a tap or a sideways swipe never shows the arrow */
8
+ const DEAD_PX = 12
9
+ /** the arrow's travel, half the finger's, that reloads on release */
10
+ const ARM_PX = 72
11
+ const MAX_PX = 110
12
+
13
+ const TOUCH = typeof window !== 'undefined' && window.parent === window && typeof window.matchMedia === 'function' && window.matchMedia('(pointer: coarse)').matches
14
+
15
+ /** a touch that starts here pulls the page: nothing under it scrolled down, nothing under it that keeps the touch for
16
+ * itself (touch-action none: a separator, a surface a drag draws on), and the page not pinch zoomed in */
17
+ function pullsFrom(target: EventTarget | null): boolean {
18
+ if ((window.visualViewport?.scale ?? 1) > 1.01) return false
19
+ for (let el = target instanceof Element ? target : null; el != null; el = el.parentElement) {
20
+ if (el.scrollTop > 0) return false
21
+ if (getComputedStyle(el).touchAction === 'none') return false
22
+ }
23
+ return true
24
+ }
25
+
26
+ export function PullRefresh() {
27
+ const ref = useRef<HTMLDivElement | null>(null)
28
+ useEffect(() => {
29
+ const el = ref.current
30
+ if (el == null) return
31
+ let from: { x: number; y: number } | null = null
32
+ let pull = -1
33
+ const draw = (px: number) => {
34
+ el.style.transform = `translate(-50%, ${px - 48}px) rotate(${px * 3}deg)`
35
+ el.style.opacity = String(Math.min(1, px / ARM_PX))
36
+ el.classList.toggle('armed', px >= ARM_PX)
37
+ }
38
+ const reset = () => {
39
+ from = null
40
+ pull = -1
41
+ el.classList.remove('drag', 'armed')
42
+ el.style.transform = ''
43
+ el.style.opacity = ''
44
+ }
45
+ const onStart = (e: TouchEvent) => {
46
+ if (e.touches.length !== 1 || !pullsFrom(e.target)) return reset()
47
+ const t = e.touches[0]!
48
+ from = { x: t.clientX, y: t.clientY }
49
+ }
50
+ const onMove = (e: TouchEvent) => {
51
+ if (from == null) return
52
+ // a second finger is a pinch: the pull lets go of it
53
+ if (e.touches.length !== 1) return reset()
54
+ const t = e.touches[0]!
55
+ const dx = t.clientX - from.x
56
+ const dy = t.clientY - from.y
57
+ if (pull < 0) {
58
+ if (Math.abs(dx) < DEAD_PX && Math.abs(dy) < DEAD_PX) return
59
+ if (dy <= Math.abs(dx)) return reset()
60
+ el.classList.add('drag')
61
+ }
62
+ pull = Math.min(MAX_PX, Math.max(0, (dy - DEAD_PX) / 2))
63
+ draw(pull)
64
+ }
65
+ const onEnd = (e: TouchEvent) => {
66
+ if (pull >= ARM_PX && e.type === 'touchend') {
67
+ el.classList.remove('drag')
68
+ el.classList.add('go')
69
+ location.reload()
70
+ return
71
+ }
72
+ reset()
73
+ }
74
+ const opts = { capture: true, passive: true }
75
+ window.addEventListener('touchstart', onStart, opts)
76
+ window.addEventListener('touchmove', onMove, opts)
77
+ window.addEventListener('touchend', onEnd, opts)
78
+ window.addEventListener('touchcancel', onEnd, opts)
79
+ return () => {
80
+ window.removeEventListener('touchstart', onStart, opts)
81
+ window.removeEventListener('touchmove', onMove, opts)
82
+ window.removeEventListener('touchend', onEnd, opts)
83
+ window.removeEventListener('touchcancel', onEnd, opts)
84
+ }
85
+ }, [])
86
+ if (!TOUCH) return null
87
+ return <div ref={ref} className="ptr" aria-hidden="true">↻</div>
88
+ }