rvlib-shipkit 2.31.0 → 2.33.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 +51 -0
- package/package.json +1 -1
- package/src/advisors/acts.ts +16 -15
- package/src/advisors/advice.ts +56 -102
- package/src/advisors/advisor-view.ts +122 -76
- package/src/advisors/app-graph.ts +1 -1
- package/src/advisors/app.ts +3 -11
- package/src/advisors/cf-api.ts +1 -1
- package/src/advisors/dir-bucket.ts +4 -3
- package/src/advisors/edge/api.ts +20 -221
- package/src/advisors/edge/bucket.ts +2 -2
- package/src/advisors/edge/handler.ts +13 -155
- package/src/advisors/edge/here.ts +5 -5
- package/src/advisors/edge/pages.ts +12 -9
- package/src/advisors/edge/shell.ts +6 -5
- package/src/advisors/edge/sign-in.ts +101 -36
- package/src/advisors/edge/status.ts +19 -6
- package/src/advisors/edge/types.ts +36 -60
- package/src/advisors/expose.ts +29 -29
- package/src/advisors/here.ts +12 -12
- package/src/advisors/invite-send.ts +79 -35
- package/src/advisors/invite.ts +31 -8
- package/src/advisors/job.ts +24 -16
- package/src/advisors/login.ts +40 -15
- package/src/advisors/owner-store.ts +46 -22
- package/src/advisors/photos.ts +3 -3
- package/src/advisors/project.ts +27 -25
- package/src/advisors/reach.ts +89 -0
- package/src/advisors/rights.ts +1 -1
- package/src/advisors/routes.ts +55 -74
- package/src/advisors/scan.ts +0 -4
- package/src/advisors/setup-run.ts +14 -14
- package/src/advisors/share-trace.ts +3 -3
- package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
- package/src/advisors/speaks.ts +29 -0
- package/src/advisors/sync.ts +97 -183
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +261 -87
- package/src/advisors/users-store.ts +81 -0
- package/src/agent-time/blocked-scan.ts +181 -0
- package/src/agent-time/registry.ts +12 -5
- package/src/agent-time/store.ts +9 -109
- package/src/asks/ask-bar-fold.ts +2 -1
- package/src/asks/ask-close.ts +2 -1
- package/src/asks/ask-doc.ts +2 -1
- package/src/asks/ask-migrate.ts +3 -2
- package/src/asks/ask-steps-fold.ts +2 -1
- package/src/asks/ask-store.ts +4 -3
- package/src/check.ts +3 -43
- package/src/checks/SK001-package-json-shape.check.ts +4 -55
- package/src/checks/SK004-gitignore-policy.check.ts +24 -69
- package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
- package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
- package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
- package/src/checks/SK020-self-spawning-check.check.ts +5 -7
- package/src/checks/SK035-public-clean.check.ts +1 -1
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
- package/src/checks/SK042-post-kinds.check.ts +5 -14
- package/src/checks/SK054-agent-allow-list.check.ts +5 -74
- package/src/checks/SK055-retired-config-keys.check.ts +45 -0
- package/src/cli/cmd_Advisors.ts +11 -45
- package/src/cli/cmd_Asks.ts +3 -10
- package/src/cli/cmd_Backup.ts +25 -127
- package/src/cli/cmd_BackupTargets.ts +1 -1
- package/src/cli/cmd_Capacity.ts +6 -2
- package/src/cli/cmd_Checks.ts +0 -14
- package/src/cli/cmd_Ci.ts +2 -1
- package/src/cli/cmd_Db.ts +3 -82
- package/src/cli/cmd_Home.ts +4 -32
- package/src/cli/cmd_Hq.ts +0 -17
- package/src/cli/cmd_Releases.ts +57 -4
- package/src/cli/cmd_Review.ts +333 -354
- package/src/cli/cmd_Shot.ts +26 -4
- package/src/cli/cmd_SocialDrafts.ts +6 -13
- package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +1 -1
- package/src/cli/inbox-hook-run.ts +5 -23
- package/src/cli/registry-heads.ts +5 -55
- package/src/cli/registry.ts +1 -5
- package/src/cli/review-here.ts +1 -1
- package/src/cli.ts +15 -4
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- package/src/core/admission.ts +268 -0
- package/src/core/agent-allow-policy.ts +32 -2
- package/src/core/agent-env.ts +8 -0
- package/src/core/allow-rows.ts +74 -0
- package/src/core/check-file-names.ts +19 -106
- package/src/core/code-lines.ts +36 -21
- package/src/core/footprint.ts +17 -13
- package/src/core/identities-root.ts +1 -4
- package/src/core/layout.ts +1 -2
- package/src/core/machine-db.ts +33 -208
- package/src/core/machine-layout.ts +14 -127
- package/src/core/machine-read.ts +5 -2
- package/src/core/mask-source.ts +60 -0
- package/src/core/memory-watch.ts +17 -14
- package/src/core/motherhome.ts +8 -35
- package/src/core/one-way-in-policy.ts +0 -3
- package/src/core/peer-sk.ts +8 -0
- package/src/core/repo-walk.ts +0 -9
- package/src/core/retention.ts +1 -9
- package/src/core/retired-checks.ts +2 -0
- package/src/core/tmux-policy.ts +1 -1
- package/src/core/tree-watch.ts +2 -2
- package/src/core/when.ts +7 -45
- package/src/gate/admit-heavy.ts +150 -0
- package/src/gate/check-runner.ts +6 -0
- package/src/gate/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/head-gate.ts +1 -1
- package/src/gate/job-run.ts +2 -1
- package/src/gate/pre-commit-discovery.ts +22 -28
- package/src/gate/run-check.ts +3 -4
- package/src/gate/run-ci.ts +4 -0
- package/src/gate/run-fix.ts +5 -17
- package/src/gate/run-fixers.ts +6 -42
- package/src/home/app-sign.ts +2 -2
- package/src/home/backup-status.ts +52 -92
- package/src/home/backup-verdict.ts +2 -2
- package/src/home/daemon-jobs.ts +51 -95
- package/src/home/database-words.ts +1 -2
- package/src/home/databases.ts +9 -25
- package/src/home/home-launchd.ts +0 -6
- package/src/home/home-paths.ts +8 -4
- package/src/home/home-routes.ts +3 -10
- package/src/home/home-state.ts +2 -14
- package/src/home/inbox-shape.ts +14 -15
- package/src/home/inbox.ts +1 -1
- package/src/home/machine-repair.ts +102 -103
- package/src/home/resume.ts +1 -15
- package/src/home/run-daemon.ts +7 -12
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/commit-msg-run.ts +61 -0
- package/src/hooks/commit-run.ts +16 -166
- package/src/hooks/gate-outcome.ts +108 -0
- package/src/hooks/git-hook.ts +9 -9
- package/src/hooks/hook-config.ts +8 -8
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/pre-commit-checks.ts +1 -1
- package/src/hooks/run-hooks.ts +2 -6
- package/src/hooks/shared-file.ts +3 -2
- package/src/hq/daemon-db.ts +8 -8
- package/src/hq/door.ts +3 -16
- package/src/hq/hq-db.ts +4 -3
- package/src/hq/hq-local.ts +1 -2
- package/src/hq/hq-store.ts +0 -15
- package/src/hq/item-direct.ts +8 -10
- package/src/hq/item-fill.ts +37 -0
- package/src/hq/kinds/item-gone.ts +7 -10
- package/src/hq/kinds/item-msg.ts +12 -18
- package/src/hq/kinds/item.ts +13 -19
- package/src/hq/kinds/report.ts +3 -4
- package/src/hq/owner-switch.ts +3 -3
- package/src/hq/report.ts +5 -9
- package/src/hq/switch.ts +2 -11
- package/src/hq/thread-sync.ts +5 -17
- package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
- package/src/http/owner-word.ts +1 -1
- package/src/identities/machine.ts +16 -0
- package/src/init-repo.ts +0 -1
- package/src/ledger/check-stats.ts +6 -5
- package/src/ledger/db.ts +2 -4
- package/src/ledger/record-kept.ts +117 -48
- package/src/ledger/run-log.ts +21 -2
- package/src/ledger/slow-tests.ts +96 -0
- package/src/ledger/store.ts +3 -86
- package/src/ledger/suite-log.ts +8 -2
- package/src/media-store/backup/facts.ts +3 -37
- package/src/media-store/backup/keys.ts +1 -8
- package/src/media-store/backup/manifest.ts +6 -67
- package/src/media-store/backup/restore.ts +4 -13
- package/src/media-store/backup/retention.ts +13 -1
- package/src/media-store/backup/run.ts +6 -267
- package/src/media-store/backup/snapshot.ts +2 -38
- package/src/media-store/backup/sources.ts +3 -113
- package/src/media-store/backup/target-send.ts +5 -29
- package/src/media-store/db.ts +8 -7
- package/src/media-store/forget-one.ts +1 -1
- package/src/media-store/forget.ts +1 -80
- package/src/orchestrator/guards.ts +0 -1
- package/src/orchestrator/presence.ts +2 -2
- package/src/orchestrator/routes.ts +1 -1
- package/src/orchestrator/started.ts +0 -9
- package/src/orchestrator/talk-key.ts +3 -4
- package/src/orchestrator/unheard.ts +1 -1
- package/src/plan/planner.ts +3 -2
- package/src/recordings/edit.ts +3 -3
- package/src/recordings/marks-draw.ts +17 -6
- package/src/recordings/marks.ts +120 -9
- package/src/reflections/reflections-queue.ts +3 -10
- package/src/release/notes.ts +1 -1
- package/src/release/public-clean.ts +66 -6
- package/src/release/run-bump.ts +11 -0
- package/src/release/run-release.ts +4 -0
- package/src/releases/from-thread.ts +3 -3
- package/src/releases/model.ts +186 -36
- package/src/releases/store.ts +13 -3
- package/src/releases/validate.ts +83 -0
- package/src/repo-config.ts +36 -64
- package/src/review/answer-kinds.ts +63 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +144 -230
- package/src/review/close.ts +39 -1
- package/src/review/doc-save.ts +3 -2
- package/src/review/draft-item.ts +1 -1
- package/src/review/events.ts +3 -7
- package/src/review/expect.ts +23 -39
- package/src/review/format.ts +79 -46
- package/src/review/glyphs.ts +1 -0
- package/src/review/hand-over.ts +3 -3
- package/src/review/heard.ts +1 -1
- package/src/review/holds-sync.ts +2 -1
- package/src/review/inbox-hook.ts +2 -2
- package/src/review/inbox-read.ts +39 -33
- package/src/review/instruction-guards.ts +12 -0
- package/src/review/instructions.ts +0 -1
- package/src/review/item-db.ts +13 -43
- package/src/review/item-hq.ts +2 -2
- package/src/review/item-rows.ts +3 -14
- package/src/review/kind-catalog.ts +3 -1
- package/src/review/kinds.ts +18 -8
- package/src/review/live-view.ts +3 -0
- package/src/review/media-kind.ts +1 -1
- package/src/review/mentions.ts +1 -2
- package/src/review/model.ts +158 -114
- package/src/review/move.ts +149 -0
- package/src/review/need-threads.ts +3 -2
- package/src/review/object-card.ts +11 -0
- package/src/review/object-read.ts +6 -1
- package/src/review/one-block.ts +1 -1
- package/src/review/owner-read.ts +1 -1
- package/src/review/phone-push.ts +10 -9
- package/src/review/previews.ts +32 -4
- package/src/review/push.ts +2 -2
- package/src/review/recap.ts +129 -0
- package/src/review/referring.ts +6 -3
- package/src/review/reflection-object.ts +4 -3
- package/src/review/routes.ts +51 -47
- package/src/review/secret-route.ts +3 -2
- package/src/review/settle.ts +0 -6
- package/src/review/snooze.ts +5 -3
- package/src/review/speaker.ts +68 -0
- package/src/review/start-title.ts +19 -0
- package/src/review/store-parties.ts +28 -0
- package/src/review/store.ts +94 -59
- package/src/review/{wakes.ts → thread-events.ts} +92 -7
- package/src/review/thread-md.ts +35 -14
- package/src/review/thread-state.ts +804 -0
- package/src/review/threads.ts +29 -347
- package/src/review/traces.ts +104 -7
- package/src/review/trailer-item.ts +1 -1
- package/src/review/unit.ts +7 -9
- package/src/review/verdict-items.ts +12 -10
- package/src/review/view-layout.ts +25 -1
- package/src/review/watch-feed.ts +1 -2
- package/src/review/working-guards.ts +2 -3
- package/src/rules/untrack-generated.ts +1 -15
- package/src/secrets/copy.ts +4 -4
- package/src/secrets/lapse.ts +2 -1
- package/src/serve/hub-app/advisor-app.tsx +4 -4
- package/src/serve/hub-app/advisor-face.tsx +9 -3
- package/src/serve/hub-app/advisor-host.ts +27 -27
- package/src/serve/hub-app/advisors-model.ts +17 -8
- package/src/serve/hub-app/advisors-rights.tsx +1 -1
- package/src/serve/hub-app/advisors-st.ts +15 -14
- package/src/serve/hub-app/advisors-view.tsx +13 -11
- package/src/serve/hub-app/app-bridge.ts +23 -3
- package/src/serve/hub-app/asks-page.tsx +1 -1
- package/src/serve/hub-app/auto-text.tsx +71 -16
- package/src/serve/hub-app/check-view.tsx +0 -8
- package/src/serve/hub-app/controls.css +14 -3
- package/src/serve/hub-app/database-view.tsx +1 -2
- package/src/serve/hub-app/dock-st.ts +1 -1
- package/src/serve/hub-app/git-view.tsx +3 -1
- package/src/serve/hub-app/hub.css +12 -5
- package/src/serve/hub-app/icons.tsx +1 -1
- package/src/serve/hub-app/inbox-view.tsx +1 -2
- package/src/serve/hub-app/live-sources.ts +2 -2
- package/src/serve/hub-app/main-panel.tsx +2 -1
- package/src/serve/hub-app/panel-repo.ts +0 -9
- package/src/serve/hub-app/pic.tsx +29 -12
- package/src/serve/hub-app/polled.ts +16 -2
- package/src/serve/hub-app/recordings-st.ts +23 -2
- package/src/serve/hub-app/recordings-view.tsx +68 -10
- package/src/serve/hub-app/ref-pill.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +1 -2
- package/src/serve/hub-app/review/advisor-add.tsx +1 -1
- package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
- package/src/serve/hub-app/review/draft-body.tsx +2 -2
- package/src/serve/hub-app/review/heard-line.tsx +1 -1
- package/src/serve/hub-app/review/instructions-view.tsx +1 -8
- package/src/serve/hub-app/review/kind-states.tsx +14 -9
- package/src/serve/hub-app/review/kit.tsx +4 -11
- package/src/serve/hub-app/review/lane-bar.tsx +3 -3
- package/src/serve/hub-app/review/lightbox.tsx +15 -11
- package/src/serve/hub-app/review/line-window.ts +4 -1
- package/src/serve/hub-app/review/live-bar-st.ts +2 -2
- package/src/serve/hub-app/review/live-view.tsx +57 -1
- package/src/serve/hub-app/review/object-panel.tsx +20 -8
- package/src/serve/hub-app/review/question-views.tsx +191 -53
- package/src/serve/hub-app/review/recap-bar.tsx +40 -0
- package/src/serve/hub-app/review/request-cell.tsx +48 -0
- package/src/serve/hub-app/review/review-cells.tsx +154 -96
- package/src/serve/hub-app/review/review-host.ts +8 -4
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +30 -35
- package/src/serve/hub-app/review/review-st.ts +32 -42
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +127 -68
- package/src/serve/hub-app/review/share-lines.tsx +4 -4
- package/src/serve/hub-app/review/start-st.ts +2 -5
- package/src/serve/hub-app/review/superseded-runs.ts +4 -3
- package/src/serve/hub-app/review/thread-close.tsx +10 -7
- package/src/serve/hub-app/review/thread-st.ts +381 -202
- package/src/serve/hub-app/review/tone-bar.tsx +129 -0
- package/src/serve/hub-app/review/tones.ts +53 -0
- package/src/serve/hub-app/review/trailer-body.tsx +2 -2
- package/src/serve/hub-app/review/trailer-st.ts +3 -2
- package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
- package/src/serve/hub-app/review.css +189 -106
- package/src/serve/hub-app/search-view.tsx +1 -1
- package/src/serve/hub-app/social/social-model.ts +0 -4
- package/src/serve/hub-app/source-acts.ts +2 -1
- package/src/serve/hub-app/stores/stores-page.tsx +2 -2
- package/src/serve/hub-app/terminal-sources.tsx +2 -1
- package/src/serve/hub-app/thread-row.tsx +3 -4
- package/src/serve/hub-app/tree-build.ts +0 -4
- package/src/serve/hub-app/urls-view.tsx +2 -1
- package/src/serve/hub-app/view-layout.css +13 -3
- package/src/serve/hub-app/wikis-view.tsx +5 -2
- package/src/serve/hub-runtime.ts +7 -37
- package/src/serve/project-gutter-route.ts +6 -2
- package/src/serve/read-thread.ts +20 -2
- package/src/serve/read-worker.ts +9 -1
- package/src/serve/record-pages.ts +46 -0
- package/src/serve/serve-hub.ts +2 -2
- package/src/serve/terminal-host.ts +1 -1
- package/src/serve/terminal-route.ts +1 -3
- package/src/serve/tracked-watch.ts +1 -3
- package/src/setup-house.ts +2 -2
- package/src/shipkit-files.ts +1 -1
- package/src/shipkit.ts +1 -6
- package/src/shot/client.ts +2 -1
- package/src/shot/film-box.ts +0 -20
- package/src/shot/on-place.ts +141 -0
- package/src/social/drafts.ts +1 -1
- package/src/social/kinds.ts +6 -29
- package/src/social/load.ts +2 -2
- package/src/social/post-object.ts +3 -2
- package/src/social/release-stage.ts +1 -1
- package/src/social/stage.ts +2 -2
- package/src/stores/model.ts +4 -0
- package/src/stores/routes.ts +11 -3
- package/src/suite/judge-suites.ts +58 -0
- package/src/suite/red-alone.ts +54 -18
- package/src/suite/runner-shapes.ts +2 -2
- package/src/suite/suite-cli.ts +67 -14
- package/src/suite/test-units.ts +2 -1
- package/src/urls/fill.ts +1 -1
- package/src/urls/places.ts +1 -2
- package/src/vault/vault-config.ts +2 -2
- package/src/vault/vault-init.ts +1 -5
- package/src/wiki/graph-page.ts +14 -2
- package/src/advisors/copy-truth.ts +0 -49
- package/src/advisors/door-child.ts +0 -112
- package/src/advisors/door-serve.ts +0 -52
- package/src/advisors/door.ts +0 -118
- package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
- package/src/checks/SK029-explicit-check-files.check.ts +0 -112
- package/src/checks/SK048-one-local-file.check.ts +0 -36
- package/src/core/config-rewrite.ts +0 -111
- package/src/core/daemon-port.ts +0 -10
- package/src/core/legacy-shapes.ts +0 -263
- package/src/core/migrate-layout.ts +0 -638
- package/src/core/port-check-cli.ts +0 -52
- package/src/core/port-check-file.ts +0 -295
- package/src/core/port-check-files.ts +0 -31
- package/src/gate/discover-legacy-checks.ts +0 -26
- package/src/home/home-move.ts +0 -527
- package/src/home/machine-fold.ts +0 -810
- package/src/hq/item-shapes.ts +0 -54
- package/src/hq/kinds/items-read.ts +0 -4
- package/src/media-store/backup/daemon.ts +0 -220
- package/src/media-store/backup/kept.ts +0 -241
- package/src/media-store/backup/prune.ts +0 -359
- package/src/media-store/backup/secret.ts +0 -88
- package/src/media-store/backup/ssh-space.ts +0 -202
- package/src/media-store/backup/watch.ts +0 -117
- package/src/review/band.ts +0 -182
- package/src/review/folders.ts +0 -216
- package/src/review/hook-ask.ts +0 -58
- package/src/review/role.ts +0 -48
- package/src/review/thread-fold.ts +0 -64
- package/src/review/wait.ts +0 -91
- package/src/rules/rule.ts +0 -43
- package/src/serve/hook-thread.ts +0 -37
- package/src/serve/hook-work.ts +0 -92
- package/src/serve/hook-worker.ts +0 -57
- package/src/serve/hub-app/review/dock.tsx +0 -147
- package/src/serve/hub-app/review/faces.tsx +0 -18
- package/src/serve/hub-app/review/item-verdict.tsx +0 -112
- package/src/serve/hub-app/review/review-board.tsx +0 -48
- /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
package/src/review/cells.ts
CHANGED
|
@@ -13,13 +13,9 @@ import {
|
|
|
13
13
|
proposeOpen,
|
|
14
14
|
type ProposeField,
|
|
15
15
|
type UpdateState,
|
|
16
|
-
isMarkItem,
|
|
17
16
|
isReply,
|
|
18
|
-
isStale,
|
|
19
17
|
laneOf,
|
|
20
|
-
moveOf,
|
|
21
18
|
partyOf,
|
|
22
|
-
reworkOf,
|
|
23
19
|
stateOf,
|
|
24
20
|
STATUS_LABEL,
|
|
25
21
|
verdictLabel,
|
|
@@ -28,6 +24,7 @@ import {
|
|
|
28
24
|
isGallery,
|
|
29
25
|
isPair,
|
|
30
26
|
verdictOf,
|
|
27
|
+
leftUnansweredOf,
|
|
31
28
|
type Item,
|
|
32
29
|
type ItemState,
|
|
33
30
|
type Message,
|
|
@@ -45,28 +42,23 @@ import {
|
|
|
45
42
|
type Verdict,
|
|
46
43
|
parentAddress,
|
|
47
44
|
isAskItem,
|
|
48
|
-
handedOver,
|
|
49
45
|
ownSave,
|
|
50
46
|
type AskState,
|
|
51
|
-
LAPSE_LATER
|
|
52
|
-
} from './
|
|
53
|
-
import {
|
|
54
|
-
import { firstTitleOf, nameOf, threadTitle, askStateOf, countedAsItsAsk, asideUntil, closedAt, addressesOfThread, ownAddressesOf, followedIds, holderOf, isActive, membersOf, openingOf, orderedThreads, sinceHeLeft, statusOf, turnOf, headWaits, nextVersionOf, type NextVersion, type Thread, type Turn } from './threads.ts'
|
|
55
|
-
import { answersTo, askOpen, kindCellAsk, wordsAlone } from './answer-kinds.ts'
|
|
47
|
+
LAPSE_LATER } from './model.ts'
|
|
48
|
+
import { nameAt, threadTitle, addressesOfThread, ownAddressesOf, followedIds, membersOf, type Thread } from './threads.ts'
|
|
49
|
+
import { answersTo, askOpen, kindCellAsk, remarkOf, wordsAlone } from './answer-kinds.ts'
|
|
56
50
|
import { currentInstructions, replacersOf, titleOf } from './supersede.ts'
|
|
57
51
|
import { judgeOf, type MessageVerdict } from './verdict-items.ts'
|
|
58
|
-
import {
|
|
59
|
-
import { laneAskOf, type LaneAsk } from './lane-ask.ts'
|
|
52
|
+
import { renameTrace, supersedeTrace, traceOf, traceWords, workingsOf, type Trace, type TraceCtx } from './traces.ts'
|
|
60
53
|
import { heardOf, type Heard } from './heard.ts'
|
|
61
54
|
import { mutedOf } from './phone-push.ts'
|
|
62
|
-
import { validatedOf } from './band.ts'
|
|
63
55
|
import { countsUnread, newToOwner, ownerCursorAt, type Fresh } from './owner-read.ts'
|
|
64
56
|
import { settledSpots, versionActs } from './settle.ts'
|
|
65
|
-
import { verbsOf, waitEntryOf, waitsMatch, type WaitsOn, waitsOfParam, type OwnerWait, type Wait } from './wait.ts'
|
|
66
57
|
import { codesOf, threadCode, type Codes } from './thread-code.ts'
|
|
67
58
|
import { refsIn } from './refs.ts'
|
|
68
59
|
import { parseSearch, tagsOfItems } from './thread-query.ts'
|
|
69
|
-
import
|
|
60
|
+
import { openingOf } from './thread-events.ts'
|
|
61
|
+
import { closerOf, askStateOf, countedAsItsAsk, isMoot, orderedThreads, recapCut, sinceHeLeft, statusOf, threadState, type Turn, type BandFacts, type ThreadState, waitsMatch, waitsOfParam, type OwnerWait } from './thread-state.ts'
|
|
70
62
|
export type CellKind = 'version' | 'verdict' | 'reply' | 'note' | 'event'
|
|
71
63
|
|
|
72
64
|
interface CellOf<K extends CellKind> {
|
|
@@ -95,7 +87,7 @@ interface CellOf<K extends CellKind> {
|
|
|
95
87
|
superseded?: { by: string; title: string; withdrawn?: true }
|
|
96
88
|
/** an act with no words of its own (an event, his bare verdict): drawn as one trace line (review/traces.ts) */
|
|
97
89
|
trace?: Trace
|
|
98
|
-
/** his word that wakes an agent (review/
|
|
90
|
+
/** his word that wakes an agent (review/thread-events.ts): the first agent read of it, null while no agent read it */
|
|
99
91
|
heard?: Heard | null
|
|
100
92
|
}
|
|
101
93
|
|
|
@@ -158,13 +150,14 @@ export interface ReplyCell extends CellOf<'reply'> {
|
|
|
158
150
|
/** an agent's question: its options, its pick, and the owner's answer once given (the option, the words) */
|
|
159
151
|
/** a question: `kind` absent on a choice; a checklist's and a confirm's lines with his ticks; a text's, a url's or a
|
|
160
152
|
* file's value; a secret's name and when it was stored, never a value; `open` while it waits on him */
|
|
161
|
-
ask?: { kind?: AnswerKind; options: string[]; pick?: number; views?: (number | null)[]; answered?: { option: number; text: string; at: string; /** a person's pick answered it: their id and name; both empty on their own copy, where it is theirs */ by?: { id: string; name: string } }; open?: boolean; /** the owner's own newest pick, whoever answered last */ ownerPick?: number; people?: PersonPick[]; lines?: { text: string; tick: boolean; at: string | null; pick?: number }[]; choices?: ({ options: string[]; pick?: number } | null)[]; value?: { text: string; at: string; opens?: number; view?: number }; secret?: { name: string; login?: boolean; stored?: string }; none?: string }
|
|
153
|
+
ask?: { kind?: AnswerKind; options: string[]; pick?: number; views?: (number | null)[]; answered?: { option: number; text: string; /** the owner's words with the pick (« pick with a remark »), '' or none for a plain pick */ remark?: string; at: string; /** a person's pick answered it: their id and name; both empty on their own copy, where it is theirs */ by?: { id: string; name: string } }; open?: boolean; /** the owner's own newest pick, whoever answered last */ ownerPick?: number; people?: PersonPick[]; lines?: { text: string; tick: boolean; at: string | null; pick?: number }[]; choices?: ({ options: string[]; pick?: number } | null)[]; value?: { text: string; at: string; opens?: number; view?: number }; secret?: { name: string; login?: boolean; stored?: string }; none?: string; /** the tone of his newest answer when it is not a plain pick (model.ts QUESTION_TONES) */ tone?: ReviewStatus; /** one row of a question with a row per thing (model.ts AskRow) */ row?: { group: string; i: number; n: number; label: string } }
|
|
162
154
|
/** an agent's proposed change of an object: each field, drawn by its type, and whether he applied it (the value he
|
|
163
|
-
* applied, the owner's edit or not); `open` while it waits on
|
|
164
|
-
|
|
155
|
+
* applied, the owner's edit or not); `open` while it waits on the owner; `none` the owner's words alone sent from its own box
|
|
156
|
+
* (« send my words »); `page` the repo's page that draws it */
|
|
157
|
+
propose?: { on: string; fields: (ProposeField & { applied?: { text: string; at: string } })[]; open: boolean; none?: string; page?: string }
|
|
165
158
|
/** the owner clicked one of the kind's actions */
|
|
166
159
|
action?: { name: string }
|
|
167
|
-
/** a request written before
|
|
160
|
+
/** a request written before the close, whoever closed, and never answered: it waits on nobody, it reads « closed, not answered » */
|
|
168
161
|
moot?: true
|
|
169
162
|
/** his answer to a question or a proposal: the cell it answers */
|
|
170
163
|
answers?: string
|
|
@@ -187,6 +180,10 @@ export interface ReplyCell extends CellOf<'reply'> {
|
|
|
187
180
|
linked?: Linked[]
|
|
188
181
|
/** an agent's words past the wall bound on purpose: why (review/reply-guards.ts), a quiet mark under them */
|
|
189
182
|
long?: string
|
|
183
|
+
/** an agent's recap of the thread (review/recap.ts): its words are markdown, judged like a version */
|
|
184
|
+
recap?: true
|
|
185
|
+
/** his request for a recap */
|
|
186
|
+
recapAsk?: true
|
|
190
187
|
}
|
|
191
188
|
|
|
192
189
|
export interface Linked {
|
|
@@ -247,15 +244,11 @@ export interface ThreadView {
|
|
|
247
244
|
topic?: string
|
|
248
245
|
lane?: string
|
|
249
246
|
origin: Origin
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
/** the head
|
|
254
|
-
|
|
255
|
-
/** the next version an agent promised, while it stands: the head asks no verdict meanwhile */
|
|
256
|
-
next?: NextVersion
|
|
257
|
-
active: boolean
|
|
258
|
-
rework: { lane: string; since: string; until: number } | null
|
|
247
|
+
/** the thread's state (review/thread-state.ts): its turn, what waits on the owner, what the agents owe, closed, its
|
|
248
|
+
* holder, working line, promise, set aside */
|
|
249
|
+
state: ThreadState
|
|
250
|
+
/** the head's own item state (its lifecycle), never the thread's */
|
|
251
|
+
headState: ItemState
|
|
259
252
|
verdict: Verdict | null
|
|
260
253
|
versions: number
|
|
261
254
|
/** other heads whose chain shares this thread's older versions */
|
|
@@ -277,30 +270,16 @@ export interface ThreadView {
|
|
|
277
270
|
* tools/shipkit/threads-asks.md, An ask's thread) */
|
|
278
271
|
/** `lapses`: the secret a refresh ask renews, so the bar offers « later »; `parked`: his « later » closed it */
|
|
279
272
|
ask?: { id: string; state: AskState; title: string; into?: { id: string; head: string | null }; lapses?: string; parked?: true }
|
|
280
|
-
/** set aside until this time, his turn again then */
|
|
281
|
-
aside?: string
|
|
282
273
|
/** his bell is off: nothing of it pushes to his phone (review/phone-push.ts) */
|
|
283
274
|
muted?: true
|
|
284
|
-
/**
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
holder?: { lane?: string; session?: string }
|
|
288
|
-
cursor?: Cursor
|
|
289
|
-
/** the agent of its newest `working` no act followed, `agent` a session's own, and when it said it: with the
|
|
290
|
-
* parties and the time, its band (review/band.ts) */
|
|
291
|
-
working?: string
|
|
292
|
-
workingAt?: string
|
|
293
|
-
/** his request for a lane while it stands (review/lane-ask.ts) */
|
|
294
|
-
laneAsk?: LaneAsk
|
|
295
|
-
/** when he closed it, null while open: a request written before reads « closed, not answered » */
|
|
296
|
-
closedAt: string | null
|
|
297
|
-
/** the objects attached to it that hold or held it open (review/holds.ts) */
|
|
298
|
-
holds: Hold[]
|
|
275
|
+
/** the newest recap he accepted (review/thread-state.ts recapCut): its cell, its time, and the cells before it that fold
|
|
276
|
+
* into one line « N messages before the recap », one click opens them; what still waits or is owed is none of them */
|
|
277
|
+
recap?: { cell: string; at: string; before: string[] }
|
|
299
278
|
cells: Cell[]
|
|
300
279
|
}
|
|
301
280
|
|
|
302
281
|
/** a thread another names by code, as its pill draws it: its code, its head to open, its title, what its band reads */
|
|
303
|
-
export type RefThread = { code: string; head: string; title: string; tags?: string[]
|
|
282
|
+
export type RefThread = { code: string; head: string; title: string; tags?: string[]; state: BandFacts }
|
|
304
283
|
|
|
305
284
|
/** a message of another thread that names this one by code: when, where (the message's cell there), that thread */
|
|
306
285
|
export type Backlink = { at: string; cell: string; from: RefThread }
|
|
@@ -336,13 +315,15 @@ const traceCell = (base: Omit<EventCell, 'kind' | 'summary' | 'trace'>, m: Messa
|
|
|
336
315
|
function verdictBy(x: ReviewItem): string {
|
|
337
316
|
const v = verdictOf(x)
|
|
338
317
|
const m = v === null ? undefined : x.thread.find((y) => y.id === v.id)
|
|
339
|
-
|
|
318
|
+
if (m?.who === 'player') return ` by ${m.advisor?.name ?? 'you'}`
|
|
319
|
+
const closer = v === null ? closerOf(x) : null
|
|
320
|
+
return closer !== null ? `: closed by ${closer}` : ''
|
|
340
321
|
}
|
|
341
322
|
|
|
342
323
|
/** the cells of one item's messages: an act with no words is a trace line (review/traces.ts), an owner's read mark no cell */
|
|
343
324
|
function messageCells(x: ReviewItem, n: number, opening: Message | undefined, gone: Gone, linkOf: LinkOf, ctx: TraceCtx, readObject?: ObjectRead): Cell[] {
|
|
344
325
|
const id = x.item.id
|
|
345
|
-
const current = verdictOf(x)?.id
|
|
326
|
+
const current = leftUnansweredOf(x)?.id ?? verdictOf(x)?.id
|
|
346
327
|
const read = { agent: readBy(x, 'agent'), owner: readBy(x, 'owner') }
|
|
347
328
|
const other = (who: string): Party => (partyOf(who) === 'owner' ? 'agent' : 'owner')
|
|
348
329
|
const updates = updatesOf(x)
|
|
@@ -351,8 +332,11 @@ function messageCells(x: ReviewItem, n: number, opening: Message | undefined, go
|
|
|
351
332
|
const out: Cell[] = []
|
|
352
333
|
// a person's word written twice by one delivery (the same words, the same moment): drawn once
|
|
353
334
|
const twice = new Set<string>()
|
|
335
|
+
// the messages that link an object: the owner's act on one reads on the linked object (`linked.decided`), never a cell
|
|
336
|
+
const linking = new Set<string>()
|
|
354
337
|
for (const m of x.thread) {
|
|
355
338
|
if (m === opening) continue
|
|
339
|
+
if (m.action !== undefined && m.re !== undefined && linking.has(m.re) && partyOf(m.who) === 'owner') continue
|
|
356
340
|
if (m.who === 'player') {
|
|
357
341
|
const k = `${m.advisor?.id ?? ''}|${m.at}|${m.re ?? ''}|${m.text ?? ''}`
|
|
358
342
|
if (twice.has(k)) continue
|
|
@@ -367,13 +351,15 @@ function messageCells(x: ReviewItem, n: number, opening: Message | undefined, go
|
|
|
367
351
|
const base = { id: `${id}/${m.id}`, on: id, at: m.at, who: his.has(m.id) ? 'owner' : m.who, ...(m.session ? { session: m.session } : {}), ...(m.advisor !== undefined ? { advisor: m.advisor } : {}), party, open: false, ...(by ? { superseded: by } : {}), ...heardOf(x, m) }
|
|
368
352
|
const replaced = supersedeTrace(m, ctx)
|
|
369
353
|
if (replaced !== null) out.push(traceCell({ ...base, id: `${base.id}~replaces` }, m, replaced))
|
|
370
|
-
|
|
354
|
+
// his tone on a question is his answer to it (store.ts answerAsk `tone`): drawn as an answer, never a verdict
|
|
355
|
+
const verdict = m.verdict !== undefined && !(m.re !== undefined && x.thread.some((y) => y.id === m.re && y.ask !== undefined))
|
|
356
|
+
if (trace !== null && !verdict) {
|
|
371
357
|
out.push(traceCell(base, m, trace))
|
|
372
358
|
continue
|
|
373
359
|
}
|
|
374
360
|
if (m.op === 'working') continue
|
|
375
361
|
const wasRead = read[other(m.who)].has(m.id)
|
|
376
|
-
if (m.verdict !== undefined) {
|
|
362
|
+
if (verdict && m.verdict !== undefined) {
|
|
377
363
|
const picked = m.pick !== undefined ? ` · picked ${x.item.views[m.pick]?.label || `view ${m.pick + 1}`}` : ''
|
|
378
364
|
const notes = m.rects && m.rects.length > 0 ? ` · ${m.rects.length} note${m.rects.length > 1 ? 's' : ''}` : ''
|
|
379
365
|
out.push({
|
|
@@ -405,7 +391,7 @@ function messageCells(x: ReviewItem, n: number, opening: Message | undefined, go
|
|
|
405
391
|
const said = update ? `${UPDATE_WORDS[update.state]}: ` : re ? `on update ${re.k}: ` : ''
|
|
406
392
|
// the newest answer: a person with a direct pick may change theirs
|
|
407
393
|
const reply = x.thread.findLast((y) => y.re === m.id && y.answer !== undefined && partyOf(y.who) === 'owner')
|
|
408
|
-
// the owner's words alone
|
|
394
|
+
// the owner's words alone in a choice's own box answer it as none of the options; a plain reply never does
|
|
409
395
|
const words = reply === undefined && m.ask ? answersTo(x.thread, m).find(wordsAlone) : undefined
|
|
410
396
|
const answers = m.ask ? x.thread.filter((y) => y.re === m.id && y.answer?.option !== undefined) : []
|
|
411
397
|
const ownerPick = answers.findLast((y) => y.who === 'owner')?.answer?.option
|
|
@@ -419,14 +405,17 @@ function messageCells(x: ReviewItem, n: number, opening: Message | undefined, go
|
|
|
419
405
|
}
|
|
420
406
|
}
|
|
421
407
|
const picks = { ...(ownerPick !== undefined ? { ownerPick } : {}), ...(people.size > 0 ? { people: [...people.values()] } : {}) }
|
|
422
|
-
const ask = m.ask ? (m.ask.kind === undefined || m.ask.kind === 'choice' ? { ...picks, options: m.ask.options, ...(m.ask.pick !== undefined ? { pick: m.ask.pick } : {}), ...(m.ask.views ? { views: m.ask.views } : {}), ...(reply?.answer?.option !== undefined ? { answered: { option: reply.answer.option, text: reply.text ?? '', at: reply.at, ...(reply.who === 'player' ? { by: reply.advisor ?? { id: '', name: '' } } : {}) } } : {}), open: askOpen(x.thread, m) && !by, ...(words !== undefined ? { none: words.text ?? '' } : {}) } : { ...kindCellAsk(x.thread, m), ...(by ? { open: false } : {}) }) : undefined
|
|
408
|
+
const ask = m.ask ? (m.ask.kind === undefined || m.ask.kind === 'choice' ? { ...picks, options: m.ask.options, ...(m.ask.pick !== undefined ? { pick: m.ask.pick } : {}), ...(m.ask.views ? { views: m.ask.views } : {}), ...(m.ask.row ? { row: m.ask.row } : {}), ...(reply?.answer?.option !== undefined ? { answered: { option: reply.answer.option, text: reply.text ?? '', remark: remarkOf(m.ask.options[reply.answer.option] ?? '', reply.text), at: reply.at, ...(reply.who === 'player' ? { by: reply.advisor ?? { id: '', name: '' } } : {}) } } : {}), open: askOpen(x.thread, m) && !by, ...(words !== undefined ? { none: words.text ?? '' } : {}), ...((reply ?? words)?.verdict !== undefined ? { tone: (reply ?? words)!.verdict! } : {}) } : { ...kindCellAsk(x.thread, m), ...(by ? { open: false } : {}) }) : undefined
|
|
423
409
|
const applied = m.propose ? appliedFields(x.thread, m) : null
|
|
410
|
+
const alone = m.propose ? x.thread.find((y) => y.re === m.id && y.answer === undefined && partyOf(y.who) === 'owner') : undefined
|
|
424
411
|
const propose = m.propose
|
|
425
|
-
? { on: m.propose.on, fields: proposeFields(m.propose).map((f) => ({ ...f, ...(applied?.has(f.key) ? { applied: applied.get(f.key)! } : {}) })), open: proposeOpen(x.thread, m) && !by, ...(m.propose.page ? { page: m.propose.page } : {}) }
|
|
412
|
+
? { on: m.propose.on, fields: proposeFields(m.propose).map((f) => ({ ...f, ...(applied?.has(f.key) ? { applied: applied.get(f.key)! } : {}) })), open: proposeOpen(x.thread, m) && !by, ...(alone ? { none: alone.text ?? '' } : {}), ...(m.propose.page ? { page: m.propose.page } : {}) }
|
|
426
413
|
: undefined
|
|
427
414
|
const asked = m.answer && m.re ? `${id}/${m.re}` : undefined
|
|
415
|
+
const linked = linkedOf(x, m, linkOf, readObject)
|
|
416
|
+
if (linked.linked !== undefined) linking.add(m.id)
|
|
428
417
|
const what = by ? (by.withdrawn ? `${by.title}: ` : `superseded by « ${by.title} »: `) : m.edit ? 'edited: ' : m.instructions ? 'new instructions: ' : m.action ? `action ${m.action.name}: ` : ask ? ('answered' in ask || ('open' in ask && !ask.open) ? 'answered: ' : 'asks: ') : propose ? (propose.open ? 'proposes: ' : 'applied: ') : asked ? 'answer: ' : ''
|
|
429
|
-
out.push({ ...base, kind: 'reply', text: m.text ?? '', ...(m.image ? { image: m.image } : {}), ...(m.files ? { files: m.files } : {}), ...(op ? { op } : {}), read: wasRead, ...(update ? { update } : {}), ...(re ? { re } : {}), ...(ask ? { ask } : {}), ...(propose ? { propose } : {}), ...(asked ? { answers: asked } : {}), ...(m.about ? { about: m.about } : {}), ...(m.to ? { to: m.to.map((t) => t.name) } : {}), ...(m.action ? { action: { name: m.action.name } } : {}), ...(m.instructions ? { instructions: { title: m.instructions.title, check: m.instructions.ask.check ?? null } } : {}), ...(m.step ? { step: m.step } : {}), ...(m.long ? { long: m.long } : {}), ...(m.edit ? { edit: { of: m.edit.of === id ? id : `${x.thread.some((y) => y.id === m.edit!.of) ? `${id}/` : ''}${m.edit.of}`, diff: m.edit.diff } } : {}), ...
|
|
418
|
+
out.push({ ...base, kind: 'reply', text: m.text ?? '', ...(m.image ? { image: m.image } : {}), ...(m.files ? { files: m.files } : {}), ...(op ? { op } : {}), read: wasRead, ...(update ? { update } : {}), ...(re ? { re } : {}), ...(ask ? { ask } : {}), ...(propose ? { propose } : {}), ...(asked ? { answers: asked } : {}), ...(m.about ? { about: m.about } : {}), ...(m.to ? { to: m.to.map((t) => t.name) } : {}), ...(m.action ? { action: { name: m.action.name } } : {}), ...(m.instructions ? { instructions: { title: m.instructions.title, check: m.instructions.ask.check ?? null } } : {}), ...(m.step ? { step: m.step } : {}), ...(m.long ? { long: m.long } : {}), ...(m.recap ? { recap: true as const } : {}), ...(m.recapAsk ? { recapAsk: true as const } : {}), ...(m.edit ? { edit: { of: m.edit.of === id ? id : `${x.thread.some((y) => y.id === m.edit!.of) ? `${id}/` : ''}${m.edit.of}`, diff: m.edit.diff } } : {}), ...linked, ...judgeOf(x.thread, m, by !== undefined), summary: `${what}${said}${firstLine(m.text)}` })
|
|
430
419
|
} else if (m.rects && m.rects.length > 0) {
|
|
431
420
|
// rectangles with no words and no verdict: the owner's note on the item
|
|
432
421
|
out.push({ ...base, kind: 'note', rects: m.rects, ...(m.image ? { image: m.image } : {}), read: wasRead, summary: `${m.rects.length} note${m.rects.length > 1 ? 's' : ''}` })
|
|
@@ -459,10 +448,24 @@ function raisedCell(x: ReviewItem): NoteCell {
|
|
|
459
448
|
}
|
|
460
449
|
}
|
|
461
450
|
|
|
451
|
+
/** a cell as the holder of the views its messages name (an option's picture, an update's file, a proposed sound): a
|
|
452
|
+
* version, or an item the owner raised, drawn as a version with no verdict (n 0, raised); null for a cell with no item */
|
|
453
|
+
export function viewHolderOf(c: Cell): VersionCell | null {
|
|
454
|
+
if (c.kind === 'version') return c
|
|
455
|
+
if (c.kind !== 'note' || c.item === undefined) return null
|
|
456
|
+
return { kind: 'version', id: c.id, on: c.on, at: c.at, who: c.who, party: c.party, open: c.open, summary: c.summary, n: 0, item: c.item, status: 'raised', label: '' }
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** a raised item's own picture, the one its note draws: its first image view that no message holds */
|
|
460
|
+
export const raisedStill = (item: Item): { name: string; size: { w: number; h: number } } | null => {
|
|
461
|
+
const v = item.views.find((x) => !isGallery(x) && x.message !== true)
|
|
462
|
+
return v && !isGallery(v) && 'image' in v.files ? { name: v.files.image, size: v.size } : null
|
|
463
|
+
}
|
|
464
|
+
|
|
462
465
|
const rank: Record<CellKind, number> = { version: 0, note: 1, verdict: 2, reply: 3, event: 4 }
|
|
463
466
|
|
|
464
467
|
/** what a linked object says now, read from where it lives (review/object-read.ts: a reflection's file); null when
|
|
465
|
-
* nothing reads it here. The
|
|
468
|
+
* nothing reads it here. The linked object draws from it whether or not a thread stands on the object */
|
|
466
469
|
export type ObjectRead = (address: string) => { title: string; md: string; standing: boolean; state?: 'open' | 'folded' | 'gone' } | null
|
|
467
470
|
|
|
468
471
|
/** the thread an address of another thread links to has, by its own address; null for none, or the thread itself */
|
|
@@ -489,7 +492,7 @@ function linkedOf(x: ReviewItem, m: Message, linkOf: LinkOf, readObject?: Object
|
|
|
489
492
|
const o = linkOf(address)
|
|
490
493
|
const f = readObject?.(address) ?? null
|
|
491
494
|
if (o === null && f === null) continue
|
|
492
|
-
const closed = o !== null &&
|
|
495
|
+
const closed = o !== null && threadState(o).closed !== null
|
|
493
496
|
const act = x.thread.filter((y) => y.re === m.id && y.action !== undefined && partyOf(y.who) === 'owner').at(-1)
|
|
494
497
|
// its file's words wherever they are (queue or harvested), else the words its own thread opened with
|
|
495
498
|
const read = f !== null && f.md !== ''
|
|
@@ -503,12 +506,20 @@ function linkedOf(x: ReviewItem, m: Message, linkOf: LinkOf, readObject?: Object
|
|
|
503
506
|
done,
|
|
504
507
|
...(done ? { folded: closed ? 'its own thread is done' : f?.state === 'folded' ? 'its triage closed it' : 'its file left the queue' } : {}),
|
|
505
508
|
...(md === '' && f?.state === 'gone' ? { lost: 'its file is in neither .shipkit/reflections/ nor the harvested reflections, and no thread kept its words' } : {}),
|
|
506
|
-
...(act ? { decided: { name: act.action!.name, text: act
|
|
509
|
+
...(act ? { decided: { name: act.action!.name, text: actWords(act, address), at: act.at } } : {}),
|
|
507
510
|
})
|
|
508
511
|
}
|
|
509
512
|
return out.length > 0 ? { linked: out } : {}
|
|
510
513
|
}
|
|
511
514
|
|
|
515
|
+
/** the owner's own words on an act on a linked object: the address the message opens with (for the holder's watch line) and the
|
|
516
|
+
* bare action name are no words of his */
|
|
517
|
+
function actWords(m: Message, address: string): string {
|
|
518
|
+
const t = (m.text ?? '').trim()
|
|
519
|
+
const bare = t === address || t === m.action?.name ? '' : t.startsWith(`${address}: `) ? t.slice(address.length + 2) : t
|
|
520
|
+
return bare.trim()
|
|
521
|
+
}
|
|
522
|
+
|
|
512
523
|
/** each superseded object's id (a message id, or the head's item id) → the cell of the one that supersedes it */
|
|
513
524
|
type Gone = ReadonlyMap<string, { by: string; title: string; bar?: true; withdrawn?: true }>
|
|
514
525
|
|
|
@@ -585,7 +596,7 @@ export function cellsOf(t: Thread, items: readonly ReviewItem[], readObject?: Ob
|
|
|
585
596
|
open: false,
|
|
586
597
|
...(gone.has(x.item.id) ? { superseded: gone.get(x.item.id)! } : {}),
|
|
587
598
|
})
|
|
588
|
-
const renamed = renameTrace(
|
|
599
|
+
const renamed = renameTrace(nameAt(t, x.item.created), x)
|
|
589
600
|
if (renamed !== null) {
|
|
590
601
|
const who = cells.find((c) => c.id === x.item.id)!.who
|
|
591
602
|
cells.push({ kind: 'event', id: `${x.item.id}~renamed`, on: x.item.id, at: x.item.created, who, ...originSession(x.item.origin), party: 'agent', open: false, trace: renamed, summary: traceWords(who, renamed) })
|
|
@@ -615,10 +626,10 @@ export function cellsOf(t: Thread, items: readonly ReviewItem[], readObject?: Ob
|
|
|
615
626
|
// a message dated at the newest version's own instant (an ask's steps, posted as its thread opens) is part of it
|
|
616
627
|
c.open = c.superseded === undefined && (c === latest || c === answer || unreadIds.has(c.id) || (latest !== undefined && c.at >= latest.at))
|
|
617
628
|
}
|
|
618
|
-
const
|
|
619
|
-
if (
|
|
629
|
+
const closed = threadState(t).closed
|
|
630
|
+
if (closed !== null)
|
|
620
631
|
for (const c of cells) {
|
|
621
|
-
if (c.kind !== 'reply' || c.party !== 'agent' ||
|
|
632
|
+
if (c.kind !== 'reply' || c.party !== 'agent' || !isMoot({ closed }, c) || !((c.ask !== undefined && (c.ask.open ?? c.ask.answered === undefined)) || c.propose?.open || c.judge?.open)) continue
|
|
622
633
|
if (c.ask) c.ask = { ...c.ask, open: false }
|
|
623
634
|
if (c.propose) c.propose = { ...c.propose, open: false }
|
|
624
635
|
if (c.judge) c.judge = { ...c.judge, open: false }
|
|
@@ -667,10 +678,11 @@ function askCellOf(t: Thread, threads: readonly Thread[]): NonNullable<ThreadVie
|
|
|
667
678
|
export function threadView(t: Thread, items: readonly ReviewItem[], threads: readonly Thread[], asked: string, now = new Date(), readObject?: ObjectRead, codes: Codes = codesOf(items.map((x) => x.item.id))): ThreadView {
|
|
668
679
|
const h = t.head
|
|
669
680
|
const followed = followedIds(items)
|
|
670
|
-
const state = stateOf(h, followed.has(h.item.id))
|
|
671
681
|
const shared = new Set(t.versions.slice(1).map((x) => x.item.id))
|
|
672
682
|
const forks = threads.filter((o) => o !== t && o.versions.slice(1).some((x) => shared.has(x.item.id))).map((o) => o.head.item.id)
|
|
673
683
|
const lane = laneOf(h)
|
|
684
|
+
const state = threadState(t, now)
|
|
685
|
+
const cells = cellsOf(t, items, readObject)
|
|
674
686
|
return {
|
|
675
687
|
head: h.item.id,
|
|
676
688
|
code: threadCode(codes, idsOf(t)),
|
|
@@ -682,18 +694,9 @@ export function threadView(t: Thread, items: readonly ReviewItem[], threads: rea
|
|
|
682
694
|
subject: h.item.subject,
|
|
683
695
|
...(h.item.topic ? { topic: h.item.topic } : {}),
|
|
684
696
|
...(lane ? { lane } : {}),
|
|
685
|
-
...holderRow(t),
|
|
686
|
-
...cursorRow(t, now),
|
|
687
|
-
...workingRow(t, now),
|
|
688
|
-
...laneAskRow(t),
|
|
689
697
|
origin: h.item.origin,
|
|
690
|
-
status: statusOf(h, items),
|
|
691
698
|
state,
|
|
692
|
-
|
|
693
|
-
waits: headWaits(t),
|
|
694
|
-
...nextRow(t),
|
|
695
|
-
active: isActive(t, now),
|
|
696
|
-
rework: reworkOf(h, followed.has(h.item.id), now),
|
|
699
|
+
headState: stateOf(h, followed.has(h.item.id)),
|
|
697
700
|
verdict: verdictOf(h),
|
|
698
701
|
versions: t.versions.length,
|
|
699
702
|
forks,
|
|
@@ -704,13 +707,24 @@ export function threadView(t: Thread, items: readonly ReviewItem[], threads: rea
|
|
|
704
707
|
coming: [],
|
|
705
708
|
drafts: [],
|
|
706
709
|
...(isAskItem(t.head.item) ? { ask: askCellOf(t, threads) } : {}),
|
|
707
|
-
...(asideUntil(t, now) !== null ? { aside: asideUntil(t, now)! } : {}),
|
|
708
710
|
...(mutedOf(t) ? { muted: true as const } : {}),
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
711
|
+
...recapFoldOf(t, cells, state),
|
|
712
|
+
cells,
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/** the cells that fold before the newest recap he accepted: each one before it that the model's cut hides and that waits
|
|
717
|
+
* on nobody (review/thread-state.ts recapCut); none without an accepted recap */
|
|
718
|
+
function recapFoldOf(t: Thread, cells: readonly Cell[], s: ThreadState): Pick<ThreadView, 'recap'> {
|
|
719
|
+
const cut = recapCut(t, s)
|
|
720
|
+
if (cut === null) return {}
|
|
721
|
+
const hidden = (c: Cell): boolean => {
|
|
722
|
+
if (c.at >= cut.recap.at || waitsOnOwner(c)) return false
|
|
723
|
+
const id = c.id.split('~')[0]!
|
|
724
|
+
const slash = id.indexOf('/')
|
|
725
|
+
return slash < 0 ? cut.hidden(id, null) : cut.hidden(id.slice(0, slash), { id: id.slice(slash + 1), at: c.at })
|
|
713
726
|
}
|
|
727
|
+
return { recap: { cell: `${cut.recap.on}/${cut.recap.id}`, at: cut.recap.at, before: cells.filter(hidden).map((c) => c.id) } }
|
|
714
728
|
}
|
|
715
729
|
|
|
716
730
|
// ── the paged list ──
|
|
@@ -735,8 +749,6 @@ export interface ThreadRow {
|
|
|
735
749
|
rule?: string
|
|
736
750
|
/** the agent session that sent the head: a watch kept to a session listens to it */
|
|
737
751
|
session?: string
|
|
738
|
-
status: ShownStatus
|
|
739
|
-
move: Move
|
|
740
752
|
versions: number
|
|
741
753
|
views: number
|
|
742
754
|
/** the file that stands for the head in a list: `/api/review/<head>/preview/tile/<thumb>` */
|
|
@@ -747,39 +759,12 @@ export interface ThreadRow {
|
|
|
747
759
|
wip: boolean
|
|
748
760
|
/** the head's newest agent update: its state and line; its picture is the row's thumb when it carries one */
|
|
749
761
|
update?: { state: UpdateState; text: string; at: string }
|
|
750
|
-
waits: boolean
|
|
751
|
-
/** the next version an agent promised, while it stands */
|
|
752
|
-
next?: NextVersion
|
|
753
|
-
active: boolean
|
|
754
762
|
/** an agent wrote after his cursor (review/owner-read.ts): a version or words new to him */
|
|
755
763
|
unread: boolean
|
|
756
|
-
rework: { lane: string; since: string; until: number } | null
|
|
757
764
|
/** every item id of the thread, the versions oldest first then the raised items: an old version's link finds its row */
|
|
758
765
|
ids: string[]
|
|
759
|
-
/**
|
|
760
|
-
|
|
761
|
-
/** what it waits on from him (review/wait.ts): the inbox's verb, the list's « what I must do » */
|
|
762
|
-
wait: Wait
|
|
763
|
-
/** what waits on him first, the icon its row draws (review/wait.ts waitEntryOf) */
|
|
764
|
-
waitsOn?: WaitsOn
|
|
765
|
-
/** on the agents' move after his last word, what still waits on him: a quiet mark, never his turn (review/wait.ts waitEntryOf) */
|
|
766
|
-
owed?: OwnerWait
|
|
767
|
-
/** every verb its open objects ask, the badge's first: what the verbs filter and its counts read (review/wait.ts verbsOf) */
|
|
768
|
-
verbs: OwnerWait[]
|
|
769
|
-
/** set aside: when it comes back, and whether an agent wrote in it since */
|
|
770
|
-
aside?: { until: string; moved: boolean }
|
|
771
|
-
/** the agent that holds it: a live claim's worker, else its newest act; `handed` when that act is a hand-over */
|
|
772
|
-
holder?: { lane?: string; session?: string; handed?: true }
|
|
773
|
-
/** where his newest word stands: an agent on it, else read by one (review/traces.ts cursorOf) */
|
|
774
|
-
cursor?: Cursor
|
|
775
|
-
/** the agent of its newest `working` no act followed, `agent` a session's own, and when it said it: with the
|
|
776
|
-
* parties and the time, its band (review/band.ts) */
|
|
777
|
-
working?: string
|
|
778
|
-
workingAt?: string
|
|
779
|
-
/** his request for a lane while it stands (review/lane-ask.ts) */
|
|
780
|
-
laneAsk?: LaneAsk
|
|
781
|
-
/** everything validated, nothing owed (review/band.ts validatedOf): the list draws it a quiet green */
|
|
782
|
-
validated?: true
|
|
766
|
+
/** the thread's state (review/thread-state.ts), the one the list's band, badge, verbs and filters read */
|
|
767
|
+
state: ThreadState
|
|
783
768
|
/** the addresses it owns, then its links */
|
|
784
769
|
addresses: string[]
|
|
785
770
|
/** the advisors who can open it now, by id (advisors/owner-store.ts openersByAddress): his hub's list alone, never
|
|
@@ -851,7 +836,7 @@ export interface ThreadPage {
|
|
|
851
836
|
subjects: string[]
|
|
852
837
|
lanes: string[]
|
|
853
838
|
broken: { id: string; error: string }[]
|
|
854
|
-
/** what moved since the owner's last act in the store (
|
|
839
|
+
/** what moved since the owner's last act in the store (thread-state.ts sinceHeLeft), null before his first */
|
|
855
840
|
since: { at: string; moved: number; yours: number } | null
|
|
856
841
|
}
|
|
857
842
|
|
|
@@ -860,7 +845,7 @@ const NO_WAITS: Readonly<Record<OwnerWait, number>> = { judge: 0, answer: 0, do:
|
|
|
860
845
|
|
|
861
846
|
type RequiredKeys<T> = { [K in keyof T]-?: object extends Pick<T, K> ? never : K }[keyof T]
|
|
862
847
|
/** every field a row always carries: a kept page with a row that lacks one was written by an older hub */
|
|
863
|
-
const ROW_KEYS = Object.keys({ head: 1, code: 1, tags: 1, title: 1, created: 1, updated: 1, subject: 1, origin: 1,
|
|
848
|
+
const ROW_KEYS = Object.keys({ head: 1, code: 1, tags: 1, title: 1, created: 1, updated: 1, subject: 1, origin: 1, versions: 1, views: 1, thumb: 1, clip: 1, pair: 1, choice: 1, wip: 1, unread: 1, ids: 1, state: 1, addresses: 1 } satisfies Record<RequiredKeys<ThreadRow>, 1>)
|
|
864
849
|
|
|
865
850
|
/** a list page as the hub reads it, from the server or from the browser's kept copy of an older hub: the page fields
|
|
866
851
|
* added since are filled (each verb at 0, no since); null when a row lacks a field rows always carry, and that page
|
|
@@ -902,40 +887,31 @@ export interface ThreadIndex {
|
|
|
902
887
|
since: ThreadPage['since']
|
|
903
888
|
}
|
|
904
889
|
|
|
905
|
-
function rowOf(t: Thread,
|
|
890
|
+
function rowOf(t: Thread, now: Date, code: string): ThreadRow {
|
|
906
891
|
const h = t.head
|
|
907
892
|
// the views a message holds (an update's, a question's option, a proposed sound) are no view of the version
|
|
908
893
|
const own = h.item.views.filter((v) => isGallery(v) || v.message !== true)
|
|
909
894
|
const first = firstView({ ...h.item, views: own })
|
|
910
895
|
const lane = laneOf(h)
|
|
911
896
|
const members = membersOf(t)
|
|
912
|
-
|
|
913
|
-
const updated = members.reduce((u, x) => {
|
|
914
|
-
// a read mark moves nothing: opening a thread never lifts it in the list
|
|
915
|
-
const m = x.thread.filter((y) => !handedOver(y) && y.op !== 'seen').at(-1)?.at ?? x.item.created
|
|
916
|
-
return m > u ? m : u
|
|
917
|
-
}, h.item.created)
|
|
897
|
+
const state = threadState(t, now)
|
|
918
898
|
const newest = updatesOf(h).at(-1)
|
|
919
899
|
const shows = newest?.update?.view !== undefined ? h.item.views[newest.update.view] : undefined
|
|
920
900
|
const picture = h.item.views.find((v) => !isGallery(v) && v.message === true && v.audio === undefined)
|
|
921
901
|
const thumbOf = shows ?? first ?? picture
|
|
922
|
-
const turn = turnOf(t, now)
|
|
923
|
-
const status = statusOf(h, items)
|
|
924
902
|
return {
|
|
925
903
|
head: h.item.id,
|
|
926
904
|
code,
|
|
927
905
|
tags: tagsOfItems(members),
|
|
928
906
|
title: threadTitle(t),
|
|
929
907
|
created: h.item.created,
|
|
930
|
-
updated,
|
|
908
|
+
updated: state.updated,
|
|
931
909
|
subject: h.item.subject.kind,
|
|
932
910
|
...(h.item.topic ? { topic: h.item.topic } : {}),
|
|
933
911
|
...(lane ? { lane } : {}),
|
|
934
912
|
origin: h.item.origin.by,
|
|
935
913
|
...(h.item.origin.by === 'auto' ? { rule: h.item.origin.rule } : {}),
|
|
936
914
|
...(h.item.origin.by === 'agent' && h.item.origin.session ? { session: h.item.origin.session } : {}),
|
|
937
|
-
status,
|
|
938
|
-
move: moveOf(stateOf(h, followed.has(h.item.id)).state),
|
|
939
915
|
versions: t.versions.length,
|
|
940
916
|
views: own.length,
|
|
941
917
|
thumb: thumbOf ? thumbFileOf(thumbOf) || null : null,
|
|
@@ -944,67 +920,46 @@ function rowOf(t: Thread, items: readonly ReviewItem[], followed: ReadonlySet<st
|
|
|
944
920
|
choice: h.item.choice === true,
|
|
945
921
|
wip: inWork(h),
|
|
946
922
|
...(newest?.update ? { update: { state: newest.update.state, text: newest.text ?? '', at: newest.at } } : {}),
|
|
947
|
-
waits: headWaits(t),
|
|
948
|
-
...nextRow(t),
|
|
949
|
-
active: isActive(t, now),
|
|
950
923
|
unread: newToOwner(members).length > 0,
|
|
951
|
-
rework: reworkOf(h, followed.has(h.item.id), now),
|
|
952
924
|
ids: idsOf(t),
|
|
953
|
-
|
|
954
|
-
...(validatedOf({ turn, status, ...(isAskItem(h.item) ? { ask: askStateOf(t)?.state ?? 'open' } : {}) }) ? { validated: true as const } : {}),
|
|
955
|
-
...waitRow(t, now),
|
|
956
|
-
...asideRow(t, now),
|
|
957
|
-
...holderRow(t),
|
|
958
|
-
...cursorRow(t, now),
|
|
959
|
-
...workingRow(t, now),
|
|
960
|
-
...laneAskRow(t),
|
|
925
|
+
state,
|
|
961
926
|
addresses: addressesOfThread(t),
|
|
962
927
|
}
|
|
963
928
|
}
|
|
964
929
|
|
|
965
|
-
const
|
|
966
|
-
const w = waitEntryOf(t, now)
|
|
967
|
-
const verbs = verbsOf(t, now)
|
|
968
|
-
return { wait: w.wait, ...(w.on ? { waitsOn: w.on } : {}), ...(w.owed ? { owed: w.owed } : {}), verbs }
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
const workingRow = (t: Thread, now: Date): { working?: string; workingAt?: string } => {
|
|
972
|
-
const last = workingsOf(t, now).last
|
|
973
|
-
return last ? { working: last.who, workingAt: last.at } : {}
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
/** the next version an agent promised, while it stands (review/threads.ts nextVersionOf) */
|
|
977
|
-
const nextRow = (t: Thread): { next?: NextVersion } => {
|
|
978
|
-
const n = nextVersionOf(t)
|
|
979
|
-
return n ? { next: n } : {}
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
const holderRow = (t: Thread): { holder?: { lane?: string; session?: string; handed?: true } } => {
|
|
983
|
-
const h = holderOf(t)
|
|
984
|
-
return h ? { holder: { ...(h.lane ? { lane: h.lane } : {}), ...(h.session ? { session: h.session } : {}), ...(h.from ? { handed: true as const } : {}) } } : {}
|
|
985
|
-
}
|
|
930
|
+
const TURN_RANK: Record<Turn, number> = { yours: 0, aside: 1, agents: 2, done: 3 }
|
|
986
931
|
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
}
|
|
932
|
+
/** the list's order: his turn, set aside, the agents', done; in each, the newest activity first */
|
|
933
|
+
const listOrder = <E extends { row: ThreadRow }>(entries: readonly E[]): E[] =>
|
|
934
|
+
entries
|
|
935
|
+
.map((e, i) => ({ e, i }))
|
|
936
|
+
.sort((a, b) => TURN_RANK[a.e.row.state.turn] - TURN_RANK[b.e.row.state.turn] || b.e.row.updated.localeCompare(a.e.row.updated) || a.i - b.i)
|
|
937
|
+
.map(({ e }) => e)
|
|
991
938
|
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
939
|
+
/** what a page of the list reads of an index: the rows in the list's order with their search text, a code's row, the
|
|
940
|
+
* counts and the filters' choices. The store's index (threadIndex) is one, the rows a person may see another */
|
|
941
|
+
export type ListIndex = Pick<ThreadIndex, 'counts' | 'subjects' | 'lanes' | 'since'> & {
|
|
942
|
+
entries: readonly { row: ThreadRow; text: string }[]
|
|
943
|
+
byCode: (code: string) => { row: ThreadRow } | null
|
|
995
944
|
}
|
|
996
945
|
|
|
997
|
-
/** a
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
946
|
+
/** the list over rows a reader of the advisors' port may see, each its search text: the hub's order and counts, a code
|
|
947
|
+
* found by the rows' own codes, what moved since the reader's last act as the port reads it */
|
|
948
|
+
export function listIndexOf(rows: readonly { row: ThreadRow; text: string }[], since: ThreadPage['since'] = null): ListIndex {
|
|
949
|
+
const entries = listOrder(rows)
|
|
950
|
+
return {
|
|
951
|
+
entries,
|
|
952
|
+
byCode: (code) => {
|
|
953
|
+
const c = code.toLowerCase().replace(/^#/, '')
|
|
954
|
+
return entries.find((e) => e.row.code !== '' && e.row.code === c) ?? null
|
|
955
|
+
},
|
|
956
|
+
counts: { threads: entries.length, active: entries.filter((e) => e.row.state.active).length, waiting: entries.filter((e) => e.row.state.turn === 'yours').length, unread: entries.filter((e) => e.row.unread && countsUnread(e.row.state.turn)).length },
|
|
957
|
+
subjects: [...new Set(entries.map((e) => e.row.subject))].sort(),
|
|
958
|
+
lanes: [],
|
|
959
|
+
since,
|
|
960
|
+
}
|
|
1004
961
|
}
|
|
1005
962
|
|
|
1006
|
-
const TURN_RANK: Record<Turn, number> = { yours: 0, aside: 1, agents: 2, done: 3 }
|
|
1007
|
-
|
|
1008
963
|
/** what a search reads of a thread: every item's title, words and id, and every message's words */
|
|
1009
964
|
const textOf = (t: Thread): string =>
|
|
1010
965
|
membersOf(t)
|
|
@@ -1019,12 +974,7 @@ export const refThreadOf = (row: ThreadRow): RefThread => ({
|
|
|
1019
974
|
head: row.head,
|
|
1020
975
|
title: row.title,
|
|
1021
976
|
...(row.tags.length > 0 ? { tags: row.tags } : {}),
|
|
1022
|
-
turn: row.turn,
|
|
1023
|
-
...(row.holder ? { holder: row.holder } : {}),
|
|
1024
|
-
...(row.working ? { working: row.working } : {}),
|
|
1025
|
-
...(row.workingAt ? { workingAt: row.workingAt } : {}),
|
|
1026
|
-
...(row.laneAsk ? { laneAsk: row.laneAsk } : {}),
|
|
1027
|
-
...(row.next ? { next: row.next } : {}),
|
|
977
|
+
state: { turn: row.state.turn, holder: row.state.holder, working: row.state.working, laneAsk: row.state.laneAsk, next: row.state.next },
|
|
1028
978
|
})
|
|
1029
979
|
|
|
1030
980
|
/** by a thread's code, the messages of the other threads that name it: each thread's words read once */
|
|
@@ -1072,14 +1022,9 @@ export function threadLinks(ix: ThreadIndex, t: Thread): Pick<ThreadView, 'refs'
|
|
|
1072
1022
|
* each, the newest activity first, the time the row shows), one row and one search text per thread. `ids`: every
|
|
1073
1023
|
* item id of the store, a broken one too, which the codes are given over (review/thread-code.ts) */
|
|
1074
1024
|
export function threadIndex(items: readonly ReviewItem[], now = new Date(), ids: Iterable<string> = items.map((x) => x.item.id)): ThreadIndex {
|
|
1075
|
-
const followed = followedIds(items)
|
|
1076
1025
|
const codes = codesOf(ids)
|
|
1077
|
-
const entries = orderedThreads(items)
|
|
1078
|
-
|
|
1079
|
-
.map((e, i) => ({ e, i }))
|
|
1080
|
-
.sort((a, b) => TURN_RANK[a.e.row.turn] - TURN_RANK[b.e.row.turn] || b.e.row.updated.localeCompare(a.e.row.updated) || a.i - b.i)
|
|
1081
|
-
.map(({ e }) => e)
|
|
1082
|
-
const waiting = new Set(entries.filter((e) => e.row.turn === 'yours').map((e) => e.row.head))
|
|
1026
|
+
const entries = listOrder(orderedThreads(items).map((t) => ({ t, row: rowOf(t, now, threadCode(codes, idsOf(t))), text: textOf(t) })))
|
|
1027
|
+
const waiting = new Set(entries.filter((e) => e.row.state.turn === 'yours').map((e) => e.row.head))
|
|
1083
1028
|
const byItem = new Map<string, (typeof entries)[number]>()
|
|
1084
1029
|
for (const e of entries) for (const id of e.row.ids) byItem.set(id, e)
|
|
1085
1030
|
const byCode: ThreadIndex['byCode'] = (code) => {
|
|
@@ -1092,7 +1037,7 @@ export function threadIndex(items: readonly ReviewItem[], now = new Date(), ids:
|
|
|
1092
1037
|
byCode,
|
|
1093
1038
|
mentions: mentionsOf(entries, byCode),
|
|
1094
1039
|
tags: knownTags(entries.map((e) => e.row)),
|
|
1095
|
-
counts: { threads: entries.length, active: entries.filter((e) => e.row.active).length, waiting: waiting.size, unread: entries.filter((e) => e.row.unread && countsUnread(e.row.turn) && !countedAsItsAsk(e.t)).length },
|
|
1040
|
+
counts: { threads: entries.length, active: entries.filter((e) => e.row.state.active).length, waiting: waiting.size, unread: entries.filter((e) => e.row.unread && countsUnread(e.row.state.turn) && !countedAsItsAsk(e.t)).length },
|
|
1096
1041
|
subjects: [...new Set(items.map((x) => x.item.subject.kind))].sort(),
|
|
1097
1042
|
lanes: [...new Set(entries.flatMap((e) => (e.row.lane ? [e.row.lane] : [])))].sort(),
|
|
1098
1043
|
waiting,
|
|
@@ -1101,15 +1046,18 @@ export function threadIndex(items: readonly ReviewItem[], now = new Date(), ids:
|
|
|
1101
1046
|
}
|
|
1102
1047
|
|
|
1103
1048
|
/** where the kept row sits among a page's rows: in the index's own order, after the last row that comes before it */
|
|
1104
|
-
function keptAt(ix:
|
|
1049
|
+
function keptAt(ix: ListIndex, rows: readonly ThreadRow[], kept: ThreadRow): number {
|
|
1105
1050
|
const order = new Map(ix.entries.map((e, i) => [e.row, i]))
|
|
1106
1051
|
const at = order.get(kept)!
|
|
1107
1052
|
const i = rows.findIndex((r) => order.get(r)! > at)
|
|
1108
1053
|
return i === -1 ? rows.length : i
|
|
1109
1054
|
}
|
|
1110
1055
|
|
|
1056
|
+
/** whose move a turn is, as the « whoever moves next » filter names it: his (his turn or set aside), an agent's, nobody's */
|
|
1057
|
+
const whoseOf = (t: Turn): Move => (t === 'yours' || t === 'aside' ? 'owner' : t === 'agents' ? 'agents' : 'none')
|
|
1058
|
+
|
|
1111
1059
|
/** one page of the index for a query; the open thread's row (`keep`) in it whatever the filters */
|
|
1112
|
-
export function pageOf(ix:
|
|
1060
|
+
export function pageOf(ix: ListIndex, q: ThreadQuery, broken: ThreadPage['broken'] = []): ThreadPage {
|
|
1113
1061
|
// words, `t:<tag>` each a thread must carry, a thread's code (review/thread-query.ts)
|
|
1114
1062
|
const { words, tags, codes } = parseSearch(q.q)
|
|
1115
1063
|
// a thread's code, `#k7m2` or bare, finds that thread first, whatever the filters but its tags
|
|
@@ -1118,18 +1066,18 @@ export function pageOf(ix: ThreadIndex, q: ThreadQuery, broken: ThreadPage['brok
|
|
|
1118
1066
|
({ row, text }) =>
|
|
1119
1067
|
!coded.includes(row) &&
|
|
1120
1068
|
tags.every((t) => row.tags.includes(t)) &&
|
|
1121
|
-
(q.handled || row.active) &&
|
|
1069
|
+
(q.handled || row.state.active) &&
|
|
1122
1070
|
(q.subject === null || row.subject === q.subject) &&
|
|
1123
|
-
(q.whose === null || row.
|
|
1124
|
-
(q.turn === null || row.turn === q.turn) &&
|
|
1125
|
-
(q.status === null || row.status === q.status) &&
|
|
1071
|
+
(q.whose === null || whoseOf(row.state.turn) === q.whose) &&
|
|
1072
|
+
(q.turn === null || row.state.turn === q.turn) &&
|
|
1073
|
+
(q.status === null || row.state.status === q.status) &&
|
|
1126
1074
|
(q.lane === null || row.lane === q.lane) &&
|
|
1127
1075
|
words.every((w) => text.includes(w)),
|
|
1128
1076
|
)
|
|
1129
1077
|
// each verb's count under every other filter, so the « what I must do » toggles say what each one gives
|
|
1130
1078
|
const byWait = { ...NO_WAITS }
|
|
1131
|
-
for (const e of hits) for (const v of e.row.verbs) byWait[v] += 1
|
|
1132
|
-
const shown = [...ix.entries.filter((e) => coded.includes(e.row)), ...hits.filter((e) => waitsMatch(q.wait, e.row.verbs))]
|
|
1079
|
+
for (const e of hits) for (const v of e.row.state.verbs) byWait[v] += 1
|
|
1080
|
+
const shown = [...ix.entries.filter((e) => coded.includes(e.row)), ...hits.filter((e) => waitsMatch(q.wait, e.row.state.verbs))]
|
|
1133
1081
|
const rows = shown.slice(q.offset, q.offset + q.limit).map((e) => e.row)
|
|
1134
1082
|
const keep = q.keep
|
|
1135
1083
|
const kept = keep === null ? null : (ix.entries.find((e) => e.row.head === keep || e.row.ids.includes(keep))?.row ?? null)
|
|
@@ -1168,47 +1116,13 @@ export function threadsOfAddress(ix: ThreadIndex, threads: readonly Thread[], as
|
|
|
1168
1116
|
const rows = new Map(ix.entries.map((e) => [e.row.head, e.row]))
|
|
1169
1117
|
const as = (t: Thread, owns: boolean): ObjectThread | null => {
|
|
1170
1118
|
const r = rows.get(t.head.item.id)
|
|
1171
|
-
return r ? { head: r.head, title: r.title, turn: r.turn, status: r.status, owns, updated: r.updated } : null
|
|
1119
|
+
return r ? { head: r.head, title: r.title, turn: r.state.turn, status: r.state.status, owns, updated: r.updated } : null
|
|
1172
1120
|
}
|
|
1173
1121
|
const up: string[] = []
|
|
1174
1122
|
for (let a: string | null = address; a !== null; a = parentAddress(a)) up.push(a)
|
|
1175
1123
|
const owner = up.map((a) => threads.find((t) => ownAddressesOf(t).includes(a))).find((t) => t !== undefined) ?? null
|
|
1176
1124
|
const naming = threads.filter((t) => addressesOfThread(t).some((a) => a === address || a.startsWith(`${address}/`)) || t === owner)
|
|
1177
1125
|
const list = naming.flatMap((t) => as(t, t === owner) ?? []).sort((a, b) => b.updated.localeCompare(a.updated))
|
|
1178
|
-
const open = ix.entries.filter((e) => e.row.turn !== 'done' && !list.some((l) => l.head === e.row.head)).slice(0, 30).flatMap((e) => as(e.t, false) ?? [])
|
|
1126
|
+
const open = ix.entries.filter((e) => e.row.state.turn !== 'done' && !list.some((l) => l.head === e.row.head)).slice(0, 30).flatMap((e) => as(e.t, false) ?? [])
|
|
1179
1127
|
return { address: asked, threads: list, noteGoesTo: owner?.head.item.id ?? null, open }
|
|
1180
1128
|
}
|
|
1181
|
-
|
|
1182
|
-
// ── the dispatcher's board ──
|
|
1183
|
-
|
|
1184
|
-
/** one raised item on the board: what he, a player or a rule raised, where it stands */
|
|
1185
|
-
export interface BoardRow {
|
|
1186
|
-
id: string
|
|
1187
|
-
title: string
|
|
1188
|
-
state: ItemState['state']
|
|
1189
|
-
topic?: string
|
|
1190
|
-
worker?: string
|
|
1191
|
-
stale: boolean
|
|
1192
|
-
/** who raised it, in a few words: `live#85`, `auto veille`, empty for him */
|
|
1193
|
-
from: string
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
/** every raised item that is not a mark, by state: the board's rows */
|
|
1197
|
-
export function boardOf(items: readonly ReviewItem[], now = new Date()): BoardRow[] {
|
|
1198
|
-
const followed = followedIds(items)
|
|
1199
|
-
return items
|
|
1200
|
-
.filter((x) => x.item.origin.by !== 'agent' && !isMarkItem(x))
|
|
1201
|
-
.map((x) => {
|
|
1202
|
-
const st = stateOf(x, followed.has(x.item.id))
|
|
1203
|
-
const o = x.item.origin
|
|
1204
|
-
return {
|
|
1205
|
-
id: x.item.id,
|
|
1206
|
-
title: x.item.title,
|
|
1207
|
-
state: st.state,
|
|
1208
|
-
...(st.topic ? { topic: st.topic } : {}),
|
|
1209
|
-
...(st.worker ? { worker: st.worker } : {}),
|
|
1210
|
-
stale: isStale(x, now),
|
|
1211
|
-
from: o.by === 'player' ? `${o.server}#${o.serverId}` : o.by === 'auto' ? `auto ${o.rule}` : '',
|
|
1212
|
-
}
|
|
1213
|
-
})
|
|
1214
|
-
}
|