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
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
// newest version (rectangles, reactions, stars, the pick, his word), each clip's clock. Made when a thread opens,
|
|
4
4
|
// disposed when another one does. Only the newest version takes his marks: an older one shows what was said on it
|
|
5
5
|
import { compareShallow, computed, computedStruct, makeAutoObservable, observableRef, runInAction } from 'mobx'
|
|
6
|
-
import {
|
|
7
|
-
import { expectOf, waitLinesOf, type Expect } from '../../../review/expect.ts'
|
|
6
|
+
import { waitLinesOf } from '../../../review/expect.ts'
|
|
8
7
|
import type { WordRefs } from '../word-refs.ts'
|
|
9
|
-
import { waitsOnOwner, type Backlink, type Cell, type EventCell, type NoteCell, type ReplyCell, type ThreadView, type VerdictCell, type VersionCell } from '../../../review/cells.ts'
|
|
10
|
-
import type
|
|
8
|
+
import { viewHolderOf, waitsOnOwner, type Backlink, type Cell, type EventCell, type NoteCell, type ReplyCell, type ThreadView, type VerdictCell, type VersionCell } from '../../../review/cells.ts'
|
|
9
|
+
import { foldQuiet, quietOf, type QuietPiece, type Trace } from '../../../review/traces.ts'
|
|
11
10
|
import type { ShareEvent } from '../../../advisors/share-trace.ts'
|
|
12
11
|
import {
|
|
13
12
|
asOptions,
|
|
@@ -36,19 +35,22 @@ import { MentionSt, partyJump } from './mention-st.ts'
|
|
|
36
35
|
import type { RefBox } from '../auto-text.tsx'
|
|
37
36
|
import { PicturesSt } from './pictures-st.ts'
|
|
38
37
|
import { ClipSt } from './clip-st.ts'
|
|
39
|
-
import { answeredAs, postJson, READ_MS } from './review-kit.ts'
|
|
38
|
+
import { answeredAs, movedOfError, postJson, READ_MS } from './review-kit.ts'
|
|
39
|
+
import { reach } from '../reach.ts'
|
|
40
40
|
import type { ReviewSt } from './review-st.ts'
|
|
41
41
|
import type { ThreadBarSt } from '../advisors-st.ts'
|
|
42
42
|
import { ADVISOR_WHO, type ReviewAct } from './review-host.ts'
|
|
43
43
|
import { TrailerSt } from './trailer-st.ts'
|
|
44
44
|
import { laneNotes, notesNow, sortedDraft, type LaneNote } from '../../../review/trailer-notes.ts'
|
|
45
45
|
import { ITEM_VERDICTS, type ItemVerdict } from '../../../review/verdict-items.ts'
|
|
46
|
+
import { questionTones, toneOfStatus } from './tones.ts'
|
|
46
47
|
import { versionActs } from '../../../review/settle.ts'
|
|
47
48
|
import type { LaneMark } from '../../../review/trailer-model.ts'
|
|
48
49
|
import { KeptFolds } from '../kept-folds.ts'
|
|
49
50
|
import { foldSuperseded, runOf } from './superseded-runs.ts'
|
|
50
51
|
import { fixReactions, spotWords, versionFix, versionObject, type ReplyOn, type Spot } from '../../../review/one-block.ts'
|
|
51
52
|
import { findLast } from '../../../core/es2022.ts'
|
|
53
|
+
import { bandOf, mootAt } from '../../../review/thread-state.ts'
|
|
52
54
|
|
|
53
55
|
|
|
54
56
|
/** what the object panel shows: the object a message links (its cell, its address), a loose picture, or a cell's
|
|
@@ -66,6 +68,8 @@ const EMPTY: Draft = { rects: [], comment: '' }
|
|
|
66
68
|
|
|
67
69
|
/** a draft's marks, its words left out */
|
|
68
70
|
type Marks = Pick<Draft, 'rects' | 'reactions' | 'pick'>
|
|
71
|
+
/** his click on a kind's action, on its way or answered: `why` the store's refusal */
|
|
72
|
+
export type ActState = { name: string; state: 'sending' | 'sent' | 'failed'; why?: string }
|
|
69
73
|
const sameMarks = (a: Marks, b: Marks): boolean => a.rects === b.rects && a.reactions === b.reactions && a.pick === b.pick
|
|
70
74
|
|
|
71
75
|
const isDirty = (d: Draft | undefined): boolean => d !== undefined && (d.rects.length > 0 || d.comment.trim() !== '' || (d.reactions ?? []).length > 0 || d.pick !== undefined)
|
|
@@ -82,8 +86,46 @@ export type TileFilter = (typeof TILE_FILTERS)[number]
|
|
|
82
86
|
export type Traced = (EventCell | VerdictCell) & { trace: Trace; share?: ShareEvent; backlink?: Backlink }
|
|
83
87
|
|
|
84
88
|
/** one line of the thread as drawn: a day's divider, a run of traces, a framed cell, or a run of items a newer one
|
|
85
|
-
* superseded, one quiet line that opens to show them (superseded-runs.ts): `key` its first cell, `n` its items
|
|
86
|
-
|
|
89
|
+
* superseded, one quiet line that opens to show them (superseded-runs.ts): `key` its first cell, `n` its items;
|
|
90
|
+
* `recap`: the run is everything before the recap he accepted */
|
|
91
|
+
export type Line = { kind: 'day'; day: string } | { kind: 'events'; cells: Traced[] } | { kind: 'cell'; cell: Framed } | { kind: 'superseded'; key: string; n: number; words: string; recap?: true; lines: Line[] }
|
|
92
|
+
|
|
93
|
+
/** one trace line as drawn: the same trace in a row said once, `n` times, from `c` to `last` */
|
|
94
|
+
export interface TraceRun {
|
|
95
|
+
c: Traced
|
|
96
|
+
n: number
|
|
97
|
+
last: Traced
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** a run of traces as drawn (review-cells.tsx TraceLines): the same trace in a row one line, then two or more quiet lines
|
|
101
|
+
* in a row one fold, its key its first cell */
|
|
102
|
+
export function traceRunsOf(cells: readonly Traced[]): QuietPiece<TraceRun>[] {
|
|
103
|
+
const runs: TraceRun[] = []
|
|
104
|
+
for (const c of cells) {
|
|
105
|
+
const run = runs.at(-1)
|
|
106
|
+
if (run && run.c.summary === c.summary) {
|
|
107
|
+
run.n++
|
|
108
|
+
run.last = c
|
|
109
|
+
} else runs.push({ c, n: 1, last: c })
|
|
110
|
+
}
|
|
111
|
+
return foldQuiet(runs, (r) => quietOf(r.c.trace))
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** the key of a fold of quiet trace lines: its first cell */
|
|
115
|
+
export const quietKey = (first: TraceRun): string => `quiet:${first.c.id}`
|
|
116
|
+
|
|
117
|
+
/** the fold of quiet trace lines a cell sits in, by its key; null when it sits in none */
|
|
118
|
+
export function quietFoldOf(lines: readonly Line[], cell: string): string | null {
|
|
119
|
+
for (const l of lines) {
|
|
120
|
+
const inner = l.kind === 'superseded' ? quietFoldOf(l.lines, cell) : null
|
|
121
|
+
if (inner !== null) return inner
|
|
122
|
+
const at = l.kind === 'events' ? l.cells.findIndex((c) => c.id === cell) : -1
|
|
123
|
+
if (l.kind !== 'events' || at < 0) continue
|
|
124
|
+
// a fold's lines are its cells in a row, first to last
|
|
125
|
+
for (const p of traceRunsOf(l.cells)) if ('fold' in p && at >= l.cells.indexOf(p.fold[0]!.c) && at <= l.cells.indexOf(p.fold.at(-1)!.last)) return quietKey(p.fold[0]!)
|
|
126
|
+
}
|
|
127
|
+
return null
|
|
128
|
+
}
|
|
87
129
|
|
|
88
130
|
/** one item of the contents strip: a cell, or one view of a version, and the key a click unfolds */
|
|
89
131
|
export interface Entry {
|
|
@@ -117,52 +159,45 @@ export interface SaidNote {
|
|
|
117
159
|
|
|
118
160
|
/** the dom id of a cell and of a view of a version: a message id carries a slash */
|
|
119
161
|
export const cellDom = (id: string): string => `rvc-${id.replace(/[^A-Za-z0-9-]/g, '_')}`
|
|
120
|
-
/** a step of an ask's instructions in the timeline
|
|
162
|
+
/** a step of an ask's instructions in the timeline */
|
|
121
163
|
export const stepDom = (cell: string, step: number): string => `${cellDom(cell)}-s${step}`
|
|
122
164
|
export const viewDom = (id: string, view: number): string => `${cellDom(id)}-v${view}`
|
|
123
165
|
export const viewKey = (id: string, view: number): string => `${id}#${view}`
|
|
124
166
|
/** one message's block in a draft version */
|
|
125
167
|
export const postDom = (id: string, key: string): string => `${cellDom(id)}-p-${key.replace(/[^a-z0-9-]/gi, '_')}`
|
|
126
|
-
export const dockDom = (id: string): string => `rvd-${id.replace(/[^A-Za-z0-9-]/g, '_')}`
|
|
127
168
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/** his answer on a question or a change, in one line; a secret says where it is stored, never a byte of it */
|
|
134
|
-
/** where a question or a change stands in its cell: orange while it waits on the owner, green once answered, grey when
|
|
135
|
-
* a newer one superseded it or the thread's close ended it unanswered */
|
|
136
|
-
export const requestState = (c: ReplyCell, waiting: boolean): 'superseded' | 'waiting' | 'moot' | 'answered' =>
|
|
137
|
-
c.superseded ? 'superseded' : waiting ? 'waiting' : c.moot ? 'moot' : 'answered'
|
|
169
|
+
/** where a question or a change stands in its cell: orange while it waits on the owner, green once answered, plain when
|
|
170
|
+
* a newer one superseded it, the thread's close ended it unanswered, or he left it unanswered (« no answer ») */
|
|
171
|
+
export const requestState = (c: ReplyCell, waiting: boolean): 'superseded' | 'waiting' | 'moot' | 'no-answer' | 'answered' =>
|
|
172
|
+
c.superseded ? 'superseded' : waiting ? 'waiting' : c.moot ? 'moot' : c.ask?.tone === 'no-answer' ? 'no-answer' : 'answered'
|
|
138
173
|
|
|
139
174
|
/** the owner's answer on a choice's row: the option clicked, else the owner's words alone, one more option at the
|
|
140
175
|
* row's end; null while none */
|
|
176
|
+
/** the kinds of question that draw the question's row (none of these on a choice, your call, no answer) */
|
|
177
|
+
const BAR_KINDS: ReadonlySet<string> = new Set(['choice', 'confirm', 'text', 'url'])
|
|
178
|
+
|
|
141
179
|
export const ownerChoice = (a: NonNullable<ReplyCell['ask']>): { option: number } | { words: string } | null =>
|
|
142
180
|
a.answered ? { option: a.answered.option } : a.none !== undefined ? { words: a.none } : null
|
|
143
181
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (a.kind === 'url' && a.value) return `${a.value.text}${a.value.opens ? '' : ' · did not open from this Mac'}`
|
|
164
|
-
if (a.value) return a.kind === 'file' ? `his file, view ${(a.value.view ?? 0) + 1}` : a.value.text
|
|
165
|
-
return 'yes'
|
|
182
|
+
/** cells in reading order: a divider when the day changes, the state changes in a row folded into one line, each run of
|
|
183
|
+
* superseded items folded into one line */
|
|
184
|
+
function linesOf(cells: readonly Cell[]): Line[] {
|
|
185
|
+
const out: Line[] = []
|
|
186
|
+
let day = ''
|
|
187
|
+
for (const c of cells) {
|
|
188
|
+
const d = dayOf(c.at)
|
|
189
|
+
if (d !== day) {
|
|
190
|
+
out.push({ kind: 'day', day: d })
|
|
191
|
+
day = d
|
|
192
|
+
}
|
|
193
|
+
const last = out.at(-1)
|
|
194
|
+
if (c.kind === 'event' || (c.kind === 'verdict' && c.trace !== undefined)) {
|
|
195
|
+
const t = c as Traced
|
|
196
|
+
if (last?.kind === 'events') last.cells.push(t)
|
|
197
|
+
else out.push({ kind: 'events', cells: [t] })
|
|
198
|
+
} else out.push({ kind: 'cell', cell: c })
|
|
199
|
+
}
|
|
200
|
+
return foldSuperseded(out)
|
|
166
201
|
}
|
|
167
202
|
|
|
168
203
|
/** a reaction is on that view, that tile of it, or that message of a draft version */
|
|
@@ -203,6 +238,8 @@ export class ThreadSt {
|
|
|
203
238
|
folds: Record<string, boolean> = {}
|
|
204
239
|
/** each run of superseded items he opened, by its first cell: kept in the browser, a run's cells belong to one thread */
|
|
205
240
|
readonly runs = new KeptFolds('hub:superseded-runs')
|
|
241
|
+
/** each fold of quiet trace lines he opened, by its first cell (review/traces.ts foldQuiet) */
|
|
242
|
+
readonly quiets = new KeptFolds('hub:quiet-traces')
|
|
206
243
|
/** a scroll asked of the thread column: it brings that dom id into view once, then clears it */
|
|
207
244
|
jump: string | null = null
|
|
208
245
|
/** the column scrolled to the newest cell once, on the first load */
|
|
@@ -211,9 +248,6 @@ export class ThreadSt {
|
|
|
211
248
|
* gallery the one tile it shows large; or the page of a version of an object (`states`), framed live */
|
|
212
249
|
boxed: { cell: string; view: number; tile?: number } | { cell: string; states: true } | null = null
|
|
213
250
|
private drafts: Record<string, Draft> = {}
|
|
214
|
-
/** the older version his answer goes to: a version landed while he wrote, or he chose to answer it. His first mark
|
|
215
|
-
* on the newest version, or « answer v4 », brings his answer back to the newest */
|
|
216
|
-
draftOn: string | null = null
|
|
217
251
|
/** the newest version's active view: the one last drawn on or picked, whose clip the keys drive */
|
|
218
252
|
view = 0
|
|
219
253
|
/** a picked rectangle of his draft: its note box opens beside it */
|
|
@@ -245,8 +279,9 @@ export class ThreadSt {
|
|
|
245
279
|
replyOn: ReplyOn | null = null
|
|
246
280
|
/** each ask to put the caret in the reply box: the composer takes it once no lightbox covers it */
|
|
247
281
|
replyAsk = 0
|
|
248
|
-
/** the kind's action he
|
|
249
|
-
|
|
282
|
+
/** the kind's action he clicked on an item, by `<item>#<link>`: drawn chosen in the click's frame (« sending… »), then
|
|
283
|
+
* « sent », or the linked object as it was with one line why */
|
|
284
|
+
acting: Record<string, ActState> = {}
|
|
250
285
|
/** the head's tag field: what he types in it, null while it is shut; « + tag » or « more » opens it */
|
|
251
286
|
tagTyping: string | null = null
|
|
252
287
|
busy = false
|
|
@@ -258,7 +293,7 @@ export class ThreadSt {
|
|
|
258
293
|
/** the popup of a face clicked on a version (its id) or a message that asks a verdict (its cell's id): the verdict
|
|
259
294
|
* `status` and its note as he types it; its send gives both in one answer, a bare send the plain verdict. `why`:
|
|
260
295
|
* the store refused that send, the popup back with the words typed. Never the reply box's words, a comment of their own */
|
|
261
|
-
note: { on: string; status: ItemVerdict; text: string; why?: string } | null = null
|
|
296
|
+
note: { on: string; status: ItemVerdict; text: string; why?: string; option?: number } | null = null
|
|
262
297
|
/** the verdicts on their way, written in the order he clicked; the number of the newest */
|
|
263
298
|
private saves: Promise<void> = Promise.resolve()
|
|
264
299
|
private saved = 0
|
|
@@ -350,6 +385,9 @@ export class ThreadSt {
|
|
|
350
385
|
this.error = null
|
|
351
386
|
})
|
|
352
387
|
} catch (e) {
|
|
388
|
+
// a thread moved to another repo: its old link opens it where it is now
|
|
389
|
+
const moved = movedOfError(e)
|
|
390
|
+
if (moved !== null && this.followMove(moved)) return
|
|
353
391
|
runInAction(() => (this.error = (e as Error).message))
|
|
354
392
|
// a pane with nothing drawn reads again by itself: under the live socket no poll would
|
|
355
393
|
if (this.data === null && !this.gone && this.again === null) {
|
|
@@ -361,8 +399,9 @@ export class ThreadSt {
|
|
|
361
399
|
}
|
|
362
400
|
}
|
|
363
401
|
|
|
364
|
-
/** a thread from the server: a cell he sees keeps its fold when a new answer changes the defaults; a
|
|
365
|
-
*
|
|
402
|
+
/** a thread from the server: a cell he sees keeps its fold when a new answer changes the defaults; a draft on an
|
|
403
|
+
* older version (one that landed while he wrote, or one kept in the browser) goes to the newest, which his answer
|
|
404
|
+
* answers when sent */
|
|
366
405
|
receive(v: ThreadView): void {
|
|
367
406
|
// the same answer again (a 304) still settles a send that turned sent since: the read that drew its message may
|
|
368
407
|
// have come before the send's own answer, and no later read changes
|
|
@@ -371,7 +410,6 @@ export class ThreadSt {
|
|
|
371
410
|
// a cell a newer object just superseded folds even under the owner's eyes: that is the point of superseding it
|
|
372
411
|
const gone = new Set(v.cells.flatMap((c) => (c.superseded ? [c.id] : [])))
|
|
373
412
|
if (before) for (const c of before.cells) if (c.kind !== 'event' && !gone.has(c.id) && this.folds[c.id] === undefined && this.defaultOpen(c, before) !== this.defaultOpen(c, v)) this.folds = { ...this.folds, [c.id]: this.defaultOpen(c, before) }
|
|
374
|
-
if (before && before.head !== v.head && this.draftOn === null && isDirty(this.drafts[before.head]) && v.members.includes(before.head)) this.draftOn = before.head
|
|
375
413
|
this.data = v
|
|
376
414
|
// an address's view on a link to an old version is that version's view, never the newest's
|
|
377
415
|
if (!before && v.asked !== v.head && this.view > 0) {
|
|
@@ -379,14 +417,14 @@ export class ThreadSt {
|
|
|
379
417
|
this.view = 0
|
|
380
418
|
this.reveal(v.asked, at)
|
|
381
419
|
}
|
|
382
|
-
|
|
383
|
-
// every version's draft kept in the browser is found again: an older one stays on its version (`parked`)
|
|
420
|
+
// every version's draft kept in the browser is found again
|
|
384
421
|
const found: Record<string, Draft> = {}
|
|
385
422
|
for (const id of v.members) {
|
|
386
423
|
const d = this.drafts[id] === undefined ? this.rv.storedDraft(id) : null
|
|
387
424
|
if (d) found[id] = d
|
|
388
425
|
}
|
|
389
426
|
if (Object.keys(found).length > 0) this.drafts = { ...this.drafts, ...found }
|
|
427
|
+
for (const id of v.members) if (id !== v.head && isDirty(this.drafts[id])) this.carry(id, v.head)
|
|
390
428
|
const ids = new Set(v.cells.map((c) => c.id))
|
|
391
429
|
this.outbox.settle(v.cells.map((c) => ({ id: c.id, who: c.who, ...(c.kind === 'reply' ? { text: c.text } : {}) })))
|
|
392
430
|
if (Object.keys(this.deleting).some((id) => !ids.has(id))) this.deleting = Object.fromEntries(Object.keys(this.deleting).filter((id) => ids.has(id)).map((id) => [id, true as const]))
|
|
@@ -404,10 +442,9 @@ export class ThreadSt {
|
|
|
404
442
|
return this.data?.cells ?? []
|
|
405
443
|
}
|
|
406
444
|
|
|
407
|
-
/** the cell the owner's verdict and reply go to: the newest version, or the raised item no version answers
|
|
408
|
-
* version his draft sits on while a newer one landed */
|
|
445
|
+
/** the cell the owner's verdict and reply go to: the newest version, or the raised item no version answers */
|
|
409
446
|
get head(): Framed | null {
|
|
410
|
-
const h = this.
|
|
447
|
+
const h = this.data?.head
|
|
411
448
|
return (this.cells.find((c) => c.id === h && c.kind !== 'event') as Framed | undefined) ?? null
|
|
412
449
|
}
|
|
413
450
|
|
|
@@ -417,68 +454,32 @@ export class ThreadSt {
|
|
|
417
454
|
return (this.cells.find((c) => c.id === h && c.kind !== 'event') as Framed | undefined) ?? null
|
|
418
455
|
}
|
|
419
456
|
|
|
420
|
-
/**
|
|
421
|
-
*
|
|
422
|
-
|
|
423
|
-
if (this.draftOn !== null || !this.data) return null
|
|
424
|
-
const head = this.data.head
|
|
425
|
-
return [...this.data.members].reverse().find((id) => id !== head && isDirty(this.drafts[id])) ?? null
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/** the newest version takes his marks while his answer sits on an older one: his first mark brings it back */
|
|
429
|
-
get claims(): boolean {
|
|
430
|
-
const n = this.newest
|
|
431
|
-
return this.draftOn !== null && n?.kind === 'version' && !n.item.wip
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/** his answer goes to the newest version; the draft on the older one stays there, parked */
|
|
435
|
-
answerNewest(): void {
|
|
436
|
-
if (this.draftOn === null) return
|
|
437
|
-
this.draftOn = null
|
|
438
|
-
this.rect = null
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/** his answer goes to the older version his parked draft is on */
|
|
442
|
-
answerParked(): void {
|
|
443
|
-
const p = this.parked
|
|
444
|
-
if (p === null) return
|
|
445
|
-
this.draftOn = p
|
|
446
|
-
this.rect = null
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/** the parked draft dropped: his notes and his word on the older version */
|
|
450
|
-
dropParked(): void {
|
|
451
|
-
const p = this.parked
|
|
452
|
-
if (p !== null) this.put(p, null)
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/** his draft moved onto the newest version: his word, and the marks whose view the newest has; what does not fit
|
|
456
|
-
* stays on the older one */
|
|
457
|
-
moveDraft(): void {
|
|
458
|
-
const from = this.draftOn ?? this.parked
|
|
459
|
-
const to = this.data?.head
|
|
460
|
-
if (from === null || !to) return
|
|
457
|
+
/** a draft moved from an older version onto `to`: his word, and the marks whose view `to` has; what does not fit
|
|
458
|
+
* stays on the older one, never dropped */
|
|
459
|
+
private carry(from: string, to: string): void {
|
|
461
460
|
const d = this.drafts[from] ?? EMPTY
|
|
462
461
|
const toItem = this.versionOf(to)?.item
|
|
463
462
|
const views = (toItem?.views ?? []).length
|
|
464
463
|
const fits = (view: number | undefined): boolean => (view ?? 0) < views
|
|
465
464
|
// a word on a message of a draft follows to a newer draft version, which holds no view
|
|
466
465
|
const takes = (r: ReviewReaction): boolean => (r.post !== undefined ? toItem?.draft !== undefined : fits(r.view))
|
|
466
|
+
const rects = d.rects.filter((r) => fits(r.view))
|
|
467
|
+
const taken = (d.reactions ?? []).filter(takes)
|
|
468
|
+
if (d.comment.trim() === '' && rects.length === 0 && taken.length === 0) return
|
|
467
469
|
const into = this.drafts[to] ?? EMPTY
|
|
468
470
|
const moved: Draft = {
|
|
469
471
|
comment: [into.comment, d.comment].filter((x) => x.trim() !== '').join('\n'),
|
|
470
|
-
rects: [...into.rects, ...
|
|
472
|
+
rects: [...into.rects, ...rects],
|
|
471
473
|
...(into.pick !== undefined ? { pick: into.pick } : {}),
|
|
472
474
|
}
|
|
473
|
-
const reactions = [...(into.reactions ?? []), ...
|
|
475
|
+
const reactions = [...(into.reactions ?? []), ...taken.filter((r) => !(into.reactions ?? []).some((q) => sameSpot(q, r.view, r.tile, r.post)))]
|
|
474
476
|
if (reactions.length > 0) moved.reactions = reactions
|
|
475
|
-
|
|
477
|
+
// a pick names a view of the older version: it stays there with it
|
|
478
|
+
const left: Draft = { comment: '', rects: d.rects.filter((r) => !fits(r.view)), ...(d.pick !== undefined ? { pick: d.pick } : {}) }
|
|
476
479
|
const leftReactions = (d.reactions ?? []).filter((r) => !takes(r))
|
|
477
480
|
if (leftReactions.length > 0) left.reactions = leftReactions
|
|
478
481
|
this.put(to, moved)
|
|
479
482
|
this.put(from, isDirty(left) ? left : null)
|
|
480
|
-
this.draftOn = null
|
|
481
|
-
this.rect = null
|
|
482
483
|
}
|
|
483
484
|
|
|
484
485
|
get headItem(): Item | null {
|
|
@@ -491,18 +492,8 @@ export class ThreadSt {
|
|
|
491
492
|
const h = this.head
|
|
492
493
|
// a thread opened with words holds nothing to judge: its questions and changes take his answer in their cells;
|
|
493
494
|
// his own save neither
|
|
494
|
-
// a promised next version replaces it: no verdict needed (review/
|
|
495
|
-
return h?.kind === 'version' && !h.item.wip && !asksNoVerdict(h.item) && this.data?.next
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
/** what is expected of him now: the band of the list and the dock's own lines (review/expect.ts expectOf, the
|
|
499
|
-
* function the cli's verbs print too); the dock draws it when nothing waits on his answer */
|
|
500
|
-
get expect(): Expect | null {
|
|
501
|
-
const v = this.data
|
|
502
|
-
if (!v) return null
|
|
503
|
-
const ver = this.verdictAbove
|
|
504
|
-
const waiting = waitLinesOf(this.openRequests, ver ? { id: ver.id, n: ver.n } : null, v.ask ? { state: v.ask.state, title: v.ask.title, head: v.head } : undefined)
|
|
505
|
-
return expectOf({ ...v, waiting, ...(v.aside ? { aside: v.aside } : {}), validated: validatedOf({ turn: v.turn, status: v.status, ...(v.ask ? { ask: v.ask.state } : {}) }) }, this.rv.parties, this.rv.bandNow)
|
|
495
|
+
// a promised next version replaces it: no verdict needed (review/thread-state.ts ThreadState next)
|
|
496
|
+
return h?.kind === 'version' && !h.item.wip && !asksNoVerdict(h.item) && this.data?.state.next == null
|
|
506
497
|
}
|
|
507
498
|
|
|
508
499
|
/** the version cell an item id names */
|
|
@@ -510,6 +501,55 @@ export class ThreadSt {
|
|
|
510
501
|
return (this.cells.find((c) => c.kind === 'version' && c.id === id) as VersionCell | undefined) ?? null
|
|
511
502
|
}
|
|
512
503
|
|
|
504
|
+
/** the cell whose item holds the views a message names: a version, or the item he raised (review/cells.ts viewHolderOf);
|
|
505
|
+
* every reader of a message's media goes through it */
|
|
506
|
+
get holders(): ReadonlyMap<string, VersionCell> {
|
|
507
|
+
const out = new Map<string, VersionCell>()
|
|
508
|
+
for (const c of this.cells) {
|
|
509
|
+
const h = viewHolderOf(c)
|
|
510
|
+
if (h !== null) out.set(c.id, h)
|
|
511
|
+
}
|
|
512
|
+
return out
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
holderOf(id: string): VersionCell | null {
|
|
516
|
+
return this.holders.get(id) ?? null
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** the house repos this thread may move to, every one but its own, as the move route takes them; null until read */
|
|
520
|
+
moveTargets: string[] | null = null
|
|
521
|
+
|
|
522
|
+
/** the house repos read once, when the head first draws its « move to project… » */
|
|
523
|
+
async readMoveTargets(): Promise<void> {
|
|
524
|
+
if (this.moveTargets !== null || this.rv.host.owner == null || !this.rv.can('move')) return
|
|
525
|
+
try {
|
|
526
|
+
const r = await (await reach(this.rv.url('/api/review/move-targets'), { cache: 'no-store' })).json() as { repos?: string[] }
|
|
527
|
+
runInAction(() => (this.moveTargets = r.repos ?? []))
|
|
528
|
+
} catch {
|
|
529
|
+
runInAction(() => (this.moveTargets = []))
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** his « move to project… »: the thread moves whole to `repo` (review/move.ts), then opens there */
|
|
534
|
+
async moveTo(repo: string): Promise<void> {
|
|
535
|
+
const head = this.data?.head
|
|
536
|
+
if (head === undefined) return
|
|
537
|
+
try {
|
|
538
|
+
const m = await postJson<{ repo: string; head: string }>(this.rv.url(`/api/review/${head}/move`), { repo })
|
|
539
|
+
this.followMove(m)
|
|
540
|
+
} catch (e) {
|
|
541
|
+
runInAction(() => (this.error = (e as Error).message))
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/** the thread opened where it moved, in its repo's threads; false at the advisors' door, which has no other repo */
|
|
546
|
+
followMove(m: { repo: string; head: string }): boolean {
|
|
547
|
+
const o = this.rv.host.owner
|
|
548
|
+
if (o == null) return false
|
|
549
|
+
o.home.openReview(m.repo, m.head)
|
|
550
|
+
return true
|
|
551
|
+
}
|
|
552
|
+
|
|
513
553
|
/** the thread's bar of advisors, where he may share: its shares' acts are lines of this timeline */
|
|
514
554
|
get shareBar(): ThreadBarSt | null {
|
|
515
555
|
const o = this.rv.host.owner
|
|
@@ -521,7 +561,7 @@ export class ThreadSt {
|
|
|
521
561
|
/** each act of the thread's shares as a trace cell, at its own time (advisors/share-trace.ts) */
|
|
522
562
|
get shareCells(): Traced[] {
|
|
523
563
|
const head = this.data?.head ?? ''
|
|
524
|
-
return (this.shareBar?.data?.trace ?? []).map((e) => ({ kind: 'event' as const, id: e.id, on: head, at: e.at, who: e.who, party: 'owner' as const, summary: e.words, open: false, trace: { act: 'share' as const, did: e.words }, share: e }))
|
|
564
|
+
return (this.shareBar?.data?.trace ?? []).map((e) => ({ kind: 'event' as const, id: e.id, on: head, at: e.at, who: e.who, party: 'owner' as const, summary: e.words, open: false, trace: { act: 'share' as const, did: e.words, ...(e.live === true ? { live: true as const } : {}) }, share: e }))
|
|
525
565
|
}
|
|
526
566
|
|
|
527
567
|
/** each message of another thread that names this one by its code, a quiet line of the timeline at its time */
|
|
@@ -538,7 +578,7 @@ export class ThreadSt {
|
|
|
538
578
|
return {
|
|
539
579
|
look: (c) => {
|
|
540
580
|
const r = refs[c]
|
|
541
|
-
return r === undefined ? null : { code: r.code, head: r.head, title: r.title, band: bandOf(r, parties, now) }
|
|
581
|
+
return r === undefined ? null : { code: r.code, head: r.head, title: r.title, band: bandOf(r.state, parties, now) }
|
|
542
582
|
},
|
|
543
583
|
open: this.openRef,
|
|
544
584
|
}
|
|
@@ -550,26 +590,20 @@ export class ThreadSt {
|
|
|
550
590
|
/** the thread in reading order: a divider when the day changes, the state changes in a row folded into one line,
|
|
551
591
|
* each run of superseded items folded into one line; the shares' acts among them by their time */
|
|
552
592
|
get lines(): Line[] {
|
|
553
|
-
const out: Line[] = []
|
|
554
|
-
let day = ''
|
|
555
593
|
const shares = [...this.shareCells, ...this.backlinkCells]
|
|
556
594
|
// the owner's words on their way stand last: the newest, whatever the clock of the store says
|
|
557
595
|
const cells = Object.keys(this.deleting).length === 0 ? this.cells : this.cells.filter((c) => !this.deleting[c.id])
|
|
558
596
|
const all: Cell[] = [...(shares.length === 0 ? cells : [...cells, ...shares].sort((a, b) => a.at.localeCompare(b.at))), ...this.outbox.cells]
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
else out.push({ kind: 'events', cells: [t] })
|
|
570
|
-
} else out.push({ kind: 'cell', cell: c })
|
|
571
|
-
}
|
|
572
|
-
return foldSuperseded(out)
|
|
597
|
+
// past a recap he accepted, what came before it is one quiet line that opens (review/cells.ts ThreadView recap)
|
|
598
|
+
const recap = this.data?.recap
|
|
599
|
+
if (recap === undefined) return linesOf(all)
|
|
600
|
+
const before = new Set(recap.before)
|
|
601
|
+
const own = new Set(cells)
|
|
602
|
+
// a share's act or a backlink before the recap folds with it
|
|
603
|
+
const fold = new Set(all.filter((c) => before.has(c.id) || (c.at < recap.at && !own.has(c))))
|
|
604
|
+
if (fold.size === 0) return linesOf(all)
|
|
605
|
+
const n = [...fold].filter((c) => c.kind !== 'event').length
|
|
606
|
+
return [{ kind: 'superseded', key: `recap:${recap.cell}`, n, words: `${n} message${n === 1 ? '' : 's'} before the recap`, recap: true, lines: linesOf(all.filter((c) => fold.has(c))) }, ...linesOf(all.filter((c) => !fold.has(c)))]
|
|
573
607
|
}
|
|
574
608
|
|
|
575
609
|
/** the run of superseded items is open: shut until he opens it */
|
|
@@ -581,42 +615,74 @@ export class ThreadSt {
|
|
|
581
615
|
this.runs.flipFold(key, false)
|
|
582
616
|
}
|
|
583
617
|
|
|
584
|
-
/** a
|
|
618
|
+
/** a fold of quiet trace lines is open: shut until he opens it */
|
|
619
|
+
quietOpen(key: string): boolean {
|
|
620
|
+
return this.quiets.isOpen(key, false)
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
toggleQuiet(key: string): void {
|
|
624
|
+
this.quiets.flipFold(key, false)
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/** a jump to a cell inside a shut run opens the run, and the fold of quiet traces it sits in */
|
|
585
628
|
private openRunOf(cell: string): void {
|
|
586
629
|
const key = runOf(this.lines, cell)
|
|
587
630
|
if (key !== null) this.runs.setFold(key, true)
|
|
631
|
+
const fold = quietFoldOf(this.lines, cell)
|
|
632
|
+
if (fold !== null) this.quiets.setFold(fold, true)
|
|
588
633
|
}
|
|
589
634
|
|
|
590
|
-
// ──
|
|
635
|
+
// ── what waits on his answer: the arrows at the column's top count it (wiki tools/shipkit/threads-page.md, The timeline) ──
|
|
591
636
|
|
|
592
637
|
/** each question and proposed change of an agent that still waits on him, oldest first: the server closes a request
|
|
593
|
-
* asked before
|
|
638
|
+
* asked before the close, whoever closed (review/cells.ts, moot), and one asked after it waits */
|
|
594
639
|
get openRequests(): ReplyCell[] {
|
|
595
|
-
|
|
640
|
+
// a question with a row per thing waits as one, by its first row: the cell that draws every row
|
|
641
|
+
const seen = new Set<string>()
|
|
642
|
+
const out: ReplyCell[] = []
|
|
643
|
+
// what the thread's state says waits on him (review/thread-state.ts), its rows as one; an answer on its way
|
|
644
|
+
// already closes its cell here
|
|
645
|
+
const waits = new Set(this.data ? waitLinesOf(this.data.state).map((l) => l.id) : [])
|
|
646
|
+
const rowOf = (c: ReplyCell): ReplyCell => (c.ask?.row ? (this.rowsOf(c)[0] ?? c) : c)
|
|
647
|
+
for (const c of this.cells.filter((x): x is ReplyCell => waitsOnOwner(x) && (waits.has(x.id) || waits.has(rowOf(x).id)))) {
|
|
648
|
+
const g = c.ask?.row?.group
|
|
649
|
+
if (g === undefined) out.push(c)
|
|
650
|
+
else if (!seen.has(g)) {
|
|
651
|
+
seen.add(g)
|
|
652
|
+
out.push(this.rowsOf(c)[0] ?? c)
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return out
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/** the rows of the question with a row per thing that `c` is one row of, in row order; empty for any other cell */
|
|
659
|
+
rowsOf(c: ReplyCell): ReplyCell[] {
|
|
660
|
+
const g = c.ask?.row?.group
|
|
661
|
+
if (g === undefined) return []
|
|
662
|
+
return this.cells.filter((x): x is ReplyCell => x.kind === 'reply' && x.ask?.row?.group === g).sort((a, b) => a.ask!.row!.i - b.ask!.row!.i)
|
|
596
663
|
}
|
|
597
664
|
|
|
598
|
-
/** every cell
|
|
665
|
+
/** every cell that waits on him: the open requests, then the version that waits for the owner's verdict */
|
|
599
666
|
get waiting(): string[] {
|
|
600
667
|
const v = this.verdictAbove
|
|
601
668
|
return [...this.openRequests.map((c) => c.id), ...(v ? [v.id] : [])]
|
|
602
669
|
}
|
|
603
670
|
|
|
604
|
-
/** when
|
|
605
|
-
*
|
|
671
|
+
/** when the close moots what was asked before it, whoever closed; null while it is open (review/thread-state.ts
|
|
672
|
+
* mootAt): a request asked before it closes with it, one asked after it still waits */
|
|
606
673
|
get closedAt(): string | null {
|
|
607
|
-
return this.data
|
|
674
|
+
return this.data ? mootAt(this.data.state) : null
|
|
608
675
|
}
|
|
609
676
|
|
|
610
|
-
/** the request still waits on him: its cell draws its controls live
|
|
677
|
+
/** the request still waits on him: its cell draws its controls live */
|
|
611
678
|
waitsNow(id: string): boolean {
|
|
612
679
|
return this.openRequests.some((c) => c.id === id)
|
|
613
680
|
}
|
|
614
681
|
|
|
615
|
-
/** the version that waits for the owner's verdict: its
|
|
616
|
-
* dock holds one line that reminds of it */
|
|
682
|
+
/** the version that waits for the owner's verdict: its answer bar sits at its foot (tone-bar.tsx) */
|
|
617
683
|
get verdictAbove(): VersionCell | null {
|
|
618
684
|
const h = this.head
|
|
619
|
-
if (h?.kind !== 'version' || !this.takesVerdict || this.chosenOn(h.id) !== undefined || this.data?.state.
|
|
685
|
+
if (h?.kind !== 'version' || !this.takesVerdict || this.chosenOn(h.id) !== undefined || this.data?.state.closed != null) return null
|
|
620
686
|
return h
|
|
621
687
|
}
|
|
622
688
|
|
|
@@ -626,12 +692,18 @@ export class ThreadSt {
|
|
|
626
692
|
return this.save(c.id, status, () => postJson(this.rv.url(`/api/review/${c.on}/item-verdict`), { re: c.id.slice(c.on.length + 1), status, ...(text !== '' ? { text } : {}) }), false)
|
|
627
693
|
}
|
|
628
694
|
|
|
629
|
-
/** V F R
|
|
630
|
-
* when none waits. It opens that
|
|
695
|
+
/** 1 to 5, V F R X Y: the tone on the newest open item that asks the owner's answer, a message, a question or the
|
|
696
|
+
* version; the version when none waits. It opens that tone's box, ok and your call too: a key alone never sends,
|
|
697
|
+
* Enter does */
|
|
631
698
|
judgeKey(status: ItemVerdict): Promise<void> | void {
|
|
632
|
-
const c = [...this.openRequests].reverse().find((x) => x.judge?.open === true)
|
|
699
|
+
const c = [...this.openRequests].reverse().find((x) => x.judge?.open === true || this.questionCell(x.id) !== undefined)
|
|
633
700
|
const v = this.verdictAbove
|
|
634
|
-
if (c !== undefined && (v === null || c.at >= v.at))
|
|
701
|
+
if (c !== undefined && (v === null || c.at >= v.at)) {
|
|
702
|
+
// a question's keys are its row's alone: a pick is a click on its option
|
|
703
|
+
const q = this.questionCell(c.id)
|
|
704
|
+
if (q !== undefined && !questionTones('row', null, q.ask!.kind ?? 'choice').some((t) => t.status === status)) return
|
|
705
|
+
return this.face(c.id, status)
|
|
706
|
+
}
|
|
635
707
|
// a version answered by its kind's acts (a draft) takes no verdict, by key either
|
|
636
708
|
const h = this.head
|
|
637
709
|
if (h?.kind !== 'version' || versionActs(h.item) !== null || !this.takesVerdict) return
|
|
@@ -640,9 +712,86 @@ export class ThreadSt {
|
|
|
640
712
|
|
|
641
713
|
/** a face clicked on `on` (a version's id, or a message's cell id): its popup opens there, its box empty; another
|
|
642
714
|
* face of that item open swaps to this one and keeps the words typed; the same face again closes it. Nothing is sent */
|
|
643
|
-
face(on: string, status: ItemVerdict): void {
|
|
644
|
-
const n = this.note?.on === on ? this.note : null
|
|
645
|
-
this.note = n?.status === status ? null : { on, status, text: n?.text ?? '' }
|
|
715
|
+
face(on: string, status: ItemVerdict, option?: number): void {
|
|
716
|
+
const n = this.note?.on === on && this.note.option === option ? this.note : null
|
|
717
|
+
this.note = n?.status === status ? null : { on, status, text: n?.text ?? '', ...(option !== undefined ? { option } : {}) }
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/** a click on a tone of the bar (tone-bar.tsx): ok and your call send at once; one that takes words, or the one
|
|
721
|
+
* already given, opens its box (face). `option`: the bar of one option of a question (the lightbox's side panel),
|
|
722
|
+
* whose ok and fix take that option */
|
|
723
|
+
tone(on: string, status: ItemVerdict, option?: number): Promise<void> | void {
|
|
724
|
+
if (toneOfStatus(status)?.words === true || this.litOn(on, status, option)) return this.face(on, status, option)
|
|
725
|
+
this.note = { on, status, text: '', ...(option !== undefined ? { option } : {}) }
|
|
726
|
+
return this.sendNote()
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/** the tone given on `on`, read for the bar of one option: its ok and fix are lit on the option he picked alone */
|
|
730
|
+
litOn(on: string, status: ItemVerdict, option?: number): boolean {
|
|
731
|
+
if (this.givenOn(on) !== status) return false
|
|
732
|
+
if (option === undefined || (status !== 'approved' && status !== 'approved-with-fix')) return true
|
|
733
|
+
const q = this.questionCell(on)
|
|
734
|
+
return q !== undefined && this.yours(q) === option
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/** the option of a question marked as the reader's: their click on its way, else their own pick (the owner's, on his hub) */
|
|
738
|
+
yours(c: ReplyCell): number | undefined {
|
|
739
|
+
const ask = c.ask
|
|
740
|
+
if (ask === undefined) return undefined
|
|
741
|
+
const local = this.picking[c.id]
|
|
742
|
+
if (local !== undefined && local.state !== 'failed') return local.option
|
|
743
|
+
if (this.rv.host.role === 'advisor') return ask.people?.find((p) => p.you === true)?.option
|
|
744
|
+
const his = ownerChoice(ask)
|
|
745
|
+
return ask.ownerPick ?? (ask.answered?.by === undefined && his !== null && 'option' in his ? his.option : undefined)
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/** the reader's remark with their pick (« pick with a remark »): their click on its way, else the answer's; '' with none */
|
|
749
|
+
yourRemark(c: ReplyCell): string {
|
|
750
|
+
const local = this.picking[c.id]
|
|
751
|
+
if (local !== undefined && local.state !== 'failed') return local.remark ?? ''
|
|
752
|
+
const yours = this.yours(c)
|
|
753
|
+
return yours !== undefined && c.ask?.answered?.option === yours ? (c.ask.answered.remark ?? '') : ''
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/** the question and its option a view of version `cell` draws (an option's picture), the newest question first; the
|
|
757
|
+
* lightbox opened on it steps through that question's options (a row question's, its row's) */
|
|
758
|
+
optionAt(cell: string, view: number): { c: ReplyCell; i: number; order: number[] } | null {
|
|
759
|
+
for (const c of [...this.cells].reverse()) {
|
|
760
|
+
if (c.kind !== 'reply' || c.ask?.views === undefined || c.on !== cell) continue
|
|
761
|
+
const i = c.ask.views.indexOf(view)
|
|
762
|
+
if (i < 0) continue
|
|
763
|
+
return { c, i, order: c.ask.views.flatMap((v, k) => (v === null ? [] : [k])) }
|
|
764
|
+
}
|
|
765
|
+
return null
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/** the question `on` names when its bar answers it (tone-bar.tsx QuestionBar): a choice, a confirm, a text or a url,
|
|
769
|
+
* no step of an ask's instructions */
|
|
770
|
+
questionCell(on: string): ReplyCell | undefined {
|
|
771
|
+
const c = this.askingCell(on)
|
|
772
|
+
return c?.ask !== undefined && BAR_KINDS.has(c.ask.kind ?? 'choice') && c.step === undefined && c.judge === undefined ? c : undefined
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/** the tone the owner's answer to a question gives, the one on its way first: a pick ok, a pick with the owner's words a fix, words
|
|
776
|
+
* alone a rework unless he named another tone */
|
|
777
|
+
private questionTone(c: ReplyCell): ItemVerdict | undefined {
|
|
778
|
+
const a = c.ask!
|
|
779
|
+
const local = this.picking[c.id]
|
|
780
|
+
if (local !== undefined && local.state !== 'failed') return local.remark ? 'approved-with-fix' : 'approved'
|
|
781
|
+
if (a.tone !== undefined && (ITEM_VERDICTS as readonly string[]).includes(a.tone)) return a.tone as ItemVerdict
|
|
782
|
+
if (a.answered !== undefined) return a.answered.remark ? 'approved-with-fix' : 'approved'
|
|
783
|
+
return a.none !== undefined ? 'rework' : undefined
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/** the owner's answer from a question's bar (sendNote, tones.ts questionTones): a pick or a pick with a remark of the
|
|
787
|
+
* option `option`; none of these, your call or no answer goes as his answer in that tone (store.ts answerAsk `tone`) */
|
|
788
|
+
private answerTone(c: ReplyCell, status: ItemVerdict, text: string, option?: number): Promise<void> {
|
|
789
|
+
if (status === 'approved' || status === 'approved-with-fix') {
|
|
790
|
+
if (option !== undefined) return this.pickOption(c, option, status === 'approved' ? '' : text)
|
|
791
|
+
this.failed = { on: c.id, why: 'click an option above to pick it' }
|
|
792
|
+
return Promise.resolve()
|
|
793
|
+
}
|
|
794
|
+
return this.save(c.id, status, () => postJson(this.rv.url(`/api/review/${c.on}/answer`), { re: c.id.slice(c.on.length + 1), tone: status, ...(text !== '' ? { text } : {}) }), false)
|
|
646
795
|
}
|
|
647
796
|
|
|
648
797
|
setNote(text: string): void {
|
|
@@ -655,8 +804,8 @@ export class ThreadSt {
|
|
|
655
804
|
}
|
|
656
805
|
|
|
657
806
|
/** the verdict already given is the one the popup holds and nothing new goes with it: a bare send changes nothing */
|
|
658
|
-
private sameAsGiven(n: { on: string; status: ItemVerdict; text: string }): boolean {
|
|
659
|
-
return n.text.trim() === '' && this.
|
|
807
|
+
private sameAsGiven(n: { on: string; status: ItemVerdict; text: string; option?: number }): boolean {
|
|
808
|
+
return n.text.trim() === '' && this.litOn(n.on, n.status, n.option) && (this.askingCell(n.on) !== undefined || !this.marked)
|
|
660
809
|
}
|
|
661
810
|
|
|
662
811
|
/** « take it back » in the popup of a version's lit face: the version waits for the owner's verdict again */
|
|
@@ -667,7 +816,8 @@ export class ThreadSt {
|
|
|
667
816
|
|
|
668
817
|
/** the verdict given on `on` (a version's id or a message's cell id), the one on its way first */
|
|
669
818
|
givenOn(on: string): ItemVerdict | undefined {
|
|
670
|
-
const
|
|
819
|
+
const q = this.questionCell(on)
|
|
820
|
+
const s = this.chosenOn(on) ?? (q !== undefined ? this.questionTone(q) : this.askingCell(on)?.judge?.verdict?.status)
|
|
671
821
|
return s !== undefined && (ITEM_VERDICTS as readonly string[]).includes(s) ? (s as ItemVerdict) : undefined
|
|
672
822
|
}
|
|
673
823
|
|
|
@@ -685,13 +835,14 @@ export class ThreadSt {
|
|
|
685
835
|
this.note = null
|
|
686
836
|
if (this.sameAsGiven(n)) return
|
|
687
837
|
const text = n.text.trim()
|
|
838
|
+
const q = this.questionCell(n.on)
|
|
688
839
|
const c = this.askingCell(n.on)
|
|
689
840
|
this.error = null
|
|
690
|
-
await (c !== undefined ? this.judge(c, n.status, text) : this.submit(n.status, text))
|
|
841
|
+
await (q !== undefined ? this.answerTone(q, n.status, text, n.option) : c !== undefined ? this.judge(c, n.status, text) : this.submit(n.status, text))
|
|
691
842
|
runInAction(() => {
|
|
692
843
|
const why = this.failed?.on === n.on ? this.failed.why : this.error
|
|
693
844
|
if (why === null || this.note !== null) return
|
|
694
|
-
this.note = { on: n.on, status: n.status, text: n.text, why }
|
|
845
|
+
this.note = { on: n.on, status: n.status, text: n.text, why, ...(n.option !== undefined ? { option: n.option } : {}) }
|
|
695
846
|
if (this.failed?.on === n.on) this.failed = null
|
|
696
847
|
this.error = null
|
|
697
848
|
})
|
|
@@ -739,13 +890,6 @@ export class ThreadSt {
|
|
|
739
890
|
if (view !== undefined && cell === this.target) this.setView(view)
|
|
740
891
|
}
|
|
741
892
|
|
|
742
|
-
/** the dock's reminder of an ask's instructions: the column scrolls to that step and lights it */
|
|
743
|
-
revealStep(cell: string, step: number): void {
|
|
744
|
-
this.openRunOf(cell)
|
|
745
|
-
this.folds = { ...this.folds, [cell]: true }
|
|
746
|
-
this.jump = stepDom(cell, step)
|
|
747
|
-
}
|
|
748
|
-
|
|
749
893
|
jumped(): void {
|
|
750
894
|
this.jump = null
|
|
751
895
|
}
|
|
@@ -875,7 +1019,7 @@ export class ThreadSt {
|
|
|
875
1019
|
const r = own ?? given
|
|
876
1020
|
const picked = this.pickShown(h) === i
|
|
877
1021
|
// a gallery is answered tile by tile: one tile scored or marked answers the view
|
|
878
|
-
const tiles = isGallery(v) && [...(this.marks.reactions ?? []), ...(sent?.reactions ?? [])].some((q) => q.view === i && q.tile !== undefined && (q.status || q.stars
|
|
1022
|
+
const tiles = isGallery(v) && [...(this.marks.reactions ?? []), ...(sent?.reactions ?? [])].some((q) => q.view === i && q.tile !== undefined && (q.status || q.stars))
|
|
879
1023
|
const answer: ViewMark['answer'] = picked ? 'picked' : r?.status ? r.status : (choice && r?.stars) || tiles ? 'scored' : sent ? 'sent' : 'none'
|
|
880
1024
|
const noted = this.marks.rects.some((q) => (q.view ?? 0) === i) || (own?.comment ?? '').trim() !== ''
|
|
881
1025
|
return { view: i, tag: viewTag(h.n, i), answer, noted }
|
|
@@ -972,7 +1116,7 @@ export class ThreadSt {
|
|
|
972
1116
|
|
|
973
1117
|
/** the id his draft and his answer go to */
|
|
974
1118
|
get target(): string | null {
|
|
975
|
-
return this.
|
|
1119
|
+
return this.data?.head ?? null
|
|
976
1120
|
}
|
|
977
1121
|
|
|
978
1122
|
get draft(): Draft {
|
|
@@ -1020,7 +1164,6 @@ export class ThreadSt {
|
|
|
1020
1164
|
const h = this.target
|
|
1021
1165
|
if (!h) return
|
|
1022
1166
|
this.put(h, null)
|
|
1023
|
-
if (this.draftOn === h) this.draftOn = null
|
|
1024
1167
|
this.rect = null
|
|
1025
1168
|
this.attach.follow('')
|
|
1026
1169
|
}
|
|
@@ -1041,7 +1184,6 @@ export class ThreadSt {
|
|
|
1041
1184
|
if (reactions.length > 0) left.reactions = reactions
|
|
1042
1185
|
this.put(on, isDirty(left) ? left : null)
|
|
1043
1186
|
}
|
|
1044
|
-
if (this.draftOn === on) this.draftOn = null
|
|
1045
1187
|
if (this.target !== on) this.rect = null
|
|
1046
1188
|
}
|
|
1047
1189
|
|
|
@@ -1207,9 +1349,9 @@ export class ThreadSt {
|
|
|
1207
1349
|
this.putReaction(view, tile, { comment: '' })
|
|
1208
1350
|
}
|
|
1209
1351
|
|
|
1210
|
-
private putReaction(view: number, tile: number | undefined, r: { status?: ReviewStatus | undefined; comment: string; stars?: number | undefined
|
|
1211
|
-
const next: ReviewReaction = { view, ...(tile !== undefined ? { tile } : {}), ...(post !== undefined ? { post } : {}), ...(r.status ? { status: r.status } : {}), comment: r.comment, ...(r.stars ? { stars: r.stars } : {})
|
|
1212
|
-
const empty = !r.status && r.comment === '' && !r.stars
|
|
1352
|
+
private putReaction(view: number, tile: number | undefined, r: { status?: ReviewStatus | undefined; comment: string; stars?: number | undefined }, post?: string): void {
|
|
1353
|
+
const next: ReviewReaction = { view, ...(tile !== undefined ? { tile } : {}), ...(post !== undefined ? { post } : {}), ...(r.status ? { status: r.status } : {}), comment: r.comment, ...(r.stars ? { stars: r.stars } : {}) }
|
|
1354
|
+
const empty = !r.status && r.comment === '' && !r.stars
|
|
1213
1355
|
this.edit((d) => {
|
|
1214
1356
|
const rest = (d.reactions ?? []).filter((q) => !sameSpot(q, view, tile, post))
|
|
1215
1357
|
return { ...d, reactions: empty ? rest : [...rest, next] }
|
|
@@ -1291,23 +1433,9 @@ export class ThreadSt {
|
|
|
1291
1433
|
tileShown(r: ReviewReaction | null): boolean {
|
|
1292
1434
|
const f = this.tileFilter
|
|
1293
1435
|
if (f === 'all') return true
|
|
1294
|
-
if (f === 'unrated') return !r?.stars && !r?.status
|
|
1436
|
+
if (f === 'unrated') return !r?.stars && !r?.status
|
|
1295
1437
|
if (f === 'low') return r?.stars !== undefined && r.stars < 3
|
|
1296
|
-
return r?.status === 'approved-with-fix' || r?.status === '
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
/** a variant kept for its row: the row's other pick clears; the same tile again clears it */
|
|
1300
|
-
pickTile(view: number, tile: number, group: string, tiles: readonly { group?: string }[]): void {
|
|
1301
|
-
const was = this.reactionOf(view, tile)?.picked === true
|
|
1302
|
-
tiles.forEach((t, k) => {
|
|
1303
|
-
if (t.group !== group) return
|
|
1304
|
-
const cur = this.reactionOf(view, k)
|
|
1305
|
-
if (cur?.picked) this.putReaction(view, k, { ...cur, picked: undefined })
|
|
1306
|
-
})
|
|
1307
|
-
if (!was) {
|
|
1308
|
-
const cur = this.reactionOf(view, tile)
|
|
1309
|
-
this.putReaction(view, tile, { ...cur, comment: cur?.comment ?? '', picked: true })
|
|
1310
|
-
}
|
|
1438
|
+
return r?.status === 'approved-with-fix' || r?.status === 'rework'
|
|
1311
1439
|
}
|
|
1312
1440
|
|
|
1313
1441
|
/** a version as thin option rows: a choice, or views that each play alone, unless he asked them full */
|
|
@@ -1455,22 +1583,26 @@ export class ThreadSt {
|
|
|
1455
1583
|
})
|
|
1456
1584
|
}
|
|
1457
1585
|
|
|
1458
|
-
/** a kind's action on item `id`
|
|
1586
|
+
/** what his click on a kind's action on item `id` (`re` the link it acts on) is doing now, if he clicked one */
|
|
1587
|
+
actOn(id: string, re?: string): ActState | undefined {
|
|
1588
|
+
return this.acting[`${id}#${re ?? ''}`]
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
/** a kind's action on item `id` with its words; `re` the link it acts on: drawn chosen at once, the store's write
|
|
1592
|
+
* behind it; a click on that object while one is on its way does nothing. True once the store took it */
|
|
1459
1593
|
async act(id: string, name: string, text: string, re?: string): Promise<boolean> {
|
|
1460
|
-
|
|
1461
|
-
this.
|
|
1462
|
-
this.
|
|
1594
|
+
const key = `${id}#${re ?? ''}`
|
|
1595
|
+
if (this.acting[key]?.state === 'sending') return false
|
|
1596
|
+
this.acting = { ...this.acting, [key]: { name, state: 'sending' } }
|
|
1463
1597
|
try {
|
|
1464
1598
|
await postJson(this.rv.url(`/api/review/${id}/action`), { name, ...(text !== '' ? { text } : {}), ...(re ? { re } : {}) })
|
|
1465
|
-
runInAction(() => (this.
|
|
1599
|
+
runInAction(() => (this.acting = { ...this.acting, [key]: { name, state: 'sent' } }))
|
|
1466
1600
|
await this.refresh()
|
|
1467
1601
|
await this.answeredHere()
|
|
1468
1602
|
return true
|
|
1469
1603
|
} catch (e) {
|
|
1470
|
-
runInAction(() => (this.
|
|
1604
|
+
runInAction(() => (this.acting = { ...this.acting, [key]: { name, state: 'failed', why: (e as Error).message } }))
|
|
1471
1605
|
return false
|
|
1472
|
-
} finally {
|
|
1473
|
-
runInAction(() => (this.busy = false))
|
|
1474
1606
|
}
|
|
1475
1607
|
}
|
|
1476
1608
|
|
|
@@ -1639,7 +1771,17 @@ export class ThreadSt {
|
|
|
1639
1771
|
private acts: Promise<void> = Promise.resolve()
|
|
1640
1772
|
/** a click on a question's option, by cell: drawn on its question at once (« sending… »), then « sent » or why not with
|
|
1641
1773
|
* « retry »; the next read of the thread draws the answer itself */
|
|
1642
|
-
picking: Record<string, { option: number; state: 'sending' | 'sent' | 'failed'; why?: string }> = {}
|
|
1774
|
+
picking: Record<string, { option: number; state: 'sending' | 'sent' | 'failed'; why?: string; remark?: string }> = {}
|
|
1775
|
+
/** the option whose « pick with a remark » box is open, by question cell: one box a question at a time */
|
|
1776
|
+
remarking: Record<string, number> = {}
|
|
1777
|
+
|
|
1778
|
+
setRemarking(cell: string, option: number | null): void {
|
|
1779
|
+
const { [cell]: _, ...rest } = this.remarking
|
|
1780
|
+
this.remarking = option === null ? rest : { ...rest, [cell]: option }
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
/** the key of the box that holds his remark with a pick, apart from the « none of these » words (`hints[c.id]`) */
|
|
1784
|
+
remarkBox = (c: { id: string }): string => `${c.id}#remark`
|
|
1643
1785
|
/** the questions he chose to answer again (« change it » on an answer a person's pick gave), by cell */
|
|
1644
1786
|
changing: Record<string, true> = {}
|
|
1645
1787
|
|
|
@@ -1648,24 +1790,31 @@ export class ThreadSt {
|
|
|
1648
1790
|
this.changing = on ? { ...rest, [cell]: true } : rest
|
|
1649
1791
|
}
|
|
1650
1792
|
|
|
1651
|
-
/** one click on an option
|
|
1652
|
-
|
|
1653
|
-
|
|
1793
|
+
/** one click on an option, `remark` the owner's words with it (« pick with a remark »; none for a plain pick): shown taken at
|
|
1794
|
+
* once, queued behind any act still on its way, never silently dropped */
|
|
1795
|
+
pickOption(c: { id: string; on: string }, option: number, remark = ''): Promise<void> {
|
|
1796
|
+
const sent = remark.trim()
|
|
1654
1797
|
const re = c.id.slice(c.on.length + 1)
|
|
1655
|
-
|
|
1798
|
+
const words = sent !== '' ? { remark: sent } : {}
|
|
1799
|
+
this.picking = { ...this.picking, [c.id]: { option, state: 'sending', ...words } }
|
|
1656
1800
|
this.error = null
|
|
1657
1801
|
const run = async (): Promise<void> => {
|
|
1658
1802
|
try {
|
|
1659
|
-
await postJson(this.rv.url(`/api/review/${c.on}/answer`), { re, option, ...(sent !== '' ? { text: sent } : {}) })
|
|
1803
|
+
const r = await postJson<{ moved?: { repo: string; head: string } }>(this.rv.url(`/api/review/${c.on}/answer`), { re, option, ...(sent !== '' ? { text: sent } : {}) })
|
|
1804
|
+
// his « move to <repo> » moved the thread: it opens there
|
|
1805
|
+
if (r.moved !== undefined && this.followMove(r.moved)) return
|
|
1660
1806
|
runInAction(() => {
|
|
1661
|
-
if (this.picking[c.id]?.option === option) this.picking = { ...this.picking, [c.id]: { option, state: 'sent' } }
|
|
1807
|
+
if (this.picking[c.id]?.option === option) this.picking = { ...this.picking, [c.id]: { option, state: 'sent', ...words } }
|
|
1662
1808
|
this.setChanging(c.id, false)
|
|
1663
|
-
if (
|
|
1809
|
+
if (sent !== '') {
|
|
1810
|
+
if (this.remarking[c.id] === option) this.setRemarking(c.id, null)
|
|
1811
|
+
if ((this.hints[this.remarkBox(c)] ?? '').trim() === sent) delete this.hints[this.remarkBox(c)]
|
|
1812
|
+
}
|
|
1664
1813
|
})
|
|
1665
1814
|
await this.answeredHere()
|
|
1666
1815
|
} catch (e) {
|
|
1667
1816
|
runInAction(() => {
|
|
1668
|
-
if (this.picking[c.id]?.option === option) this.picking = { ...this.picking, [c.id]: { option, state: 'failed', why: (e as Error).message } }
|
|
1817
|
+
if (this.picking[c.id]?.option === option) this.picking = { ...this.picking, [c.id]: { option, state: 'failed', why: (e as Error).message, ...words } }
|
|
1669
1818
|
})
|
|
1670
1819
|
}
|
|
1671
1820
|
}
|
|
@@ -1687,6 +1836,36 @@ export class ThreadSt {
|
|
|
1687
1836
|
/** the key of the box that holds the owner's edit of one field's value */
|
|
1688
1837
|
fieldBox = (c: { id: string }, key: string): string => `${c.id}#${key}`
|
|
1689
1838
|
|
|
1839
|
+
/** a text or a url he gave, by cell: drawn given at his click while the store writes it (a url after the hub tried
|
|
1840
|
+
* it, up to 4 s), or his value back in its field with why it was not sent */
|
|
1841
|
+
giving: Record<string, { value: string; state: 'sending' | 'failed'; why?: string }> = {}
|
|
1842
|
+
|
|
1843
|
+
/** his « send » on a text or a url question: given at once, queued behind any act on its way, never dropped */
|
|
1844
|
+
give(c: { id: string; on: string }, value: string): Promise<void> {
|
|
1845
|
+
const sent = value.trim()
|
|
1846
|
+
if (sent === '') return this.acts
|
|
1847
|
+
this.giving = { ...this.giving, [c.id]: { value: sent, state: 'sending' } }
|
|
1848
|
+
this.error = null
|
|
1849
|
+
const box = this.fieldBox(c, 'value')
|
|
1850
|
+
const run = async (): Promise<void> => {
|
|
1851
|
+
try {
|
|
1852
|
+
await postJson(this.rv.url(`/api/review/${c.on}/answer`), { re: c.id.slice(c.on.length + 1), value: sent })
|
|
1853
|
+
runInAction(() => {
|
|
1854
|
+
if ((this.hints[box] ?? '').trim() === sent) delete this.hints[box]
|
|
1855
|
+
})
|
|
1856
|
+
await this.answeredHere()
|
|
1857
|
+
runInAction(() => {
|
|
1858
|
+
const { [c.id]: _, ...rest } = this.giving
|
|
1859
|
+
this.giving = rest
|
|
1860
|
+
})
|
|
1861
|
+
} catch (e) {
|
|
1862
|
+
runInAction(() => (this.giving = { ...this.giving, [c.id]: { value: sent, state: 'failed', why: (e as Error).message } }))
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
this.acts = this.acts.then(run)
|
|
1866
|
+
return this.acts
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1690
1869
|
private async answering(c: { id: string; on: string }, all: readonly { option?: number; apply?: true; field?: string; tick?: boolean; value?: string }[]): Promise<void> {
|
|
1691
1870
|
const sent = this.hints[c.id] ?? ''
|
|
1692
1871
|
const re = c.id.slice(c.on.length + 1)
|