teamsmith 0.1.2 → 0.2.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/README.md +13 -7
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +39 -0
- package/skills/teamsmith/SKILL.md +18 -7
- package/skills/teamsmith/references/agent-adapters.md +7 -7
- package/skills/teamsmith/references/config.md +29 -15
- package/skills/teamsmith/references/migration.md +38 -2
- package/skills/teamsmith/references/protocol.md +81 -13
- package/skills/teamsmith/references/workflows.md +31 -19
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +210 -70
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +70 -9
- package/skills/teamsmith/scripts/lib/cmd-config.sh +222 -70
- package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
- package/skills/teamsmith/scripts/lib/cmd-project.sh +134 -17
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +13 -10
- package/skills/teamsmith/scripts/lib/cmd-status.sh +42 -13
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +75 -13
- package/skills/teamsmith/scripts/lib/common.sh +797 -71
- package/skills/teamsmith/scripts/monitor.mjs +34 -3
- package/skills/teamsmith/scripts/panel/README.md +22 -11
- package/skills/teamsmith/scripts/panel/panel.js +217 -215
- package/skills/teamsmith/scripts/panel/src/App.tsx +421 -164
- package/skills/teamsmith/scripts/panel/src/data.ts +84 -4
- package/skills/teamsmith/scripts/panel/src/layout.ts +502 -91
- package/skills/teamsmith/scripts/panel/src/main.tsx +97 -12
- package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +56 -21
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +56 -21
- package/skills/teamsmith/scripts/panel/src/types.ts +178 -16
- package/skills/teamsmith/scripts/replies.mjs +893 -0
- package/skills/teamsmith/scripts/team +1 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +15 -2
- package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
- package/skills/teamsmith/templates/config.sh.tmpl +10 -5
- package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +20 -1
- package/skills/teamsmith/templates/report.md.tmpl +12 -0
- package/skills/teamsmith/templates/task.md.tmpl +4 -0
- package/skills/teamsmith/tests/config-cli.sh +162 -288
- package/skills/teamsmith/tests/death-cause.sh +5 -2
- package/skills/teamsmith/tests/install-shape.sh +4 -2
- package/skills/teamsmith/tests/key-replies-pty.sh +375 -0
- package/skills/teamsmith/tests/key-replies-ui.sh +332 -0
- package/skills/teamsmith/tests/key-replies.sh +1075 -0
- package/skills/teamsmith/tests/ledger-ban.sh +4 -4
- package/skills/teamsmith/tests/ledger-claim.sh +247 -0
- package/skills/teamsmith/tests/lib/model-policy.sh +26 -0
- package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
- package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
- package/skills/teamsmith/tests/lib/model-routing-flips.py +136 -0
- package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
- package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +372 -0
- package/skills/teamsmith/tests/lib/tmux-iso.sh +8 -0
- package/skills/teamsmith/tests/panel-b2.sh +1 -1
- package/skills/teamsmith/tests/panel-b3-stub.sh +27 -0
- package/skills/teamsmith/tests/panel-b3.sh +14 -10
- package/skills/teamsmith/tests/panel-choices.sh +74 -61
- package/skills/teamsmith/tests/panel-cpu.sh +1 -1
- package/skills/teamsmith/tests/panel-p21.sh +311 -190
- package/skills/teamsmith/tests/perf.sh +1 -1
- package/skills/teamsmith/tests/pm-box-real.sh +1 -1
- package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
- package/skills/teamsmith/tests/routes.sh +43 -22
- package/skills/teamsmith/tests/section-budgets.tsv +8 -4
- package/skills/teamsmith/tests/section-paths.tsv +26 -16
- package/skills/teamsmith/tests/section-select.sh +82 -6
- package/skills/teamsmith/tests/smoke.sh +782 -180
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
- package/skills/teamsmith/tests/task-header-model.sh +2 -1
- package/skills/teamsmith/tests/task-model-routing.sh +1014 -0
- package/skills/teamsmith-init/SKILL.md +38 -38
- package/skills/teamsmith-init/references/bootstrap.md +6 -4
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
|
@@ -12,13 +12,31 @@
|
|
|
12
12
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
13
13
|
import { writeSync } from 'node:fs'
|
|
14
14
|
import { Box, Text, useApp, useCursor, useInput } from 'ink'
|
|
15
|
-
import { layout, resolveFocus, focusRefOf, focusRow, rowKey, settingsViewRows } from './layout.js'
|
|
16
|
-
import type { LayoutInput } from './layout.js'
|
|
15
|
+
import { layout, resolveFocus, focusRefOf, focusRow, rowKey, settingsRowFocusable, settingsViewRows } from './layout.js'
|
|
16
|
+
import type { LayoutInput, SettingsRow } from './layout.js'
|
|
17
17
|
import { clockOf } from './format.js'
|
|
18
18
|
import { fill, stringsFor, type Strings } from './strings/index.js'
|
|
19
19
|
import { composeKey, cpLength, cursorView, insertAt, intake, killSpan, moveCursor, popUndo, pushKill, pushUndo, receiptLine, resetKillDirection, ringEntry, type ComposeMode, type ComposeView, type KillRing, type Receipt, type UndoSnapshot } from './compose.js'
|
|
20
20
|
import type { Settings } from './settings.js'
|
|
21
|
-
import type {
|
|
21
|
+
import type {
|
|
22
|
+
Action,
|
|
23
|
+
DetailWindow,
|
|
24
|
+
FocusRef,
|
|
25
|
+
FrameInput,
|
|
26
|
+
PageId,
|
|
27
|
+
PrefName,
|
|
28
|
+
ReplyDocWindow,
|
|
29
|
+
ReplyEntry,
|
|
30
|
+
ReplyWindow,
|
|
31
|
+
Segment,
|
|
32
|
+
SettingsBlock,
|
|
33
|
+
SettingsCategory,
|
|
34
|
+
SettingsChoiceEntry,
|
|
35
|
+
SettingsChoicePicker,
|
|
36
|
+
SettingsKey,
|
|
37
|
+
SettingsWindow,
|
|
38
|
+
ViewState,
|
|
39
|
+
} from './types.js'
|
|
22
40
|
import type { Palette } from './theme.js'
|
|
23
41
|
import { dispWidth } from './width.js'
|
|
24
42
|
|
|
@@ -27,13 +45,17 @@ const TRAY_TR = '╮'
|
|
|
27
45
|
const TRAY_H = '─'
|
|
28
46
|
const TRAY_V = '│'
|
|
29
47
|
|
|
48
|
+
/** The focusable row of the view as the App walks it (headings are skipped). */
|
|
49
|
+
type SettingsFocusRow = Extract<SettingsRow, { kind: 'key' | 'category' | 'assignment' | 'pm-launch' }>
|
|
50
|
+
|
|
30
51
|
/**
|
|
31
52
|
* The kinds whose editor is the choice picker (M55). `enum` joins only when the command reports
|
|
32
53
|
* values (an enum with no constraints has no choice set: R3's visible fallback names the reason),
|
|
33
54
|
* and a key the command reports without a `choices` object falls back to the compose editor — the
|
|
34
|
-
* bundle works against an older command instead of inventing options.
|
|
55
|
+
* bundle works against an older command instead of inventing options. `task-model-map` is
|
|
56
|
+
* deliberately absent: its editor is the categories block (P232), never a composed pair list.
|
|
35
57
|
*/
|
|
36
|
-
const CHOICE_KINDS = new Set(['bool', 'enum', 'int', 'seconds', 'mb', 'bytes', 'pct', 'path', 'model', '
|
|
58
|
+
const CHOICE_KINDS = new Set(['bool', 'enum', 'int', 'seconds', 'mb', 'bytes', 'pct', 'path', 'model', 'winlist', 'pattern'])
|
|
37
59
|
const NUMERIC_KINDS = new Set(['int', 'seconds', 'mb', 'bytes', 'pct'])
|
|
38
60
|
|
|
39
61
|
function hasChoiceEditor(key: SettingsKey): boolean {
|
|
@@ -96,6 +118,13 @@ export interface PanelApi {
|
|
|
96
118
|
* discovered file when omitted). Both are cached options, so an unchanged call rebuilds nothing.
|
|
97
119
|
*/
|
|
98
120
|
setDetail(id: string | null, file?: string | null): void
|
|
121
|
+
/**
|
|
122
|
+
* Page 5's demand reads (pulse-key-replies): the list cursor (`before`, null = the newest page and
|
|
123
|
+
* null also drops the list from the wanted set when the page is parked) and the open viewer's
|
|
124
|
+
* number (`no`, null = closed). Both are request keys: changing one clears the cached block, kills
|
|
125
|
+
* the child still in flight and makes a late response for the old key a no-op.
|
|
126
|
+
*/
|
|
127
|
+
setReply(opts: { list: boolean; before: number | null; no: number | null }): void
|
|
99
128
|
/** Rebuild the patrol window as the headless tick loop (`team pulse collapse`). */
|
|
100
129
|
collapse(): Promise<{ ok: boolean; line: string }>
|
|
101
130
|
/** Represents one `team config set` result: the exit code (the machine contract) + one line. */
|
|
@@ -110,9 +139,9 @@ export interface PanelApi {
|
|
|
110
139
|
* next interaction sees. Never awaited on the interaction path.
|
|
111
140
|
*/
|
|
112
141
|
refreshSettingsSoon(): void
|
|
113
|
-
/** One `team config set-
|
|
114
|
-
|
|
115
|
-
|
|
142
|
+
/** One `team config set-task-model <category> <model>` invocation (P232). */
|
|
143
|
+
setTaskModel(
|
|
144
|
+
category: string,
|
|
116
145
|
model: string,
|
|
117
146
|
opts: { dryRun?: boolean; fingerprint?: string | null },
|
|
118
147
|
): Promise<{ code: number; line: string }>
|
|
@@ -261,6 +290,14 @@ export function App({
|
|
|
261
290
|
const [detailId, setDetailId] = useState<string | null>(null)
|
|
262
291
|
const [detailIndex, setDetailIndex] = useState(0)
|
|
263
292
|
const [detailScroll, setDetailScroll] = useState(0)
|
|
293
|
+
// Page 5 (pulse-key-replies): the cursor chain, the stable-number focus, the open body and the
|
|
294
|
+
// document's scroll. `replyStack` is the chain `Newer` walks back through — no full-history load.
|
|
295
|
+
const [replyFocus, setReplyFocus] = useState<number | null>(null)
|
|
296
|
+
const [replyCursor, setReplyCursor] = useState<number | null>(null)
|
|
297
|
+
const [replyStack, setReplyStack] = useState<number[]>([])
|
|
298
|
+
const [replyBody, setReplyBody] = useState<number | null>(null)
|
|
299
|
+
const [replyScroll, setReplyScroll] = useState(0)
|
|
300
|
+
const [replyOffset, setReplyOffset] = useState<number | null>(null)
|
|
264
301
|
// P22/B2: the project-settings view (opened from the overlay's navigation row), its window and
|
|
265
302
|
// its filter. The view is a view, not a page: the four-page composition and `state/panel-page`
|
|
266
303
|
// keep their meaning, and `esc` lands back on the overlay row it was opened from.
|
|
@@ -276,9 +313,7 @@ export function App({
|
|
|
276
313
|
const [settingsOffset, setSettingsOffset] = useState<number | null>(null)
|
|
277
314
|
/** The pending two-step write confirmation ({danger} = the command answered 7). */
|
|
278
315
|
const [settingConfirm, setSettingConfirm] = useState<{ key: string; next: string; danger: boolean } | null>(null)
|
|
279
|
-
/** The
|
|
280
|
-
const [seatPicker, setSeatPicker] = useState<{ agent: string; row: number; models: string[]; index: number } | null>(null)
|
|
281
|
-
/** The choice picker (M55): the key's schema-derived entries and the selection. */
|
|
316
|
+
/** The choice picker (M55/P232): the row's schema-derived entries and the selection. */
|
|
282
317
|
const [choicePicker, setChoicePicker] = useState<SettingsChoicePicker | null>(null)
|
|
283
318
|
const { exit } = useApp()
|
|
284
319
|
const scrollRef = useRef(0)
|
|
@@ -299,6 +334,17 @@ export function App({
|
|
|
299
334
|
const pasteOpenRef = useRef(false)
|
|
300
335
|
const settingsRef = useRef(settings)
|
|
301
336
|
const pageRef = useRef(page)
|
|
337
|
+
const replyFocusRef = useRef(replyFocus)
|
|
338
|
+
replyFocusRef.current = replyFocus
|
|
339
|
+
const replyCursorRef = useRef(replyCursor)
|
|
340
|
+
replyCursorRef.current = replyCursor
|
|
341
|
+
const replyStackRef = useRef(replyStack)
|
|
342
|
+
replyStackRef.current = replyStack
|
|
343
|
+
const replyBodyRef = useRef(replyBody)
|
|
344
|
+
replyBodyRef.current = replyBody
|
|
345
|
+
/** Page 5's list window / the viewer's document window as the last frame rendered them. */
|
|
346
|
+
const replyListRef = useRef<ReplyWindow | null>(null)
|
|
347
|
+
const replyDocRef = useRef<ReplyDocWindow | null>(null)
|
|
302
348
|
const targetsRef = useRef<{ row: number; hit: { start: number; end: number; action: Action } }[]>([])
|
|
303
349
|
const overlayIndexRef = useRef(0)
|
|
304
350
|
const focusRef = useRef<FocusRef | null>(null)
|
|
@@ -316,10 +362,12 @@ export function App({
|
|
|
316
362
|
const settingsOffsetRef = useRef<number | null>(null)
|
|
317
363
|
/** The row window the last frame drew (the wheel and the focus keys clamp against it). */
|
|
318
364
|
const settingsWindowRef = useRef<SettingsWindow | null>(null)
|
|
319
|
-
/**
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
365
|
+
/**
|
|
366
|
+
* The row the open `setting` editor writes (the fingerprint was pinned when it opened).
|
|
367
|
+
* `category` is set when the row is a task category: the same editor then writes through
|
|
368
|
+
* `team config set-task-model <category> <model>` instead of `team config set <KEY>` (P232).
|
|
369
|
+
*/
|
|
370
|
+
const settingRowRef = useRef<{ row: number; key: string; value: string; cls: string; fingerprint: string; category?: string; kind?: string; choices?: SettingsKey['choices'] } | null>(null)
|
|
323
371
|
const choicePickerRef = useRef<SettingsChoicePicker | null>(null)
|
|
324
372
|
choicePickerRef.current = choicePicker
|
|
325
373
|
const settingConfirmRef = useRef<{ key: string; next: string; danger: boolean } | null>(null)
|
|
@@ -360,8 +408,21 @@ export function App({
|
|
|
360
408
|
|
|
361
409
|
const goPage = useCallback(
|
|
362
410
|
(next: PageId) => {
|
|
411
|
+
const previous = pageRef.current
|
|
363
412
|
pageRef.current = next
|
|
364
413
|
setPage(next)
|
|
414
|
+
// Page 5's demand reads follow the page: entering it starts a fresh newest chain, leaving it
|
|
415
|
+
// closes the viewer — which is what drops the `reply_body` request (design §4: no body read
|
|
416
|
+
// after leaving page 5).
|
|
417
|
+
if (next === 5 && previous !== 5) {
|
|
418
|
+
setReplyCursor(null)
|
|
419
|
+
setReplyStack([])
|
|
420
|
+
setReplyFocus(null)
|
|
421
|
+
setReplyOffset(null)
|
|
422
|
+
setReplyBody(null)
|
|
423
|
+
} else if (next !== 5) {
|
|
424
|
+
setReplyBody(null)
|
|
425
|
+
}
|
|
365
426
|
setViewEntry(null)
|
|
366
427
|
setDetailId(null)
|
|
367
428
|
setDetailIndex(0)
|
|
@@ -521,12 +582,18 @@ export function App({
|
|
|
521
582
|
const conf = settingConfirmRef.current
|
|
522
583
|
const timing =
|
|
523
584
|
target.cls === 'restart' ? stringsRef.current.settingTimingRestart : stringsRef.current.settingTimingApply
|
|
524
|
-
|
|
525
|
-
|
|
585
|
+
// P232: a category row keeps the same editor, but its write is the CLI's per-category
|
|
586
|
+
// command (`set-task-model`) — the console never composes the pair list.
|
|
526
587
|
const call = (dryRun: boolean, allowDanger: boolean): Promise<{ code: number; line: string }> =>
|
|
527
|
-
|
|
528
|
-
? api.
|
|
588
|
+
target.category
|
|
589
|
+
? api.setTaskModel(target.category, text, { dryRun, fingerprint: target.fingerprint })
|
|
529
590
|
: api.setSetting(target.key, text, { dryRun, fingerprint: target.fingerprint, allowDanger })
|
|
591
|
+
const written = (): string =>
|
|
592
|
+
target.category
|
|
593
|
+
? fill(stringsRef.current.settingCategoryWritten, { category: target.category, value: text })
|
|
594
|
+
: target.key === 'TEAM_PM_MODEL'
|
|
595
|
+
? fill(stringsRef.current.settingPmWritten, { value: text })
|
|
596
|
+
: fill(stringsRef.current.settingWritten, { key: target.key, value: text, timing })
|
|
530
597
|
if (!conf) {
|
|
531
598
|
const r = await call(true, false)
|
|
532
599
|
if (r.code === 0) {
|
|
@@ -534,11 +601,11 @@ export function App({
|
|
|
534
601
|
setSettingConfirm(settingConfirmRef.current)
|
|
535
602
|
setReceipt(null)
|
|
536
603
|
setStatus(
|
|
537
|
-
|
|
538
|
-
? fill(stringsRef.current.
|
|
539
|
-
|
|
604
|
+
target.category
|
|
605
|
+
? fill(stringsRef.current.settingCategoryConfirm, {
|
|
606
|
+
category: target.category,
|
|
540
607
|
old: target.value || stringsRef.current.dash,
|
|
541
|
-
next:
|
|
608
|
+
next: text,
|
|
542
609
|
})
|
|
543
610
|
: fill(stringsRef.current.settingConfirm, {
|
|
544
611
|
key: target.key,
|
|
@@ -570,14 +637,7 @@ export function App({
|
|
|
570
637
|
const r = await call(false, conf.danger)
|
|
571
638
|
if (r.code === 0) {
|
|
572
639
|
setReceipt(null)
|
|
573
|
-
|
|
574
|
-
setStatus(
|
|
575
|
-
isSeat
|
|
576
|
-
? seatModel === '-'
|
|
577
|
-
? fill(stringsRef.current.settingSeatRemoved, { seat: target.seat as string, value: fallback || stringsRef.current.dash })
|
|
578
|
-
: fill(stringsRef.current.settingSeatWritten, { seat: target.seat as string, value: seatModel })
|
|
579
|
-
: fill(stringsRef.current.settingWritten, { key: target.key, value: text, timing }),
|
|
580
|
-
)
|
|
640
|
+
setStatus(written())
|
|
581
641
|
settingRowRef.current = null
|
|
582
642
|
settingConfirmRef.current = null
|
|
583
643
|
setSettingConfirm(null)
|
|
@@ -745,9 +805,10 @@ export function App({
|
|
|
745
805
|
next.lang = cur.lang === 'zh' ? 'en' : 'zh'
|
|
746
806
|
break
|
|
747
807
|
case 'defaultPage':
|
|
748
|
-
//
|
|
749
|
-
//
|
|
750
|
-
|
|
808
|
+
// Five pages since pulse-key-replies: the cycle covers 1–5 and wraps (a cycle that still
|
|
809
|
+
// stopped at 4 would leave 5 unreachable as a remembered default and reset it on the next
|
|
810
|
+
// launch — the silent reset this branch exists to avoid).
|
|
811
|
+
next.defaultPage = cur.defaultPage === 5 ? 1 : ((cur.defaultPage + 1) as PageId)
|
|
751
812
|
goPage(next.defaultPage)
|
|
752
813
|
break
|
|
753
814
|
case 'activity':
|
|
@@ -908,9 +969,9 @@ export function App({
|
|
|
908
969
|
// ---- project settings (P22/B2): the view's focus walk, its origin and its row opening.
|
|
909
970
|
|
|
910
971
|
/** The view's focusable rows as the last assembly saw them (the walk must match the screen). */
|
|
911
|
-
const settingsRowsNow = useCallback(():
|
|
972
|
+
const settingsRowsNow = useCallback((): SettingsFocusRow[] => {
|
|
912
973
|
const rows = settingsViewRows(dataRef.current.blocks?.settings, settingsFilterRef.current, stringsRef.current)
|
|
913
|
-
return rows.filter(
|
|
974
|
+
return rows.filter(settingsRowFocusable)
|
|
914
975
|
}, [])
|
|
915
976
|
|
|
916
977
|
const moveSettingsFocus = useCallback(
|
|
@@ -991,7 +1052,7 @@ export function App({
|
|
|
991
1052
|
pushValue(key.value, 'current')
|
|
992
1053
|
pushValue(key.default, 'default')
|
|
993
1054
|
for (const v of values) pushValue(v, 'value')
|
|
994
|
-
if (kind === 'bool' || kind === 'enum'
|
|
1055
|
+
if (kind === 'bool' || kind === 'enum') return out
|
|
995
1056
|
if (kind === 'path') {
|
|
996
1057
|
if (ch.empty) out.push({ value: '', kind: 'clear' })
|
|
997
1058
|
out.push({ value: '', kind: 'free', seed: base })
|
|
@@ -1018,6 +1079,21 @@ export function App({
|
|
|
1018
1079
|
const choiceTarget = useCallback(
|
|
1019
1080
|
(picker: SettingsChoicePicker): NonNullable<typeof settingRowRef.current> => {
|
|
1020
1081
|
const rows = settingsRowsNow()
|
|
1082
|
+
const fingerprint = dataRef.current.blocks?.settings?.fingerprint ?? ''
|
|
1083
|
+
if (picker.category) {
|
|
1084
|
+
// P232: a category picker writes `set-task-model <category> <model>`; its "current" value is
|
|
1085
|
+
// the future policy's model for that category — read from the row the picker was opened on.
|
|
1086
|
+
const catNow = rows.find((r) => r.kind === 'category' && r.category.category === picker.key)
|
|
1087
|
+
return {
|
|
1088
|
+
row: picker.row,
|
|
1089
|
+
key: picker.key,
|
|
1090
|
+
value: catNow && catNow.kind === 'category' ? catNow.category.model : '',
|
|
1091
|
+
cls: 'apply',
|
|
1092
|
+
fingerprint,
|
|
1093
|
+
category: picker.key,
|
|
1094
|
+
kind: picker.kind,
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1021
1097
|
// By key name, not by index: the picker's row index is a focus index and the row list can be
|
|
1022
1098
|
// replaced by a settle re-read while the picker is open.
|
|
1023
1099
|
const rowNow = rows.find((r) => r.kind === 'key' && r.key.name === picker.key) ?? rows[picker.row]
|
|
@@ -1027,7 +1103,7 @@ export function App({
|
|
|
1027
1103
|
key: picker.key,
|
|
1028
1104
|
value: keyNow?.value ?? '',
|
|
1029
1105
|
cls: keyNow?.class ?? 'apply',
|
|
1030
|
-
fingerprint
|
|
1106
|
+
fingerprint,
|
|
1031
1107
|
kind: picker.kind,
|
|
1032
1108
|
choices: keyNow?.choices,
|
|
1033
1109
|
}
|
|
@@ -1051,11 +1127,23 @@ export function App({
|
|
|
1051
1127
|
setBusy(true)
|
|
1052
1128
|
const timing =
|
|
1053
1129
|
target.cls === 'restart' ? stringsRef.current.settingTimingRestart : stringsRef.current.settingTimingApply
|
|
1130
|
+
// P232: a category accept writes through the CLI's per-category command; a key accept keeps
|
|
1131
|
+
// the contract-set path. Both are the owning command's subprocess — never a direct write.
|
|
1132
|
+
const call = (dryRun: boolean, allowDanger: boolean): Promise<{ code: number; line: string }> =>
|
|
1133
|
+
target.category
|
|
1134
|
+
? api.setTaskModel(target.category, value, { dryRun, fingerprint: target.fingerprint })
|
|
1135
|
+
: api.setSetting(target.key, value, { dryRun, fingerprint: target.fingerprint, allowDanger })
|
|
1136
|
+
const writtenLine = (): string =>
|
|
1137
|
+
target.category
|
|
1138
|
+
? fill(stringsRef.current.settingCategoryWritten, { category: target.category, value })
|
|
1139
|
+
: target.key === 'TEAM_PM_MODEL'
|
|
1140
|
+
? fill(stringsRef.current.settingPmWritten, { value })
|
|
1141
|
+
: fill(stringsRef.current.settingWritten, { key: target.key, value, timing })
|
|
1054
1142
|
try {
|
|
1055
1143
|
const danger = choiceDangerRef.current
|
|
1056
1144
|
const dangerAccept = Boolean(danger && danger.key === target.key && danger.value === value)
|
|
1057
1145
|
if (!dangerAccept) {
|
|
1058
|
-
const dry = await
|
|
1146
|
+
const dry = await call(true, false)
|
|
1059
1147
|
if (dry.code === 7) {
|
|
1060
1148
|
choiceDangerRef.current = { key: target.key, value }
|
|
1061
1149
|
setReceipt(null)
|
|
@@ -1079,15 +1167,11 @@ export function App({
|
|
|
1079
1167
|
return
|
|
1080
1168
|
}
|
|
1081
1169
|
}
|
|
1082
|
-
const r = await
|
|
1083
|
-
dryRun: false,
|
|
1084
|
-
fingerprint: target.fingerprint,
|
|
1085
|
-
allowDanger: dangerAccept,
|
|
1086
|
-
})
|
|
1170
|
+
const r = await call(false, dangerAccept)
|
|
1087
1171
|
choiceDangerRef.current = null
|
|
1088
1172
|
if (r.code === 0) {
|
|
1089
1173
|
setReceipt(null)
|
|
1090
|
-
setStatus(
|
|
1174
|
+
setStatus(writtenLine())
|
|
1091
1175
|
settingRowRef.current = null
|
|
1092
1176
|
setChoicePicker(null)
|
|
1093
1177
|
choicePickerRef.current = null
|
|
@@ -1121,29 +1205,30 @@ export function App({
|
|
|
1121
1205
|
)
|
|
1122
1206
|
|
|
1123
1207
|
/**
|
|
1124
|
-
* The
|
|
1125
|
-
*
|
|
1126
|
-
* the
|
|
1127
|
-
* on screen.
|
|
1208
|
+
* The whole-map row's editor is the categories block (P232): `enter` moves the focus to the first
|
|
1209
|
+
* category row — no compose editor, no option list, and the pair list is never composed here. A
|
|
1210
|
+
* filter that hides the block is dropped, because otherwise "focus the categories block" would
|
|
1211
|
+
* name a row that is not on screen. When the policy carries no category at all (a legacy or empty
|
|
1212
|
+
* map) the block has nothing to focus: the CLI route is named instead, and nothing is written.
|
|
1128
1213
|
*/
|
|
1129
|
-
const
|
|
1214
|
+
const routeCategories = useCallback(() => {
|
|
1130
1215
|
const rows = settingsRowsNow()
|
|
1131
|
-
let
|
|
1132
|
-
if (
|
|
1216
|
+
let at = rows.findIndex((r) => r.kind === 'category')
|
|
1217
|
+
if (at < 0) {
|
|
1133
1218
|
settingsFilterRef.current = ''
|
|
1134
1219
|
setSettingsFilter('')
|
|
1135
1220
|
// The focus index counts focusable rows, not the group headings `settingsViewRows` also
|
|
1136
1221
|
// returns — counting those would land the cursor on the wrong row (or past the end).
|
|
1137
|
-
const all =
|
|
1138
|
-
|
|
1139
|
-
)
|
|
1140
|
-
seat = all.findIndex((r) => r.kind === 'seat')
|
|
1222
|
+
const all = settingsRowsNow()
|
|
1223
|
+
at = all.findIndex((r) => r.kind === 'category')
|
|
1141
1224
|
}
|
|
1142
1225
|
setChoicePicker(null)
|
|
1143
1226
|
choicePickerRef.current = null
|
|
1144
|
-
if (
|
|
1227
|
+
if (at >= 0) setSettingsFocus(at)
|
|
1145
1228
|
setReceipt(null)
|
|
1146
|
-
setStatus(
|
|
1229
|
+
setStatus(
|
|
1230
|
+
at >= 0 ? stringsRef.current.settingsCategoryMapHint : stringsRef.current.settingsCategoryMapEmpty,
|
|
1231
|
+
)
|
|
1147
1232
|
}, [settingsRowsNow])
|
|
1148
1233
|
|
|
1149
1234
|
/**
|
|
@@ -1232,8 +1317,6 @@ export function App({
|
|
|
1232
1317
|
setSettingsOffset(null)
|
|
1233
1318
|
settingsOffsetRef.current = null
|
|
1234
1319
|
settingsWindowRef.current = null
|
|
1235
|
-
setSeatPicker(null)
|
|
1236
|
-
seatPickerRef.current = null
|
|
1237
1320
|
setChoicePicker(null)
|
|
1238
1321
|
choicePickerRef.current = null
|
|
1239
1322
|
api.setSettingsOpen(false)
|
|
@@ -1243,9 +1326,40 @@ export function App({
|
|
|
1243
1326
|
overlayIndexRef.current = settingsOrigin
|
|
1244
1327
|
}, [api, settingsOrigin])
|
|
1245
1328
|
|
|
1329
|
+
/**
|
|
1330
|
+
* Builds the entries of a category picker (P232). The vocabulary is exactly the project's own:
|
|
1331
|
+
* the policy's model for the category when there is one, then the models the command reports as
|
|
1332
|
+
* known — plus the free-text entry. The machine's Pi catalogue is not a source here, and there is
|
|
1333
|
+
* no removal entry: the writer has no per-category delete, so the console must not invent one.
|
|
1334
|
+
*/
|
|
1335
|
+
const buildCategoryEntries = useCallback(
|
|
1336
|
+
(cat: SettingsCategory): SettingsChoiceEntry[] => {
|
|
1337
|
+
const known = dataRef.current.blocks?.settings?.models?.known ?? []
|
|
1338
|
+
const synthetic: SettingsKey = {
|
|
1339
|
+
name: cat.category,
|
|
1340
|
+
class: 'apply',
|
|
1341
|
+
kind: 'model',
|
|
1342
|
+
form: 'plain',
|
|
1343
|
+
value: cat.model,
|
|
1344
|
+
default: '',
|
|
1345
|
+
set: cat.model !== '',
|
|
1346
|
+
comment: '',
|
|
1347
|
+
warning: '',
|
|
1348
|
+
route: '',
|
|
1349
|
+
choices: { source: 'known', values: [...known], min: '', max: '', empty: false, note: '' },
|
|
1350
|
+
group: 'task-model',
|
|
1351
|
+
known: true,
|
|
1352
|
+
}
|
|
1353
|
+
return buildChoiceEntries(synthetic)
|
|
1354
|
+
},
|
|
1355
|
+
[buildChoiceEntries],
|
|
1356
|
+
)
|
|
1357
|
+
|
|
1246
1358
|
/**
|
|
1247
1359
|
* Enter on a view row: a `refuse` row opens no editor and surfaces the owning command's route;
|
|
1248
|
-
* an editable row opens the value editor (the compose line's `setting` mode, B3)
|
|
1360
|
+
* an editable row opens the value editor (the compose line's `setting` mode, B3); a category row
|
|
1361
|
+
* opens its own picker (P232); a committed assignment is read-only and only names the route that
|
|
1362
|
+
* decides it.
|
|
1249
1363
|
*/
|
|
1250
1364
|
const openSettingsRow = useCallback(
|
|
1251
1365
|
(index: number) => {
|
|
@@ -1255,31 +1369,49 @@ export function App({
|
|
|
1255
1369
|
const at = index < 0 ? settingsFocusRef.current : index
|
|
1256
1370
|
const row = rows[at]
|
|
1257
1371
|
if (!row) return
|
|
1258
|
-
if (row.kind === '
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1372
|
+
if (row.kind === 'category') {
|
|
1373
|
+
const entries = buildCategoryEntries(row.category)
|
|
1374
|
+
const picker: SettingsChoicePicker = {
|
|
1375
|
+
row: at,
|
|
1376
|
+
key: row.category.category,
|
|
1377
|
+
kind: 'model',
|
|
1378
|
+
entries,
|
|
1379
|
+
index: 0,
|
|
1380
|
+
interval: null,
|
|
1381
|
+
category: true,
|
|
1382
|
+
}
|
|
1383
|
+
choiceDangerRef.current = null
|
|
1384
|
+
setChoicePicker(picker)
|
|
1385
|
+
choicePickerRef.current = picker
|
|
1264
1386
|
setReceipt(null)
|
|
1265
1387
|
setStatus(null)
|
|
1266
1388
|
return
|
|
1267
1389
|
}
|
|
1390
|
+
if (row.kind === 'assignment' || row.kind === 'pm-launch') {
|
|
1391
|
+
// Read-only: the actual model is the committed record's, decided by dispatch/resume. The
|
|
1392
|
+
// console offers no editor for it (and never a "restart this seat" action).
|
|
1393
|
+
setReceipt(null)
|
|
1394
|
+
setChoicePicker(null)
|
|
1395
|
+
choicePickerRef.current = null
|
|
1396
|
+
setStatus(row.kind === 'assignment' ? stringsRef.current.settingsAssignmentHint : stringsRef.current.settingsPmLaunchHint)
|
|
1397
|
+
return
|
|
1398
|
+
}
|
|
1268
1399
|
const key = row.key
|
|
1269
1400
|
if (key.class === 'refuse') {
|
|
1270
1401
|
setReceipt(null)
|
|
1271
1402
|
setStatus(`${key.name} · ${key.route || key.warning || stringsRef.current.settingsRefusedRoute}`)
|
|
1272
1403
|
return
|
|
1273
1404
|
}
|
|
1405
|
+
// The whole-map row's editor is the categories block, never a composed pair list (P232).
|
|
1406
|
+
if (String(key.kind ?? '') === 'task-model-map') {
|
|
1407
|
+
routeCategories()
|
|
1408
|
+
return
|
|
1409
|
+
}
|
|
1274
1410
|
// M65/D11: the editor opens on the `settings` block already on screen — no `config list` or
|
|
1275
1411
|
// `__panel-data` stands between the keystroke and the frame that answers it. The fingerprint
|
|
1276
1412
|
// is that block's, so a contract changed underneath is the owning command's conflict verdict
|
|
1277
1413
|
// (CAS), not a reason to re-read before every action.
|
|
1278
1414
|
if (hasChoiceEditor(key)) {
|
|
1279
|
-
if (String(key.kind ?? '') === 'pairlist') {
|
|
1280
|
-
routePairlist()
|
|
1281
|
-
return
|
|
1282
|
-
}
|
|
1283
1415
|
const entries = buildChoiceEntries(key)
|
|
1284
1416
|
if (entries.length) {
|
|
1285
1417
|
const kind = String(key.kind ?? '')
|
|
@@ -1300,7 +1432,7 @@ export function App({
|
|
|
1300
1432
|
}
|
|
1301
1433
|
}
|
|
1302
1434
|
settingRowRef.current = {
|
|
1303
|
-
row:
|
|
1435
|
+
row: at,
|
|
1304
1436
|
key: key.name,
|
|
1305
1437
|
value: key.value,
|
|
1306
1438
|
cls: key.class,
|
|
@@ -1317,63 +1449,9 @@ export function App({
|
|
|
1317
1449
|
setStatus(fill(stringsRef.current.settingsChoiceNoChoice, { kind: String(key.kind ?? '') }))
|
|
1318
1450
|
}
|
|
1319
1451
|
},
|
|
1320
|
-
[buildChoiceEntries, openCompose,
|
|
1452
|
+
[buildCategoryEntries, buildChoiceEntries, openCompose, routeCategories, settingsRowsNow],
|
|
1321
1453
|
)
|
|
1322
1454
|
|
|
1323
|
-
/**
|
|
1324
|
-
* One picker choice: a model opens the editor holding it, `-` opens it holding the removal,
|
|
1325
|
-
* the free-text row opens it empty. The editor's two Enter presses are the confirmation.
|
|
1326
|
-
*/
|
|
1327
|
-
/** Resolve a picker index (or -1 = the selected one) into the picker + its option. */
|
|
1328
|
-
const pickerIndex = useCallback(
|
|
1329
|
-
(index: number): { picker: { agent: string; row: number; models: string[]; index: number }; option: string } | null => {
|
|
1330
|
-
const p = seatPickerRef.current
|
|
1331
|
-
if (!p) return null
|
|
1332
|
-
const options = [...p.models, '-', '']
|
|
1333
|
-
const i = index < 0 ? p.index : index
|
|
1334
|
-
if (i < 0 || i >= options.length) return null
|
|
1335
|
-
return { picker: p, option: options[i] }
|
|
1336
|
-
},
|
|
1337
|
-
[],
|
|
1338
|
-
)
|
|
1339
|
-
|
|
1340
|
-
const chooseSeatOption = useCallback(
|
|
1341
|
-
(index: number) => {
|
|
1342
|
-
const picker = pickerIndex(index)
|
|
1343
|
-
if (!picker) return
|
|
1344
|
-
const { picker: p, option } = picker
|
|
1345
|
-
const seat = p.agent
|
|
1346
|
-
// M65/D11: the editor opens from the block already on screen (no read on the interaction
|
|
1347
|
-
// path); its fingerprint is that block's, so CAS catches a contract changed underneath.
|
|
1348
|
-
const block = dataRef.current.blocks?.settings
|
|
1349
|
-
const seatRow = (block?.models?.seats ?? []).find((x) => x.agent === seat)
|
|
1350
|
-
const initial = option === '' ? '' : option
|
|
1351
|
-
settingRowRef.current = {
|
|
1352
|
-
row: p.row,
|
|
1353
|
-
key: seat,
|
|
1354
|
-
value: seatRow?.model ?? '',
|
|
1355
|
-
cls: 'restart',
|
|
1356
|
-
fingerprint: block?.fingerprint ?? '',
|
|
1357
|
-
seat,
|
|
1358
|
-
}
|
|
1359
|
-
settingConfirmRef.current = null
|
|
1360
|
-
setSettingConfirm(null)
|
|
1361
|
-
setSeatPicker(null)
|
|
1362
|
-
seatPickerRef.current = null
|
|
1363
|
-
openCompose('setting', initial)
|
|
1364
|
-
},
|
|
1365
|
-
[openCompose, pickerIndex],
|
|
1366
|
-
)
|
|
1367
|
-
|
|
1368
|
-
const moveSeatPicker = useCallback((delta: number) => {
|
|
1369
|
-
const p = seatPickerRef.current
|
|
1370
|
-
if (!p) return
|
|
1371
|
-
const count = p.models.length + 2
|
|
1372
|
-
const next = { ...p, index: Math.max(0, Math.min(count - 1, p.index + delta)) }
|
|
1373
|
-
seatPickerRef.current = next
|
|
1374
|
-
setSeatPicker(next)
|
|
1375
|
-
}, [])
|
|
1376
|
-
|
|
1377
1455
|
/** The detail view's file tabs: `←`/`→` clamp at the ends (no wrap — the row shows the order). */
|
|
1378
1456
|
const moveDetailTab = useCallback((delta: number) => {
|
|
1379
1457
|
const files = dataRef.current.blocks?.detail?.files ?? []
|
|
@@ -1406,6 +1484,94 @@ export function App({
|
|
|
1406
1484
|
api.setDetail(detailId, files[detailIndexRef.current]?.path ?? null)
|
|
1407
1485
|
}, [api, detailId, detailIndex, detailBlockData])
|
|
1408
1486
|
|
|
1487
|
+
/** Page 5's slots as the last snapshot carries them (never a re-read of the store). */
|
|
1488
|
+
const replyEntries = useCallback((): ReplyEntry[] => dataRef.current.blocks?.reply_list?.entries ?? [], [])
|
|
1489
|
+
|
|
1490
|
+
/** Page 5's `↑`/`↓`: the focus walks the drawn rows; the window follows it (offset = null). */
|
|
1491
|
+
const moveReplyFocus = useCallback(
|
|
1492
|
+
(delta: number) => {
|
|
1493
|
+
const entries = replyEntries()
|
|
1494
|
+
if (!entries.length) return
|
|
1495
|
+
const at = entries.findIndex((e) => e.no === replyFocusRef.current)
|
|
1496
|
+
const next = Math.max(0, Math.min(entries.length - 1, (at < 0 ? 0 : at) + delta))
|
|
1497
|
+
setReplyFocus(entries[next].no)
|
|
1498
|
+
setReplyOffset(null)
|
|
1499
|
+
},
|
|
1500
|
+
[replyEntries],
|
|
1501
|
+
)
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* Page 5's `Older`/`Newer`. Older fetches the page's own `next_before` and pushes the cursor the
|
|
1505
|
+
* current page was fetched with onto the chain; Newer pops it — the retained chain is what lets
|
|
1506
|
+
* the user walk back without a full-history load, and `0` in the chain means "the newest page".
|
|
1507
|
+
*/
|
|
1508
|
+
const replyPage = useCallback(
|
|
1509
|
+
(dir: -1 | 1) => {
|
|
1510
|
+
const list = dataRef.current.blocks?.reply_list
|
|
1511
|
+
if (!list) return
|
|
1512
|
+
if (dir === 1) {
|
|
1513
|
+
const stack = replyStackRef.current
|
|
1514
|
+
if (!stack.length) return
|
|
1515
|
+
const back = stack[stack.length - 1]
|
|
1516
|
+
setReplyStack(stack.slice(0, -1))
|
|
1517
|
+
setReplyCursor(back === 0 ? null : back)
|
|
1518
|
+
} else {
|
|
1519
|
+
const older = list.next_before
|
|
1520
|
+
if (!older) return
|
|
1521
|
+
setReplyStack([...replyStackRef.current, replyCursorRef.current ?? 0])
|
|
1522
|
+
setReplyCursor(older)
|
|
1523
|
+
}
|
|
1524
|
+
setReplyFocus(null)
|
|
1525
|
+
setReplyOffset(null)
|
|
1526
|
+
},
|
|
1527
|
+
[],
|
|
1528
|
+
)
|
|
1529
|
+
|
|
1530
|
+
/** `r` on page 5: drop the chain and fetch the newest page again. */
|
|
1531
|
+
const replyReset = useCallback(() => {
|
|
1532
|
+
setReplyCursor(null)
|
|
1533
|
+
setReplyStack([])
|
|
1534
|
+
setReplyFocus(null)
|
|
1535
|
+
setReplyOffset(null)
|
|
1536
|
+
}, [])
|
|
1537
|
+
|
|
1538
|
+
/** Open a numbered body (a click on the focused row, or Enter on it). */
|
|
1539
|
+
const openReply = useCallback(
|
|
1540
|
+
(index?: number) => {
|
|
1541
|
+
const entries = replyEntries()
|
|
1542
|
+
const entry = index != null ? entries[index] : (entries.find((e) => e.no === replyFocusRef.current) ?? entries[0])
|
|
1543
|
+
if (!entry || !entry.available) return
|
|
1544
|
+
setReplyBody(entry.no)
|
|
1545
|
+
setReplyScroll(0)
|
|
1546
|
+
},
|
|
1547
|
+
[replyEntries],
|
|
1548
|
+
)
|
|
1549
|
+
|
|
1550
|
+
/** The viewer document's scroll, clamped against the window the last frame reported. */
|
|
1551
|
+
const scrollReply = useCallback((delta: number) => {
|
|
1552
|
+
const win = replyDocRef.current
|
|
1553
|
+
const max = win ? Math.max(0, win.total - win.visible) : 0
|
|
1554
|
+
setReplyScroll((v) => Math.max(0, Math.min(max, v + delta)))
|
|
1555
|
+
}, [])
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* Page 5's demand reads (design §4): the list is wanted only on page 5 — and only for the cursor
|
|
1559
|
+
* in view — while the body is wanted only while the viewer is open. Leaving the page clears both,
|
|
1560
|
+
* so a parked console spawns neither child. `setReply` is idempotent for an unchanged pair, so
|
|
1561
|
+
* this effect (and a re-render) never forces a rebuild of what is already on screen.
|
|
1562
|
+
*/
|
|
1563
|
+
const replyListData = data.blocks?.reply_list
|
|
1564
|
+
const replyBodyData = data.blocks?.reply_body
|
|
1565
|
+
useEffect(() => {
|
|
1566
|
+
api.setReply({ list: page === 5 && replyBody == null, before: replyCursor, no: replyBody })
|
|
1567
|
+
}, [api, page, replyCursor, replyBody])
|
|
1568
|
+
|
|
1569
|
+
// A body that left the store between the click and the read: keep the list usable rather than
|
|
1570
|
+
// pinning the viewer on a number the readers refuse (the viewer itself renders the notice).
|
|
1571
|
+
useEffect(() => {
|
|
1572
|
+
if (replyBody != null && replyBodyData == null) return
|
|
1573
|
+
}, [replyBody, replyBodyData])
|
|
1574
|
+
|
|
1409
1575
|
const dispatch = useCallback(
|
|
1410
1576
|
(action: Action) => {
|
|
1411
1577
|
switch (action.kind) {
|
|
@@ -1426,7 +1592,7 @@ export function App({
|
|
|
1426
1592
|
goPage(action.page)
|
|
1427
1593
|
return
|
|
1428
1594
|
case 'page-cycle':
|
|
1429
|
-
goPage(pageRef.current ===
|
|
1595
|
+
goPage(pageRef.current === 5 ? 1 : ((pageRef.current + 1) as PageId))
|
|
1430
1596
|
return
|
|
1431
1597
|
case 'scroll':
|
|
1432
1598
|
updateScroll((v) => v + action.delta)
|
|
@@ -1449,6 +1615,47 @@ export function App({
|
|
|
1449
1615
|
case 'focus':
|
|
1450
1616
|
setFocus({ lane: action.lane, id: action.id, nth: action.nth ?? 0 })
|
|
1451
1617
|
return
|
|
1618
|
+
case 'reply-click': {
|
|
1619
|
+
// One action, two behaviours (the kanban's rule): a click on an unfocused row focuses it,
|
|
1620
|
+
// a click on the already focused row opens its body.
|
|
1621
|
+
const entries = replyEntries()
|
|
1622
|
+
const entry = entries[action.index]
|
|
1623
|
+
if (!entry) return
|
|
1624
|
+
if (replyFocusRef.current === entry.no) openReply(action.index)
|
|
1625
|
+
else {
|
|
1626
|
+
setReplyFocus(entry.no)
|
|
1627
|
+
setReplyOffset(null)
|
|
1628
|
+
}
|
|
1629
|
+
return
|
|
1630
|
+
}
|
|
1631
|
+
case 'reply-move':
|
|
1632
|
+
moveReplyFocus(action.delta)
|
|
1633
|
+
return
|
|
1634
|
+
case 'reply-page':
|
|
1635
|
+
replyPage(action.dir)
|
|
1636
|
+
return
|
|
1637
|
+
case 'reply-reset':
|
|
1638
|
+
replyReset()
|
|
1639
|
+
return
|
|
1640
|
+
case 'reply-open':
|
|
1641
|
+
openReply(action.index)
|
|
1642
|
+
return
|
|
1643
|
+
case 'reply-scroll':
|
|
1644
|
+
scrollReply(action.delta)
|
|
1645
|
+
return
|
|
1646
|
+
case 'reply-close':
|
|
1647
|
+
// Back to the list with its cursor, focus and viewport untouched.
|
|
1648
|
+
setReplyBody(null)
|
|
1649
|
+
return
|
|
1650
|
+
case 'reply-open-latest':
|
|
1651
|
+
replyReset()
|
|
1652
|
+
goPage(5)
|
|
1653
|
+
if (action.no) {
|
|
1654
|
+
setReplyFocus(action.no)
|
|
1655
|
+
setReplyBody(action.no)
|
|
1656
|
+
setReplyScroll(0)
|
|
1657
|
+
}
|
|
1658
|
+
return
|
|
1452
1659
|
case 'open-focused': {
|
|
1453
1660
|
// One action kind, two pages: the kanban resolves its lane/card focus, the work page the
|
|
1454
1661
|
// drawn row order (P20/B5).
|
|
@@ -1516,16 +1723,9 @@ export function App({
|
|
|
1516
1723
|
case 'choice-close':
|
|
1517
1724
|
closeChoicePicker()
|
|
1518
1725
|
return
|
|
1519
|
-
case 'seat-pick':
|
|
1520
|
-
if (action.index < 0) chooseSeatOption(-1)
|
|
1521
|
-
else chooseSeatOption(action.index)
|
|
1522
|
-
return
|
|
1523
|
-
case 'seat-move':
|
|
1524
|
-
moveSeatPicker(action.delta)
|
|
1525
|
-
return
|
|
1526
1726
|
}
|
|
1527
1727
|
},
|
|
1528
|
-
[boardRows, chooseChoiceOption, closeChoicePicker, closeSettingsView, collapse, cyclePref, goPage, moveBoardFocus, moveChoicePicker, moveDetailTab, moveFocus,
|
|
1728
|
+
[boardRows, chooseChoiceOption, closeChoicePicker, closeSettingsView, collapse, cyclePref, goPage, moveBoardFocus, moveChoicePicker, moveDetailTab, moveFocus, moveSettingsFocus, openCompose, openDetail, openSettingsRow, openSettingsView, openWorkFocused, runAction, scrollDetail, scrollLane, scrollSettings, toggleLaneFold, updateScroll],
|
|
1529
1729
|
)
|
|
1530
1730
|
|
|
1531
1731
|
const effectiveActivity = activityPinned ? data.activity : settings.activity
|
|
@@ -1597,8 +1797,13 @@ export function App({
|
|
|
1597
1797
|
settingsFocus,
|
|
1598
1798
|
settingsFilter,
|
|
1599
1799
|
settingsOffset,
|
|
1600
|
-
seatPicker,
|
|
1601
1800
|
choicePicker,
|
|
1801
|
+
replyFocus,
|
|
1802
|
+
replyCursor,
|
|
1803
|
+
replyBody,
|
|
1804
|
+
replyScroll,
|
|
1805
|
+
replyOffset,
|
|
1806
|
+
replyBodyFailed: Boolean(data.replyBodyFailed) && replyBodyData == null,
|
|
1602
1807
|
}
|
|
1603
1808
|
// The geometry comes from the live terminal, not from the frame's snapshot of it: a resize must
|
|
1604
1809
|
// re-lay out the next frame (the spec's "A resize re-lays out live"), and `data.width` is frozen
|
|
@@ -1619,6 +1824,8 @@ export function App({
|
|
|
1619
1824
|
boardOrderRef.current = themed.boardOrder ?? []
|
|
1620
1825
|
detailRef.current = themed.detail ?? null
|
|
1621
1826
|
settingsWindowRef.current = themed.settings ?? null
|
|
1827
|
+
replyListRef.current = themed.replyList ?? null
|
|
1828
|
+
replyDocRef.current = themed.replyDoc ?? null
|
|
1622
1829
|
return { frame: themed, input, hint, bottom, pad, boxed, inputView }
|
|
1623
1830
|
}, [
|
|
1624
1831
|
data,
|
|
@@ -1643,8 +1850,12 @@ export function App({
|
|
|
1643
1850
|
settingsFocus,
|
|
1644
1851
|
settingsFilter,
|
|
1645
1852
|
settingsOffset,
|
|
1646
|
-
seatPicker,
|
|
1647
1853
|
choicePicker,
|
|
1854
|
+
replyFocus,
|
|
1855
|
+
replyCursor,
|
|
1856
|
+
replyBody,
|
|
1857
|
+
replyScroll,
|
|
1858
|
+
replyOffset,
|
|
1648
1859
|
size,
|
|
1649
1860
|
composing,
|
|
1650
1861
|
mode,
|
|
@@ -1742,16 +1953,10 @@ export function App({
|
|
|
1742
1953
|
// on the page the view was opened from (the work page's rows open it too, P20/B5).
|
|
1743
1954
|
if (choicePickerRef.current) {
|
|
1744
1955
|
// The choice picker's entries may outrun the budget: the wheel walks the list like
|
|
1745
|
-
// ↑/↓ (the window follows the selection
|
|
1956
|
+
// ↑/↓ (the window follows the selection).
|
|
1746
1957
|
moveChoicePicker(delta)
|
|
1747
1958
|
return
|
|
1748
1959
|
}
|
|
1749
|
-
if (seatPickerRef.current) {
|
|
1750
|
-
// P30/D5: the seat picker's wheel used to fall through to the page. It walks its
|
|
1751
|
-
// entries now, exactly like the choice picker, and the page still does not move.
|
|
1752
|
-
moveSeatPicker(delta)
|
|
1753
|
-
return
|
|
1754
|
-
}
|
|
1755
1960
|
if (settingsViewRef.current) {
|
|
1756
1961
|
// P30/D5: while the project-settings view is open the wheel is its region — the row
|
|
1757
1962
|
// window moves one row per notch, the focus stays, and the page behind it is untouched.
|
|
@@ -1762,6 +1967,22 @@ export function App({
|
|
|
1762
1967
|
scrollDetail(delta)
|
|
1763
1968
|
return
|
|
1764
1969
|
}
|
|
1970
|
+
if (pageRef.current === 5 && replyBodyRef.current != null) {
|
|
1971
|
+
// The reply viewer's document is the one scrollable region on page 5.
|
|
1972
|
+
scrollReply(delta)
|
|
1973
|
+
return
|
|
1974
|
+
}
|
|
1975
|
+
if (pageRef.current === 5) {
|
|
1976
|
+
// Page 5's list: the wheel moves the *viewport*, never the focus (the documented rule),
|
|
1977
|
+
// and never fetches hidden history.
|
|
1978
|
+
const win = replyListRef.current
|
|
1979
|
+
setReplyOffset((v) => {
|
|
1980
|
+
const base = v ?? win?.offset ?? 0
|
|
1981
|
+
const max = win ? Math.max(0, win.count - win.visible) : 0
|
|
1982
|
+
return Math.max(0, Math.min(max, base + delta))
|
|
1983
|
+
})
|
|
1984
|
+
return
|
|
1985
|
+
}
|
|
1765
1986
|
// On the board page the wheel scrolls the lane under the cursor (a card hit carries its
|
|
1766
1987
|
// lane, the lane's own hover target covers the rest); elsewhere it scrolls the page's list.
|
|
1767
1988
|
if (pageRef.current === 4) {
|
|
@@ -1952,22 +2173,6 @@ export function App({
|
|
|
1952
2173
|
}
|
|
1953
2174
|
return
|
|
1954
2175
|
}
|
|
1955
|
-
if (seatPickerRef.current) {
|
|
1956
|
-
if (key.escape) {
|
|
1957
|
-
setSeatPicker(null)
|
|
1958
|
-
seatPickerRef.current = null
|
|
1959
|
-
return
|
|
1960
|
-
}
|
|
1961
|
-
if (key.upArrow || key.downArrow) {
|
|
1962
|
-
moveSeatPicker(key.upArrow ? -1 : 1)
|
|
1963
|
-
return
|
|
1964
|
-
}
|
|
1965
|
-
if (key.return) {
|
|
1966
|
-
chooseSeatOption(-1)
|
|
1967
|
-
return
|
|
1968
|
-
}
|
|
1969
|
-
return
|
|
1970
|
-
}
|
|
1971
2176
|
if (key.escape) {
|
|
1972
2177
|
closeSettingsView()
|
|
1973
2178
|
return
|
|
@@ -2008,16 +2213,51 @@ export function App({
|
|
|
2008
2213
|
}
|
|
2009
2214
|
// Enter adds no action here (no write operation), and the page keys stay live below.
|
|
2010
2215
|
}
|
|
2216
|
+
// The reply viewer (page 5) is read-only and full-page: Esc or `q` backs out to the same list
|
|
2217
|
+
// cursor, focus and viewport — never collapses. `↑`/`↓`, PgUp/PgDn, Home/End and the wheel
|
|
2218
|
+
// scroll the whole document; the page keys stay live below (they replace the viewer's page).
|
|
2219
|
+
if (page === 5 && replyBodyRef.current != null) {
|
|
2220
|
+
if (key.escape || (input === 'q' && !key.ctrl)) {
|
|
2221
|
+
setReplyBody(null)
|
|
2222
|
+
return
|
|
2223
|
+
}
|
|
2224
|
+
const step = Math.max(1, (size.rows || 10) - 4)
|
|
2225
|
+
if (key.upArrow) {
|
|
2226
|
+
scrollReply(-1)
|
|
2227
|
+
return
|
|
2228
|
+
}
|
|
2229
|
+
if (key.downArrow) {
|
|
2230
|
+
scrollReply(1)
|
|
2231
|
+
return
|
|
2232
|
+
}
|
|
2233
|
+
if (key.pageUp) {
|
|
2234
|
+
scrollReply(-step)
|
|
2235
|
+
return
|
|
2236
|
+
}
|
|
2237
|
+
if (key.pageDown) {
|
|
2238
|
+
scrollReply(step)
|
|
2239
|
+
return
|
|
2240
|
+
}
|
|
2241
|
+
if (key.home) {
|
|
2242
|
+
setReplyScroll(0)
|
|
2243
|
+
return
|
|
2244
|
+
}
|
|
2245
|
+
if (key.end) {
|
|
2246
|
+
const win = replyDocRef.current
|
|
2247
|
+
setReplyScroll(win ? Math.max(0, win.total - win.visible) : 0)
|
|
2248
|
+
return
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2011
2251
|
if (input === 'q' || (key.ctrl && input === 'c')) {
|
|
2012
2252
|
void collapse()
|
|
2013
2253
|
return
|
|
2014
2254
|
}
|
|
2015
2255
|
if (busy) return
|
|
2016
2256
|
if (key.tab) {
|
|
2017
|
-
goPage(pageRef.current ===
|
|
2257
|
+
goPage(pageRef.current === 5 ? 1 : ((pageRef.current + 1) as PageId))
|
|
2018
2258
|
return
|
|
2019
2259
|
}
|
|
2020
|
-
if (input === '1' || input === '2' || input === '3' || input === '4') {
|
|
2260
|
+
if (input === '1' || input === '2' || input === '3' || input === '4' || input === '5') {
|
|
2021
2261
|
goPage(Number(input) as PageId)
|
|
2022
2262
|
return
|
|
2023
2263
|
}
|
|
@@ -2039,12 +2279,29 @@ export function App({
|
|
|
2039
2279
|
return
|
|
2040
2280
|
}
|
|
2041
2281
|
if (input === 'r') {
|
|
2042
|
-
// `r` is the human asking for it: rebuild every block now, not "when its TTL is up".
|
|
2282
|
+
// `r` is the human asking for it: rebuild every block now, not "when its TTL is up". On
|
|
2283
|
+
// page 5 it is the documented "back to the newest page" key instead (design §5).
|
|
2284
|
+
if (page === 5) {
|
|
2285
|
+
replyReset()
|
|
2286
|
+
return
|
|
2287
|
+
}
|
|
2043
2288
|
setReceipt(null)
|
|
2044
2289
|
setStatus(null)
|
|
2045
2290
|
api.refreshNow()
|
|
2046
2291
|
return
|
|
2047
2292
|
}
|
|
2293
|
+
if (page === 5 && (key.leftArrow || key.rightArrow)) {
|
|
2294
|
+
replyPage(key.leftArrow ? -1 : 1)
|
|
2295
|
+
return
|
|
2296
|
+
}
|
|
2297
|
+
if (page === 5 && (key.upArrow || key.downArrow)) {
|
|
2298
|
+
moveReplyFocus(key.upArrow ? -1 : 1)
|
|
2299
|
+
return
|
|
2300
|
+
}
|
|
2301
|
+
if (page === 5 && key.return) {
|
|
2302
|
+
openReply()
|
|
2303
|
+
return
|
|
2304
|
+
}
|
|
2048
2305
|
if (page === 4 && input === 'c' && !detailId) {
|
|
2049
2306
|
// P123: `c` folds/unfolds the lane the focus names. The detail view and the settings
|
|
2050
2307
|
// surfaces own the page region and never reach here (their branches returned above).
|