rvlib-shipkit 2.27.0 → 2.28.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/agent-time/hooks.ts +10 -3
- package/src/agent-time/live.ts +11 -5
- package/src/agent-time/registry.ts +289 -0
- package/src/agent-time/store.ts +2 -2
- package/src/annex/born.ts +2 -2
- package/src/annex/offload.ts +12 -11
- package/src/asks/ask-after.ts +6 -2
- package/src/asks/ask-bar-fold.ts +57 -0
- package/src/asks/ask-migrate.ts +280 -0
- package/src/asks/ask-steps-fold.ts +166 -0
- package/src/asks/ask-store.ts +586 -0
- package/src/assets/kits/identity-kit.ts +106 -38
- package/src/assets/kits/poster-thumbnail.ts +282 -0
- package/src/checks/SK003-claude-md-shape.check.ts +92 -25
- package/src/checks/SK004-gitignore-policy.check.ts +8 -4
- package/src/checks/SK013-one-way-in-policy.check.ts +10 -0
- package/src/checks/SK026-asks-autoclose.check.ts +9 -23
- package/src/checks/SK038-speaks-as.check.ts +3 -3
- package/src/checks/SK042-post-kinds.check.ts +26 -24
- package/src/checks/SK049-thread-answers-hook.check.ts +81 -0
- package/src/checks/SK050-retired-commands.check.ts +127 -0
- package/src/cli/cmd_Asks.ts +204 -53
- package/src/cli/cmd_Backup.ts +151 -8
- package/src/cli/cmd_Calls.ts +1 -0
- package/src/cli/cmd_Commands.ts +140 -34
- package/src/cli/cmd_Contracts.ts +1 -0
- package/src/cli/cmd_Keys.ts +1 -0
- package/src/cli/cmd_Lanes.ts +15 -4
- package/src/cli/cmd_Messages.ts +152 -1
- package/src/cli/cmd_Needs.ts +1 -0
- package/src/cli/cmd_Review.ts +931 -229
- package/src/cli/cmd_Secret.ts +255 -34
- package/src/cli/cmd_Social.ts +36 -33
- package/src/cli/cmd_SocialDrafts.ts +235 -0
- package/src/cli/cmd_Sound.ts +22 -1
- package/src/cli/cmd_Start.ts +3 -2
- package/src/cli/cmd_ThreadHolds.ts +34 -0
- package/src/cli/cmd_ThreadKinds.ts +146 -0
- package/src/cli/cmd_ThreadReflect.ts +83 -0
- package/src/cli/cmd_ThreadSyncNeeds.ts +62 -0
- package/src/cli/cmd_Vault.ts +1 -1
- package/src/cli/cmd_When.ts +1 -0
- package/src/cli/family-help.ts +2 -2
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/kit/builtins.ts +1 -0
- package/src/cli/kit/verb.ts +6 -2
- package/src/cli/registry.ts +21 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +25 -74
- package/src/collections/collection-types.ts +9 -5
- package/src/collections/md-body.ts +5 -3
- package/src/collections/pings.ts +13 -6
- package/src/collections/providers.ts +53 -61
- package/src/collections/reflections.ts +9 -4
- package/src/core/discover-checks.ts +18 -3
- package/src/core/git.ts +31 -0
- package/src/core/house-layout.ts +17 -0
- package/src/core/layout.ts +10 -5
- package/src/core/locked-write.ts +4 -1
- package/src/core/machine-db.ts +5 -3
- package/src/core/migrate-layout.ts +8 -10
- package/src/home/activity.ts +8 -15
- package/src/home/daemon-jobs.ts +13 -1
- package/src/home/home-paths.ts +6 -3
- package/src/home/home-routes.ts +8 -0
- package/src/home/inbox-shape.ts +233 -100
- package/src/home/inbox.ts +26 -71
- package/src/home/machine-fold.ts +10 -15
- package/src/home/machine-host.ts +19 -1
- package/src/home/other-macs.ts +2 -2
- package/src/home/serve-web.ts +6 -5
- package/src/home/space-page.ts +1 -1
- package/src/home/vault-page.ts +51 -17
- package/src/home/vault-words.ts +2 -2
- package/src/hooks/one-way-in-guard.ts +24 -2
- package/src/hq/files-send.ts +27 -28
- package/src/hq/hq-db.ts +4 -1
- package/src/hq/hq-local.ts +37 -4
- package/src/hq/hq-routes.ts +10 -2
- package/src/hq/hq-store.ts +6 -2
- package/src/hq/kinds/ask.ts +6 -6
- package/src/hq/outbox.ts +5 -3
- package/src/hq/replica.ts +1 -2
- package/src/hq/vault-route.ts +112 -0
- package/src/identities/collection.ts +2 -2
- package/src/identities/identities.ts +9 -8
- package/src/identities/machine-route.ts +8 -3
- package/src/ledger/db.ts +8 -1
- package/src/media-store/backup/daemon.ts +48 -8
- package/src/media-store/backup/keys.ts +1 -1
- package/src/media-store/backup/manifest.ts +20 -2
- package/src/media-store/backup/prune.ts +365 -0
- package/src/media-store/backup/retention.ts +122 -0
- package/src/media-store/backup/run.ts +14 -8
- package/src/media-store/backup/sources.ts +18 -17
- package/src/media-store/backup/thread-copy.ts +340 -0
- package/src/media-store/copy/config.ts +3 -4
- package/src/media-store/copy/store.ts +2 -2
- package/src/media-store/db.ts +2 -2
- package/src/media-store/forget.ts +118 -0
- package/src/media-store/purge.ts +3 -2
- package/src/media-store/space-listing.ts +20 -4
- package/src/media-store/space.ts +6 -5
- package/src/messages/guard.ts +49 -0
- package/src/messages/model.ts +1 -1
- package/src/messages/objects.ts +201 -0
- package/src/messages/routes.ts +2 -2
- package/src/messages/score.ts +1 -1
- package/src/messages/write.ts +285 -0
- package/src/pages/frame-client.ts +181 -4
- package/src/reflections/reflections-queue.ts +1 -1
- package/src/release/gate-checkout.ts +2 -1
- package/src/release/git-facts.ts +3 -2
- package/src/release/public-clean.ts +3 -2
- package/src/repo-config.ts +40 -18
- package/src/review/anim.ts +1 -1
- package/src/review/answer-kinds.ts +131 -0
- package/src/review/band.ts +53 -0
- package/src/review/branch-hold.ts +84 -0
- package/src/review/card-db.ts +16 -6
- package/src/review/card-rows.ts +4 -3
- package/src/review/cells.ts +297 -65
- package/src/review/close.ts +92 -0
- package/src/review/draft-card.ts +8 -16
- package/src/review/draft-model.ts +2 -2
- package/src/review/events.ts +171 -0
- package/src/review/format.ts +128 -14
- package/src/review/glyphs.ts +63 -0
- package/src/review/gone.ts +1 -1
- package/src/review/holds-sync.ts +62 -0
- package/src/review/holds.ts +85 -0
- package/src/review/house-kind-defs.ts +41 -0
- package/src/review/inbox-hook.ts +22 -9
- package/src/review/inbox-read.ts +201 -0
- package/src/review/instructions.ts +199 -0
- package/src/review/kind-apply.ts +61 -0
- package/src/review/kind-catalog.ts +96 -0
- package/src/review/kinds.ts +278 -0
- package/src/review/lane-ask.ts +109 -0
- package/src/review/model.ts +396 -86
- package/src/review/move.ts +3 -3
- package/src/review/need-address.ts +15 -0
- package/src/review/need-threads.ts +93 -0
- package/src/review/object-card.ts +48 -0
- package/src/review/object-read.ts +31 -0
- package/src/review/owner-verdict.ts +36 -0
- package/src/review/parties.ts +182 -0
- package/src/review/previews.ts +3 -1
- package/src/review/projections.ts +235 -0
- package/src/review/referring.ts +54 -0
- package/src/review/reflection-object.ts +195 -0
- package/src/review/routes.ts +137 -32
- package/src/review/secret-route.ts +80 -0
- package/src/review/snooze.ts +38 -0
- package/src/review/stage-card.ts +4 -4
- package/src/review/store.ts +366 -85
- package/src/review/supersede.ts +116 -0
- package/src/review/take-back.ts +52 -0
- package/src/review/thread-fold.ts +20 -7
- package/src/review/threads.ts +236 -39
- package/src/review/traces.ts +218 -0
- package/src/review/trailer-card.ts +2 -2
- package/src/review/unit.ts +71 -5
- package/src/review/verdict-items.ts +73 -0
- package/src/review/verdict-write.ts +15 -0
- package/src/review/wait.ts +85 -0
- package/src/review/watchers.ts +22 -9
- package/src/scaffold/files/claude-settings-local.json +2 -0
- package/src/secrets/archive-mark.ts +52 -0
- package/src/secrets/archive.ts +83 -0
- package/src/secrets/copy.ts +14 -14
- package/src/secrets/keychain-write.ts +48 -0
- package/src/secrets/keychain.ts +8 -5
- package/src/secrets/lapse-mark.ts +33 -0
- package/src/secrets/lapse.ts +60 -0
- package/src/secrets/list.ts +16 -22
- package/src/secrets/manager.ts +31 -16
- package/src/secrets/read.ts +161 -33
- package/src/secrets/tail.ts +31 -0
- package/src/serve/hub-app/asks-page.tsx +2 -1
- package/src/serve/hub-app/auto-text.tsx +14 -6
- package/src/serve/hub-app/benign-errors.ts +15 -1
- package/src/serve/hub-app/card-head.tsx +49 -0
- package/src/serve/hub-app/check-view.tsx +3 -2
- package/src/serve/hub-app/code-copy.ts +35 -0
- package/src/serve/hub-app/col-card.tsx +31 -40
- package/src/serve/hub-app/col-list-page.tsx +5 -2
- package/src/serve/hub-app/col-tables-view.tsx +7 -4
- package/src/serve/hub-app/col-tables.ts +5 -5
- package/src/serve/hub-app/cols-svc.ts +4 -79
- package/src/serve/hub-app/commands/commands-page.tsx +2 -1
- package/src/serve/hub-app/controls.css +83 -0
- package/src/serve/hub-app/frames-st.ts +17 -1
- package/src/serve/hub-app/git-view.tsx +3 -2
- package/src/serve/hub-app/home-st.ts +57 -6
- package/src/serve/hub-app/home-strip.css +1 -6
- package/src/serve/hub-app/home-strip.tsx +2 -1
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/house-wiki-view.tsx +20 -0
- package/src/serve/hub-app/hub-app.tsx +48 -32
- package/src/serve/hub-app/hub-types.ts +2 -0
- package/src/serve/hub-app/hub.css +50 -61
- package/src/serve/hub-app/icons.tsx +14 -4
- package/src/serve/hub-app/identities-view.tsx +4 -3
- package/src/serve/hub-app/inbox-st.ts +203 -42
- package/src/serve/hub-app/inbox-view.tsx +189 -101
- package/src/serve/hub-app/inbox.css +47 -44
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/instructions.css +30 -0
- package/src/serve/hub-app/keys.ts +5 -3
- package/src/serve/hub-app/machine-st.ts +2 -2
- package/src/serve/hub-app/machines-view.tsx +4 -11
- package/src/serve/hub-app/machines.css +0 -9
- package/src/serve/hub-app/markdown.css +51 -0
- package/src/serve/hub-app/md-copy.tsx +18 -40
- package/src/serve/hub-app/md.ts +25 -9
- package/src/serve/hub-app/media-view.tsx +2 -2
- package/src/serve/hub-app/messages/messages-page.tsx +2 -1
- package/src/serve/hub-app/messages/messages-st.ts +1 -1
- package/src/serve/hub-app/messages.css +0 -1
- package/src/serve/hub-app/objects.css +51 -0
- package/src/serve/hub-app/page-keys.ts +1 -1
- package/src/serve/hub-app/pages-frames.tsx +11 -1
- package/src/serve/hub-app/palette-st.ts +4 -4
- package/src/serve/hub-app/pane-boundary.tsx +72 -0
- package/src/serve/hub-app/pane-errors.ts +54 -0
- package/src/serve/hub-app/plan-view.tsx +3 -2
- package/src/serve/hub-app/planned-view.tsx +3 -3
- package/src/serve/hub-app/planned.css +0 -4
- package/src/serve/hub-app/processes-view.tsx +3 -2
- package/src/serve/hub-app/project-list.css +5 -13
- package/src/serve/hub-app/project-list.tsx +3 -6
- package/src/serve/hub-app/projects-svc.ts +6 -2
- package/src/serve/hub-app/readme.css +9 -15
- package/src/serve/hub-app/reflections-page.tsx +54 -1
- package/src/serve/hub-app/releases/releases-page.tsx +3 -2
- package/src/serve/hub-app/releases.css +0 -1
- package/src/serve/hub-app/review/code-colors.ts +30 -0
- package/src/serve/hub-app/review/diff-view.tsx +75 -0
- package/src/serve/hub-app/review/dock.tsx +104 -0
- package/src/serve/hub-app/review/draft-card.tsx +2 -2
- package/src/serve/hub-app/review/group-block.tsx +209 -0
- package/src/serve/hub-app/review/instructions-view.tsx +116 -0
- package/src/serve/hub-app/review/item-verdict.tsx +38 -0
- package/src/serve/hub-app/review/kind-states.tsx +193 -0
- package/src/serve/hub-app/review/kind-view.tsx +1 -37
- package/src/serve/hub-app/review/kit.tsx +57 -54
- package/src/serve/hub-app/review/lane-bar.tsx +64 -0
- package/src/serve/hub-app/review/object-card.tsx +62 -0
- package/src/serve/hub-app/review/object-panel.tsx +179 -0
- package/src/serve/hub-app/review/question-views.tsx +385 -0
- package/src/serve/hub-app/review/review-cells.tsx +86 -105
- package/src/serve/hub-app/review/review-list.tsx +104 -47
- package/src/serve/hub-app/review/review-page.tsx +5 -4
- package/src/serve/hub-app/review/review-st.ts +68 -28
- package/src/serve/hub-app/review/review-thread.tsx +171 -40
- package/src/serve/hub-app/review/review-views.tsx +35 -31
- package/src/serve/hub-app/review/thread-close.tsx +124 -0
- package/src/serve/hub-app/review/thread-control.tsx +4 -4
- package/src/serve/hub-app/review/thread-st.ts +222 -22
- package/src/serve/hub-app/review/trailer-card.tsx +1 -1
- package/src/serve/hub-app/review/trailer-timeline.tsx +2 -2
- package/src/serve/hub-app/review.css +216 -57
- package/src/serve/hub-app/section-head.tsx +51 -0
- package/src/serve/hub-app/social/calendar.tsx +5 -11
- package/src/serve/hub-app/social/comms-page.tsx +23 -10
- package/src/serve/hub-app/social/kit.tsx +8 -15
- package/src/serve/hub-app/social/next-release.tsx +3 -5
- package/src/serve/hub-app/social/post-card.tsx +3 -0
- package/src/serve/hub-app/social/post-page.tsx +80 -0
- package/src/serve/hub-app/social/problems.tsx +5 -9
- package/src/serve/hub-app/social/social-model.ts +13 -5
- package/src/serve/hub-app/social/social-page.tsx +1 -1
- package/src/serve/hub-app/social/social-st.ts +42 -5
- package/src/serve/hub-app/social.css +7 -17
- package/src/serve/hub-app/space.css +1 -1
- package/src/serve/hub-app/stores/stores-page.tsx +6 -2
- package/src/serve/hub-app/thread-row.tsx +101 -0
- package/src/serve/hub-app/time-ago.tsx +3 -2
- package/src/serve/hub-app/time-view.tsx +2 -1
- package/src/serve/hub-app/time.css +2 -5
- package/src/serve/hub-app/tree-row.tsx +1 -9
- package/src/serve/hub-app/vault-view.tsx +4 -4
- package/src/serve/hub-app/veille/veille-page.tsx +2 -11
- package/src/serve/hub-app/veille.css +0 -1
- package/src/serve/hub-app/waiting-svc.ts +4 -4
- package/src/serve/hub-app/when-view.tsx +6 -3
- package/src/serve/hub-app/wiki-st.ts +30 -4
- package/src/serve/hub-app/wikis-view.tsx +4 -3
- package/src/serve/hub-runtime.ts +20 -6
- package/src/serve/project-gutter-route.ts +16 -6
- package/src/serve/project-gutter.ts +6 -53
- package/src/serve/same-origin.ts +3 -0
- package/src/serve/secret-gate.ts +21 -0
- package/src/serve/serve-hub.ts +29 -20
- package/src/serve/tailnet-caller.ts +117 -0
- package/src/shipkit.ts +2 -2
- package/src/site/desk.ts +2 -2
- package/src/smoke/run-smoke.ts +3 -4
- package/src/social/brands.ts +4 -0
- package/src/social/card-drafts.ts +11 -19
- package/src/social/desk-index.ts +34 -13
- package/src/social/drafts.ts +4 -4
- package/src/social/import-drafts.ts +244 -0
- package/src/social/kind-pages.ts +3 -3
- package/src/social/kinds.ts +1 -1
- package/src/social/load.ts +89 -64
- package/src/social/media-kind.ts +68 -161
- package/src/social/media-of.ts +5 -4
- package/src/social/open.ts +3 -2
- package/src/social/post-object.ts +120 -0
- package/src/social/post-sources.ts +136 -0
- package/src/social/post-text.ts +103 -0
- package/src/social/posts.ts +378 -0
- package/src/social/presence.ts +7 -5
- package/src/social/publish/index.ts +17 -5
- package/src/social/publish/secret.ts +2 -2
- package/src/social/release-stage.ts +58 -57
- package/src/social/routes.ts +64 -24
- package/src/social/stage.ts +42 -57
- package/src/social/text.ts +4 -3
- package/src/social/thumbnail.ts +135 -43
- package/src/social/tracker.ts +1 -1
- package/src/social/writes.ts +12 -29
- package/src/stores/desk.ts +16 -11
- package/src/stores/unit.ts +2 -2
- package/src/trailer/sound/eleven.ts +33 -3
- package/src/urls/rows.ts +1 -1
- package/src/vault/vault-http.ts +11 -3
- package/src/vault/vault-import.ts +6 -1
- package/src/veille/identity.ts +2 -2
- package/src/wiki/graph-pages.ts +13 -1
- package/src/wiki/scan-md.ts +1 -1
- package/src/asks/asks-queue.ts +0 -424
- package/src/messages/suggest.ts +0 -96
- package/src/social/migrate.ts +0 -123
package/src/home/daemon-jobs.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { contextSourcesStamp, GLOBAL_CONTEXT_DONE, GLOBAL_CONTEXT_EVERY_MS, GLOB
|
|
|
19
19
|
import { APPS_DONE, APPS_EVERY_MS, appsDue, appsSourcesStamp } from './process-apps.ts'
|
|
20
20
|
import { REPORT_EVERY_MS } from '../hq/machine-notes.ts'
|
|
21
21
|
|
|
22
|
-
export type JobId = 'backup' | 'retention sweep' | 'media store' | 'annex' | 'global context' | 'apps' | 'agent time' | 'hq report' | 'hq cards' | 'db census' | 'space copy' | 'space listing' | 'vault' | 'db fold'
|
|
22
|
+
export type JobId = 'backup' | 'retention sweep' | 'media store' | 'annex' | 'global context' | 'apps' | 'agent time' | 'hq report' | 'hq cards' | 'db census' | 'space copy' | 'space listing' | 'vault' | 'db fold' | 'thread copy'
|
|
23
23
|
|
|
24
24
|
/** how often the transcripts' new lines join the index of `sk time` */
|
|
25
25
|
export const AGENT_TIME_EVERY_MS = 10 * 60_000
|
|
@@ -66,6 +66,9 @@ export const DAEMON_JOBS: readonly DaemonJob[] = [
|
|
|
66
66
|
{ id: 'retention sweep', everyMs: 5 * 60_000, firstMs: 10_000, due: (now) => now - (machineGet<number>(SWEPT_AT) ?? 0) >= SWEEP_EVERY_MS },
|
|
67
67
|
// a watch of the sources: a look only once a source may have moved, a run waits, or a clock says so
|
|
68
68
|
{ id: 'backup', everyMs: BACKUP_EVERY_MS, firstMs: BACKUP_EVERY_MS, hold: (root, printErr) => backupHold(root, printErr) },
|
|
69
|
+
// the thread store's second copy on another machine: a look is one count query of the machine db, a child only
|
|
70
|
+
// once the store moved and the last copy is 10 min old (media-store/backup/thread-copy.ts)
|
|
71
|
+
{ id: 'thread copy', everyMs: BACKUP_EVERY_MS, firstMs: 60_000, due: async (now) => (await import('../media-store/backup/thread-copy.ts')).threadCopyDue(now) },
|
|
69
72
|
// the house's generated context: its unit files are imported to be read, a second of compile the loop never pays
|
|
70
73
|
{ id: 'global context', everyMs: GLOBAL_CONTEXT_EVERY_MS, firstMs: 30_000, due: async (now, root) => contextDue(now, await contextSourcesStamp(root)) },
|
|
71
74
|
// every global process with a url as an app in ~/Applications: built when missing or stale, removed when gone (process-apps.ts)
|
|
@@ -294,6 +297,15 @@ export async function runJobBody(id: JobId, o: { root: string; home: string; pri
|
|
|
294
297
|
const { machineSpace } = await import('../media-store/space.ts')
|
|
295
298
|
return backupTick({ home: o.home, repos: [...repos, ...house.archived.map((r) => r.path)], space: machineSpace, print: o.print, printErr: o.printErr })
|
|
296
299
|
}
|
|
300
|
+
if (id === 'thread copy') {
|
|
301
|
+
const { sendThreadCopy } = await import('../media-store/backup/thread-copy.ts')
|
|
302
|
+
const r = await sendThreadCopy()
|
|
303
|
+
if (r.sent != null) {
|
|
304
|
+
o.print(`ok: thread copy: ${r.sent}, ${(r.bytes / 1e6).toFixed(1)} MB, ${r.pruned} pruned`)
|
|
305
|
+
if (r.why) o.printErr(`WARN thread copy: ${r.why}`)
|
|
306
|
+
} else if (!r.why.startsWith('the store did not move')) o.printErr(`WARN thread copy: ${r.why}`)
|
|
307
|
+
return
|
|
308
|
+
}
|
|
297
309
|
if (id === 'media store') {
|
|
298
310
|
const { mediaTick } = await import('../media-store/daemon.ts')
|
|
299
311
|
const { mediaKinds } = await import('../media-kinds.ts')
|
package/src/home/home-paths.ts
CHANGED
|
@@ -46,15 +46,18 @@ export async function pmUp(port = pmPort(), timeoutMs = 400): Promise<boolean> {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/** shipkit's own suite run without its preload (tests/_setup.ts gives each run a temp home): it would read, write and
|
|
49
|
-
* delete the machine's real home
|
|
50
|
-
|
|
49
|
+
* delete the machine's real home and its machine db, the media index and the review cards included. Throws then */
|
|
50
|
+
export function refuseRealHomeInSuite(): void {
|
|
51
|
+
if (process.env.NODE_ENV === 'test' && /\/rvlib-shipkit\/tests\//.test(Bun.main))
|
|
52
|
+
throw new Error(`${Bun.main}: a shipkit suite reached the machine's real home; run it from packages/rvlib-shipkit (its bunfig preload gives the run a temp home) or through sk ci --only test`)
|
|
53
|
+
}
|
|
51
54
|
|
|
52
55
|
/** `~/.shipkit/home` (in `~/.config/shipkit/` until the machine moved: layout.ts machinePath), beside the rail order
|
|
53
56
|
* file (project-gutter-route.ts orderFile) */
|
|
54
57
|
export const homeDir = (): string => {
|
|
55
58
|
const dir = process.env.SHIPKIT_HOME_DIR
|
|
56
59
|
if (dir) return dir
|
|
57
|
-
|
|
60
|
+
refuseRealHomeInSuite()
|
|
58
61
|
return machinePath('home')
|
|
59
62
|
}
|
|
60
63
|
|
package/src/home/home-routes.ts
CHANGED
|
@@ -350,6 +350,14 @@ export function homeRoutes(d: HomeDeps) {
|
|
|
350
350
|
return Response.json(await houseUrls(repos), { headers: { 'cache-control': 'no-store' } })
|
|
351
351
|
}
|
|
352
352
|
if (req.method !== 'POST') return null
|
|
353
|
+
// a pane of the page that failed to draw (hub-app/pane-errors.ts): one line in this process's log, where the
|
|
354
|
+
// home's own errors already go, for an agent that never saw the page
|
|
355
|
+
if (path === '/api/home/page-error') {
|
|
356
|
+
const b = await body(req)
|
|
357
|
+
const cut = (v: unknown): string => String(v).slice(0, 400)
|
|
358
|
+
console.error(`page error: the ${cut(b.pane)} pane failed to draw: ${cut(b.message)} (${cut(b.url)})`)
|
|
359
|
+
return Response.json({ ok: true })
|
|
360
|
+
}
|
|
353
361
|
if (path === '/api/home/hub') {
|
|
354
362
|
const b = await body(req)
|
|
355
363
|
if (repos.length === 0) await refresh()
|
package/src/home/inbox-shape.ts
CHANGED
|
@@ -1,47 +1,58 @@
|
|
|
1
|
-
// the inbox as data (wiki tools/shipkit/home.md
|
|
2
|
-
//
|
|
3
|
-
// already holds, never a store of its own: its review store's
|
|
1
|
+
// the inbox as data (wiki tools/shipkit/home-inbox.md): every thread of every house repo, each once, in the list of who
|
|
2
|
+
// acts now, badged with what it waits on from him (review/wait.ts). Pure and browser safe: the daemon (inbox.ts), the
|
|
3
|
+
// page and the tests share it. Each repo gives what it already holds, never a store of its own: its review store's
|
|
4
|
+
// thread index and its hub's needs, a need being a row only while no thread stands for it.
|
|
4
5
|
//
|
|
5
|
-
// the one constraint a reader breaks first: a row
|
|
6
|
-
//
|
|
7
|
-
import { afterWords } from '../asks/ask-after.ts'
|
|
6
|
+
// the one constraint a reader breaks first: a row is never typed by what its thread is (a version, an ask, a check);
|
|
7
|
+
// its badge is the verb, so the filter and the counts read one field, `wait`
|
|
8
8
|
import { REVIEW_COL, type Resource } from '../collections/collection-types.ts'
|
|
9
|
+
import { bandOf } from '../review/band.ts'
|
|
9
10
|
import type { ThreadIndex, ThreadRow } from '../review/cells.ts'
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
export type InboxList = 'main' | '
|
|
20
|
-
/** the
|
|
21
|
-
export
|
|
11
|
+
import { canonicalAddress } from '../review/model.ts'
|
|
12
|
+
import { needAddress } from '../review/need-address.ts'
|
|
13
|
+
import { NO_PARTIES, type Parties } from '../review/parties.ts'
|
|
14
|
+
import { askVerb, isOwnerWait, OWNER_WAITS, verbsOf, waitOf, waitsMatch, type OwnerWait, type Wait, type WaitsOn } from '../review/wait.ts'
|
|
15
|
+
|
|
16
|
+
export { OWNER_WAITS, type OwnerWait, type Wait } from '../review/wait.ts'
|
|
17
|
+
|
|
18
|
+
/** who acts now (review/band.ts): him (`main`), a live agent works on it (`working`), an agent's move nobody works
|
|
19
|
+
* (`waiting`), him from a day still ahead (`later`), nobody (`done`) */
|
|
20
|
+
export type InboxList = 'main' | 'working' | 'waiting' | 'later' | 'done'
|
|
21
|
+
/** the lists in the order drawn */
|
|
22
|
+
export const INBOX_LISTS = ['main', 'working', 'waiting', 'later', 'done'] as const satisfies readonly InboxList[]
|
|
23
|
+
/** the lists shown and counted by default: `done` is read only once picked */
|
|
24
|
+
export const DEFAULT_STATE: readonly InboxList[] = ['main', 'working', 'waiting', 'later']
|
|
25
|
+
/** a state that names `working` shows `waiting` too: a pref kept before the split keeps the threads that moved */
|
|
26
|
+
const withWaiting = (s: InboxList[]): InboxList[] => (s.includes('working') && !s.includes('waiting') ? INBOX_LISTS.filter((l) => l === 'waiting' || s.includes(l)) : s)
|
|
27
|
+
/** the lists whose rows carry a verb of his: the verbs filter and count these */
|
|
28
|
+
const HIS: ReadonlySet<InboxList> = new Set(['main', 'later'])
|
|
22
29
|
/** what the rows group by: each one on or off on its own, nested in this order */
|
|
23
|
-
export const INBOX_GROUPS = ['
|
|
30
|
+
export const INBOX_GROUPS = ['project', 'wait', 'lane'] as const
|
|
24
31
|
export type InboxGroup = (typeof INBOX_GROUPS)[number]
|
|
25
32
|
|
|
26
|
-
/**
|
|
27
|
-
export
|
|
33
|
+
/** the verbs filter: null every verb, else these */
|
|
34
|
+
export type WaitSel = null | OwnerWait[]
|
|
35
|
+
export const waitIn = (sel: WaitSel, w: Wait): boolean => sel === null || (sel as readonly string[]).includes(w)
|
|
28
36
|
|
|
29
37
|
export interface InboxRow {
|
|
30
38
|
/** `<repo>/<id>`, one per row of the whole inbox */
|
|
31
39
|
key: string
|
|
32
40
|
repo: string
|
|
33
|
-
|
|
34
|
-
/** the item's id in its repo: a review thread's head, or a need's id */
|
|
41
|
+
/** a thread's head, or a need's id while no thread stands for it */
|
|
35
42
|
id: string
|
|
36
|
-
/** a need's collection, the section of its repo's hub */
|
|
43
|
+
/** a need's collection, the section of its repo's hub; a thread has none */
|
|
37
44
|
col?: string
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
/** what it waits on from him first: the badge */
|
|
46
|
+
wait: Wait
|
|
47
|
+
/** what waits on him first, the icon its row draws (review/wait.ts waitEntryOf) */
|
|
48
|
+
waitsOn?: WaitsOn
|
|
49
|
+
/** every verb its open objects ask: what the verbs filter and its counts read (review/wait.ts verbsOf) */
|
|
50
|
+
verbs: OwnerWait[]
|
|
41
51
|
title: string
|
|
52
|
+
/** agent words he has not read */
|
|
53
|
+
unread?: true
|
|
42
54
|
/** one more line: the lane and the versions, the need's sentence */
|
|
43
55
|
sub?: string
|
|
44
|
-
/** the lane the card belongs to; a need has none */
|
|
45
56
|
lane?: string
|
|
46
57
|
/** epoch ms of its newest move, null when nothing dates it */
|
|
47
58
|
at: number | null
|
|
@@ -56,8 +67,8 @@ export interface InboxSource {
|
|
|
56
67
|
repo: string
|
|
57
68
|
review: { tag: string; ix: ThreadIndex } | null
|
|
58
69
|
needs: Resource[]
|
|
59
|
-
/**
|
|
60
|
-
|
|
70
|
+
/** the sessions and lanes its threads' holders name: whether a live agent works a thread (none: nobody does) */
|
|
71
|
+
parties?: Parties
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
export interface InboxAnswer {
|
|
@@ -67,11 +78,15 @@ export interface InboxAnswer {
|
|
|
67
78
|
total: number
|
|
68
79
|
offset: number
|
|
69
80
|
limit: number
|
|
70
|
-
/** the rows of each list the
|
|
81
|
+
/** the rows of each list under the filters; `done` is 0 while it is not asked */
|
|
71
82
|
counts: Record<InboxList, number>
|
|
72
|
-
/** the rows of each
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
/** the rows of each verb of his in the lists of `state`, under the projects filter: they add up to those lists */
|
|
84
|
+
byWait: Partial<Record<OwnerWait, number>>
|
|
85
|
+
/** the threads of his turn under the other filters, each once: « all » of the verbs, which their counts no longer
|
|
86
|
+
* add up to, a thread being counted under each verb it asks */
|
|
87
|
+
waitsAll: number
|
|
88
|
+
/** the rows of each repo in the lists of `state`, under the verbs filter */
|
|
89
|
+
byProject: Record<string, number>
|
|
75
90
|
/** per repo, the rows of each list: its own badges count the same */
|
|
76
91
|
repos: Record<string, Record<InboxList, number>>
|
|
77
92
|
/** a repo whose items are not here, and why (its hub is down, a read broke) */
|
|
@@ -79,8 +94,6 @@ export interface InboxAnswer {
|
|
|
79
94
|
}
|
|
80
95
|
|
|
81
96
|
export const INBOX_PAGE = 50
|
|
82
|
-
/** a repo with no commit for this long is quiet: nobody works there, its red checks fold into « can wait » */
|
|
83
|
-
export const QUIET_DAYS = 7
|
|
84
97
|
export const INBOX_MAX = 500
|
|
85
98
|
|
|
86
99
|
/** where a repo's hub answers on the home */
|
|
@@ -101,18 +114,25 @@ export const isReviewId = (id: string): boolean => /^\d{8}-\d{6}-/.test(id)
|
|
|
101
114
|
|
|
102
115
|
const IMAGE = /\.(png|jpe?g|webp)$/i
|
|
103
116
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
117
|
+
/** the list of who acts now on a thread: its band, with the repo's parties */
|
|
118
|
+
const listOfRow = (r: ThreadRow, p: Parties): InboxList => {
|
|
119
|
+
const b = bandOf(r, p)
|
|
120
|
+
return b === 'yours' ? 'main' : b === 'aside' ? 'later' : b
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function threadRow(repo: string, r: ThreadRow, wait: Wait, verbs: OwnerWait[]): InboxRow {
|
|
124
|
+
const later = r.turn === 'aside' && r.aside != null ? `after ${r.aside.until.slice(0, 10)}` : null
|
|
125
|
+
const sub = [later, r.lane, r.versions > 1 ? `v${r.versions}` : null].filter((x): x is string => x != null && x !== '').join(' · ')
|
|
107
126
|
const at = Date.parse(r.updated)
|
|
108
127
|
return {
|
|
109
128
|
key: `${repo}/${r.head}`,
|
|
110
129
|
repo,
|
|
111
|
-
kind,
|
|
112
130
|
id: r.head,
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
wait,
|
|
132
|
+
verbs,
|
|
133
|
+
...(r.waitsOn && isOwnerWait(wait) ? { waitsOn: r.waitsOn } : {}),
|
|
115
134
|
title: r.title,
|
|
135
|
+
...(r.unread ? { unread: true as const } : {}),
|
|
116
136
|
...(sub !== '' ? { sub } : {}),
|
|
117
137
|
...(r.lane ? { lane: r.lane } : {}),
|
|
118
138
|
at: Number.isFinite(at) ? at : null,
|
|
@@ -124,45 +144,47 @@ function reviewRow(repo: string, r: ThreadRow, kind: InboxKind, tone: InboxTone)
|
|
|
124
144
|
/** when a need moved: a check's last run, else what `dated` reads off its file (an ask's birth, a file's last write) */
|
|
125
145
|
export type Dated = (n: Resource) => number | null
|
|
126
146
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
147
|
+
/** a need no thread stands for yet: his hands when its type says so (an ask, a picture to update on an account), else
|
|
148
|
+
* an agent's, which nobody works while no thread stands for it */
|
|
149
|
+
function needRow(repo: string, n: Resource, dated: Dated): { list: InboxList; row: InboxRow } {
|
|
150
|
+
const wait: Wait = n.collection === 'asks' ? askVerb(n.ask?.kind ?? 'action') : n.type === 'ask' ? 'do' : 'agents'
|
|
151
|
+
const sub = n.text !== n.title ? n.text : n.slot
|
|
131
152
|
return {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
list: wait === 'agents' ? 'waiting' : 'main',
|
|
154
|
+
row: {
|
|
155
|
+
key: `${repo}/${n.id}`,
|
|
156
|
+
repo,
|
|
157
|
+
id: n.id,
|
|
158
|
+
col: n.collection,
|
|
159
|
+
wait,
|
|
160
|
+
verbs: isOwnerWait(wait) ? [wait] : [],
|
|
161
|
+
title: n.title,
|
|
162
|
+
...(sub != null && sub !== '' ? { sub } : {}),
|
|
163
|
+
at: n.check?.lastAt ?? dated(n),
|
|
164
|
+
thumb: null,
|
|
165
|
+
open: inboxAddress(repo, n.id),
|
|
166
|
+
},
|
|
144
167
|
}
|
|
145
168
|
}
|
|
146
169
|
|
|
147
|
-
/** one repo's rows:
|
|
148
|
-
*
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
for (const { row } of s.review?.ix.entries ?? [])
|
|
153
|
-
if (s.review!.ix.waiting.has(row.head)) out.main.push(reviewRow(s.repo, row, row.origin === 'agent' ? 'card' : 'question', 'review'))
|
|
154
|
-
else if (row.active && row.move === 'agents' && row.origin !== 'agent') out.yellow.push(reviewRow(s.repo, row, 'raised', 'yellow'))
|
|
155
|
-
}
|
|
170
|
+
/** one repo's rows by who acts now: each thread once, in its turn's list; a need only while no thread stands for it (an
|
|
171
|
+
* ask, a check, a reflection by its address). `done` rows only when asked: a store holds thousands */
|
|
172
|
+
export function repoRows(s: InboxSource, dated: Dated, withDone = false, now = new Date()): Record<InboxList, InboxRow[]> {
|
|
173
|
+
const out: Record<InboxList, InboxRow[]> = { main: [], working: [], waiting: [], later: [], done: [] }
|
|
174
|
+
const owned = new Set<string>()
|
|
175
|
+
for (const { row } of s.review?.ix.entries ?? []) for (const a of row.addresses) owned.add(a)
|
|
156
176
|
for (const n of s.needs) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
177
|
+
// a reflection is an object, listed by its repo's reflections page; a thread opened on it is a row below
|
|
178
|
+
if (n.severity == null || n.collection === REVIEW_COL || n.collection === 'reflections' || n.askOwned === true) continue
|
|
179
|
+
const a = n.collection === 'asks' ? canonicalAddress(n.id) : needAddress(s.repo, n)
|
|
180
|
+
if (a !== null && owned.has(a)) continue
|
|
181
|
+
const { list, row } = needRow(s.repo, n, dated)
|
|
182
|
+
out[list].push(row)
|
|
183
|
+
}
|
|
184
|
+
for (const { t, row } of s.review?.ix.entries ?? []) {
|
|
185
|
+
const l = listOfRow(row, s.parties ?? NO_PARTIES)
|
|
186
|
+
if (l === 'done' && !withDone) continue
|
|
187
|
+
out[l].push(threadRow(s.repo, row, l === 'done' ? 'done' : l === 'working' || l === 'waiting' ? 'agents' : waitOf(t, now), HIS.has(l) ? verbsOf(t, now) : []))
|
|
166
188
|
}
|
|
167
189
|
return out
|
|
168
190
|
}
|
|
@@ -171,36 +193,88 @@ export function repoRows(s: InboxSource, dated: Dated): Record<InboxList, InboxR
|
|
|
171
193
|
export const byNewest = (a: InboxRow, b: InboxRow): number =>
|
|
172
194
|
(b.at ?? -Infinity) - (a.at ?? -Infinity) || a.repo.localeCompare(b.repo) || a.title.localeCompare(b.title)
|
|
173
195
|
|
|
196
|
+
export type InboxLists = Record<InboxList, InboxRow[]> & { repos: InboxAnswer['repos'] }
|
|
197
|
+
|
|
174
198
|
/** every repo's rows, each list in its order; `dated` dates a need of that repo */
|
|
175
|
-
export function inboxRows<S extends InboxSource>(sources: readonly S[], dated: (s: S) => Dated
|
|
176
|
-
const main:
|
|
177
|
-
const yellow: InboxRow[] = []
|
|
178
|
-
const later: InboxRow[] = []
|
|
179
|
-
const repos: InboxAnswer['repos'] = {}
|
|
199
|
+
export function inboxRows<S extends InboxSource>(sources: readonly S[], dated: (s: S) => Dated, withDone = false): InboxLists {
|
|
200
|
+
const all: InboxLists = { main: [], working: [], waiting: [], later: [], done: [], repos: {} }
|
|
180
201
|
for (const s of sources) {
|
|
181
|
-
const r = repoRows(s, dated(s))
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
later.push(...r.later)
|
|
185
|
-
repos[s.repo] = { main: r.main.length, yellow: r.yellow.length, later: r.later.length }
|
|
202
|
+
const r = repoRows(s, dated(s), withDone)
|
|
203
|
+
for (const l of INBOX_LISTS) all[l].push(...r[l])
|
|
204
|
+
all.repos[s.repo] = { main: r.main.length, working: r.working.length, waiting: r.waiting.length, later: r.later.length, done: r.done.length }
|
|
186
205
|
}
|
|
187
|
-
|
|
206
|
+
for (const l of INBOX_LISTS) all[l].sort(byNewest)
|
|
207
|
+
return all
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface InboxQuery {
|
|
211
|
+
list: InboxList
|
|
212
|
+
waits: WaitSel
|
|
213
|
+
/** none is every repo */
|
|
214
|
+
projects: string[]
|
|
215
|
+
/** the lists the facet counts read */
|
|
216
|
+
state: InboxList[]
|
|
217
|
+
offset: number
|
|
218
|
+
limit: number
|
|
188
219
|
}
|
|
189
220
|
|
|
221
|
+
/** whether a query reads the done list */
|
|
222
|
+
export const wantsDone = (q: Pick<InboxQuery, 'list' | 'state'>): boolean => q.list === 'done' || q.state.includes('done')
|
|
223
|
+
|
|
224
|
+
/** a comma list of a url's search, empty when absent */
|
|
225
|
+
const listOf = (v: string | null): string[] => (v == null || v === '' ? [] : v.split(',').filter((x) => x !== ''))
|
|
226
|
+
const ownerVerbsIn = (vs: readonly string[]): OwnerWait[] => OWNER_WAITS.filter((w) => vs.includes(w))
|
|
227
|
+
const sameLists = (a: readonly InboxList[], b: readonly InboxList[]): boolean => a.join() === b.join()
|
|
228
|
+
|
|
190
229
|
/** the query from a url's search: a value out of range is its default */
|
|
191
|
-
export function inboxQuery(p: URLSearchParams):
|
|
230
|
+
export function inboxQuery(p: URLSearchParams): InboxQuery {
|
|
192
231
|
const n = (k: string, d: number, max: number): number => {
|
|
193
232
|
const v = Number(p.get(k) || NaN)
|
|
194
233
|
return Number.isInteger(v) && v >= 0 ? Math.min(v, max) : d
|
|
195
234
|
}
|
|
196
235
|
const list = p.get('list')
|
|
197
|
-
|
|
236
|
+
const waits = p.get('waits')
|
|
237
|
+
return {
|
|
238
|
+
list: (INBOX_LISTS as readonly string[]).includes(list ?? '') ? (list as InboxList) : 'main',
|
|
239
|
+
waits: waits == null ? null : ownerVerbsIn(listOf(waits)),
|
|
240
|
+
projects: listOf(p.get('projects')),
|
|
241
|
+
state: p.has('state') ? withWaiting(INBOX_LISTS.filter((l) => listOf(p.get('state')).includes(l))) : [...DEFAULT_STATE],
|
|
242
|
+
offset: n('offset', 0, Number.MAX_SAFE_INTEGER),
|
|
243
|
+
limit: Math.max(1, n('limit', INBOX_PAGE, INBOX_MAX)),
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** a value in an address, its colons kept as they are: a link stays readable */
|
|
248
|
+
const enc = (v: string): string => encodeURIComponent(v).replaceAll('%3A', ':')
|
|
249
|
+
|
|
250
|
+
/** the address's search of a query: the defaults left out */
|
|
251
|
+
export function inboxSearch(q: Partial<InboxQuery>): string {
|
|
252
|
+
const p: string[] = []
|
|
253
|
+
if (q.list != null && q.list !== 'main') p.push(`list=${q.list}`)
|
|
254
|
+
if (q.waits != null) p.push(`waits=${q.waits.join(',')}`)
|
|
255
|
+
if (q.projects != null && q.projects.length > 0) p.push(`projects=${q.projects.map(enc).join(',')}`)
|
|
256
|
+
if (q.state != null && !sameLists(q.state, DEFAULT_STATE)) p.push(`state=${q.state.join(',')}`)
|
|
257
|
+
if (q.limit != null) p.push(`limit=${q.limit}`)
|
|
258
|
+
return p.length === 0 ? '' : `?${p.join('&')}`
|
|
198
259
|
}
|
|
199
260
|
|
|
200
|
-
/** one page of one list */
|
|
201
|
-
export function inboxPage(all:
|
|
202
|
-
|
|
203
|
-
const
|
|
261
|
+
/** one page of one list. The verbs filter the lists of his turn; `working`, `waiting` and `done` are the state filter's alone */
|
|
262
|
+
export function inboxPage(all: InboxLists, q: InboxQuery, missing: InboxAnswer['missing']): InboxAnswer {
|
|
263
|
+
const verbOk = (l: InboxList, r: InboxRow): boolean => !HIS.has(l) || waitsMatch(q.waits, r.verbs)
|
|
264
|
+
const projectOk = (r: InboxRow): boolean => q.projects.length === 0 || q.projects.includes(r.repo)
|
|
265
|
+
const shown = (l: InboxList): InboxRow[] => all[l].filter((r) => verbOk(l, r) && projectOk(r))
|
|
266
|
+
const byWait: InboxAnswer['byWait'] = {}
|
|
267
|
+
const byProject: Record<string, number> = {}
|
|
268
|
+
let waitsAll = 0
|
|
269
|
+
for (const l of q.state) {
|
|
270
|
+
for (const r of all[l]) {
|
|
271
|
+
if (HIS.has(l) && projectOk(r)) {
|
|
272
|
+
waitsAll++
|
|
273
|
+
for (const v of r.verbs) byWait[v] = (byWait[v] ?? 0) + 1
|
|
274
|
+
}
|
|
275
|
+
if (verbOk(l, r)) byProject[r.repo] = (byProject[r.repo] ?? 0) + 1
|
|
276
|
+
}
|
|
277
|
+
}
|
|
204
278
|
const rows = shown(q.list)
|
|
205
279
|
return {
|
|
206
280
|
list: q.list,
|
|
@@ -208,22 +282,21 @@ export function inboxPage(all: ReturnType<typeof inboxRows>, q: ReturnType<typeo
|
|
|
208
282
|
total: rows.length,
|
|
209
283
|
offset: q.offset,
|
|
210
284
|
limit: q.limit,
|
|
211
|
-
counts: { main: shown('main').length,
|
|
212
|
-
|
|
213
|
-
|
|
285
|
+
counts: { main: shown('main').length, working: shown('working').length, waiting: shown('waiting').length, later: shown('later').length, done: shown('done').length },
|
|
286
|
+
byWait,
|
|
287
|
+
waitsAll,
|
|
288
|
+
byProject,
|
|
214
289
|
repos: all.repos,
|
|
215
290
|
missing,
|
|
216
291
|
}
|
|
217
292
|
}
|
|
218
293
|
|
|
219
|
-
const KIND_LABEL: Record<InboxKind, string> = { card: 'cards', question: 'questions', ask: 'asks', need: 'needs', raised: 'raised' }
|
|
220
|
-
|
|
221
294
|
/** a group of rows: its words, its rows' count, then its rows or its inner groups */
|
|
222
295
|
export type InboxGroupNode = { key: string; label: string; n: number; rows: InboxRow[]; groups: InboxGroupNode[] | null }
|
|
223
296
|
|
|
224
|
-
const groupOf = (r: InboxRow, by: InboxGroup): string => (by === '
|
|
297
|
+
const groupOf = (r: InboxRow, by: InboxGroup): string => (by === 'project' ? r.repo : by === 'wait' ? r.wait : r.lane ?? 'no lane')
|
|
225
298
|
|
|
226
|
-
/** the rows grouped by each axis that is on, nested
|
|
299
|
+
/** the rows grouped by each axis that is on, nested project then wait then lane; a group keeps its rows' order, and the
|
|
227
300
|
* groups come in the order their first row comes (newest first). No axis on: one group of every row */
|
|
228
301
|
export function groupRows(rows: readonly InboxRow[], on: readonly InboxGroup[], prefix = ''): InboxGroupNode[] {
|
|
229
302
|
const axes = INBOX_GROUPS.filter((g) => on.includes(g))
|
|
@@ -245,3 +318,63 @@ export function groupRows(rows: readonly InboxRow[], on: readonly InboxGroup[],
|
|
|
245
318
|
return { key, label: k, n: rs.length, rows: rs, groups: rest.length > 0 ? groupRows(rs, rest, key) : null }
|
|
246
319
|
})
|
|
247
320
|
}
|
|
321
|
+
|
|
322
|
+
/** what the page filters and groups by, and the groups folded: its hash and its kept pref */
|
|
323
|
+
export interface InboxFilters {
|
|
324
|
+
waits: WaitSel
|
|
325
|
+
projects: string[]
|
|
326
|
+
state: InboxList[]
|
|
327
|
+
groupBy: InboxGroup[]
|
|
328
|
+
/** the keys of the groups folded (InboxGroupNode.key), only those the grouping can draw */
|
|
329
|
+
fold: string[]
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const GROUP_KEYS = new Set<string>(INBOX_GROUPS)
|
|
333
|
+
|
|
334
|
+
/** the folds a grouping can draw: a key's axes, in order, are the first axes grouped by (`wait:judge/` under wait,
|
|
335
|
+
* `project:orchard/wait:judge/` under project then wait); a folded list's keys lead with the list (`working/wait:do/`) */
|
|
336
|
+
export function foldsUnder(fold: readonly string[], groupBy: readonly InboxGroup[]): string[] {
|
|
337
|
+
return [...new Set(fold)].filter((k) => {
|
|
338
|
+
const axes = [...k.matchAll(/(?:^|\/)(project|wait|lane):/g)].map((m) => m[1])
|
|
339
|
+
return axes.length > 0 && axes.length <= groupBy.length && axes.every((a, i) => a === groupBy[i])
|
|
340
|
+
})
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** a fold key as text: the trailing slash left out, slashes and colons kept readable */
|
|
344
|
+
const foldText = (k: string): string => enc(k.replace(/\/$/, '')).replaceAll('%2F', '/')
|
|
345
|
+
|
|
346
|
+
/** the filters as text, `waits=judge,answer&projects=orchard&state=main&group=project&fold=project:orchard`: the hash
|
|
347
|
+
* and the kept pref share it, what is at its default left out */
|
|
348
|
+
export function filtersText(f: InboxFilters): string {
|
|
349
|
+
const p = inboxSearch({ waits: f.waits, projects: f.projects, state: f.state }).replace(/^\?/, '')
|
|
350
|
+
const fold = foldsUnder(f.fold, f.groupBy)
|
|
351
|
+
return [p, f.groupBy.length > 0 ? `group=${f.groupBy.join(',')}` : '', fold.length > 0 ? `fold=${fold.map(foldText).join(',')}` : ''].filter((x) => x !== '').join('&')
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** filters read back from their text: a part missing or broken is its default */
|
|
355
|
+
export function filtersOf(text: string): InboxFilters {
|
|
356
|
+
const kv = new Map<string, string>()
|
|
357
|
+
for (const part of text.split('&')) {
|
|
358
|
+
const at = part.indexOf('=')
|
|
359
|
+
if (at > 0) kv.set(part.slice(0, at), part.slice(at + 1))
|
|
360
|
+
}
|
|
361
|
+
const list = (k: string): string[] | null => {
|
|
362
|
+
const v = kv.get(k)
|
|
363
|
+
if (v == null) return null
|
|
364
|
+
try {
|
|
365
|
+
return v.split(',').filter((x) => x !== '').map(decodeURIComponent)
|
|
366
|
+
} catch {
|
|
367
|
+
return []
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const waits = list('waits')
|
|
371
|
+
const state = list('state')
|
|
372
|
+
const groupBy = INBOX_GROUPS.filter((g) => (list('group') ?? []).filter((x) => GROUP_KEYS.has(x)).includes(g))
|
|
373
|
+
return {
|
|
374
|
+
waits: waits == null ? null : ownerVerbsIn(waits),
|
|
375
|
+
projects: list('projects') ?? [],
|
|
376
|
+
state: state == null ? [...DEFAULT_STATE] : withWaiting(INBOX_LISTS.filter((l) => state.includes(l))),
|
|
377
|
+
groupBy,
|
|
378
|
+
fold: foldsUnder((list('fold') ?? []).map((k) => `${k}/`), groupBy),
|
|
379
|
+
}
|
|
380
|
+
}
|