rvlib-shipkit 2.8.0 → 2.10.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.
- package/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/checks/SK005-rvlib-versions.check.ts +17 -11
- package/src/cli/cmd_Fleet.ts +8 -5
- package/src/cli/cmd_Review.ts +2 -1
- package/src/core/update-policy.ts +6 -0
- package/src/fleet/commit-bump.ts +123 -0
- package/src/fleet/push-fleet.ts +9 -3
- package/src/fleet/update-fleet.ts +38 -9
- package/src/review/cells.ts +548 -0
- package/src/review/format.ts +1 -1
- package/src/review/model.ts +29 -4
- package/src/review/previews.ts +124 -0
- package/src/review/routes.ts +82 -45
- package/src/review/store.ts +6 -5
- package/src/serve/hub-app/auto-text.tsx +52 -0
- package/src/serve/hub-app/hub.css +2 -0
- package/src/serve/hub-app/media-view.tsx +3 -11
- package/src/serve/hub-app/review/kind-view.tsx +21 -22
- package/src/serve/hub-app/review/kit.tsx +11 -12
- package/src/serve/hub-app/review/review-board.tsx +15 -13
- package/src/serve/hub-app/review/review-cells.tsx +241 -0
- package/src/serve/hub-app/review/review-kit.ts +79 -0
- package/src/serve/hub-app/review/review-list.tsx +87 -122
- package/src/serve/hub-app/review/review-page.tsx +25 -66
- package/src/serve/hub-app/review/review-st.ts +269 -668
- package/src/serve/hub-app/review/review-thread.tsx +301 -0
- package/src/serve/hub-app/review/review-views.tsx +372 -234
- package/src/serve/hub-app/review/thread-st.ts +770 -0
- package/src/serve/hub-app/review/trailer-page.tsx +5 -4
- package/src/serve/hub-app/review.css +252 -90
- package/src/serve/hub-app/review/review-answer.tsx +0 -248
|
@@ -1,47 +1,15 @@
|
|
|
1
|
-
// a repo's review page as state (wiki build/shipkit/review.md, The review page): the
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
isChoice,
|
|
9
|
-
isGallery,
|
|
10
|
-
isPair,
|
|
11
|
-
laneOf,
|
|
12
|
-
moveOf,
|
|
13
|
-
pasteBlock,
|
|
14
|
-
reworkOf,
|
|
15
|
-
STARS,
|
|
16
|
-
STATUS_LABEL,
|
|
17
|
-
stateOf,
|
|
18
|
-
unreadBy,
|
|
19
|
-
verdictOf,
|
|
20
|
-
type MediaView,
|
|
21
|
-
type Message,
|
|
22
|
-
type Move,
|
|
23
|
-
type Rect,
|
|
24
|
-
type ReviewItem,
|
|
25
|
-
type ReviewReaction,
|
|
26
|
-
type ReviewStatus,
|
|
27
|
-
type ShownStatus,
|
|
28
|
-
type Side,
|
|
29
|
-
type Spec,
|
|
30
|
-
} from '../../../review/model.ts'
|
|
31
|
-
import { answererOf, chainOf, childrenOf, conversationOf, followedIds, isActive, membersOf, orderedThreads, statusOf, threadOfItem, waitingOnOwner, waits, type Thread } from '../../../review/threads.ts'
|
|
32
|
-
import { reach } from '../reach.ts'
|
|
33
|
-
import type { RepoSt } from '../repo-st.ts'
|
|
34
|
-
import type { Role } from '../../../review/role.ts'
|
|
1
|
+
// a repo's review page as state (wiki build/shipkit/review.md, The review page): the list as pages of threads
|
|
2
|
+
// (`GET /api/review/threads`, the filters and the search asked of the server), the open card as a thread
|
|
3
|
+
// (thread-st.ts), the watches, the board, his prefs. Every read is polled every 2 s while the page shows and answered
|
|
4
|
+
// 304 when the store did not move. His drafts are kept in the browser until they are sent
|
|
5
|
+
import { makeAutoObservable, observableRef, reaction, runInAction } from 'mobx'
|
|
6
|
+
import { PAGE, type BoardRow, type ThreadPage, type ThreadRow } from '../../../review/cells.ts'
|
|
7
|
+
import { MOVE_LABEL, pasteBlock, STATUS_LABEL, type Move, type ShownStatus, type Spec } from '../../../review/model.ts'
|
|
35
8
|
import type { PasteHosts } from '../../../review/paste.ts'
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
comment: string
|
|
41
|
-
reactions?: ReviewReaction[]
|
|
42
|
-
/** the option he picked, on a choice card */
|
|
43
|
-
pick?: number
|
|
44
|
-
}
|
|
9
|
+
import type { Role } from '../../../review/role.ts'
|
|
10
|
+
import type { RepoSt } from '../repo-st.ts'
|
|
11
|
+
import { copyText, etagLoader, kept, postJson, ZOOMS, type Zoom } from './review-kit.ts'
|
|
12
|
+
import { ThreadSt, type Draft } from './thread-st.ts'
|
|
45
13
|
|
|
46
14
|
/** a live `sk review watch`: its process, the session or lane it keeps, when it started */
|
|
47
15
|
export interface Watcher {
|
|
@@ -51,61 +19,25 @@ export interface Watcher {
|
|
|
51
19
|
started: string
|
|
52
20
|
}
|
|
53
21
|
|
|
54
|
-
export interface Listing {
|
|
55
|
-
items: ReviewItem[]
|
|
56
|
-
broken: { id: string; error: string }[]
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** the zoom of a view: fit the column (and the window's height), or a share of the image's own pixels */
|
|
60
|
-
export const ZOOMS = ['fit', '1', '1.5', '2'] as const
|
|
61
|
-
export type Zoom = (typeof ZOOMS)[number]
|
|
62
|
-
|
|
63
22
|
/** how a pair of images shows: side by side, the curtain, one over the other, the after alone */
|
|
64
23
|
export type CompareMode = 'side' | 'swipe' | 'onion' | 'mod'
|
|
65
24
|
export const COMPARE_MODES: readonly CompareMode[] = ['side', 'swipe', 'onion', 'mod']
|
|
66
25
|
/** the side a rectangle lands on: the after alone draws on the after */
|
|
67
|
-
export const drawnSide = (mode: CompareMode, drawn:
|
|
26
|
+
export const drawnSide = (mode: CompareMode, drawn: 'before' | 'after'): 'before' | 'after' => (mode === 'mod' ? 'after' : drawn)
|
|
68
27
|
|
|
69
|
-
/** below this width the page is the phone's: one column at a time, the verdicts in a bar under the thumb */
|
|
70
28
|
/** a repo's review unit as the page reads it: the words of its kinds and topics, its dispatcher and who holds the role */
|
|
71
29
|
export type RepoSpec = Spec & { role: Role | null; sources: string[]; auto: { id: string; every: string }[]; where?: PasteHosts | null }
|
|
72
30
|
|
|
31
|
+
/** below this width the page is the phone's: one pane at a time, the verdicts in a bar under the thumb */
|
|
73
32
|
export const PHONE_PX = 768
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
export
|
|
77
|
-
/** where the card sits against its answer: on top of it, left of it, or by the page's width */
|
|
78
|
-
export const CARD_PLACES = ['top', 'left', 'auto'] as const
|
|
79
|
-
export type CardPlace = (typeof CARD_PLACES)[number]
|
|
80
|
-
export type PhonePane = 'list' | 'card' | 'answer'
|
|
33
|
+
/** the thread column at least this wide shows the contents strip beside the cells, else behind a button */
|
|
34
|
+
export const RAIL_PX = 1020
|
|
35
|
+
export type PhonePane = 'list' | 'card'
|
|
81
36
|
export type PairSide = 'before' | 'after' | 'swipe'
|
|
82
37
|
|
|
83
38
|
const POLL_MS = 2000
|
|
84
|
-
/**
|
|
85
|
-
const
|
|
86
|
-
/** ← → on a sound jump this many seconds */
|
|
87
|
-
const SOUND_JUMP = 2
|
|
88
|
-
|
|
89
|
-
const sameSpot = (r: ReviewReaction, view: number, tile: number | undefined): boolean => r.view === view && r.tile === tile
|
|
90
|
-
|
|
91
|
-
/** what a reload must not lose, under keys of this repo: a blocked storage only loses persistence */
|
|
92
|
-
const store = {
|
|
93
|
-
get(k: string): string | null {
|
|
94
|
-
try {
|
|
95
|
-
return localStorage.getItem(k)
|
|
96
|
-
} catch {
|
|
97
|
-
return null
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
put(k: string, v: string | null): void {
|
|
101
|
-
try {
|
|
102
|
-
if (v === null) localStorage.removeItem(k)
|
|
103
|
-
else localStorage.setItem(k, v)
|
|
104
|
-
} catch {
|
|
105
|
-
// as above
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
}
|
|
39
|
+
/** the search goes to the server once he stops typing this long */
|
|
40
|
+
const SEARCH_MS = 250
|
|
109
41
|
|
|
110
42
|
const draftOf = (s: string | null): Draft | null => {
|
|
111
43
|
try {
|
|
@@ -117,68 +49,19 @@ const draftOf = (s: string | null): Draft | null => {
|
|
|
117
49
|
}
|
|
118
50
|
}
|
|
119
51
|
|
|
120
|
-
/** a loader for a polled list: it sends the tag of its last answer, and on « not modified » gives that answer again */
|
|
121
|
-
function unchangedAware<T>(url: () => string): () => Promise<T> {
|
|
122
|
-
let last: { tag: string; value: T } | null = null
|
|
123
|
-
return async () => {
|
|
124
|
-
const res = await reach(url(), { cache: 'no-store', headers: last ? { 'If-None-Match': last.tag } : {} })
|
|
125
|
-
if (res.status === 304 && last) return last.value
|
|
126
|
-
if (!res.ok) throw new Error(`${url()}: HTTP ${res.status} ${await res.text().catch(() => '')}`.trim())
|
|
127
|
-
const value = (await res.json()) as T
|
|
128
|
-
const tag = res.headers.get('ETag')
|
|
129
|
-
last = tag ? { tag, value } : null
|
|
130
|
-
return value
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async function postJson<T>(url: string, body: unknown): Promise<T> {
|
|
135
|
-
const res = await reach(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })
|
|
136
|
-
const text = await res.text()
|
|
137
|
-
if (!res.ok) {
|
|
138
|
-
let msg = text
|
|
139
|
-
try {
|
|
140
|
-
msg = (JSON.parse(text) as { error?: string }).error ?? text
|
|
141
|
-
} catch {
|
|
142
|
-
// a plain text answer says it already
|
|
143
|
-
}
|
|
144
|
-
throw new Error(msg || `HTTP ${res.status}`)
|
|
145
|
-
}
|
|
146
|
-
return JSON.parse(text) as T
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/** a text to the clipboard: the clipboard api, else (a page over plain http, the phone through a public host) the
|
|
150
|
-
* old copy command on a hidden field */
|
|
151
|
-
async function copyText(text: string): Promise<boolean> {
|
|
152
|
-
try {
|
|
153
|
-
await navigator.clipboard.writeText(text)
|
|
154
|
-
return true
|
|
155
|
-
} catch {
|
|
156
|
-
const el = document.createElement('textarea')
|
|
157
|
-
el.value = text
|
|
158
|
-
el.setAttribute('readonly', '')
|
|
159
|
-
el.style.position = 'fixed'
|
|
160
|
-
el.style.opacity = '0'
|
|
161
|
-
document.body.appendChild(el)
|
|
162
|
-
el.select()
|
|
163
|
-
const ok = document.execCommand('copy')
|
|
164
|
-
el.remove()
|
|
165
|
-
return ok
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
52
|
/** the pair's compare mode, the curtain's line and the onion's opacity, shared by every pair of the page */
|
|
170
53
|
export class CompareSt {
|
|
171
54
|
mode: CompareMode = 'side'
|
|
172
55
|
split = 0.5
|
|
173
56
|
opacity = 0.5
|
|
174
57
|
constructor(private readonly key: string) {
|
|
175
|
-
const m =
|
|
58
|
+
const m = kept.get(key)
|
|
176
59
|
if (m && (COMPARE_MODES as readonly string[]).includes(m)) this.mode = m as CompareMode
|
|
177
60
|
makeAutoObservable<this, 'key'>(this, { key: false })
|
|
178
61
|
}
|
|
179
62
|
setMode(m: CompareMode): void {
|
|
180
63
|
this.mode = m
|
|
181
|
-
|
|
64
|
+
kept.put(this.key, m)
|
|
182
65
|
}
|
|
183
66
|
setSplit(v: number): void {
|
|
184
67
|
this.split = Math.max(0, Math.min(1, v))
|
|
@@ -188,7 +71,7 @@ export class CompareSt {
|
|
|
188
71
|
}
|
|
189
72
|
}
|
|
190
73
|
|
|
191
|
-
/** the phone's state: which pane shows, « circle » drawing on, the side of a pair */
|
|
74
|
+
/** the phone's state: which pane shows, « circle » drawing on, the side of a pair, the contents sheet */
|
|
192
75
|
export class PhoneSt {
|
|
193
76
|
on = false
|
|
194
77
|
pane: PhonePane = 'list'
|
|
@@ -216,136 +99,116 @@ export class PhoneSt {
|
|
|
216
99
|
const isShownStatus = (s: string): s is ShownStatus => Object.hasOwn(STATUS_LABEL, s)
|
|
217
100
|
|
|
218
101
|
export class ReviewSt {
|
|
219
|
-
|
|
102
|
+
page: ThreadPage | null = null
|
|
220
103
|
listError: string | null = null
|
|
221
|
-
/** the
|
|
104
|
+
/** the rows asked of the server: a page more on « more » or when the list's end scrolls into view */
|
|
105
|
+
shown = PAGE
|
|
106
|
+
/** the repo's review unit in words, read when the page starts */
|
|
222
107
|
spec: RepoSpec | null = null
|
|
223
108
|
/** the dispatcher's board in place of the cards */
|
|
224
109
|
board = false
|
|
110
|
+
boardRows: BoardRow[] | null = null
|
|
225
111
|
watchers: Watcher[] = []
|
|
226
|
-
/** each clip view's own clock on the open card, by view index, made on first use */
|
|
227
|
-
private readonly clips = new Map<number, ClipSt>()
|
|
228
|
-
private clipsCard = ''
|
|
229
112
|
selectedId: string | null = null
|
|
113
|
+
/** the card opened with none named (the list's first row then): it stays open until he picks another */
|
|
114
|
+
pinned: string | null = null
|
|
115
|
+
/** the open card as a thread: made when a card opens */
|
|
116
|
+
card: ThreadSt | null = null
|
|
117
|
+
/** what the search box holds; `q` is what the server was asked, once he stopped typing */
|
|
230
118
|
query = ''
|
|
119
|
+
q = ''
|
|
231
120
|
subject: string | null = null
|
|
232
121
|
whose: Move | null = null
|
|
233
122
|
status: ShownStatus | null = null
|
|
234
|
-
drafts: Record<string, Draft> = {}
|
|
235
|
-
/** the rectangle of the open card picked on the image, its index */
|
|
236
|
-
rect: number | null = null
|
|
237
|
-
/** the subject rings over the image (M) */
|
|
238
|
-
marksOn = true
|
|
239
|
-
/** the open card's active view, its index: the one last drawn on or picked, whose clip the keys drive */
|
|
240
|
-
view = 0
|
|
241
|
-
zoom: Zoom = 'fit'
|
|
242
|
-
viewZoom: Record<number, Zoom> = {}
|
|
243
|
-
/** the gallery tile shown large across the column, `<view>/<tile>` */
|
|
244
|
-
bigTile: string | null = null
|
|
245
|
-
/** a card of options shown full, every view stacked, by id: his switch, this visit */
|
|
246
|
-
full: Record<string, boolean> = {}
|
|
247
|
-
/** the option rows unfolded to their full view, by view index */
|
|
248
|
-
openRows: Record<number, boolean> = {}
|
|
249
|
-
replies: Record<string, string> = {}
|
|
250
|
-
private reading = new Set<string>()
|
|
251
123
|
/** « hide handled »: only the active threads in the list */
|
|
252
124
|
hideHandled = true
|
|
253
125
|
/** « by lane »: the list grouped under one header per lane */
|
|
254
126
|
byLane = false
|
|
255
|
-
/** the
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
127
|
+
/** the subject rings over the image (M) */
|
|
128
|
+
marksOn = true
|
|
129
|
+
zoom: Zoom = 'fit'
|
|
130
|
+
/** the contents strip beside the cells, when the column is wide enough; folded by hand */
|
|
131
|
+
railOn = true
|
|
132
|
+
/** the contents as a sheet over the cells: a narrow column or the phone */
|
|
133
|
+
sheet = false
|
|
134
|
+
/** the thread column's width, measured */
|
|
135
|
+
width = 0
|
|
259
136
|
/** what the last copy put on the clipboard, in words, shown a moment */
|
|
260
137
|
toast: string | null = null
|
|
261
|
-
private toastTimer: ReturnType<typeof setTimeout> | null = null
|
|
262
|
-
/** the card against its answer, his pick, kept with the prefs */
|
|
263
|
-
place: CardPlace = 'auto'
|
|
264
|
-
/** the page is narrower than STACK_PX */
|
|
265
|
-
narrow = false
|
|
266
138
|
readonly compare: CompareSt
|
|
267
139
|
readonly phone = new PhoneSt()
|
|
140
|
+
/** the view a link names before its card is made */
|
|
141
|
+
pendingView = 0
|
|
142
|
+
private toastTimer: ReturnType<typeof setTimeout> | null = null
|
|
143
|
+
private searchTimer: ReturnType<typeof setTimeout> | null = null
|
|
268
144
|
private timer: ReturnType<typeof setInterval> | null = null
|
|
269
|
-
private readonly
|
|
145
|
+
private readonly loadPage: () => Promise<ThreadPage>
|
|
270
146
|
private readonly loadWatchers: () => Promise<Watcher[]>
|
|
147
|
+
private readonly loadBoard: () => Promise<{ role: Role | null; rows: BoardRow[] }>
|
|
271
148
|
private readonly prefix: string
|
|
272
149
|
|
|
273
|
-
/** the page measured its width */
|
|
274
|
-
fit(px: number): void {
|
|
275
|
-
const on = px > 0 && px < STACK_PX
|
|
276
|
-
if (this.narrow !== on) this.narrow = on
|
|
277
|
-
}
|
|
278
|
-
/** the card over its answer in one column: picked, or `auto` on a narrow page */
|
|
279
|
-
get stacked(): boolean {
|
|
280
|
-
return this.place === 'top' || (this.place === 'auto' && this.narrow)
|
|
281
|
-
}
|
|
282
|
-
setPlace(p: CardPlace): void {
|
|
283
|
-
this.place = p
|
|
284
|
-
}
|
|
285
|
-
/** the open card as thin option rows: a choice, or views that each play alone, unless he asked them full */
|
|
286
|
-
get rows(): boolean {
|
|
287
|
-
const x = this.open
|
|
288
|
-
return x !== null && asOptions(x.item) && this.full[x.item.id] !== true
|
|
289
|
-
}
|
|
290
|
-
setFull(on: boolean): void {
|
|
291
|
-
const id = this.open?.item.id
|
|
292
|
-
if (id) this.full = { ...this.full, [id]: on }
|
|
293
|
-
}
|
|
294
|
-
get choice(): boolean {
|
|
295
|
-
const x = this.open
|
|
296
|
-
return x !== null && isChoice(x.item)
|
|
297
|
-
}
|
|
298
|
-
/** the card's header (title, state, what, and in one column the verdicts) sits over its views: one column, the
|
|
299
|
-
* phone's card pane, a choice's options */
|
|
300
|
-
get headInViews(): boolean {
|
|
301
|
-
return this.stacked || this.phone.on || this.choice
|
|
302
|
-
}
|
|
303
|
-
toggleRow(i: number): void {
|
|
304
|
-
this.openRows = { ...this.openRows, [i]: !this.openRows[i] }
|
|
305
|
-
}
|
|
306
|
-
|
|
307
150
|
constructor(private readonly st: RepoSt) {
|
|
308
151
|
this.prefix = `shipkit.review.${st.key}.`
|
|
309
|
-
this.
|
|
310
|
-
this.loadWatchers =
|
|
152
|
+
this.loadPage = etagLoader(() => st.url(`/api/review/threads?${this.listQuery}`))
|
|
153
|
+
this.loadWatchers = etagLoader(() => st.url('/api/review/watchers'))
|
|
154
|
+
this.loadBoard = etagLoader(() => st.url('/api/review/board'))
|
|
311
155
|
this.compare = new CompareSt(`${this.prefix}compare`)
|
|
312
156
|
try {
|
|
313
|
-
const p = JSON.parse(
|
|
157
|
+
const p = JSON.parse(kept.get(`${this.prefix}prefs`) ?? '{}') as { hideHandled?: boolean; byLane?: boolean; zoom?: string; marks?: boolean; rail?: boolean }
|
|
314
158
|
if (p.hideHandled === false) this.hideHandled = false
|
|
315
159
|
if (p.byLane === true) this.byLane = true
|
|
316
160
|
if (p.marks === false) this.marksOn = false
|
|
161
|
+
if (p.rail === false) this.railOn = false
|
|
317
162
|
if ((ZOOMS as readonly string[]).includes(p.zoom ?? '')) this.zoom = p.zoom as Zoom
|
|
318
|
-
if ((CARD_PLACES as readonly string[]).includes(p.place ?? '')) this.place = p.place as CardPlace
|
|
319
163
|
} catch {
|
|
320
164
|
// a broken pref is the default
|
|
321
165
|
}
|
|
322
|
-
makeAutoObservable<this, 'st' | '
|
|
166
|
+
makeAutoObservable<this, 'st' | 'toastTimer' | 'searchTimer' | 'timer' | 'loadPage' | 'loadWatchers' | 'loadBoard' | 'prefix'>(this, {
|
|
323
167
|
st: false,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
reading: false,
|
|
168
|
+
toastTimer: false,
|
|
169
|
+
searchTimer: false,
|
|
327
170
|
timer: false,
|
|
328
|
-
|
|
171
|
+
loadPage: false,
|
|
329
172
|
loadWatchers: false,
|
|
173
|
+
loadBoard: false,
|
|
330
174
|
prefix: false,
|
|
331
|
-
toastTimer: false,
|
|
332
175
|
compare: false,
|
|
333
176
|
phone: false,
|
|
177
|
+
card: observableRef,
|
|
178
|
+
page: observableRef,
|
|
179
|
+
boardRows: observableRef,
|
|
334
180
|
})
|
|
335
|
-
// opening a card reads the agent's messages on its whole thread
|
|
336
181
|
reaction(
|
|
337
|
-
() => (this.
|
|
338
|
-
(
|
|
339
|
-
|
|
340
|
-
|
|
182
|
+
() => JSON.stringify({ hideHandled: this.hideHandled, byLane: this.byLane, zoom: this.zoom, marks: this.marksOn, rail: this.railOn }),
|
|
183
|
+
(s) => kept.put(`${this.prefix}prefs`, s),
|
|
184
|
+
)
|
|
185
|
+
// the card the address names, else the list's first: a new one is a new thread state, the old one disposed
|
|
186
|
+
reaction(
|
|
187
|
+
() => this.openId,
|
|
188
|
+
(id) => this.openCard(id),
|
|
189
|
+
{ fireImmediately: true },
|
|
341
190
|
)
|
|
191
|
+
// a filter moved: the list asks its first page again
|
|
342
192
|
reaction(
|
|
343
|
-
() =>
|
|
344
|
-
(
|
|
193
|
+
() => this.listFilters,
|
|
194
|
+
() => {
|
|
195
|
+
this.shown = PAGE
|
|
196
|
+
if (this.timer !== null) void this.refresh()
|
|
197
|
+
},
|
|
345
198
|
)
|
|
346
199
|
}
|
|
347
200
|
|
|
348
|
-
/**
|
|
201
|
+
/** an absolute hub path as this repo's hub answers it */
|
|
202
|
+
url(p: string): string {
|
|
203
|
+
return this.st.url(p)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** the repo's one second clock: every « 3h ago » of the page reads it */
|
|
207
|
+
get now(): number {
|
|
208
|
+
return this.st.clock.now
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** the list, the watches and the open card, read now and every 2 s while the page shows; the unit's words once */
|
|
349
212
|
start(): void {
|
|
350
213
|
void this.refresh()
|
|
351
214
|
void fetch(this.st.url('/api/review/spec'))
|
|
@@ -361,171 +224,118 @@ export class ReviewSt {
|
|
|
361
224
|
}
|
|
362
225
|
|
|
363
226
|
async refresh(): Promise<void> {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
227
|
+
const card = this.card
|
|
228
|
+
await Promise.all([
|
|
229
|
+
this.loadPage().then(
|
|
230
|
+
(page) => runInAction(() => {
|
|
231
|
+
if (page !== this.page) this.page = page
|
|
232
|
+
this.listError = null
|
|
233
|
+
}),
|
|
234
|
+
(e: Error) => runInAction(() => (this.listError = e.message)),
|
|
235
|
+
),
|
|
236
|
+
this.loadWatchers().then(
|
|
237
|
+
(w) => runInAction(() => w !== this.watchers && (this.watchers = w)),
|
|
238
|
+
() => undefined,
|
|
239
|
+
),
|
|
240
|
+
this.board ? this.loadBoard().then((b) => runInAction(() => b.rows !== this.boardRows && (this.boardRows = b.rows)), () => undefined) : null,
|
|
241
|
+
card?.refresh(),
|
|
242
|
+
])
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** a verdict or a reply went out: the card, the list, the tree's count and the project list's pill move at once */
|
|
246
|
+
async answered(): Promise<void> {
|
|
247
|
+
await this.refresh()
|
|
248
|
+
void this.st.cols.poll(true)
|
|
249
|
+
void this.st.home.projects.load()
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private openCard(id: string | null): void {
|
|
253
|
+
if (this.card?.id === id) return
|
|
254
|
+
// an id of the open thread (an old version's link) stays in it: the cell shows, nothing is rebuilt
|
|
255
|
+
if (id !== null && this.card?.data?.members.includes(id)) {
|
|
256
|
+
this.card.reveal(id)
|
|
257
|
+
return
|
|
382
258
|
}
|
|
259
|
+
// the list's first row opened with no card named stays open: a poll that reorders the list never swaps it
|
|
260
|
+
if (this.selectedId === null && id !== null) this.pinned = id
|
|
261
|
+
this.card?.dispose()
|
|
262
|
+
this.card = id === null ? null : new ThreadSt(this, id, this.pendingView)
|
|
263
|
+
this.pendingView = 0
|
|
264
|
+
if (this.card && this.timer !== null) void this.card.refresh()
|
|
383
265
|
}
|
|
384
266
|
|
|
385
|
-
|
|
386
|
-
* it whole, its link here and on the phone (C) */
|
|
387
|
-
async copyCard(): Promise<void> {
|
|
388
|
-
const x = this.open
|
|
389
|
-
if (!x) return
|
|
390
|
-
const id = x.item.id
|
|
391
|
-
const w = this.spec?.where
|
|
392
|
-
const here = typeof location === 'undefined' ? (w?.open ?? '') : `${location.origin}${location.pathname}${location.search}`
|
|
393
|
-
const text = pasteBlock(x.item, STATUS_LABEL[this.statusOf(x)], {
|
|
394
|
-
root: w?.root ?? '<the repo>',
|
|
395
|
-
open: `${here}#page:review:${id}`,
|
|
396
|
-
phone: w?.phone ? `${w.phone}#page:review:${id}` : null,
|
|
397
|
-
})
|
|
398
|
-
const ok = await copyText(text)
|
|
399
|
-
runInAction(() => {
|
|
400
|
-
this.toast = ok ? `copied for an agent: title, repo, sk review show, ${w?.phone ? 'links' : 'link'}` : 'the browser refused the copy'
|
|
401
|
-
if (this.toastTimer !== null) clearTimeout(this.toastTimer)
|
|
402
|
-
this.toastTimer = setTimeout(() => runInAction(() => (this.toast = null)), 2600)
|
|
403
|
-
})
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
setBoard(on: boolean): void {
|
|
407
|
-
this.board = on
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
fileUrl(id: string, name: string): string {
|
|
411
|
-
return this.st.url(`/api/review/${id}/${name}`)
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
thumbUrl(x: ReviewItem, name: string): string {
|
|
415
|
-
return /\.(png|jpe?g|webp)$/.test(name) ? this.st.url(`/api/review/${x.item.id}/thumb/${name}`) : this.fileUrl(x.item.id, name)
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
threadImageUrl(id: string, name: string): string {
|
|
419
|
-
return this.st.url(`/api/review/${id}/thread/${name}`)
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
get items(): ReviewItem[] {
|
|
423
|
-
return this.list?.items ?? []
|
|
424
|
-
}
|
|
267
|
+
// ── the list ──
|
|
425
268
|
|
|
426
|
-
|
|
427
|
-
|
|
269
|
+
/** the filters the server is asked, in its keys */
|
|
270
|
+
get listFilters(): string {
|
|
271
|
+
const p = new URLSearchParams()
|
|
272
|
+
if (!this.hideHandled) p.set('handled', '1')
|
|
273
|
+
if (this.subject !== null) p.set('subject', this.subject)
|
|
274
|
+
if (this.whose !== null) p.set('whose', this.whose)
|
|
275
|
+
if (this.status !== null) p.set('status', this.status)
|
|
276
|
+
if (this.q) p.set('q', this.q)
|
|
277
|
+
return p.toString()
|
|
428
278
|
}
|
|
429
279
|
|
|
430
|
-
|
|
431
|
-
|
|
280
|
+
get listQuery(): string {
|
|
281
|
+
const f = this.listFilters
|
|
282
|
+
return `${f ? `${f}&` : ''}limit=${this.shown}`
|
|
432
283
|
}
|
|
433
284
|
|
|
434
|
-
get
|
|
435
|
-
return
|
|
285
|
+
get rows(): ThreadRow[] {
|
|
286
|
+
return this.page?.rows ?? []
|
|
436
287
|
}
|
|
437
288
|
|
|
438
|
-
|
|
439
|
-
|
|
289
|
+
/** more rows sit on the server past the ones shown */
|
|
290
|
+
get more(): number {
|
|
291
|
+
return Math.max(0, (this.page?.total ?? 0) - this.rows.length)
|
|
440
292
|
}
|
|
441
293
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
)
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
get threads(): Thread[] {
|
|
450
|
-
return orderedThreads(this.items)
|
|
294
|
+
showMore(): void {
|
|
295
|
+
if (this.more === 0 || this.page === null || this.page.limit < this.shown) return
|
|
296
|
+
this.shown += PAGE
|
|
297
|
+
void this.refresh()
|
|
451
298
|
}
|
|
452
299
|
|
|
453
300
|
/** what waits on the owner, the one count of every surface (collections/review.ts waitingCards) */
|
|
454
301
|
get pendingCount(): number {
|
|
455
|
-
return
|
|
302
|
+
return this.page?.counts.waiting ?? 0
|
|
456
303
|
}
|
|
457
304
|
|
|
458
305
|
get activeCount(): number {
|
|
459
|
-
return this.
|
|
306
|
+
return this.page?.counts.active ?? 0
|
|
460
307
|
}
|
|
461
308
|
|
|
462
|
-
/** the subject kinds this store holds, for the filter */
|
|
463
309
|
get subjects(): string[] {
|
|
464
|
-
return
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/** the list as the switch, the filters and the search show it: one thread per head */
|
|
468
|
-
get visible(): Thread[] {
|
|
469
|
-
const q = this.query.trim().toLowerCase()
|
|
470
|
-
return this.threads.filter(
|
|
471
|
-
(t) =>
|
|
472
|
-
(!this.hideHandled || isActive(t)) &&
|
|
473
|
-
(this.subject === null || t.head.item.subject.kind === this.subject) &&
|
|
474
|
-
(this.whose === null || this.moveOf(t.head) === this.whose) &&
|
|
475
|
-
(this.status === null || this.statusOf(t.head) === this.status) &&
|
|
476
|
-
(q === '' || membersOf(t).some((x) => `${x.item.title} ${x.item.what ?? ''} ${x.item.id}`.toLowerCase().includes(q))),
|
|
477
|
-
)
|
|
310
|
+
return this.page?.subjects ?? []
|
|
478
311
|
}
|
|
479
312
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
const groups = new Map<string | null, Thread[]>()
|
|
483
|
-
for (const t of this.visible) {
|
|
484
|
-
const lane = laneOf(t.head) ?? null
|
|
485
|
-
groups.set(lane, [...(groups.get(lane) ?? []), t])
|
|
486
|
-
}
|
|
487
|
-
const all = [...groups].map(([lane, threads]) => ({ lane, threads }))
|
|
488
|
-
return [...all.filter((g) => g.lane !== null), ...all.filter((g) => g.lane === null)]
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
get open(): ReviewItem | null {
|
|
492
|
-
return this.items.find((x) => x.item.id === this.selectedId) ?? this.visible[0]?.head ?? this.threads[0]?.head ?? null
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
get openThread(): Thread | null {
|
|
496
|
-
const id = this.open?.item.id
|
|
497
|
-
return id === undefined ? null : threadOfItem(id, this.threads)
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/** the reports and notes nested in the open card */
|
|
501
|
-
get answered(): ReviewItem[] {
|
|
502
|
-
const t = this.openThread
|
|
503
|
-
const id = this.open?.item.id
|
|
504
|
-
return t && t.versions.some((x) => x.item.id === id) ? t.answers : []
|
|
313
|
+
get broken(): ThreadPage['broken'] {
|
|
314
|
+
return this.page?.broken ?? []
|
|
505
315
|
}
|
|
506
316
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
get history(): ReviewItem[] {
|
|
514
|
-
const x = this.open
|
|
515
|
-
return x ? chainOf(x, this.items).slice(1) : []
|
|
317
|
+
/** the rows under one header per lane; null: the rows with no lane */
|
|
318
|
+
get laneGroups(): { lane: string | null; rows: ThreadRow[] }[] {
|
|
319
|
+
const groups = new Map<string | null, ThreadRow[]>()
|
|
320
|
+
for (const r of this.rows) groups.set(r.lane ?? null, [...(groups.get(r.lane ?? null) ?? []), r])
|
|
321
|
+
const all = [...groups].map(([lane, rows]) => ({ lane, rows }))
|
|
322
|
+
return [...all.filter((g) => g.lane !== null), ...all.filter((g) => g.lane === null)]
|
|
516
323
|
}
|
|
517
324
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
return
|
|
325
|
+
/** the card shown: the one the address names, else the list's first */
|
|
326
|
+
get openId(): string | null {
|
|
327
|
+
return this.selectedId ?? this.pinned ?? this.rows[0]?.head ?? null
|
|
521
328
|
}
|
|
522
329
|
|
|
523
|
-
|
|
524
|
-
|
|
330
|
+
/** the list's row of the open card: the one whose thread holds its id */
|
|
331
|
+
get openRow(): ThreadRow | null {
|
|
332
|
+
const id = this.card?.data?.head ?? this.openId
|
|
333
|
+
return id === null ? null : (this.rows.find((r) => r.head === id || r.ids.includes(id)) ?? null)
|
|
525
334
|
}
|
|
526
335
|
|
|
527
|
-
|
|
528
|
-
|
|
336
|
+
/** the live watches that read his answer on any of these threads */
|
|
337
|
+
listenersOf(heads: readonly { lane?: string | undefined; session?: string | undefined }[]): Watcher[] {
|
|
338
|
+
return this.watchers.filter((w) => heads.some((h) => (w.session === null || h.session === w.session) && (w.lane === null || h.lane === w.lane)))
|
|
529
339
|
}
|
|
530
340
|
|
|
531
341
|
setHideHandled(on: boolean): void {
|
|
@@ -536,8 +346,16 @@ export class ReviewSt {
|
|
|
536
346
|
this.byLane = on
|
|
537
347
|
}
|
|
538
348
|
|
|
349
|
+
setBoard(on: boolean): void {
|
|
350
|
+
this.board = on
|
|
351
|
+
if (on) void this.refresh()
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** the search box: the server is asked once he stops typing */
|
|
539
355
|
setQuery(q: string): void {
|
|
540
356
|
this.query = q
|
|
357
|
+
if (this.searchTimer !== null) clearTimeout(this.searchTimer)
|
|
358
|
+
this.searchTimer = setTimeout(() => runInAction(() => (this.q = this.query.trim().toLowerCase())), q === '' ? 0 : SEARCH_MS)
|
|
541
359
|
}
|
|
542
360
|
|
|
543
361
|
setFilter(f: { subject?: string | null; whose?: Move | null; status?: ShownStatus | null }): void {
|
|
@@ -546,52 +364,14 @@ export class ReviewSt {
|
|
|
546
364
|
if (f.status !== undefined) this.status = f.status
|
|
547
365
|
}
|
|
548
366
|
|
|
549
|
-
|
|
550
|
-
return moveOf(stateOf(x, this.followed.has(x.item.id)).state)
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
/** what the form edits: the draft, else the sent feedback, else nothing yet */
|
|
554
|
-
get draft(): Draft {
|
|
555
|
-
const x = this.open
|
|
556
|
-
if (!x) return { rects: [], comment: '' }
|
|
557
|
-
const v = verdictOf(x)
|
|
558
|
-
const sent = v?.reactions
|
|
559
|
-
return (
|
|
560
|
-
this.drafts[x.item.id] ?? {
|
|
561
|
-
rects: v?.rects ?? [],
|
|
562
|
-
comment: v?.comment ?? '',
|
|
563
|
-
...(sent && sent.length > 0 ? { reactions: sent } : {}),
|
|
564
|
-
...(v?.pick !== undefined ? { pick: v.pick } : {}),
|
|
565
|
-
}
|
|
566
|
-
)
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
get dirty(): boolean {
|
|
570
|
-
const x = this.open
|
|
571
|
-
return x !== null && this.drafts[x.item.id] !== undefined
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
private edit(f: (d: Draft) => Draft): void {
|
|
575
|
-
const x = this.open
|
|
576
|
-
if (!x) return
|
|
577
|
-
const d = this.draft
|
|
578
|
-
const { reactions, ...rest } = f({ ...d, rects: [...d.rects], reactions: [...(d.reactions ?? [])] })
|
|
579
|
-
const next: Draft = reactions && reactions.length > 0 ? { ...rest, reactions } : rest
|
|
580
|
-
this.drafts = { ...this.drafts, [x.item.id]: next }
|
|
581
|
-
store.put(`${this.prefix}draft.${x.item.id}`, JSON.stringify(next))
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
/** opens a card from the page: its address follows */
|
|
585
|
-
pick(id: string): void {
|
|
586
|
-
this.st.showReview(id)
|
|
587
|
-
if (this.phone.on) this.phone.show('card')
|
|
588
|
-
}
|
|
367
|
+
// ── the address ──
|
|
589
368
|
|
|
590
369
|
/** what the address carries beside the card: its view and the list's filters, `view=1&subject=place`, each only
|
|
591
370
|
* off its default (`handled=1` shows the handled threads, `lanes=1` groups by lane) */
|
|
592
371
|
get address(): string {
|
|
593
372
|
const q = new URLSearchParams()
|
|
594
|
-
|
|
373
|
+
const view = this.card?.view ?? this.pendingView
|
|
374
|
+
if (view > 0) q.set('view', String(view))
|
|
595
375
|
if (this.subject !== null) q.set('subject', this.subject)
|
|
596
376
|
if (this.whose !== null) q.set('whose', this.whose)
|
|
597
377
|
if (this.status !== null) q.set('status', this.status)
|
|
@@ -604,347 +384,168 @@ export class ReviewSt {
|
|
|
604
384
|
applyAddress(raw: string): void {
|
|
605
385
|
const q = new URLSearchParams(raw)
|
|
606
386
|
const view = Number(q.get('view'))
|
|
607
|
-
if (Number.isInteger(view) && view > 0)
|
|
387
|
+
if (Number.isInteger(view) && view > 0) {
|
|
388
|
+
if (this.card) this.card.setView(view)
|
|
389
|
+
else this.pendingView = view
|
|
390
|
+
}
|
|
608
391
|
const subject = q.get('subject')
|
|
609
392
|
if (subject) this.subject = subject
|
|
610
393
|
const whose = q.get('whose')
|
|
611
|
-
if (whose
|
|
394
|
+
if (whose !== null && Object.hasOwn(MOVE_LABEL, whose)) this.whose = whose as Move
|
|
612
395
|
const status = q.get('status')
|
|
613
396
|
if (status !== null && isShownStatus(status)) this.status = status
|
|
614
397
|
if (q.get('handled') === '1') this.hideHandled = false
|
|
615
398
|
if (q.get('lanes') === '1') this.byLane = true
|
|
616
399
|
}
|
|
617
400
|
|
|
618
|
-
/** the card the address names
|
|
401
|
+
/** the card the address names */
|
|
619
402
|
select(id: string | null): void {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
this.viewZoom = {}
|
|
623
|
-
this.bigTile = null
|
|
624
|
-
this.openRows = {}
|
|
625
|
-
// a link to a card on the phone opens the card, never the list
|
|
626
|
-
if (id !== null && this.phone.on) this.phone.show('card')
|
|
627
|
-
}
|
|
403
|
+
// a link to a card on the phone opens the card, never the list
|
|
404
|
+
if (id !== null && id !== this.selectedId && this.phone.on) this.phone.show('card')
|
|
628
405
|
this.selectedId = id
|
|
629
|
-
if (id !== null) {
|
|
630
|
-
const stored = draftOf(store.get(`${this.prefix}draft.${id}`))
|
|
631
|
-
if (stored) this.drafts = { ...this.drafts, [id]: stored }
|
|
632
|
-
else if (this.drafts[id]) {
|
|
633
|
-
const { [id]: _, ...rest } = this.drafts
|
|
634
|
-
this.drafts = rest
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
this.rect = null
|
|
638
|
-
this.error = null
|
|
639
406
|
}
|
|
640
407
|
|
|
641
|
-
/**
|
|
408
|
+
/** opens a card from the page: its address follows */
|
|
409
|
+
pick(id: string): void {
|
|
410
|
+
this.st.showReview(id)
|
|
411
|
+
if (this.phone.on) this.phone.show('card')
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** ↑↓ on the page: the next row of the list */
|
|
642
415
|
move(delta: 1 | -1): void {
|
|
643
|
-
const
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
if (next) this.pick(next.head.item.id)
|
|
416
|
+
const at = this.rows.findIndex((r) => r === this.openRow)
|
|
417
|
+
const next = this.rows[Math.max(0, Math.min(this.rows.length - 1, at + delta))]
|
|
418
|
+
if (next) this.pick(next.head)
|
|
647
419
|
}
|
|
648
420
|
|
|
649
|
-
/** N: the next
|
|
421
|
+
/** N: the next card that waits on him after the open one, wrapping */
|
|
650
422
|
nextPending(): void {
|
|
651
|
-
const pend = this.
|
|
423
|
+
const pend = this.rows.filter((r) => r.waits)
|
|
652
424
|
if (pend.length === 0) return
|
|
653
|
-
const at = pend.findIndex((
|
|
425
|
+
const at = pend.findIndex((r) => r === this.openRow)
|
|
654
426
|
const next = pend[(at + 1) % pend.length]
|
|
655
|
-
if (next) this.pick(next.head
|
|
427
|
+
if (next) this.pick(next.head)
|
|
656
428
|
}
|
|
657
429
|
|
|
658
|
-
|
|
659
|
-
addRect(r: { x: number; y: number; w: number; h: number }, side: Side | undefined, on: number = this.view): void {
|
|
660
|
-
if (on !== this.view) this.setView(on)
|
|
661
|
-
const view = this.view > 0 ? { view: this.view } : {}
|
|
662
|
-
const t = this.clipKey ? { t: Math.round(this.clip.time * 1000) / 1000 } : {}
|
|
663
|
-
this.edit((d) => ({ ...d, rects: [...d.rects, { ...r, comment: '', ...view, ...(side ? { side } : {}), ...t }] }))
|
|
664
|
-
this.rect = this.draft.rects.length - 1
|
|
665
|
-
}
|
|
430
|
+
// ── the thread column ──
|
|
666
431
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
this.
|
|
432
|
+
/** the thread column measured its width */
|
|
433
|
+
fit(px: number): void {
|
|
434
|
+
if (this.width !== px) this.width = px
|
|
670
435
|
}
|
|
671
436
|
|
|
672
|
-
/** the
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (!v || isGallery(v)) return null
|
|
676
|
-
return v.clip || (v.audio && this.rows && !isPair(v.files)) ? v : null
|
|
437
|
+
/** the contents strip sits beside the cells */
|
|
438
|
+
get rail(): boolean {
|
|
439
|
+
return this.railOn && !this.phone.on && this.width >= RAIL_PX
|
|
677
440
|
}
|
|
678
441
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
442
|
+
toggleRail(): void {
|
|
443
|
+
if (this.phone.on || this.width < RAIL_PX) this.sheet = !this.sheet
|
|
444
|
+
else this.railOn = !this.railOn
|
|
682
445
|
}
|
|
683
446
|
|
|
684
|
-
|
|
685
|
-
|
|
447
|
+
closeSheet(): void {
|
|
448
|
+
this.sheet = false
|
|
686
449
|
}
|
|
687
450
|
|
|
688
451
|
setZoom(z: Zoom): void {
|
|
689
452
|
this.zoom = z
|
|
690
|
-
this.viewZoom = {}
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
setViewZoom(i: number, z: Zoom): void {
|
|
694
|
-
this.viewZoom = { ...this.viewZoom, [i]: z }
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
toggleTile(view: number, tile: number): void {
|
|
698
|
-
const k = `${view}/${tile}`
|
|
699
|
-
this.bigTile = this.bigTile === k ? null : k
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
reactionOf(view: number, tile?: number): ReviewReaction | null {
|
|
703
|
-
return (this.draft.reactions ?? []).find((r) => sameSpot(r, view, tile)) ?? null
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
/** a reaction's toggle: sets that status, or clears it when it is already the one */
|
|
707
|
-
react(view: number, tile: number | undefined, status: ReviewStatus): void {
|
|
708
|
-
const cur = this.reactionOf(view, tile)
|
|
709
|
-
this.putReaction(view, tile, { ...cur, status: cur?.status === status ? undefined : status, comment: cur?.comment ?? '' })
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
setReactionComment(view: number, tile: number | undefined, comment: string): void {
|
|
713
|
-
this.putReaction(view, tile, { ...this.reactionOf(view, tile), comment })
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
/** an option's stars; the same number again clears them */
|
|
717
|
-
setStars(view: number, n: number): void {
|
|
718
|
-
const cur = this.reactionOf(view)
|
|
719
|
-
this.putReaction(view, undefined, { ...cur, comment: cur?.comment ?? '', stars: cur?.stars === n ? undefined : n })
|
|
720
453
|
}
|
|
721
454
|
|
|
722
|
-
|
|
723
|
-
this.
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/** « pick »: that option is his answer, sent at once as an approval; his stars and words go with it */
|
|
727
|
-
async choose(view: number): Promise<void> {
|
|
728
|
-
if (!this.choice) return
|
|
729
|
-
this.edit((d) => ({ ...d, pick: view }))
|
|
730
|
-
await this.submit('approved')
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
/** the reactions that go to the agent with the verdict, in the card's order */
|
|
734
|
-
get outgoingReactions(): ReviewReaction[] {
|
|
735
|
-
return [...(this.draft.reactions ?? [])].sort((a, b) => a.view - b.view || (a.tile ?? -1) - (b.tile ?? -1))
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
private putReaction(view: number, tile: number | undefined, r: { status?: ReviewStatus | undefined; comment: string; stars?: number | undefined }): void {
|
|
739
|
-
const next: ReviewReaction = { view, ...(tile !== undefined ? { tile } : {}), ...(r.status ? { status: r.status } : {}), comment: r.comment, ...(r.stars ? { stars: r.stars } : {}) }
|
|
740
|
-
const empty = !r.status && r.comment === '' && !r.stars
|
|
741
|
-
this.edit((d) => {
|
|
742
|
-
const rest = (d.reactions ?? []).filter((q) => !sameSpot(q, view, tile))
|
|
743
|
-
return { ...d, reactions: empty ? rest : [...rest, next] }
|
|
744
|
-
})
|
|
455
|
+
toggleMarks(): void {
|
|
456
|
+
this.marksOn = !this.marksOn
|
|
745
457
|
}
|
|
746
458
|
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
return x && this.playableAt(this.view) ? `${x.item.id}#${this.view}` : ''
|
|
459
|
+
setView(i: number): void {
|
|
460
|
+
if (this.card) this.card.setView(i)
|
|
461
|
+
else this.pendingView = i
|
|
751
462
|
}
|
|
752
463
|
|
|
753
|
-
|
|
754
|
-
listen(i: number): void {
|
|
755
|
-
this.setView(i)
|
|
756
|
-
const c = this.clipOf(i)
|
|
757
|
-
if (c.paused) c.listen()
|
|
758
|
-
else c.pause()
|
|
759
|
-
}
|
|
464
|
+
// ── his drafts, kept in the browser ──
|
|
760
465
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
const id = this.open?.item.id ?? ''
|
|
764
|
-
if (id !== this.clipsCard) {
|
|
765
|
-
this.clips.clear()
|
|
766
|
-
this.clipsCard = id
|
|
767
|
-
}
|
|
768
|
-
let c = this.clips.get(view)
|
|
769
|
-
if (!c) {
|
|
770
|
-
c = new ClipSt()
|
|
771
|
-
const views = this.open?.item.views ?? []
|
|
772
|
-
const v = views[view]
|
|
773
|
-
const media = v && !isGallery(v) ? v : undefined
|
|
774
|
-
// one thing plays at a time: the first clip of a card loops on its own, the others and every option wait
|
|
775
|
-
const first = views.findIndex((w) => !isGallery(w) && w.clip !== undefined)
|
|
776
|
-
const still = this.rows || view !== first
|
|
777
|
-
if (media?.audio) c.load(`${id}#${view}`, media.audio.duration, SOUND_FPS, true)
|
|
778
|
-
else c.load(`${id}#${view}`, media?.clip?.duration ?? 0, media?.clip?.fps ?? 20, still)
|
|
779
|
-
this.clips.set(view, c)
|
|
780
|
-
}
|
|
781
|
-
return c
|
|
466
|
+
storedDraft(head: string): Draft | null {
|
|
467
|
+
return draftOf(kept.get(`${this.prefix}draft.${head}`))
|
|
782
468
|
}
|
|
783
469
|
|
|
784
|
-
|
|
785
|
-
|
|
470
|
+
keepDraft(head: string, d: Draft | null): void {
|
|
471
|
+
kept.put(`${this.prefix}draft.${head}`, d === null ? null : JSON.stringify(d))
|
|
786
472
|
}
|
|
787
473
|
|
|
788
|
-
|
|
789
|
-
const t = this.openThread
|
|
790
|
-
return t ? conversationOf(t) : []
|
|
791
|
-
}
|
|
474
|
+
// ── files ──
|
|
792
475
|
|
|
793
|
-
/** a
|
|
794
|
-
|
|
795
|
-
return
|
|
476
|
+
/** a card's file at full size; a draft card's carries its frame, so each new frame is a new url */
|
|
477
|
+
fileUrl(id: string, name: string, wip?: { frame: number }): string {
|
|
478
|
+
return `${this.st.url(`/api/review/${id}/${name}`)}${wip ? `?f=${wip.frame}` : ''}`
|
|
796
479
|
}
|
|
797
480
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
return
|
|
481
|
+
/** an image at the size the card column draws it (1600 px webp); any other file is the file itself */
|
|
482
|
+
fitUrl(id: string, name: string, wip?: { frame: number }): string {
|
|
483
|
+
return /\.(png|jpe?g|webp)$/i.test(name) ? `${this.st.url(`/api/review/${id}/preview/fit/${name}`)}${wip ? `?f=${wip.frame}` : ''}` : this.fileUrl(id, name, wip)
|
|
801
484
|
}
|
|
802
485
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
this.replies = { ...this.replies, [id]: text }
|
|
807
|
-
store.put(`${this.prefix}reply.${id}`, text || null)
|
|
486
|
+
/** an image at the list's size (480 px webp) */
|
|
487
|
+
thumbUrl(id: string, name: string): string {
|
|
488
|
+
return /\.(png|jpe?g|webp)$/i.test(name) ? this.st.url(`/api/review/${id}/preview/thumb/${name}`) : this.fileUrl(id, name)
|
|
808
489
|
}
|
|
809
490
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
const x = this.open
|
|
813
|
-
const text = this.reply.trim()
|
|
814
|
-
if (!x || !text || this.busy) return
|
|
815
|
-
const id = x.item.id
|
|
816
|
-
this.busy = true
|
|
817
|
-
this.error = null
|
|
818
|
-
try {
|
|
819
|
-
await postJson(this.st.url(`/api/review/${id}/reply`), { text })
|
|
820
|
-
runInAction(() => {
|
|
821
|
-
const { [id]: _, ...rest } = this.replies
|
|
822
|
-
this.replies = rest
|
|
823
|
-
store.put(`${this.prefix}reply.${id}`, null)
|
|
824
|
-
})
|
|
825
|
-
void this.refresh()
|
|
826
|
-
} catch (e) {
|
|
827
|
-
runInAction(() => (this.error = (e as Error).message))
|
|
828
|
-
} finally {
|
|
829
|
-
runInAction(() => (this.busy = false))
|
|
830
|
-
}
|
|
491
|
+
threadImageUrl(id: string, name: string): string {
|
|
492
|
+
return this.st.url(`/api/review/${id}/thread/${name}`)
|
|
831
493
|
}
|
|
832
494
|
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
this.reading.add(id)
|
|
495
|
+
/** the card's folder, or one of its files, shown in the Finder of the machine the hub runs on */
|
|
496
|
+
async reveal(id: string, file?: string): Promise<void> {
|
|
836
497
|
try {
|
|
837
|
-
await postJson(this.st.url(`/api/review/${id}/
|
|
838
|
-
void this.refresh()
|
|
498
|
+
await postJson(this.st.url(`/api/review/${id}/reveal`), file ? { file } : {})
|
|
839
499
|
} catch (e) {
|
|
840
|
-
runInAction(() => (this.error = (e as Error).message))
|
|
841
|
-
} finally {
|
|
842
|
-
this.reading.delete(id)
|
|
500
|
+
runInAction(() => this.card && (this.card.error = (e as Error).message))
|
|
843
501
|
}
|
|
844
502
|
}
|
|
845
503
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
const
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
setRectComment(i: number, comment: string): void {
|
|
861
|
-
this.edit((d) => ({ ...d, rects: d.rects.map((r, j) => (j === i ? { ...r, comment } : r)) }))
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
removeRect(i: number): void {
|
|
865
|
-
this.edit((d) => ({ ...d, rects: d.rects.filter((_, j) => j !== i) }))
|
|
866
|
-
this.rect = null
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
setComment(comment: string): void {
|
|
870
|
-
this.edit((d) => ({ ...d, comment }))
|
|
504
|
+
/** the open card as one paste a fresh agent session in any repo acts on: what it is, its repo, the command that shows
|
|
505
|
+
* it whole, its link here and on the phone (C) */
|
|
506
|
+
async copyCard(): Promise<void> {
|
|
507
|
+
const v = this.card?.data
|
|
508
|
+
const item = this.card?.headItem
|
|
509
|
+
if (!v || !item) return
|
|
510
|
+
const w = this.spec?.where
|
|
511
|
+
const here = typeof location === 'undefined' ? (w?.open ?? '') : `${location.origin}${location.pathname}${location.search}`
|
|
512
|
+
const text = pasteBlock(item, STATUS_LABEL[v.status], {
|
|
513
|
+
root: w?.root ?? '<the repo>',
|
|
514
|
+
open: `${here}#page:review:${v.head}`,
|
|
515
|
+
phone: w?.phone ? `${w.phone}#page:review:${v.head}` : null,
|
|
516
|
+
})
|
|
517
|
+
await this.copied(text, `copied for an agent: title, repo, sk review show, ${w?.phone ? 'links' : 'link'}`)
|
|
871
518
|
}
|
|
872
519
|
|
|
873
|
-
/**
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
if (!x) return
|
|
877
|
-
const { [x.item.id]: _, ...rest } = this.drafts
|
|
878
|
-
this.drafts = rest
|
|
879
|
-
store.put(`${this.prefix}draft.${x.item.id}`, null)
|
|
880
|
-
this.rect = null
|
|
520
|
+
/** one cell's id, for an agent to name it */
|
|
521
|
+
async copyId(id: string): Promise<void> {
|
|
522
|
+
await this.copied(id, `copied ${id}`)
|
|
881
523
|
}
|
|
882
524
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
this.
|
|
889
|
-
|
|
890
|
-
}
|
|
891
|
-
if (x.item.wip) {
|
|
892
|
-
this.error = 'a draft card: the verdict comes once its agent makes it ready; a word goes in a reply'
|
|
893
|
-
return
|
|
894
|
-
}
|
|
895
|
-
const id = x.item.id
|
|
896
|
-
const d = this.draft
|
|
897
|
-
this.busy = true
|
|
898
|
-
this.error = null
|
|
899
|
-
try {
|
|
900
|
-
const pick = isChoice(x.item) && isApproved(status) && d.pick !== undefined ? { pick: d.pick } : {}
|
|
901
|
-
const m = await postJson<Message>(this.st.url(`/api/review/${id}/feedback`), { status, comment: d.comment, rects: d.rects, reactions: d.reactions ?? [], ...pick })
|
|
902
|
-
runInAction(() => {
|
|
903
|
-
// the verdict shows at once: the list of every card comes back after it
|
|
904
|
-
const r = this.list
|
|
905
|
-
if (r) this.list = { ...r, items: r.items.map((y) => (y.item.id === id ? { ...y, thread: [...y.thread, m] } : y)) }
|
|
906
|
-
const { [id]: _, ...rest } = this.drafts
|
|
907
|
-
this.drafts = rest
|
|
908
|
-
store.put(`${this.prefix}draft.${id}`, null)
|
|
909
|
-
})
|
|
910
|
-
void this.refresh()
|
|
911
|
-
// the tree's count of what waits on the owner moves at once, and so does the project list's pill
|
|
912
|
-
void this.st.cols.poll(true)
|
|
913
|
-
void this.st.home.projects.load()
|
|
914
|
-
} catch (e) {
|
|
915
|
-
runInAction(() => (this.error = (e as Error).message))
|
|
916
|
-
} finally {
|
|
917
|
-
runInAction(() => (this.busy = false))
|
|
918
|
-
}
|
|
525
|
+
private async copied(text: string, said: string): Promise<void> {
|
|
526
|
+
const ok = await copyText(text)
|
|
527
|
+
runInAction(() => {
|
|
528
|
+
this.toast = ok ? said : 'the browser refused the copy'
|
|
529
|
+
if (this.toastTimer !== null) clearTimeout(this.toastTimer)
|
|
530
|
+
this.toastTimer = setTimeout(() => runInAction(() => (this.toast = null)), 2600)
|
|
531
|
+
})
|
|
919
532
|
}
|
|
920
533
|
|
|
921
534
|
/** the page's keys, as the atelier takes its own: true when it used the key. V approves, F ok with a fix, R rejects,
|
|
922
|
-
* A archives, N the next waiting card, C copies the card for an agent, M the rings,
|
|
923
|
-
*
|
|
924
|
-
* read from its physical key (`code`), so ⇧ and an AZERTY keyboard read the same */
|
|
535
|
+
* A archives, N the next waiting card, C copies the card for an agent, M the rings, ↑ ↓ the list; the card takes
|
|
536
|
+
* the rest (ThreadSt.key). A digit is read from its physical key (`code`), so ⇧ and an AZERTY keyboard read the same */
|
|
925
537
|
key(e: Pick<KeyboardEvent, 'key' | 'shiftKey'> & { code?: string }): boolean {
|
|
538
|
+
const card = this.card
|
|
539
|
+
if (card?.key(e)) return true
|
|
926
540
|
const k = e.key.toLowerCase()
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
if (
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
if (digit <= STARS) this.setStars(this.view, digit)
|
|
933
|
-
} else if (this.choice && k === 'p') void this.choose(this.view)
|
|
934
|
-
else if (this.clipKey && e.key === ' ') {
|
|
935
|
-
if (this.clip.paused && this.rows) this.clip.listen()
|
|
936
|
-
else this.clip.toggle()
|
|
937
|
-
} else if (this.clipKey && sound && (e.key === 'ArrowLeft' || e.key === 'ArrowRight')) this.clip.jump(this.clip.time + (e.key === 'ArrowRight' ? SOUND_JUMP : -SOUND_JUMP))
|
|
938
|
-
else if (this.clipKey && (e.key === 'ArrowLeft' || e.key === 'ArrowRight')) this.clip.step(e.key === 'ArrowRight' ? 1 : -1)
|
|
939
|
-
else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') this.move(e.key === 'ArrowDown' ? 1 : -1)
|
|
940
|
-
else if (k === 'v') void this.submit('approved')
|
|
941
|
-
else if (k === 'f') void this.submit('approved-with-fix')
|
|
942
|
-
else if (k === 'r') void this.submit('rejected')
|
|
943
|
-
else if (k === 'a') void this.submit('archived')
|
|
541
|
+
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') this.move(e.key === 'ArrowDown' ? 1 : -1)
|
|
542
|
+
else if (k === 'v') void card?.submit('approved')
|
|
543
|
+
else if (k === 'f') void card?.submit('approved-with-fix')
|
|
544
|
+
else if (k === 'r') void card?.submit('rejected')
|
|
545
|
+
else if (k === 'a') void card?.submit('archived')
|
|
944
546
|
else if (k === 'n') this.nextPending()
|
|
945
547
|
else if (k === 'c') void this.copyCard()
|
|
946
548
|
else if (k === 'm') this.toggleMarks()
|
|
947
|
-
else if ((e.key === 'Delete' || e.key === 'Backspace') && this.rect !== null) this.removeRect(this.rect)
|
|
948
549
|
else return false
|
|
949
550
|
return true
|
|
950
551
|
}
|