rvlib-shipkit 2.9.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/package.json +1 -1
  3. package/src/cli/cmd_Media.ts +164 -0
  4. package/src/cli/cmd_Review.ts +2 -1
  5. package/src/cli/family-pages.ts +1 -0
  6. package/src/cli/registry.ts +2 -0
  7. package/src/collections/pings.ts +6 -4
  8. package/src/core/app-icon.ts +17 -4
  9. package/src/core/scratch-objects.ts +56 -0
  10. package/src/core/trace-audit.ts +13 -1
  11. package/src/home/home-paths.ts +4 -0
  12. package/src/home/home-routes.ts +36 -2
  13. package/src/home/hubs.ts +5 -0
  14. package/src/home/inbox-shape.ts +182 -0
  15. package/src/home/inbox.ts +48 -0
  16. package/src/home/run-daemon.ts +12 -2
  17. package/src/home/serve-web.ts +155 -16
  18. package/src/ledger/git-scan.ts +73 -25
  19. package/src/ledger/repo-view.ts +2 -22
  20. package/src/media-kinds.ts +7 -0
  21. package/src/media-store/content.ts +51 -0
  22. package/src/media-store/daemon.ts +91 -0
  23. package/src/media-store/db.ts +74 -0
  24. package/src/media-store/fact.ts +9 -0
  25. package/src/media-store/kind.ts +44 -0
  26. package/src/media-store/purge.ts +139 -0
  27. package/src/media-store/remote.ts +93 -0
  28. package/src/media-store/space.ts +124 -0
  29. package/src/media-store/sync.ts +101 -0
  30. package/src/media-store/upload.ts +98 -0
  31. package/src/repo-config.ts +4 -0
  32. package/src/review/anim.ts +6 -5
  33. package/src/review/cells.ts +552 -0
  34. package/src/review/format.ts +1 -1
  35. package/src/review/media-kind.ts +84 -0
  36. package/src/review/media-read.ts +48 -0
  37. package/src/review/model.ts +43 -5
  38. package/src/review/previews.ts +153 -0
  39. package/src/review/routes.ts +105 -47
  40. package/src/review/store.ts +106 -45
  41. package/src/review/trailer-desk.ts +79 -46
  42. package/src/review/trailer-media.ts +163 -0
  43. package/src/review/trailer-routes.ts +5 -2
  44. package/src/serve/hub-app/home-st.ts +39 -9
  45. package/src/serve/hub-app/home.html +2 -1
  46. package/src/serve/hub-app/hub-app.tsx +7 -23
  47. package/src/serve/hub-app/icons.tsx +2 -0
  48. package/src/serve/hub-app/inbox-st.ts +144 -0
  49. package/src/serve/hub-app/inbox-view.tsx +205 -0
  50. package/src/serve/hub-app/inbox.css +73 -0
  51. package/src/serve/hub-app/item-view.tsx +19 -0
  52. package/src/serve/hub-app/keys.ts +4 -3
  53. package/src/serve/hub-app/palette-st.ts +2 -1
  54. package/src/serve/hub-app/project-list.tsx +1 -0
  55. package/src/serve/hub-app/projects-svc.ts +1 -1
  56. package/src/serve/hub-app/repo-st.ts +1 -1
  57. package/src/serve/hub-app/review/kind-view.tsx +21 -22
  58. package/src/serve/hub-app/review/kit.tsx +11 -12
  59. package/src/serve/hub-app/review/review-board.tsx +15 -13
  60. package/src/serve/hub-app/review/review-cells.tsx +241 -0
  61. package/src/serve/hub-app/review/review-kit.ts +79 -0
  62. package/src/serve/hub-app/review/review-list.tsx +87 -122
  63. package/src/serve/hub-app/review/review-page.tsx +22 -79
  64. package/src/serve/hub-app/review/review-st.ts +269 -698
  65. package/src/serve/hub-app/review/review-thread.tsx +302 -0
  66. package/src/serve/hub-app/review/review-views.tsx +322 -253
  67. package/src/serve/hub-app/review/thread-st.ts +770 -0
  68. package/src/serve/hub-app/review.css +235 -91
  69. package/src/serve/hub-runtime.ts +9 -4
  70. package/src/serve/serve-hub.ts +4 -1
  71. package/src/serve/warm-cell.ts +6 -1
  72. package/src/trailer/footage.ts +6 -2
  73. package/src/trailer/passage.ts +4 -2
  74. package/src/trailer/prune.ts +6 -10
  75. package/src/serve/hub-app/review/review-answer.tsx +0 -249
@@ -20,6 +20,7 @@ import { PaletteSt } from './palette-st.ts'
20
20
  import { PlannedSt } from './planned-st.ts'
21
21
  import { ActivitySt } from './activity-st.ts'
22
22
  import { InsightsSt } from './insights-st.ts'
23
+ import { InboxSt } from './inbox-st.ts'
23
24
  import { ProjectsSvc } from './projects-svc.ts'
24
25
  import { parseFilter, RepoSt } from './repo-st.ts'
25
26
  import { openSection, repoSections, sectionOfRepo } from './repo-sections.ts'
@@ -27,11 +28,11 @@ import { openSection, repoSections, sectionOfRepo } from './repo-sections.ts'
27
28
  /** the longest one repo's read ahead holds the next one back */
28
29
  export const PREFETCH_WAIT_MS = 10_000
29
30
 
30
- /** what the page shows: the machine overview, the plan, the activity, the insights, the archived repos, or one repo */
31
- export type Page = 'overview' | 'planned' | 'activity' | 'insights' | 'archived' | 'repo'
31
+ /** what the page shows: the machine overview, the inbox, the plan, the activity, the insights, the archived repos, or one repo */
32
+ export type Page = 'overview' | 'inbox' | 'planned' | 'activity' | 'insights' | 'archived' | 'repo'
32
33
 
