rvlib-shipkit 2.32.0 → 2.34.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 +42 -0
- package/package.json +1 -1
- package/src/advisors/advisor-view.ts +29 -7
- package/src/advisors/edge/api.ts +1 -30
- package/src/advisors/project.ts +3 -3
- package/src/advisors/sync.ts +11 -4
- package/src/advisors/users-router.ts +13 -11
- package/src/cli/cmd_BackupTargets.ts +49 -8
- package/src/cli/cmd_Capacity.ts +6 -2
- package/src/cli/cmd_Ci.ts +2 -1
- package/src/cli/cmd_Media.ts +1 -1
- package/src/cli/cmd_Shot.ts +26 -4
- package/src/cli/cmd_Start.ts +3 -3
- package/src/cli.ts +13 -2
- package/src/core/admission.ts +268 -0
- package/src/core/code-lines.ts +36 -21
- package/src/core/machine-read.ts +5 -2
- package/src/core/memory-watch.ts +1 -1
- package/src/core/peer-sk.ts +8 -0
- package/src/gate/admit-heavy.ts +150 -0
- package/src/gate/check-runner.ts +6 -0
- package/src/gate/gate-checks.ts +7 -5
- package/src/gate/head-gate.ts +1 -1
- package/src/gate/job-run.ts +2 -1
- package/src/gate/pre-commit-discovery.ts +6 -3
- package/src/gate/run-check.ts +3 -0
- package/src/gate/run-ci.ts +4 -0
- package/src/home/backup-status.ts +41 -13
- package/src/home/backup-verdict.ts +1 -0
- package/src/home/daemon-jobs.ts +5 -0
- package/src/home/home-routes.ts +3 -2
- package/src/home/house-bucket.ts +14 -0
- package/src/home/run-daemon.ts +3 -1
- package/src/home/this-house.ts +68 -0
- package/src/home/via-hub.ts +2 -1
- 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 +2 -1
- package/src/hooks/pre-commit-checks.ts +1 -1
- package/src/hooks/run-hooks.ts +2 -1
- package/src/hooks/shared-file.ts +3 -2
- package/src/hq/backup-targets.ts +58 -5
- package/src/hq/hq-local.ts +1 -1
- package/src/media-store/backup/bucket-target.ts +58 -0
- package/src/media-store/backup/target-send.ts +7 -4
- package/src/media-store/space.ts +2 -0
- package/src/plan/planner.ts +3 -2
- package/src/repo-config.ts +8 -1
- package/src/review/answer-kinds.ts +2 -0
- package/src/review/cells.ts +40 -9
- package/src/review/format.ts +1 -1
- package/src/review/model.ts +3 -3
- package/src/review/routes.ts +2 -28
- package/src/review/store-parties.ts +28 -0
- package/src/review/store.ts +11 -2
- package/src/review/thread-state.ts +9 -3
- package/src/scaffold/project-scaffold.ts +2 -2
- package/src/secrets/copy.ts +4 -4
- package/src/serve/hub-app/auto-text.tsx +3 -1
- package/src/serve/hub-app/dock-st.ts +1 -1
- package/src/serve/hub-app/review/question-views.tsx +28 -17
- package/src/serve/hub-app/review/review-host.ts +6 -2
- package/src/serve/hub-app/review/review-list.tsx +8 -5
- package/src/serve/hub-app/review/review-st.ts +2 -2
- package/src/serve/hub-app/review/review-thread.tsx +2 -1
- package/src/serve/hub-app/review/review-views.tsx +10 -7
- package/src/serve/hub-app/review/thread-st.ts +25 -11
- package/src/serve/hub-app/review/tone-bar.tsx +29 -24
- package/src/serve/hub-app/review/tones.ts +18 -0
- package/src/serve/hub-app/review.css +11 -2
- package/src/setup-house.ts +1 -7
- package/src/shot/client.ts +2 -1
- package/src/shot/on-place.ts +141 -0
- package/src/start-repo.ts +27 -30
|
@@ -9,7 +9,7 @@ import { readdirSync, readFileSync, mkdtempSync, rmSync, statSync } from 'node:f
|
|
|
9
9
|
import { tmpdir } from 'node:os'
|
|
10
10
|
import { join } from 'node:path'
|
|
11
11
|
import { machineGet, machineSet } from '../../core/machine-db.ts'
|
|
12
|
-
import type
|
|
12
|
+
import { configBucket, ownBucket, type BackupTarget, type BucketAddress } from '../../hq/backup-targets.ts'
|
|
13
13
|
import type { ReplicaPlace } from '../../hq/replica.ts'
|
|
14
14
|
import type { BackupRetention } from './retention.ts'
|
|
15
15
|
import { copyName, homeRelative, houseSsh, SAFE, sha256, sshPrune, sshPut, type Ssh } from './ssh-target.ts'
|
|
@@ -30,7 +30,7 @@ export const HQ_EVERY_MS = 60 * 60_000
|
|
|
30
30
|
const RETRY_MS = 10 * 60_000
|
|
31
31
|
|
|
32
32
|
/** the targets this job sends to: every one on, except the Space, which each store reaches its own way */
|
|
33
|
-
export const sealedTargets = (targets: readonly BackupTarget[]): BackupTarget[] => targets.filter((t) => t.on &&
|
|
33
|
+
export const sealedTargets = (targets: readonly BackupTarget[]): BackupTarget[] => targets.filter((t) => t.on && configBucket(t.address) !== 'mediaSpace')
|
|
34
34
|
|
|
35
35
|
/** the vault's newest sealed snapshot beside it, null when none */
|
|
36
36
|
export function newestVaultSnap(dir: string): { file: string; mtime: number } | null {
|
|
@@ -56,6 +56,8 @@ export type SendDeps = {
|
|
|
56
56
|
policy: BackupRetention | null
|
|
57
57
|
/** the second place's bucket, or why there is none (copy/config.ts houseCopy) */
|
|
58
58
|
secondPlace: () => Promise<{ put: (key: string, bytes: Uint8Array) => Promise<void> } | { why: string }>
|
|
59
|
+
/** a bucket a row holds itself, or why it cannot be reached (bucket-target.ts) */
|
|
60
|
+
bucket: (a: BucketAddress) => Promise<{ put: (key: string, bytes: Uint8Array) => Promise<void> } | { why: string }>
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/** one file of one store to one target, the send kept for the status. The line to print */
|
|
@@ -80,7 +82,8 @@ export async function sendTo(store: StoreId, t: BackupTarget, f: { name: string;
|
|
|
80
82
|
if (d.policy != null) pruned = await sshPrune({ ssh, peer: t.address.host, dir, now: at, policy: d.policy }).then((n) => `, ${n} pruned`, (e: Error) => `; the old copies were not pruned: ${e.message}`)
|
|
81
83
|
return `ok: ${store} to ${t.label}: ${t.address.host}:~/${dir}/${f.name}, ${(f.bytes.length / 1e6).toFixed(1)} MB, checked by its sha there${pruned}`
|
|
82
84
|
}
|
|
83
|
-
const
|
|
85
|
+
const own = ownBucket(t.address)
|
|
86
|
+
const place = own == null ? await d.secondPlace() : await d.bucket(own)
|
|
84
87
|
if ('why' in place) return fail(place.why)
|
|
85
88
|
const key = `_snapshots/${store}/${d.machine}/${f.name}`
|
|
86
89
|
await place.put(key, f.bytes)
|
|
@@ -95,7 +98,7 @@ export async function sendTo(store: StoreId, t: BackupTarget, f: { name: string;
|
|
|
95
98
|
* hour old. Cheap: rows of the machine db and one directory read */
|
|
96
99
|
export function targetsDue(targets: readonly BackupTarget[], o: { vaultDir: string | null; carriesHq: boolean; now: number; stream?: ReplicaPlace | null }): { vault: BackupTarget[]; hq: BackupTarget[] } {
|
|
97
100
|
const to = sealedTargets(targets)
|
|
98
|
-
const streamed = (t: BackupTarget): boolean =>
|
|
101
|
+
const streamed = (t: BackupTarget): boolean => o.stream != null && configBucket(t.address) === o.stream
|
|
99
102
|
const snap = o.vaultDir == null ? null : newestVaultSnap(o.vaultDir)
|
|
100
103
|
return {
|
|
101
104
|
vault: snap == null ? [] : to.filter((t) => vaultDueTo(lastSentTo('vault', t.id), snap.mtime, o.now)),
|
package/src/media-store/space.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface MediaSpace {
|
|
|
14
14
|
endpoint: string
|
|
15
15
|
bucket: string
|
|
16
16
|
region: string
|
|
17
|
+
/** the bucket in the path, not the host: MinIO and any server at one origin want it, its `endpoint` then the origin alone */
|
|
18
|
+
path?: boolean
|
|
17
19
|
/** the CDN edge a signed URL is handed out on */
|
|
18
20
|
cdn?: string
|
|
19
21
|
/** the two secrets of its key, read through the house store */
|
package/src/plan/planner.ts
CHANGED
|
@@ -166,7 +166,7 @@ export class Planner {
|
|
|
166
166
|
* the window it had (catch-up.ts) */
|
|
167
167
|
private readonly bootAt: number
|
|
168
168
|
|
|
169
|
-
constructor(private o: { now?: () => number; timers?: PlanTimers; quietMs?: number; maxWaitMs?: number; machine?: () => MachineLoad; catchUp?: CatchUpStore; onError?: (repo: string, e: Error) => void } = {}) {
|
|
169
|
+
constructor(private o: { now?: () => number; timers?: PlanTimers; quietMs?: number; maxWaitMs?: number; machine?: () => MachineLoad; /** the biggest user of the CPU in a few words, named on the held line (core/admission.ts topUserWatch) */ who?: () => string | null; catchUp?: CatchUpStore; onError?: (repo: string, e: Error) => void } = {}) {
|
|
170
170
|
this.now = o.now ?? Date.now
|
|
171
171
|
this.catchUp = o.catchUp ?? null
|
|
172
172
|
this.bootAt = this.catchUp != null ? resumeCatchUp(this.now(), this.catchUp) : this.now()
|
|
@@ -421,7 +421,8 @@ export class Planner {
|
|
|
421
421
|
if (effectiveLoad(m) > LOAD_MAX * Math.max(1, m.cores)) {
|
|
422
422
|
due = due.filter((x) => x.reason === 'asked')
|
|
423
423
|
if (due.length === 0) {
|
|
424
|
-
|
|
424
|
+
const top = this.o.who?.() ?? null
|
|
425
|
+
this.holdReason = `held: ${machineWords(m)}${top == null ? '' : `, most by ${top}`}`
|
|
425
426
|
return null
|
|
426
427
|
}
|
|
427
428
|
}
|
package/src/repo-config.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { RETIRED_CHECK_IDS } from './core/retired-checks.ts'
|
|
|
21
21
|
import { normalizeVendored, vendoredOfText, vendoredProblem } from './core/vendored.ts'
|
|
22
22
|
import { foreignOfText } from './core/foreign.ts'
|
|
23
23
|
import { budgetValueProblem } from './core/budget.ts'
|
|
24
|
+
import { heavyProblem } from './core/admission.ts'
|
|
24
25
|
import { browsersProblem } from './core/slots.ts'
|
|
25
26
|
import { leakAllowProblems } from './hooks/leak-guard.ts'
|
|
26
27
|
import type { HooksConfig } from './hooks/run-hooks.ts'
|
|
@@ -416,6 +417,10 @@ export type RepoConfig = {
|
|
|
416
417
|
* slow suites the quick tier leaves out, and the suites that cannot run in
|
|
417
418
|
* parallel, each with its reason. suite/judge-suites.ts */
|
|
418
419
|
tests?: TestsConfig
|
|
420
|
+
/** sk command lines that wait while the machine is full, like ['trailer', 'assets gen']: each matches the argv it
|
|
421
|
+
* starts, and waits with a line every 10 s that names who uses the CPU, until its bound, then runs with a WARN.
|
|
422
|
+
* The gate's heavy checks, a clip, a loop of shots and sk smoke wait without being listed. core/admission.ts */
|
|
423
|
+
heavy?: string[]
|
|
419
424
|
/** the live dashboard, `shipkit tui`. */
|
|
420
425
|
tui?: {
|
|
421
426
|
/** extra dashboard panels, appended after the built-in build steps and checks panels (`shipkit tui`) */
|
|
@@ -451,7 +456,7 @@ export type RepoConfig = {
|
|
|
451
456
|
logDir?: string
|
|
452
457
|
}
|
|
453
458
|
|
|
454
|
-
const KNOWN_KEYS = new Set(['name', 'id', 'venues', 'social', 'speaksAs', 'backup', 'annex','docsBase', 'defaults', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'retired', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'budgets', 'instantHooks', 'visibility', 'privateApps', 'ownerRepo', 'archived', 'foreign', 'onSave', 'history', 'reviewer', 'oneWayIn', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'tui', 'serve', 'recorder', 'identity', 'guiColor', 'appIcon', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
|
|
459
|
+
const KNOWN_KEYS = new Set(['name', 'id', 'venues', 'social', 'speaksAs', 'backup', 'annex','docsBase', 'defaults', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'retired', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'budgets', 'instantHooks', 'visibility', 'privateApps', 'ownerRepo', 'archived', 'foreign', 'onSave', 'history', 'reviewer', 'oneWayIn', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'tui', 'serve', 'recorder', 'identity', 'guiColor', 'appIcon', 'logDir', 'smoke', 'tests', 'browsers', 'heavy', 'start'])
|
|
455
460
|
|
|
456
461
|
/** a key that is gone, and what to write instead */
|
|
457
462
|
const REMOVED_KEYS: Record<string, string> = {
|
|
@@ -580,6 +585,8 @@ export function defineRepo(c: RepoConfig): RepoConfig {
|
|
|
580
585
|
if (c.smoke != null) validateSmokeConfig(c.smoke)
|
|
581
586
|
const browsers = browsersProblem(c.browsers)
|
|
582
587
|
if (browsers != null) throw new Error(`defineRepo: ${browsers}`)
|
|
588
|
+
const heavy = heavyProblem(c.heavy)
|
|
589
|
+
if (heavy != null) throw new Error(`defineRepo: ${heavy}`)
|
|
583
590
|
// a malformed skip list would let sk start wire the checkout it exists to leave alone
|
|
584
591
|
if (c.start !== undefined) {
|
|
585
592
|
const skip = (c.start as { skip?: unknown }).skip
|
|
@@ -194,6 +194,8 @@ export function kindCellAsk(thread: readonly Message[], m: Message) {
|
|
|
194
194
|
...(valued?.answer ? { value: { text: valued.answer.value ?? '', at: valued.at, ...(valued.answer.opens !== undefined ? { opens: valued.answer.opens } : {}), ...(valued.answer.view !== undefined ? { view: valued.answer.view } : {}) } } : {}),
|
|
195
195
|
...(m.ask?.secret ? { secret: { name: m.ask.secret.name, ...(m.ask.secret.login ? { login: true } : {}), ...(stored ? { stored: stored.at } : {}) } } : {}),
|
|
196
196
|
...(none !== undefined ? { none } : {}),
|
|
197
|
+
// his your call or no answer from the question's row (store.ts answerAsk `tone`)
|
|
198
|
+
...(none !== undefined && last?.verdict !== undefined ? { tone: last.verdict } : {}),
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
201
|
|
package/src/review/cells.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// reply, note and state change is one cell, in time order, built at read time from the store's files (a supersedes chain
|
|
3
3
|
// folds into one thread, nothing is rewritten). The paged list's rows and its query. Pure and browser safe: the routes
|
|
4
4
|
// send these shapes, the hub page draws them
|
|
5
|
+
import { findLast } from '../core/es2022.ts'
|
|
5
6
|
import {
|
|
6
7
|
type AnswerKind,
|
|
7
8
|
canonicalAddress,
|
|
@@ -184,6 +185,9 @@ export interface ReplyCell extends CellOf<'reply'> {
|
|
|
184
185
|
recap?: true
|
|
185
186
|
/** his request for a recap */
|
|
186
187
|
recapAsk?: true
|
|
188
|
+
/** a person's ok or fix on a version that waits for the owner, on their own view (advisors/sync.ts pendingCells): its
|
|
189
|
+
* tone and the version it judges, which their answer bar draws lit */
|
|
190
|
+
advice?: { status: 'approved' | 'approved-with-fix'; on: string }
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
export interface Linked {
|
|
@@ -390,11 +394,11 @@ function messageCells(x: ReviewItem, n: number, opening: Message | undefined, go
|
|
|
390
394
|
const re = reOn ? { id: `${id}/${m.re}`, k: rk + 1, state: reOn.state } : undefined
|
|
391
395
|
const said = update ? `${UPDATE_WORDS[update.state]}: ` : re ? `on update ${re.k}: ` : ''
|
|
392
396
|
// the newest answer: a person with a direct pick may change theirs
|
|
393
|
-
const reply = x.thread
|
|
397
|
+
const reply = findLast(x.thread, (y) => y.re === m.id && y.answer !== undefined && partyOf(y.who) === 'owner')
|
|
394
398
|
// the owner's words alone in a choice's own box answer it as none of the options; a plain reply never does
|
|
395
399
|
const words = reply === undefined && m.ask ? answersTo(x.thread, m).find(wordsAlone) : undefined
|
|
396
400
|
const answers = m.ask ? x.thread.filter((y) => y.re === m.id && y.answer?.option !== undefined) : []
|
|
397
|
-
const ownerPick =
|
|
401
|
+
const ownerPick = findLast(answers, (y) => y.who === 'owner')?.answer?.option
|
|
398
402
|
const people = new Map<string, PersonPick>()
|
|
399
403
|
for (const y of m.ask ? x.thread : []) {
|
|
400
404
|
if (y.who !== 'player' || y.at < m.at) continue
|
|
@@ -929,6 +933,37 @@ function rowOf(t: Thread, now: Date, code: string): ThreadRow {
|
|
|
929
933
|
|
|
930
934
|
const TURN_RANK: Record<Turn, number> = { yours: 0, aside: 1, agents: 2, done: 3 }
|
|
931
935
|
|
|
936
|
+
/** the list's order: his turn, set aside, the agents', done; in each, the newest activity first */
|
|
937
|
+
const listOrder = <E extends { row: ThreadRow }>(entries: readonly E[]): E[] =>
|
|
938
|
+
entries
|
|
939
|
+
.map((e, i) => ({ e, i }))
|
|
940
|
+
.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)
|
|
941
|
+
.map(({ e }) => e)
|
|
942
|
+
|
|
943
|
+
/** 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
|
|
944
|
+
* counts and the filters' choices. The store's index (threadIndex) is one, the rows a person may see another */
|
|
945
|
+
export type ListIndex = Pick<ThreadIndex, 'counts' | 'subjects' | 'lanes' | 'since'> & {
|
|
946
|
+
entries: readonly { row: ThreadRow; text: string }[]
|
|
947
|
+
byCode: (code: string) => { row: ThreadRow } | null
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/** the list over rows a reader of the advisors' port may see, each its search text: the hub's order and counts, a code
|
|
951
|
+
* found by the rows' own codes, what moved since the reader's last act as the port reads it */
|
|
952
|
+
export function listIndexOf(rows: readonly { row: ThreadRow; text: string }[], since: ThreadPage['since'] = null): ListIndex {
|
|
953
|
+
const entries = listOrder(rows)
|
|
954
|
+
return {
|
|
955
|
+
entries,
|
|
956
|
+
byCode: (code) => {
|
|
957
|
+
const c = code.toLowerCase().replace(/^#/, '')
|
|
958
|
+
return entries.find((e) => e.row.code !== '' && e.row.code === c) ?? null
|
|
959
|
+
},
|
|
960
|
+
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 },
|
|
961
|
+
subjects: [...new Set(entries.map((e) => e.row.subject))].sort(),
|
|
962
|
+
lanes: [],
|
|
963
|
+
since,
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
932
967
|
/** what a search reads of a thread: every item's title, words and id, and every message's words */
|
|
933
968
|
const textOf = (t: Thread): string =>
|
|
934
969
|
membersOf(t)
|
|
@@ -992,11 +1027,7 @@ export function threadLinks(ix: ThreadIndex, t: Thread): Pick<ThreadView, 'refs'
|
|
|
992
1027
|
* item id of the store, a broken one too, which the codes are given over (review/thread-code.ts) */
|
|
993
1028
|
export function threadIndex(items: readonly ReviewItem[], now = new Date(), ids: Iterable<string> = items.map((x) => x.item.id)): ThreadIndex {
|
|
994
1029
|
const codes = codesOf(ids)
|
|
995
|
-
const entries = orderedThreads(items)
|
|
996
|
-
.map((t) => ({ t, row: rowOf(t, now, threadCode(codes, idsOf(t))), text: textOf(t) }))
|
|
997
|
-
.map((e, i) => ({ e, i }))
|
|
998
|
-
.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)
|
|
999
|
-
.map(({ e }) => e)
|
|
1030
|
+
const entries = listOrder(orderedThreads(items).map((t) => ({ t, row: rowOf(t, now, threadCode(codes, idsOf(t))), text: textOf(t) })))
|
|
1000
1031
|
const waiting = new Set(entries.filter((e) => e.row.state.turn === 'yours').map((e) => e.row.head))
|
|
1001
1032
|
const byItem = new Map<string, (typeof entries)[number]>()
|
|
1002
1033
|
for (const e of entries) for (const id of e.row.ids) byItem.set(id, e)
|
|
@@ -1019,7 +1050,7 @@ export function threadIndex(items: readonly ReviewItem[], now = new Date(), ids:
|
|
|
1019
1050
|
}
|
|
1020
1051
|
|
|
1021
1052
|
/** where the kept row sits among a page's rows: in the index's own order, after the last row that comes before it */
|
|
1022
|
-
function keptAt(ix:
|
|
1053
|
+
function keptAt(ix: ListIndex, rows: readonly ThreadRow[], kept: ThreadRow): number {
|
|
1023
1054
|
const order = new Map(ix.entries.map((e, i) => [e.row, i]))
|
|
1024
1055
|
const at = order.get(kept)!
|
|
1025
1056
|
const i = rows.findIndex((r) => order.get(r)! > at)
|
|
@@ -1030,7 +1061,7 @@ function keptAt(ix: ThreadIndex, rows: readonly ThreadRow[], kept: ThreadRow): n
|
|
|
1030
1061
|
const whoseOf = (t: Turn): Move => (t === 'yours' || t === 'aside' ? 'owner' : t === 'agents' ? 'agents' : 'none')
|
|
1031
1062
|
|
|
1032
1063
|
/** one page of the index for a query; the open thread's row (`keep`) in it whatever the filters */
|
|
1033
|
-
export function pageOf(ix:
|
|
1064
|
+
export function pageOf(ix: ListIndex, q: ThreadQuery, broken: ThreadPage['broken'] = []): ThreadPage {
|
|
1034
1065
|
// words, `t:<tag>` each a thread must carry, a thread's code (review/thread-query.ts)
|
|
1035
1066
|
const { words, tags, codes } = parseSearch(q.q)
|
|
1036
1067
|
// a thread's code, `#k7m2` or bare, finds that thread first, whatever the filters but its tags
|
package/src/review/format.ts
CHANGED
|
@@ -127,7 +127,7 @@ function answerLine(x: ReviewItem, m: Message): string | null {
|
|
|
127
127
|
|
|
128
128
|
/** what his tone on a question with no option asks of the agent */
|
|
129
129
|
const QUESTION_TONE_WORDS: Record<QuestionTone, string> = {
|
|
130
|
-
rework: 'none of these
|
|
130
|
+
rework: 'none of these: read the owner\'s words for what he wants instead, then ask again or build it',
|
|
131
131
|
'wrong-direction': 'wrong direction: stop, rethink the question itself, and ask again before you build',
|
|
132
132
|
'your-call': 'your call: decide yourself if it still holds, else drop it, and say what you chose',
|
|
133
133
|
'no-answer': 'no answer: he left it unanswered, nothing owed',
|
package/src/review/model.ts
CHANGED
|
@@ -744,9 +744,9 @@ export const isApproved = (s: ReviewStatus): boolean => s === 'approved' || s ==
|
|
|
744
744
|
/** the tones that give the version back to its agent with work owed: every one but ok and archived */
|
|
745
745
|
export const OWES_WORK: ReadonlySet<ReviewStatus> = new Set(['approved-with-fix', 'rework', 'wrong-direction', 'your-call'])
|
|
746
746
|
|
|
747
|
-
/** the tones a choice question takes besides a pick and a pick with a remark: none of
|
|
748
|
-
*
|
|
749
|
-
*
|
|
747
|
+
/** the tones a choice question takes besides a pick and a pick with a remark: « none of these » (a rework, the owner's
|
|
748
|
+
* words), « your call » (the agent's pick if it still holds), « no answer »; `wrong-direction` the hub no longer offers on a
|
|
749
|
+
* question, kept to read and write the rows that hold it */
|
|
750
750
|
export const QUESTION_TONES = ['rework', 'wrong-direction', 'your-call', 'no-answer'] as const satisfies readonly ReviewStatus[]
|
|
751
751
|
export type QuestionTone = (typeof QUESTION_TONES)[number]
|
|
752
752
|
|
package/src/review/routes.ts
CHANGED
|
@@ -37,7 +37,7 @@ import type { HeldOf } from '../secrets/held.ts'
|
|
|
37
37
|
import type { SecretStore } from '../secrets/manager.ts'
|
|
38
38
|
import { specData, type ReviewUnit } from './unit.ts'
|
|
39
39
|
import { liveWatchers } from './watchers.ts'
|
|
40
|
-
import {
|
|
40
|
+
import { partiesOfStore } from './store-parties.ts'
|
|
41
41
|
import { repoNameOf } from '../agent-time/registry.ts'
|
|
42
42
|
import { harvestedOf, objectReaderOf, objectsTag } from './object-read.ts'
|
|
43
43
|
import { orchestratorOf } from './lane-ask.ts'
|
|
@@ -73,33 +73,7 @@ async function mentionsOf(dir: string, id: string): Promise<MentionCandidate[]>
|
|
|
73
73
|
return mentionCandidates({ members: membersOf(t), parties, repo, holder: h === null ? null : { ...(h.lane ? { lane: h.lane } : {}), ...(h.session ? { session: h.session } : {}) }, advisors })
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
* held answer stands only while the stamp it was read under holds: the page asks on the stream's notice that the
|
|
78
|
-
* parties moved, and nothing asks again after that answer */
|
|
79
|
-
const PARTIES_MS = 4000
|
|
80
|
-
const partiesHeld = new Map<string, { at: number; stamp: string; value: Promise<StoreParties> }>()
|
|
81
|
-
/** the cheap sign that a store's parties moved, given by the hub (serve/serve-hub.ts): its stream follows the same */
|
|
82
|
-
let partiesStampOf: (dir: string) => string = () => ''
|
|
83
|
-
export const partiesStampWith = (stamp: (dir: string) => string): void => {
|
|
84
|
-
partiesStampOf = stamp
|
|
85
|
-
}
|
|
86
|
-
/** who reads them: this process, or the daemon's read thread (serve/read-thread.ts), off the loop every page waits on */
|
|
87
|
-
let partiesReader: (dir: string) => Promise<StoreParties> = storeParties
|
|
88
|
-
export const readPartiesWith = (reader: (dir: string) => Promise<StoreParties>): void => {
|
|
89
|
-
partiesReader = reader
|
|
90
|
-
}
|
|
91
|
-
export function partiesOfStore(dir: string, now = Date.now()): Promise<StoreParties> {
|
|
92
|
-
const held = partiesHeld.get(dir)
|
|
93
|
-
const stamp = partiesStampOf(dir)
|
|
94
|
-
if (held && now - held.at < PARTIES_MS && held.stamp === stamp) return held.value
|
|
95
|
-
const value = partiesReader(dir)
|
|
96
|
-
// a read that failed is asked again by the next caller, never kept for its few seconds
|
|
97
|
-
value.catch(() => {
|
|
98
|
-
if (partiesHeld.get(dir)?.value === value) partiesHeld.delete(dir)
|
|
99
|
-
})
|
|
100
|
-
partiesHeld.set(dir, { at: now, stamp, value })
|
|
101
|
-
return value
|
|
102
|
-
}
|
|
76
|
+
export { partiesOfStore, partiesStampWith, readPartiesWith } from './store-parties.ts'
|
|
103
77
|
import { autoRulesOf } from '../veille/auto.ts'
|
|
104
78
|
import { draftsOfThread } from '../social/thread-drafts.ts'
|
|
105
79
|
import { itemsDb } from './item-db.ts'
|
|
@@ -20,3 +20,31 @@ export async function storeParties(dir: string, o: Pick<Parameters<typeof readPa
|
|
|
20
20
|
for (const r of readSessionRecords()) if (r.stores.includes(dir)) ids.add(r.session)
|
|
21
21
|
return { repo: repoNameOf(dirname(dirname(dir))), parties: await readParties({ sessions: [...ids], watchers: liveWatchers(dir), ...o }) }
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
/** a store's parties as the page reads them, read again at most every few seconds: the registry reads transcripts. A
|
|
25
|
+
* held answer stands only while the stamp it was read under holds: the page asks on the stream's notice that the
|
|
26
|
+
* parties moved, and nothing asks again after that answer */
|
|
27
|
+
const PARTIES_MS = 4000
|
|
28
|
+
const partiesHeld = new Map<string, { at: number; stamp: string; value: Promise<StoreParties> }>()
|
|
29
|
+
/** the cheap sign that a store's parties moved, given by the hub (serve/serve-hub.ts): its stream follows the same */
|
|
30
|
+
let partiesStampOf: (dir: string) => string = () => ''
|
|
31
|
+
export const partiesStampWith = (stamp: (dir: string) => string): void => {
|
|
32
|
+
partiesStampOf = stamp
|
|
33
|
+
}
|
|
34
|
+
/** who reads them: this process, or the daemon's read thread (serve/read-thread.ts), off the loop every page waits on */
|
|
35
|
+
let partiesReader: (dir: string) => Promise<StoreParties> = storeParties
|
|
36
|
+
export const readPartiesWith = (reader: (dir: string) => Promise<StoreParties>): void => {
|
|
37
|
+
partiesReader = reader
|
|
38
|
+
}
|
|
39
|
+
export function partiesOfStore(dir: string, now = Date.now()): Promise<StoreParties> {
|
|
40
|
+
const held = partiesHeld.get(dir)
|
|
41
|
+
const stamp = partiesStampOf(dir)
|
|
42
|
+
if (held && now - held.at < PARTIES_MS && held.stamp === stamp) return held.value
|
|
43
|
+
const value = partiesReader(dir)
|
|
44
|
+
// a read that failed is asked again by the next caller, never kept for its few seconds
|
|
45
|
+
value.catch(() => {
|
|
46
|
+
if (partiesHeld.get(dir)?.value === value) partiesHeld.delete(dir)
|
|
47
|
+
})
|
|
48
|
+
partiesHeld.set(dir, { at: now, stamp, value })
|
|
49
|
+
return value
|
|
50
|
+
}
|
package/src/review/store.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// (item-rows.ts), its head and each message, never rewritten; its media wait in the spool beside that file (item-db.ts
|
|
3
3
|
// spoolOf) until the media store sent them up. A view's files are written in a dot folder and land whole, so no reader
|
|
4
4
|
// sees half of one. `io` is the one way in: every function here reads and writes through it
|
|
5
|
+
import { findLast } from '../core/es2022.ts'
|
|
5
6
|
import { ownerCursorAt } from './owner-read.ts'
|
|
6
7
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
7
8
|
import { basename, dirname, extname, join, resolve } from 'node:path'
|
|
@@ -1162,7 +1163,8 @@ export async function postPropose(dir: string, id: string, p: { who: string; tex
|
|
|
1162
1163
|
|
|
1163
1164
|
/** the owner's answer to a question (an option) or to a proposed change (apply one field, the value as proposed or the owner's
|
|
1164
1165
|
* edit of it in `value`), with the owner's words; `tone` on a choice: none of its options right (a rework, a wrong
|
|
1165
|
-
* direction), or his « your call », which takes the agent's pick if it still holds (model.ts QUESTION_TONES)
|
|
1166
|
+
* direction), or his « your call », which takes the agent's pick if it still holds (model.ts QUESTION_TONES); on a
|
|
1167
|
+
* text or a url: your call or no answer; on a confirm: no answer */
|
|
1166
1168
|
export function answerAsk(dir: string, id: string, a: { re: string; option?: number; apply?: boolean; field?: string; value?: string; text?: string; tick?: boolean; pick?: number; opens?: number; tone?: QuestionTone; now?: Date }): Message {
|
|
1167
1169
|
const x = readItem(dir, id)
|
|
1168
1170
|
if (!x) throw new Error(`no item ${id}`)
|
|
@@ -1173,6 +1175,13 @@ export function answerAsk(dir: string, id: string, a: { re: string; option?: num
|
|
|
1173
1175
|
const kind = m.ask?.kind ?? 'choice'
|
|
1174
1176
|
if (m.ask && kind === 'secret') throw new Error('a secret is typed into its own field of the hub, and its value never goes into a thread')
|
|
1175
1177
|
if (m.ask && kind === 'file') throw new Error('a file question is answered by the file he drops')
|
|
1178
|
+
// a text or a url takes the question's row too: your call or no answer; a confirm, a step only the owner does, no
|
|
1179
|
+
// answer alone; words alone say none
|
|
1180
|
+
if (m.ask && a.tone !== undefined && (kind === 'confirm' || kind === 'text' || kind === 'url')) {
|
|
1181
|
+
if (kind === 'confirm' && a.tone !== 'no-answer') throw new Error("tone: no-answer alone on a confirm, a step only the owner does; the owner's words alone answer it otherwise")
|
|
1182
|
+
if (a.tone !== 'your-call' && a.tone !== 'no-answer') throw new Error(`tone: your-call or no-answer on a ${kind}; the owner's words alone answer it otherwise`)
|
|
1183
|
+
return appendMessage(dir, id, { who: 'owner', re: a.re, verdict: a.tone, text: words === '' ? STATUS_LABEL[a.tone] : words }, at)
|
|
1184
|
+
}
|
|
1176
1185
|
if (m.ask && (kind === 'checklist' || kind === 'confirm')) {
|
|
1177
1186
|
const lines = linesOf(m)
|
|
1178
1187
|
const o = kind === 'confirm' ? 0 : a.option
|
|
@@ -1246,7 +1255,7 @@ export function postAction(dir: string, id: string, a: { name: string; text?: st
|
|
|
1246
1255
|
const text = words === '' ? a.name : words
|
|
1247
1256
|
const now = a.now ?? new Date()
|
|
1248
1257
|
// the same click twice (a double click, a second press while the first was on its way): one act, the first one
|
|
1249
|
-
const twice = x.thread
|
|
1258
|
+
const twice = findLast(x.thread, (m) => m.action !== undefined && partyOf(m.who) === 'owner' && m.re === a.re)
|
|
1250
1259
|
if (twice?.action?.name === a.name && twice.text === text && now.getTime() - Date.parse(twice.at) < SAME_ACT_MS) return twice
|
|
1251
1260
|
return appendMessage(dir, id, { who: 'owner', action: { name: a.name }, text, ...(a.re !== undefined ? { re: a.re } : {}) }, { now })
|
|
1252
1261
|
}
|
|
@@ -145,6 +145,9 @@ export interface ThreadState {
|
|
|
145
145
|
recap: RecapState | null
|
|
146
146
|
/** the newest message of any of its items (no read mark, no hand over), else the head's time: the row's time */
|
|
147
147
|
updated: string
|
|
148
|
+
/** a person's copy alone (personState): whether a live agent works it now, read from the owner's parties, which
|
|
149
|
+
* never reach them; the band reads it in place of the holder and the parties */
|
|
150
|
+
works?: boolean
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
const kept = new WeakMap<Thread, { members: number; messages: number; now: number; s: ThreadState }>()
|
|
@@ -367,7 +370,7 @@ export const validatedOf = (f: { turn: Turn; status: string; ask?: AskState }):
|
|
|
367
370
|
* the copy's state `copy`. The owner's turn reads « waits for the owner » (aside) to them, unless he deferred the thread
|
|
368
371
|
* to them; when the copy's head is an older version (`headKept` false), nothing of it waits and its status is the
|
|
369
372
|
* thread's only once the thread is done */
|
|
370
|
-
export function personState(real: ThreadState, copy: ThreadState, o: { deferred: boolean; headKept: boolean }): ThreadState {
|
|
373
|
+
export function personState(real: ThreadState, copy: ThreadState, o: { deferred: boolean; headKept: boolean; works?: boolean }): ThreadState {
|
|
371
374
|
const turn: Turn = o.deferred && real.turn === 'aside' ? 'yours' : real.turn === 'yours' || real.turn === 'aside' ? 'aside' : real.turn
|
|
372
375
|
return {
|
|
373
376
|
...copy,
|
|
@@ -378,6 +381,9 @@ export function personState(real: ThreadState, copy: ThreadState, o: { deferred:
|
|
|
378
381
|
waitsOwner: o.headKept ? copy.waitsOwner : copy.waitsOwner.filter((w) => w.what !== 'version'),
|
|
379
382
|
active: turn !== 'done',
|
|
380
383
|
validated: copy.validated && (o.headKept || real.turn === 'done'),
|
|
384
|
+
// what they must do: a verdict, an answer; a step of the owner's hands is never theirs, nothing once it is done
|
|
385
|
+
verbs: turn === 'done' ? [] : copy.verbs.filter((v) => v !== 'do'),
|
|
386
|
+
works: o.works ?? false,
|
|
381
387
|
}
|
|
382
388
|
}
|
|
383
389
|
|
|
@@ -389,7 +395,7 @@ export type Band = (typeof BANDS)[number]
|
|
|
389
395
|
export const BAND_WORDS: Record<Band, string> = { yours: 'your turn', aside: 'set aside', working: 'an agent works on it', waiting: 'waiting for an agent', done: 'done' }
|
|
390
396
|
|
|
391
397
|
/** what the band reads of a thread's state */
|
|
392
|
-
export type BandFacts = Pick<ThreadState, 'turn' | 'holder' | 'working' | 'laneAsk' | 'next'>
|
|
398
|
+
export type BandFacts = Pick<ThreadState, 'turn' | 'holder' | 'working' | 'laneAsk' | 'next' | 'works'>
|
|
393
399
|
|
|
394
400
|
const laneOf = (p: Parties, name: string, session: string | undefined) => p.lanes.find((l) => l.name === name && (session === undefined || l.session === session))
|
|
395
401
|
|
|
@@ -415,7 +421,7 @@ export function worksNow(f: BandFacts, p: Parties, now = new Date()): boolean {
|
|
|
415
421
|
/** the band: the turn, an agent's move split by whether a live agent works it now (wiki tools/shipkit/threads-how-it-fits.md,
|
|
416
422
|
* The bands) */
|
|
417
423
|
export const bandOf = (f: BandFacts, p: Parties, now = new Date()): Band =>
|
|
418
|
-
f.turn !== 'agents' ? f.turn : (f.laneAsk != null && laneAskOwed(f.laneAsk, p)) || !worksNow(f, p, now) ? 'waiting' : 'working'
|
|
424
|
+
f.turn !== 'agents' ? f.turn : f.works !== undefined ? (f.works ? 'working' : 'waiting') : (f.laneAsk != null && laneAskOwed(f.laneAsk, p)) || !worksNow(f, p, now) ? 'waiting' : 'working'
|
|
419
425
|
|
|
420
426
|
/** a `working` line past its time on the agents' move, as the owner's row says it (« said working 14 h ago, nothing since »);
|
|
421
427
|
* a promised version counts its own time; null while it counts or on any other turn */
|
|
@@ -175,11 +175,11 @@ function writeHouseFiles(write: (rel: string, body: string) => void, vars: Recor
|
|
|
175
175
|
* include lines pull it into the house contract, so it gets the house half
|
|
176
176
|
* of the day-one shape and nothing that says what the repo IS. Create-only,
|
|
177
177
|
* so every file the repo already holds wins. Returns the paths it wrote */
|
|
178
|
-
export function adoptHouse(root: string, opts: { name: string; today?: string; print?: (line: string) => void; cli?: boolean }): string[] {
|
|
178
|
+
export function adoptHouse(root: string, opts: { name: string; today?: string; print?: (line: string) => void; cli?: boolean; claudePolicy: boolean }): string[] {
|
|
179
179
|
const p = opts.print ?? console.log
|
|
180
180
|
const vars = { NAME: opts.name, PORT: String(defaultHubPort(opts.name)), DATE: opts.today ?? dayStamp(), ...cliIndexVars(opts.name, opts.cli === true) }
|
|
181
181
|
const written: string[] = []
|
|
182
|
-
writeHouseFiles((rel, body) => { if (put(root, rel, body)) written.push(rel) }, vars,
|
|
182
|
+
writeHouseFiles((rel, body) => { if (put(root, rel, body)) written.push(rel) }, vars, opts.claudePolicy, written, p)
|
|
183
183
|
if (written.length > 0) p(`ok: adopted into the house, ${written.length} file(s) seeded: ${written.join(', ')}`)
|
|
184
184
|
return written
|
|
185
185
|
}
|
package/src/secrets/copy.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// secrets copied to another Mac over ssh: each read through the lib's one read and written by the peer's own
|
|
2
2
|
// `sk secret set`, from the house checkout at the same place under its home. A value only ever travels on ssh's
|
|
3
3
|
// stdin: never an argv, a file or a printed line. A secret the peer already answers is left as it is.
|
|
4
|
+
import { peerSk, shq } from '../core/peer-sk.ts'
|
|
4
5
|
|
|
5
6
|
export type Copied = { name: string; did: 'copied' | 'there' | 'not here' | 'failed'; why?: string }
|
|
6
7
|
|
|
@@ -18,11 +19,10 @@ const spawnRun: Run = async (argv, stdin) => {
|
|
|
18
19
|
return { code: await p.exited, out, err }
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
const q = (s: string): string => `'${s.replaceAll("'", `'\\''`)}'`
|
|
22
|
+
const q = shq
|
|
23
23
|
|
|
24
|
-
/** the line the peer's shell runs
|
|
25
|
-
export const peerLine = (houseRel: string, args: string): string =>
|
|
24
|
+
/** the line the peer's shell runs for `sk secret <args>` */
|
|
25
|
+
export const peerLine = (houseRel: string, args: string): string => peerSk(houseRel, `secret ${args}`)
|
|
26
26
|
|
|
27
27
|
/** the unlock a locked peer needs, said once */
|
|
28
28
|
export const unlockHint = (to: string): string => `the login keychain of ${to} is locked to ssh, and an unlock holds for its own ssh session only: run \`sk secret copy --to ${to} --unlock\` from your terminal (it asks for that Mac's login password once)`
|
|
@@ -207,7 +207,9 @@ class Twin {
|
|
|
207
207
|
const cs = t.ownerDocument.defaultView?.getComputedStyle?.(t)
|
|
208
208
|
if (cs) for (const p of TWIN_COPIES) this.el.style.setProperty(p, cs.getPropertyValue(p))
|
|
209
209
|
this.el.style.width = `${t.clientWidth}px`
|
|
210
|
-
|
|
210
|
+
// the borders as css says them: under a page zoom (WebKit, sk gui) offsetHeight and clientHeight round apart by a
|
|
211
|
+
// px that depends on the height just set, so the box flipped between two heights each frame
|
|
212
|
+
this.edge = cs ? parseFloat(cs.borderTopWidth) + parseFloat(cs.borderBottomWidth) : t.offsetHeight - t.clientHeight
|
|
211
213
|
const max = parseFloat(cs?.maxHeight ?? '')
|
|
212
214
|
this.max = Number.isFinite(max) ? max : Infinity
|
|
213
215
|
this.rows = rows
|
|
@@ -151,7 +151,7 @@ export function dockPills(view: HouseView | null, size: DockSize): DockPill[] {
|
|
|
151
151
|
const d = line.match(DEFERRED)
|
|
152
152
|
if (m != null) settling.push(`${m[1]} ${m[2]}`)
|
|
153
153
|
else if (d != null) deferred.push({ short: `${d[1]} ${d[2]}`, line })
|
|
154
|
-
else out.push({ key: `held:${held++}`, tone: 'warn', text: line.replace(/ on \d+ cores$/, ''), title: line })
|
|
154
|
+
else out.push({ key: `held:${held++}`, tone: 'warn', text: line.replace(/ on \d+ cores(?=$|, most by )/, '').replace(/(, most by .*) \([^()]*\)$/, '$1'), title: line })
|
|
155
155
|
}
|
|
156
156
|
// a save held behind a gate someone started is the plan working as meant: one dim pill, each sentence on hover
|
|
157
157
|
if (deferred.length > 0)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// what an agent asks of the owner in a thread, answered in one click (wiki tools/shipkit/threads.md, A question, A proposed
|
|
2
2
|
// change): a question's options, each words or a media drawn as a view, and a proposed change, each field drawn by its
|
|
3
|
-
// type and applied alone. A
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// type and applied alone. A question answers in question words, never a verdict's (tones.ts questionTones): a click on an
|
|
4
|
+
// option picks it, its pencil picks it with the owner's remark; under the options one row, none of these in the owner's words,
|
|
5
|
+
// your call, no answer (tone-bar.tsx)
|
|
6
6
|
import { observer } from 'mobx-react-lite'
|
|
7
7
|
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
8
8
|
import type { PersonPick, ReplyCell } from '../../../review/cells.ts'
|
|
@@ -12,9 +12,9 @@ import { CodeHunk, Swatches, WordDiff } from './diff-view.tsx'
|
|
|
12
12
|
import { AutoText } from '../auto-text.tsx'
|
|
13
13
|
import { renderMdInline } from '../md.ts'
|
|
14
14
|
import { WordsInline } from '../words.tsx'
|
|
15
|
-
import { keepFocus
|
|
15
|
+
import { keepFocus } from './kit.tsx'
|
|
16
16
|
import { ToneBar, ToneMark } from './tone-bar.tsx'
|
|
17
|
-
import { toneOfStatus } from './tones.ts'
|
|
17
|
+
import { questionToneClass, questionTones, toneOfStatus, type Tone } from './tones.ts'
|
|
18
18
|
import type { ReviewSt } from './review-st.ts'
|
|
19
19
|
import { secretFacts } from './secret-facts.ts'
|
|
20
20
|
import { ReadableLine } from '../secret-readable.tsx'
|
|
@@ -26,6 +26,12 @@ import { tip } from '../tips.ts'
|
|
|
26
26
|
|
|
27
27
|
type Field = NonNullable<ReplyCell['propose']>['fields'][number]
|
|
28
28
|
|
|
29
|
+
/** his answer in words alone as the question's row names it: none of these unless he named your call or no answer */
|
|
30
|
+
const questionAnswerTone = (tone: string | undefined): Tone => {
|
|
31
|
+
const row = questionTones('row', null)
|
|
32
|
+
return row.find((t) => t.status === tone) ?? row[0]!
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
/** an option's or a field's media, a view of the item the message sits on, drawn read only; an option's name is its
|
|
30
36
|
* button's, so its view draws no caption of its own (`named`) */
|
|
31
37
|
const MessageView = observer(({ rv, thread, c, i, named = true }: { rv: ReviewSt; thread: ThreadSt; c: ReplyCell; i: number; named?: boolean }) => {
|
|
@@ -119,9 +125,9 @@ const PickLines = observer(({ rv, thread, c, ask }: { rv: ReviewSt; thread: Thre
|
|
|
119
125
|
)
|
|
120
126
|
})
|
|
121
127
|
|
|
122
|
-
/** an agent's question, answered in
|
|
123
|
-
*
|
|
124
|
-
*
|
|
128
|
+
/** an agent's question, answered in question words (tones.ts questionTones): a click on an option picks it; its « pick
|
|
129
|
+
* with a remark » mark opens a box under it, the option and the owner's words sent together; the row under the options
|
|
130
|
+
* answers none of these in the owner's words, your call, or no answer. Its media over each option, the agent's pick marked as
|
|
125
131
|
* a suggestion. Answered, his answer is the one lit in its tone, his remark under its option. A person's pick shows in
|
|
126
132
|
* the question's lines (PickLines), never above the thread */
|
|
127
133
|
export const AskBody = observer(({ rv, thread, c, ask }: { rv: ReviewSt; thread: ThreadSt; c: ReplyCell; ask: NonNullable<ReplyCell['ask']> }) => {
|
|
@@ -170,7 +176,7 @@ export const AskBody = observer(({ rv, thread, c, ask }: { rv: ReviewSt; thread:
|
|
|
170
176
|
<button type="button" className={`rv-askremark${remarking === i ? ' open' : ''}`} aria-label={`pick ${i + 1} with a remark`} aria-expanded={remarking === i} data-check="pick-remark"
|
|
171
177
|
{...tip(`pick ${i + 1} with a remark: a box opens for your words, and the agent reads the option and your words together`)} onMouseDown={keepFocus}
|
|
172
178
|
onClick={() => thread.setRemarking(c.id, remarking === i ? null : i)}>
|
|
173
|
-
<span className="st-
|
|
179
|
+
<span className="st-remark"><ToneMark t={toneOfStatus('approved-with-fix')!} /></span>
|
|
174
180
|
</button>
|
|
175
181
|
) : null
|
|
176
182
|
const choice = (o: string, i: number) => (
|
|
@@ -181,17 +187,17 @@ export const AskBody = observer(({ rv, thread, c, ask }: { rv: ReviewSt; thread:
|
|
|
181
187
|
)
|
|
182
188
|
const remarkBox = remarking !== undefined && remarking < ask.options.length ? <RemarkBox thread={thread} c={c} i={remarking} /> : null
|
|
183
189
|
const remarkSaid = (i: number) => (mine(i) && remark !== '' ? <div className="rv-askremarksaid" {...tip('your remark with this pick')}>« {remark} »</div> : null)
|
|
184
|
-
// his answer in words alone
|
|
185
|
-
const given =
|
|
190
|
+
// his answer in words alone, in the question's words: none of these (an older wrong direction too), your call, no answer
|
|
191
|
+
const given = questionAnswerTone(ask.tone)
|
|
186
192
|
const said = his !== null && 'words' in his ? (
|
|
187
|
-
<button key="words" className={`rv-askopt picked none words ${
|
|
188
|
-
<span className="rv-asknonelabel"><ToneMark t={given} /> {given.
|
|
189
|
-
{his.words !== given.word ? <span className="rv-askoptlabel">« {his.words} »</span> : null}
|
|
193
|
+
<button key="words" className={`rv-askopt picked none words ${questionToneClass(given.status)}`} disabled {...tip(`your answer, ${given.word}: « ${his.words} »`)}>
|
|
194
|
+
<span className="rv-asknonelabel"><ToneMark t={given} /> {given.word}</span>
|
|
195
|
+
{his.words !== given.word && his.words !== toneOfStatus(given.status)?.word ? <span className="rv-askoptlabel">« {his.words} »</span> : null}
|
|
190
196
|
<span className="rv-yours">✓ yours</span>
|
|
191
197
|
</button>
|
|
192
198
|
) : null
|
|
193
|
-
// the
|
|
194
|
-
//
|
|
199
|
+
// the question's row under the options (tone-bar.tsx): none of these in the owner's words, your call (the agent's
|
|
200
|
+
// pick), no answer; a pick is a click on its option. A step of an ask's instructions keeps its words
|
|
195
201
|
const bar = c.step === undefined && !c.superseded ? <ToneBar thread={thread} on={c.id} question={c} pick={ask.pick !== undefined ? (ask.options[ask.pick] ?? `option ${ask.pick + 1}`) : null} /> : null
|
|
196
202
|
// a step's escape hatch: « none of these », the owner's words instead of an option. Answered in words, it holds the
|
|
197
203
|
// words, selected
|
|
@@ -287,6 +293,10 @@ const KindAskBody = observer(({ rv, thread, c, ask }: { rv: ReviewSt; thread: Th
|
|
|
287
293
|
const words = (thread.hints[c.id] ?? '').trim() !== ''
|
|
288
294
|
// answered with the owner's words alone: they stand where its control stood, in green, never over the question
|
|
289
295
|
const inWords = ask.none !== undefined && ask.kind !== 'checklist' && !ask.open
|
|
296
|
+
// a confirm, a text or a url: its own control, then the question's row (your call on a text or a url, no answer), kept once answered
|
|
297
|
+
// so the question keeps its layout, as a choice keeps its row
|
|
298
|
+
const row = thread.questionCell(c.id) !== undefined && !c.superseded ? <ToneBar thread={thread} on={c.id} question={c} pick={null} /> : null
|
|
299
|
+
const toned = inWords && ask.tone !== undefined ? questionAnswerTone(ask.tone) : null
|
|
290
300
|
return (
|
|
291
301
|
<div className={`rv-ask rv-ask-${ask.kind}`}>
|
|
292
302
|
{ask.kind === 'checklist' ? <Checklist thread={thread} c={c} ask={ask} /> : null}
|
|
@@ -294,7 +304,7 @@ const KindAskBody = observer(({ rv, thread, c, ask }: { rv: ReviewSt; thread: Th
|
|
|
294
304
|
{(ask.kind === 'text' || ask.kind === 'url') && !inWords ? <ValueField thread={thread} c={c} ask={ask} /> : null}
|
|
295
305
|
{ask.kind === 'secret' ? <SecretPlace rv={rv} thread={thread} c={c} ask={ask} /> : null}
|
|
296
306
|
{ask.kind === 'file' && !inWords ? <div className="rv-dim">{ask.value ? `his file: view ${(ask.value.view ?? 0) + 1}` : 'a file he drops: not built in the hub yet'}</div> : null}
|
|
297
|
-
{inWords ? (
|
|
307
|
+
{inWords && toned !== null ? null : inWords ? (
|
|
298
308
|
<div className="rv-askfield rv-askvalue given">
|
|
299
309
|
<AutoText className="rv-answerwords rv-askgiven" readOnly value={ask.none ?? ''} onText={() => undefined} />
|
|
300
310
|
<button className="rv-askopt pick picked" disabled {...tip('your answer, in your words')}>✓ in your words</button>
|
|
@@ -311,6 +321,7 @@ const KindAskBody = observer(({ rv, thread, c, ask }: { rv: ReviewSt; thread: Th
|
|
|
311
321
|
) : null}
|
|
312
322
|
</div>
|
|
313
323
|
) : null}
|
|
324
|
+
{row}
|
|
314
325
|
</div>
|
|
315
326
|
)
|
|
316
327
|
})
|