33
34
  /** the address of each page of the home that is no repo's */
34
- export const PLACE_PATH = { overview: '/', planned: '/planned', activity: '/activity', insights: '/insights', archived: '/archived' } as const
35
+ export const PLACE_PATH = { overview: '/', inbox: '/inbox', planned: '/planned', activity: '/activity', insights: '/insights', archived: '/archived' } as const
35
36
 
36
37
  /** where a repo's hub answers on the home */
37
38
  export const repoBase = (name: string): string => `/r/${encodeURIComponent(name)}`
@@ -49,6 +50,7 @@ export const checkAddress = (repo: string, check: string): string =>
49
50
  export function routeOf(pathname: string): { page: Page; repo: string | null } {
50
51
  const m = /^\/r\/([^/]+)/.exec(pathname)
51
52
  if (m != null) return { page: 'repo', repo: decodeURIComponent(m[1]!) }
53
+ if (/^\/inbox\/?$/.test(pathname)) return { page: 'inbox', repo: null }
52
54
  if (/^\/planned\/?$/.test(pathname)) return { page: 'planned', repo: null }
53
55
  if (/^\/activity\/?$/.test(pathname)) return { page: 'activity', repo: null }
54
56
  if (/^\/insights\/?$/.test(pathname)) return { page: 'insights', repo: null }
@@ -78,6 +80,8 @@ export class HomeSt {
78
80
  /** what every repo committed and holds, polled while it is the page */
79
81
  activity: ActivitySt
80
82
  insights: InsightsSt
83
+ /** everything that waits on the owner in every repo, polled while it is the page */
84
+ inbox: InboxSt
81
85
  /** the one picker, cmd+j */
82
86
  palette: PaletteSt
83
87
  /** the widths of the project list and a repo's sidebar */
@@ -106,12 +110,13 @@ export class HomeSt {
106
110
  this.planned = new PlannedSt(this)
107
111
  this.activity = new ActivitySt(this)
108
112
  this.insights = new InsightsSt(this)
113
+ this.inbox = new InboxSt(this)
109
114
  this.palette = new PaletteSt(this)
110
115
  this.layout = new LayoutSt()
111
116
  this.dock = new DockSt(this)
112
117
  this.machine = o.home ? new MachineSt(this, o) : null
113
118
  this.page = o.home ? 'overview' : 'repo'
114
- makeAutoObservable<this, 'disposers' | 'onUrl' | 'prefetching' | 'base'>(this, { base: false, machine: false, projects: false, planned: false, activity: false, insights: false, palette: false, layout: false, theme: false, dock: false, repos: observableShallow, disposers: false, onUrl: false, prefetching: false })
119
+ makeAutoObservable<this, 'disposers' | 'onUrl' | 'prefetching' | 'base'>(this, { base: false, machine: false, projects: false, planned: false, activity: false, insights: false, inbox: false, palette: false, layout: false, theme: false, dock: false, repos: observableShallow, disposers: false, onUrl: false, prefetching: false })
115
120
  const m = this.machine
116
121
  if (m != null) {
117
122
  this.projects.onSelect = (name) => this.select(name)
@@ -147,6 +152,7 @@ export class HomeSt {
147
152
 
148
153
  get title(): string {
149
154
  if (this.page === 'overview') return 'home'
155
+ if (this.page === 'inbox') return this.inbox.count > 0 ? `inbox · ${this.inbox.count}` : 'inbox'
150
156
  if (this.page === 'planned') return 'planned'
151
157
  if (this.page === 'activity') return 'activity'
152
158
  if (this.page === 'insights') return 'insights'
@@ -193,6 +199,7 @@ export class HomeSt {
193
199
  this.machine?.stop()
194
200
  this.planned.stop()
195
201
  this.activity.stop()
202
+ this.inbox.stop()
196
203
  this.dock.dispose()
197
204
  for (const r of this.repos.values()) r.dispose()
198
205
  }
@@ -216,7 +223,12 @@ export class HomeSt {
216
223
  /** a check: its own page in its repo, in place. The selection is written
217
224
  * before the repo is shown, so the one history entry already names it */
218
225
  openCheck(repo: string, check: string): void {
219
- this.repo(repo).cols.select('checks', `check:${check}`)
226
+ this.openItem(repo, 'checks', `check:${check}`)
227
+ }
228
+
229
+ /** one row of a repo: its own page in its repo, in place, as one history entry */
230
+ openItem(repo: string, col: string, id: string): void {
231
+ this.repo(repo).cols.select(col, id)
220
232
  this.show('repo', repo, 'push')
221
233
  }
222
234
 
@@ -232,9 +244,20 @@ export class HomeSt {
232
244
  const u = new URL(path, 'http://home.invalid')
233
245
  const r = routeOf(u.pathname)
234
246
  if (r.page === 'planned') this.planned.query = u.searchParams.get('q') ?? ''
247
+ if (r.page === 'inbox') this.inbox.fromSearch(u.search)
235
248
  this.show(r.page, r.repo, 'push')
236
249
  }
237
250
 
251
+ /** the inbox on one item, or on its list: an item is a history entry of its own, so back returns to the list */
252
+ openInbox(item: { repo: string; id: string } | null): void {
253
+ const was = this.inbox.open
254
+ if (item != null) this.repo(item.repo)
255
+ this.inbox.open = item
256
+ const same = was?.repo === item?.repo && was?.id === item?.id
257
+ if (this.page === 'inbox' && same) return
258
+ this.show('inbox', null, item != null && this.page === 'inbox' ? 'push' : this.page === 'inbox' ? 'replace' : 'push')
259
+ }
260
+
238
261
  /** the url decides the page: the first load, back, forward and a hand
239
262
  * edited address all land here */
240
263
  fromUrl(): void {
@@ -246,6 +269,9 @@ export class HomeSt {
246
269
  // an address from before repo pages had their own path (`/#<repo>`)
247
270
  const legacy = r.page === 'overview' ? currentHash() : ''
248
271
  if (legacy !== '') return this.show('repo', legacy, 'replace')
272
+ // on a phone the home opens on the inbox
273
+ if (r.page === 'overview' && this.inbox.phone && location.search === '') return this.show('inbox', null, 'replace')
274
+ if (r.page === 'inbox') this.inbox.fromSearch(location.search)
249
275
  if (r.page === 'planned') this.planned.query = new URLSearchParams(location.search).get('q') ?? ''
250
276
  if (r.page === 'repo') this.repo(r.repo!).filter = parseFilter(location.search)
251
277
  this.show(r.page, r.repo, 'none')
@@ -259,7 +285,7 @@ export class HomeSt {
259
285
  const prevPage = this.page
260
286
  const next = page === 'repo' && repo != null ? this.repo(repo) : null
261
287
  // the page already shown is never a second history entry
262
- if (how === 'push' && page === this.page && next === prev && page !== 'planned') how = 'none'
288
+ if (how === 'push' && page === this.page && next === prev && page !== 'planned' && page !== 'inbox') how = 'none'
263
289
  if (prev != null && prev !== next) prev.pause()
264
290
  next?.markSeen()
265
291
  this.page = page
@@ -269,13 +295,17 @@ export class HomeSt {
269
295
  this.projects.away = next == null
270
296
  this.projects.place = page === 'repo' || page === 'archived' ? null : page
271
297
  if (how !== 'none') {
272
- const to = next != null ? `${repoPage(next.key)}${next.search}${next.hash}` : page === 'planned' ? this.planned.address : page === 'activity' || page === 'insights' || page === 'archived' ? PLACE_PATH[page] : '/'
273
- if (how === 'push') history.pushState(null, '', to)
274
- else history.replaceState(null, '', to)
298
+ const to = next != null ? `${repoPage(next.key)}${next.search}${next.hash}` : page === 'planned' ? this.planned.address : page === 'inbox' ? `${PLACE_PATH.inbox}${this.inbox.search}` : page === 'activity' || page === 'insights' || page === 'archived' ? PLACE_PATH[page] : '/'
299
+ // an inbox item marks its entry, so its back button goes back rather than forward to the list
300
+ const state = page === 'inbox' && this.inbox.open != null ? { inbox: 'item' } : null
301
+ if (how === 'push') history.pushState(state, '', to)
302
+ else history.replaceState(state, '', to)
275
303
  }
276
304
  if (page === 'planned') this.planned.start()
277
305
  else this.planned.stop()
278
306
  if (page === 'insights' && prevPage !== 'insights') this.insights.start()
307
+ if (page === 'inbox') this.inbox.start()
308
+ else this.inbox.stop()
279
309
  if (page === 'activity') this.activity.start()
280
310
  else this.activity.stop()
281
311
  if (next != null && next !== prev && this.machine?.data != null) void this.machine.hub(next.key, 'ensure')
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
6
  <title>home</title>
7
7
  <link rel="stylesheet" href="./hub.css" />
8
8
  <link rel="stylesheet" href="./project-list.css" />
@@ -15,6 +15,7 @@
15
15
  <link rel="stylesheet" href="./dock.css" />
16
16
  <link rel="stylesheet" href="./controls.css" />
17
17
  <link rel="stylesheet" href="./review.css" />
18
+ <link rel="stylesheet" href="./inbox.css" />
18
19
  </head>
19
20
  <body data-home>
20
21
  <div id="root"></div>
@@ -11,18 +11,16 @@ import { reaction, runInAction } from 'mobx'
11
11
  import { observer } from 'mobx-react-lite'
12
12
  import { StrictMode, useEffect, useLayoutEffect, useRef } from 'react'
13
13
  import { createRoot } from 'react-dom/client'
14
- import { ColCard, StatusCard } from './col-card.tsx'
14
+ import { StatusCard } from './col-card.tsx'
15
15
  import { AskTable, CheckTable, ItemTable, SecretTable } from './col-tables-view.tsx'
16
- import { WIKIS, WikisView } from './wikis-view.tsx'
17
- import { ComfyOverlay, ComfyView } from './comfy-view.tsx'
16
+ import { ComfyOverlay } from './comfy-view.tsx'
17
+ import { ItemView } from './item-view.tsx'
18
+ import { InboxView } from './inbox-view.tsx'
18
19
  import type { Filter, RepoSt } from './repo-st.ts'
19
20
  import { HomeSt, PLACE_PATH } from './home-st.ts'
20
21
  import { hashFor } from './hash-route.ts'
21
- import { TimelineView } from './timeline-view.tsx'
22
22
  import { HeaderBar, notUp } from './header-bar.tsx'
23
23
  import { FOLLOW_KEY } from './timeline-chart.tsx'
24
- import { CheckCard } from './check-view.tsx'
25
- import { TestCard } from './test-view.tsx'
26
24
  import { TestsPage } from './tests-view.tsx'
27
25
  import { AssetStage, CatGrid, InfoChips, MediaTopbar, ToolsBar, VariantsBar } from './media-view.tsx'
28
26
  import { Sidebar } from './sidebar.tsx'
@@ -81,22 +79,7 @@ const AssetRemarks = observer(({ app }: { app: RepoSt }) => {
81
79
  const Main = observer(({ app }: { app: RepoSt }) => {
82
80
  const m = app.media
83
81
  const errs = m.errors.length > 0 ? <div className="errs">{m.errors.join('\n')}</div> : null
84
- if (app.sel?.t === 'item') return (
85
- <main>
86
- {errs}
87
- {app.sel.col === WIKIS
88
- ? <WikisView app={app} id={app.sel.id} />
89
- : app.sel.col === 'comfy'
90
- ? <ComfyView app={app} id={app.sel.id} />
91
- : app.sel.col === 'checks'
92
- ? <div className="stagewrap"><CheckCard app={app} id={app.sel.id} /></div>
93
- : app.sel.col === 'tests'
94
- ? <div className="stagewrap"><TestCard app={app} id={app.sel.id} /></div>
95
- : app.sel.col === 'runs'
96
- ? <div className="stagewrap"><TimelineView app={app} /></div>
97
- : <div className="stagewrap"><ColCard app={app} col={app.sel.col} id={app.sel.id} /></div>}
98
- </main>
99
- )
82
+ if (app.sel?.t === 'item') return <main>{errs}<ItemView app={app} col={app.sel.col} id={app.sel.id} /></main>
100
83
  if (app.sel?.t === 'col') return (
101
84
  <main>
102
85
  {errs}
@@ -218,7 +201,7 @@ function onKey(e: KeyboardEvent): void {
218
201
  if (pk.t === 'picker') home.palette.toggle()
219
202
  else if (pk.t === 'dock') home.dock.cycle()
220
203
  else if (pk.t === 'rail') home.layout.toggleRail()
221
- else if (pk.t === 'home' || pk.t === 'planned' || pk.t === 'activity' || pk.t === 'insights') {
204
+ else if (pk.t === 'home' || pk.t === 'inbox' || pk.t === 'planned' || pk.t === 'activity' || pk.t === 'insights') {
222
205
  home.palette.close()
223
206
  if (home.machine != null) home.navigate(PLACE_PATH[pk.t === 'home' ? 'overview' : pk.t])
224
207
  } else if (pk.t === 'step') {
@@ -361,6 +344,7 @@ const App = observer(() => {
361
344
  <Panel id="page" minSize={320} className="appcol" style={PANEL}>
362
345
  {home.machine == null ? null : <HomeStrip app={home} />}
363
346
  {home.page === 'overview' ? <Overview app={home} /> : null}
347
+ {home.page === 'inbox' ? <InboxView app={home} /> : null}
364
348
  {home.page === 'planned' ? <PlannedView app={home} /> : null}
365
349
  {home.page === 'activity' ? <ActivityView app={home} /> : null}
366
350
  {home.page === 'insights' ? <InsightsView app={home} /> : null}
@@ -14,6 +14,8 @@ export const ICON = {
14
14
  archived: 'M2.5 4h15v3.5h-15zM4 7.5V16h12V7.5M8 10.5h4',
15
15
  insights: 'M3 16.5h14M5 16.5V11M9 16.5V5M13 16.5V8.5M17 16.5V12',
16
16
  home: 'M3 9.5 10 3.5l7 6M5 8v8.5h10V8M8.5 16.5v-4.5h3v4.5',
17
+ // a tray: what waits on the owner, every repo
18
+ inbox: 'M3 11.5 5.5 4h9l2.5 7.5V16H3zM3 11.5h4.5l1 2h3l1-2H17',
17
19
  planned: 'M5.5 3h9M5.5 17h9M6.5 3c0 4 7 4 7 7s-7 3-7 7M13.5 3c0 4-7 4-7 7s7 3 7 7',
18
20
  browser: 'M10 2.5a7.5 7.5 0 1 0 0 15a7.5 7.5 0 1 0 0-15M2.5 10h15M10 2.5c-3 3-3 12 0 15M10 2.5c3 3 3 12 0 15',
19
21
  window: 'M2.5 4h15v12h-15zM2.5 7.5h15M5 5.75h.01M7 5.75h.01',
@@ -0,0 +1,144 @@
1
+ // the inbox page as state (wiki build/shipkit/home.md, The inbox), a node of the root (home-st.ts): the main list in
2
+ // pages of `GET /api/inbox`, the folded yellow list read once it unfolds, and the item open in place. Polled every few
3
+ // seconds while the page shows and the tab is visible, 304 when nothing moved. An item opens in its repo's own state
4
+ // (RepoSt): a card in that repo's review thread, an ask or a need in its item view, the same components as its hub
5
+ //
6
+ // the one constraint a reader breaks first: the address and the open item move together, through HomeSt.show; `open`
7
+ // only says which item the address names
8
+ import { makeAutoObservable, observableRef, runInAction } from 'mobx'
9
+ import { INBOX_PAGE, openOf, type InboxAnswer, type InboxRow } from '../../home/inbox-shape.ts'
10
+ import { etagLoader } from './review/review-kit.ts'
11
+ import { ownTrouble } from './reach.ts'
12
+ import { ClockSvc } from './clock-svc.ts'
13
+ import type { HomeSt } from './home-st.ts'
14
+
15
+ const POLL_MS = 4000
16
+
17
+ /** below this width the inbox is the phone's: one pane at a time, the list or the item */
18
+ export const INBOX_PHONE_PX = 768
19
+
20
+ export class InboxSt {
21
+ page: InboxAnswer | null = null
22
+ yellowPage: InboxAnswer | null = null
23
+ error = ''
24
+ /** the rows asked of the main list: a page more on « more » */
25
+ shown = INBOX_PAGE
26
+ /** the folded list unfolded: read while it is */
27
+ yellowOpen = false
28
+ /** the item the address names */
29
+ open: { repo: string; id: string } | null = null
30
+ /** on a phone the list or the item, one at a time */
31
+ phone = false
32
+ /** every row's age reads it, ticking while the page shows */
33
+ readonly clock = new ClockSvc()
34
+ private timer: ReturnType<typeof setInterval> | null = null
35
+ private readonly loadMain: () => Promise<InboxAnswer>
36
+ private readonly loadYellow: () => Promise<InboxAnswer>
37
+ private readonly onVisible = (): void => {
38
+ if (document.visibilityState === 'visible' && this.timer != null) void this.poll()
39
+ }
40
+
41
+ constructor(private readonly home: HomeSt) {
42
+ this.loadMain = etagLoader(() => `/api/inbox?limit=${this.shown}`)
43
+ this.loadYellow = etagLoader(() => '/api/inbox?list=yellow&limit=500')
44
+ makeAutoObservable<this, 'home' | 'timer' | 'loadMain' | 'loadYellow' | 'onVisible'>(this, { home: false, timer: false, loadMain: false, loadYellow: false, onVisible: false, clock: false, page: observableRef, yellowPage: observableRef })
45
+ if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
46
+ const mq = window.matchMedia(`(max-width: ${INBOX_PHONE_PX - 1}px)`)
47
+ this.phone = mq.matches
48
+ mq.addEventListener('change', (e) => runInAction(() => (this.phone = e.matches)))
49
+ }
50
+ }
51
+
52
+ get rows(): InboxRow[] {
53
+ return this.page?.rows ?? []
54
+ }
55
+
56
+ get yellowRows(): InboxRow[] {
57
+ return this.yellowPage?.rows ?? []
58
+ }
59
+
60
+ get count(): number {
61
+ return this.page?.counts.main ?? 0
62
+ }
63
+
64
+ get yellowCount(): number {
65
+ return this.page?.counts.yellow ?? 0
66
+ }
67
+
68
+ get more(): number {
69
+ return Math.max(0, (this.page?.total ?? 0) - this.rows.length)
70
+ }
71
+
72
+ /** the row of the open item, from either list; null while the lists have not answered or once it left them */
73
+ get openRow(): InboxRow | null {
74
+ const o = this.open
75
+ if (o == null) return null
76
+ const key = `${o.repo}/${o.id}`
77
+ return this.rows.find((r) => r.key === key) ?? this.yellowRows.find((r) => r.key === key) ?? null
78
+ }
79
+
80
+ /** the address's part after /inbox */
81
+ get search(): string {
82
+ return this.open == null ? '' : `?open=${encodeURIComponent(`${this.open.repo}/${this.open.id}`)}`
83
+ }
84
+
85
+ /** the address read back: the item it names, or the list */
86
+ fromSearch(search: string): void {
87
+ const o = openOf(search)
88
+ // the repo's state is made here, never while a view draws
89
+ if (o != null) this.home.repo(o.repo)
90
+ if (o?.repo !== this.open?.repo || o?.id !== this.open?.id) this.open = o
91
+ }
92
+
93
+ start(): void {
94
+ if (this.timer != null) return
95
+ this.clock.start(10_000)
96
+ void this.poll()
97
+ this.timer = setInterval(() => {
98
+ if (document.visibilityState === 'visible') void this.poll()
99
+ }, POLL_MS)
100
+ document.addEventListener('visibilitychange', this.onVisible)
101
+ }
102
+
103
+ stop(): void {
104
+ if (this.timer != null) clearInterval(this.timer)
105
+ this.timer = null
106
+ this.clock.stop()
107
+ document.removeEventListener('visibilitychange', this.onVisible)
108
+ }
109
+
110
+ async poll(): Promise<void> {
111
+ await Promise.all([
112
+ this.loadMain().then(
113
+ (p) => runInAction(() => {
114
+ if (p !== this.page) this.page = p
115
+ this.error = ''
116
+ }),
117
+ (e: Error) => runInAction(() => (this.error = ownTrouble(e, this.home.machine, (m) => `the inbox cannot be read: ${m}`))),
118
+ ),
119
+ this.yellowOpen ? this.loadYellow().then((p) => runInAction(() => p !== this.yellowPage && (this.yellowPage = p)), () => undefined) : null,
120
+ ])
121
+ }
122
+
123
+ showMore(): void {
124
+ if (this.more === 0) return
125
+ this.shown += INBOX_PAGE
126
+ void this.poll()
127
+ }
128
+
129
+ toggleYellow(): void {
130
+ this.yellowOpen = !this.yellowOpen
131
+ if (this.yellowOpen) void this.poll()
132
+ }
133
+
134
+ /** a row tapped: the item in place, as a history entry */
135
+ pick(row: Pick<InboxRow, 'repo' | 'id'>): void {
136
+ this.home.openInbox({ repo: row.repo, id: row.id })
137
+ }
138
+
139
+ /** back to the list: the entry the item pushed, else the list's own address */
140
+ back(): void {
141
+ if (history.state?.inbox === 'item') history.back()
142
+ else this.home.openInbox(null)
143
+ }
144
+ }
@@ -0,0 +1,205 @@
1
+ // the inbox page (wiki build/shipkit/home.md, The inbox): every repo's items that wait on the owner, newest first, each
2
+ // row with its repo's icon, its kind, its title, its age and a thumb; what can wait folded at the bottom. A row opens
3
+ // its item in place with its repo's own views: a card in the review thread (review-thread.tsx), an ask or a need in
4
+ // its item view (item-view.tsx). On the desktop the list and the item side by side; on a phone one pane at a time,
5
+ // the list kept under the item so back finds it where it was
6
+ import { observer } from 'mobx-react-lite'
7
+ import { useLayoutEffect } from 'react'
8
+ import { isReviewId, type InboxRow } from '../../home/inbox-shape.ts'
9
+ import { hashFor } from './hash-route.ts'
10
+ import { plainClick, repoPage, type HomeSt } from './home-st.ts'
11
+ import { Icon, ICON } from './icons.tsx'
12
+ import type { InboxSt } from './inbox-st.ts'
13
+ import { ItemView } from './item-view.tsx'
14
+ import { Face } from './project-list.tsx'
15
+ import type { RepoSt } from './repo-st.ts'
16
+ import { ThreadColumn } from './review/review-thread.tsx'
17
+ import { TimeAgo } from './time-ago.tsx'
18
+
19
+ /** the words of a kind, on its badge's tooltip */
20
+ const KIND_WORDS: Record<InboxRow['kind'], string> = {
21
+ card: 'a card an agent sent, waiting for your verdict',
22
+ question: 'a question or a blocked item, waiting for your answer',
23
+ ask: 'an ask: something only your hands do',
24
+ need: 'something in the repo that needs someone',
25
+ raised: 'an item raised in the review, in the agents’ hands',
26
+ }
27
+
28
+ export const InboxView = observer(({ app }: { app: HomeSt }) => {
29
+ const ib = app.inbox
30
+ const open = ib.open
31
+ if (ib.phone)
32
+ return (
33
+ <div className="ib-phone">
34
+ <div className="ib-pane">
35
+ <div className="ib-head">
36
+ <h1>inbox</h1>
37
+ <Counts ib={ib} />
38
+ </div>
39
+ <InboxList app={app} />
40
+ </div>
41
+ {open != null ? <OpenItem app={app} item={open} /> : null}
42
+ </div>
43
+ )
44
+ return (
45
+ <div className="ib-desk">
46
+ <div className="ib-pane ib-listcol">
47
+ <div className="ib-head">
48
+ <h1>inbox</h1>
49
+ <Counts ib={ib} />
50
+ </div>
51
+ <InboxList app={app} />
52
+ </div>
53
+ <div className="ib-itemcol">{open != null ? <OpenItem app={app} item={open} /> : <div className="ph">{ib.count > 0 ? 'pick a row: it opens here' : ''}</div>}</div>
54
+ </div>
55
+ )
56
+ })
57
+
58
+ const Counts = observer(({ ib }: { ib: InboxSt }) =>
59
+ ib.page == null ? null : (
60
+ <span className="ib-counts">
61
+ {ib.count > 0 ? <b>{ib.count} for you</b> : <span>nothing for you</span>}
62
+ {ib.yellowCount > 0 ? <span className="ib-dim">{ib.yellowCount} can wait</span> : null}
63
+ </span>
64
+ ),
65
+ )
66
+
67
+ const InboxList = observer(({ app }: { app: HomeSt }) => {
68
+ const ib = app.inbox
69
+ const p = ib.page
70
+ return (
71
+ <div className="ib-list">
72
+ {ib.error !== '' ? <div className="err">✗ {ib.error}</div> : null}
73
+ {p == null ? (
74
+ ib.error === '' ? <div className="ib-wait"><span className="spin" />reading every repo…</div> : null
75
+ ) : ib.rows.length === 0 ? (
76
+ <div className="ib-clear">nothing waits on you ✨</div>
77
+ ) : (
78
+ ib.rows.map((r) => <Row key={r.key} app={app} r={r} />)
79
+ )}
80
+ {ib.more > 0 ? <button className="ib-more" onClick={() => ib.showMore()}>{ib.more} more</button> : null}
81
+ {ib.yellowCount > 0 ? (
82
+ <div className={`ib-fold${ib.yellowOpen ? ' on' : ''}`}>
83
+ <button className="ib-foldhead" aria-expanded={ib.yellowOpen} onClick={() => ib.toggleYellow()}>
84
+ <span className="ib-caret">{ib.yellowOpen ? '▾' : '▸'}</span>
85
+ <span>can wait</span>
86
+ <span className="ib-n">{ib.yellowCount}</span>
87
+ </button>
88
+ {ib.yellowOpen ? ib.yellowRows.map((r) => <Row key={r.key} app={app} r={r} />) : null}
89
+ </div>
90
+ ) : null}
91
+ {p != null && p.missing.length > 0 ? (
92
+ <div className="ib-missing">
93
+ {p.missing.map((m) => <div key={m.repo}><b>{m.repo}</b>: {m.why}, so its items are not here</div>)}
94
+ </div>
95
+ ) : null}
96
+ </div>
97
+ )
98
+ })
99
+
100
+ const Row = observer(({ app, r }: { app: HomeSt; r: InboxRow }) => {
101
+ const ib = app.inbox
102
+ const p = app.projects.list.find((x) => x.name === r.repo)
103
+ const on = ib.open?.repo === r.repo && ib.open.id === r.id
104
+ return (
105
+ <a className={`ib-row t-${r.tone}${on ? ' cur' : ''}`} href={r.open} onClick={(e) => {
106
+ if (!plainClick(e)) return
107
+ e.preventDefault()
108
+ ib.pick(r)
109
+ }}>
110
+ <span className="ib-face" title={r.repo}>{p != null ? <Face p={p} px={28} /> : <span className="pgi h0">{r.repo.charAt(0).toUpperCase()}</span>}</span>
111
+ <span className="ib-main">
112
+ <span className="ib-l1">
113
+ <span className={`ib-tag t-${r.tone}`} title={KIND_WORDS[r.kind]}>{r.tag}</span>
114
+ <span className="ib-title">{r.title}</span>
115
+ </span>
116
+ <span className="ib-l2">
117
+ <span className="ib-repo">{r.repo}</span>
118
+ {r.sub != null ? <span className="ib-sub">{r.sub}</span> : null}
119
+ {r.at != null ? <TimeAgo clock={ib.clock} at={r.at} /> : null}
120
+ </span>
121
+ </span>
122
+ {r.thumb != null ? <img className="ib-thumb" src={r.thumb} alt="" loading="lazy" decoding="async" draggable={false} /> : null}
123
+ </a>
124
+ )
125
+ })
126
+
127
+ /** the address of the item in its repo's own page */
128
+ const hubAddress = (repo: string, id: string, col: string | null): string =>
129
+ `${repoPage(repo)}#${hashFor(isReviewId(id) ? { t: 'review', id } : { t: 'item', col: col ?? '', id }) ?? ''}`
130
+
131
+ /** the item in its repo's own page, in place */
132
+ const openInHub = (app: HomeSt, repo: string, id: string, col: string | null): void => {
133
+ if (isReviewId(id)) app.openReview(repo, id)
134
+ else if (col != null) app.openItem(repo, col, id)
135
+ }
136
+
137
+ const OpenItem = observer(({ app, item }: { app: HomeSt; item: { repo: string; id: string } }) => {
138
+ // made by the move that opened it (InboxSt.fromSearch, HomeSt.openInbox)
139
+ const repo = app.repos.get(item.repo)
140
+ if (repo == null) return null
141
+ return <OpenIn app={app} repo={repo} id={item.id} />
142
+ })
143
+
144
+ const OpenIn = observer(({ app, repo, id }: { app: HomeSt; repo: RepoSt; id: string }) => {
145
+ const row = app.inbox.openRow
146
+ // its clock moves only while its repo shows: here it shows
147
+ useLayoutEffect(() => {
148
+ repo.clock.start()
149
+ return () => repo.clock.stop()
150
+ }, [repo])
151
+ if (isReviewId(id)) return <ReviewItem app={app} repo={repo} id={id} />
152
+ const col = row?.col ?? repo.cols.resources.find((r) => r.id === id)?.collection ?? null
153
+ return <NeedItem app={app} repo={repo} id={id} col={col} />
154
+ })
155
+
156
+ /** the line over an open item: back to the list on a phone, the repo, its own page */
157
+ const ItemTop = observer(({ app, repo, id, col }: { app: HomeSt; repo: RepoSt; id: string; col: string | null }) => {
158
+ const p = app.projects.list.find((x) => x.name === repo.name)
159
+ return (
160
+ <div className="rv-phonetop ib-top">
161
+ {app.inbox.phone ? <button className="ghost rv-back" aria-label="back to the inbox" onClick={() => app.inbox.back()}>◂</button> : null}
162
+ {p != null ? <Face p={p} px={20} /> : null}
163
+ <b>{repo.name}</b>
164
+ <span className="sp" />
165
+ <a className="ib-hub" href={hubAddress(repo.name, id, col)} title="open it in its repo's hub" onClick={(e) => {
166
+ if (!plainClick(e)) return
167
+ e.preventDefault()
168
+ openInHub(app, repo.name, id, col)
169
+ }}>
170
+ <Icon d={ICON.link} /> its hub
171
+ </a>
172
+ </div>
173
+ )
174
+ })
175
+
176
+ const ReviewItem = observer(({ app, repo, id }: { app: HomeSt; repo: RepoSt; id: string }) => {
177
+ const rv = repo.review
178
+ // before the first paint, so the column never draws the card the repo's page held
179
+ useLayoutEffect(() => {
180
+ rv.select(id)
181
+ rv.start()
182
+ return () => rv.stop()
183
+ }, [rv, id])
184
+ return (
185
+ <div className={app.inbox.phone ? 'rv-phone ib-open' : 'ib-open ib-review'}>
186
+ <ItemTop app={app} repo={repo} id={id} col={null} />
187
+ <ThreadColumn rv={rv} back={null} />
188
+ </div>
189
+ )
190
+ })
191
+
192
+ const NeedItem = observer(({ app, repo, id, col }: { app: HomeSt; repo: RepoSt; id: string; col: string | null }) => {
193
+ useLayoutEffect(() => {
194
+ void repo.cols.poll()
195
+ }, [repo, id])
196
+ const ready = repo.cols.loaded || repo.cols.cached
197
+ return (
198
+ <div className={app.inbox.phone ? 'ib-sheet ib-open' : 'ib-open'}>
199
+ <ItemTop app={app} repo={repo} id={id} col={col} />
200
+ <div className="ib-itembody">
201
+ {!ready ? <div className="ib-wait"><span className="spin" />reading {repo.name}…</div> : col == null ? <div className="ph">this no longer waits on you</div> : <ItemView app={repo} col={col} id={id} />}
202
+ </div>
203
+ </div>
204
+ )
205
+ })
@@ -0,0 +1,73 @@
1
+ /* the inbox (inbox-view.tsx): the list and the item side by side on a desktop, one pane at a time on a phone, where
2
+ the page covers the home as an app (the safe area kept clear, every target a thumb's size, no field under 16px) */
3
+ .ib-desk{flex:1;min-height:0;display:grid;grid-template-columns:minmax(300px,440px) minmax(0,1fr)}
4
+ .ib-pane{min-height:0;overflow-y:auto;overscroll-behavior:contain}
5
+ .ib-listcol{border-right:1px solid var(--line);background:var(--bg-side)}
6
+ .ib-itemcol{min-width:0;min-height:0;display:flex;flex-direction:column}
7
+ .ib-itemcol>.ph{margin:auto;color:var(--dim)}
8
+ .ib-head{display:flex;align-items:baseline;gap:var(--s3);padding:var(--s3) var(--s4) var(--s2)}
9
+ .ib-head h1{margin:0;font-size:22px;font-weight:700;letter-spacing:-.01em}
10
+ .ib-counts{display:flex;gap:var(--s3);font-size:13px;color:var(--ink)}
11
+ .ib-counts b{color:var(--review)}
12
+ .ib-dim{color:var(--dim)}
13
+ .ib-list{display:flex;flex-direction:column;padding:0 0 var(--s4)}
14
+ .ib-list>.err{color:var(--red);padding:var(--s2) var(--s4);font-size:13px}
15
+ .ib-wait{display:flex;align-items:center;gap:var(--s2);color:var(--dim);padding:var(--s4)}
16
+ .ib-clear{color:var(--dim);font-size:15px;padding:var(--s4)}
17
+
18
+ /* a row: the repo's icon, the kind and the title, the repo, a line and the age, the thumb; its tone a bar on its left */
19
+ a.ib-row,a.ib-row:visited{display:flex;align-items:center;gap:var(--s3);min-height:60px;padding:var(--s2) var(--s4) var(--s2) var(--s3);
20
+ color:var(--ink);text-decoration:none;border-left:3px solid transparent;border-bottom:1px solid var(--line);-webkit-tap-highlight-color:transparent}
21
+ a.ib-row:hover{background:var(--wash2)}
22
+ a.ib-row:active{background:var(--wash)}
23
+ a.ib-row.cur{background:var(--sel)}
24
+ a.ib-row.t-review{border-left-color:var(--review)}
25
+ a.ib-row.t-red{border-left-color:var(--red)}
26
+ a.ib-row.t-yellow{border-left-color:var(--warn)}
27
+ .ib-face{flex:none;width:28px;height:28px;display:flex}
28
+ .ib-face img,.ib-face .pgi{width:28px;height:28px;border-radius:7px;object-fit:contain;font-size:14px}
29
+ .ib-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--s0)}
30
+ .ib-l1{display:flex;align-items:baseline;gap:var(--s2);min-width:0}
31
+ .ib-title{font-size:15px;line-height:1.3;font-weight:600;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow-wrap:anywhere}
32
+ .ib-tag{flex:none;font-size:11px;line-height:18px;font-weight:700;text-transform:lowercase;padding:0 var(--s1);border-radius:3px;border:1px solid currentColor}
33
+ .ib-tag.t-review{color:var(--review)}
34
+ .ib-tag.t-red{color:var(--red)}
35
+ .ib-tag.t-yellow{color:var(--warn)}
36
+ .ib-l2{display:flex;gap:var(--s2);font-size:12.5px;color:var(--dim);min-width:0;white-space:nowrap}
37
+ .ib-repo{flex:none;color:var(--ink);opacity:.75}
38
+ .ib-sub{overflow:hidden;text-overflow:ellipsis;min-width:0}
39
+ .ib-l2 .ago{flex:none;margin-left:auto}
40
+ .ib-thumb{flex:none;width:64px;height:48px;object-fit:cover;border-radius:4px;border:1px solid var(--line);background:var(--panel2)}
41
+
42
+ /* the folded list and the repos it could not read */
43
+ button.ib-more{margin:var(--s3) var(--s4) 0;min-height:44px;font-size:14px}
44
+ .ib-fold{margin-top:var(--s4);border-top:1px solid var(--line)}
45
+ button.ib-foldhead{display:flex;align-items:center;gap:var(--s2);width:100%;min-height:48px;padding:0 var(--s4);border:0;border-radius:0;
46
+ background:transparent;color:var(--dim);font-size:14px;text-align:left}
47
+ button.ib-foldhead:hover{color:var(--ink)}
48
+ .ib-caret{width:12px}
49
+ .ib-n{color:var(--warn);font-weight:700}
50
+ .ib-fold.on a.ib-row{opacity:.85}
51
+ .ib-missing{padding:var(--s3) var(--s4);color:var(--dim);font-size:12.5px;display:flex;flex-direction:column;gap:var(--s1)}
52
+
53
+ /* an open item: its line (the repo, its own page), then the item as its repo draws it */
54
+ .ib-open{flex:1;min-height:0;display:flex;flex-direction:column}
55
+ .ib-open>.rv-thread{flex:1;min-height:0;height:auto}
56
+ .ib-top{gap:var(--s2);min-height:44px}
57
+ .ib-top img,.ib-top .pgi{width:20px;height:20px;border-radius:5px;object-fit:contain}
58
+ .ib-top .sp{flex:1}
59
+ a.ib-hub,a.ib-hub:visited{display:inline-flex;align-items:center;gap:var(--s1);color:var(--accent);text-decoration:none;font-size:13px;min-height:44px;padding:0 var(--s2)}
60
+ a.ib-hub svg{width:14px;height:14px}
61
+ .ib-itembody{flex:1;min-height:0;display:flex;flex-direction:column;overflow-y:auto}
62
+
63
+ /* the phone: the inbox covers the home as an app; an open item covers the list, which stays where it was below it */
64
+ .ib-phone{position:fixed;inset:0;z-index:28;background:var(--bg);display:flex;flex-direction:column}
65
+ .ib-phone>.ib-pane{flex:1;padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)}
66
+ .ib-phone .ib-head{padding:var(--s4) var(--s4) var(--s3)}
67
+ .ib-phone .ib-head h1{font-size:28px}
68
+ .ib-sheet{position:fixed;inset:0;z-index:31;background:var(--bg);padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)}
69
+ .ib-phone .rv-back{min-width:44px;min-height:44px}
70
+ .ib-phone input,.ib-phone textarea,.ib-phone select{font-size:16px}
71
+ .ib-phone .ib-pane button,.ib-sheet button{min-height:44px}
72
+ .ib-phone .stagewrap{padding:var(--s3)}
73
+ .ib-phone .colcard input{min-width:0}