teamsmith 0.4.7 → 0.4.8
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 +4 -4
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +11 -0
- package/skills/teamsmith/SKILL.md +12 -8
- package/skills/teamsmith/references/config.md +11 -12
- package/skills/teamsmith/scripts/lib/cmd-review.sh +21 -33
- package/skills/teamsmith/scripts/lib/common.sh +1 -1
- package/skills/teamsmith/scripts/panel/README.md +35 -33
- package/skills/teamsmith/scripts/panel/panel.js +217 -199
- package/skills/teamsmith/scripts/panel/src/App.tsx +221 -66
- package/skills/teamsmith/scripts/panel/src/layout.ts +139 -302
- package/skills/teamsmith/scripts/panel/src/project-settings.ts +46 -0
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +71 -205
- package/skills/teamsmith/scripts/panel/src/strings/index.ts +3 -5
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +72 -204
- package/skills/teamsmith/scripts/panel/src/types.ts +23 -4
- package/skills/teamsmith/scripts/strings/commands.tsv +1 -1
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +7 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +10 -6
- package/skills/teamsmith/tests/help-surface.sh +75 -7
- package/skills/teamsmith/tests/install-shape.sh +7 -7
- package/skills/teamsmith/tests/key-replies-ui.sh +11 -5
- package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +2 -0
- package/skills/teamsmith/tests/lib/model-routing-boundary.sh +255 -90
- package/skills/teamsmith/tests/lib/model-routing-expansion.sh +181 -61
- package/skills/teamsmith/tests/lib/model-routing-roles.sh +125 -67
- package/skills/teamsmith/tests/lib/reply-fixture.sh +14 -9
- package/skills/teamsmith/tests/lib/tmp-root.sh +1 -1
- package/skills/teamsmith/tests/loop-inventory.tsv +2 -0
- package/skills/teamsmith/tests/panel-b2.sh +91 -31
- package/skills/teamsmith/tests/panel-p21.sh +607 -1162
- package/skills/teamsmith/tests/panel-strings.mjs +21 -113
- package/skills/teamsmith/tests/remind-adversarial-faults.mjs +65 -38
- package/skills/teamsmith/tests/remind-adversarial-faults.sh +64 -12
- package/skills/teamsmith/tests/remind-adversarial-real.sh +13 -12
- package/skills/teamsmith/tests/remind-tool-real.mjs +159 -112
- package/skills/teamsmith/tests/remind-tool-real.sh +178 -3
- package/skills/teamsmith/tests/section-paths.tsv +10 -10
- package/skills/teamsmith/tests/smoke.sh +108 -114
- package/skills/teamsmith/tests/task-model-routing.sh +57 -26
- package/skills/teamsmith/tests/tmp-hygiene.sh +1 -1
- package/skills/teamsmith-init/SKILL.md +1 -1
|
@@ -12,7 +12,9 @@
|
|
|
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 {
|
|
15
|
+
import { effectiveSetting, settingLabel, isSecondsSetting, settingTiming, limitsTokens, limitFields, limitsValue, withLimitsTokens } from './project-settings.js'
|
|
16
|
+
import type { SettingsPage, LimitsDraft } from './types.js'
|
|
17
|
+
import { settingsRecordDetails, layout, resolveFocus, focusRefOf, focusRow, rowKey, settingsRowFocusable, settingsViewRows, boardFocusRef, rowSourceOf } from './layout.js'
|
|
16
18
|
import type { LayoutInput, SettingsRow } from './layout.js'
|
|
17
19
|
import { clockOf } from './format.js'
|
|
18
20
|
import { fill, stringsFor, type Strings } from './strings/index.js'
|
|
@@ -47,7 +49,7 @@ const TRAY_H = '─'
|
|
|
47
49
|
const TRAY_V = '│'
|
|
48
50
|
|
|
49
51
|
/** The focusable row of the view as the App walks it (headings are skipped). */
|
|
50
|
-
type SettingsFocusRow =
|
|
52
|
+
type SettingsFocusRow = Exclude<SettingsRow, { kind: 'group' }>
|
|
51
53
|
|
|
52
54
|
/**
|
|
53
55
|
* The kinds whose editor is the choice picker (M55). `enum` joins only when the command reports
|
|
@@ -308,6 +310,14 @@ export function App({
|
|
|
308
310
|
// its filter. The view is a view, not a page: the four-page composition and `state/panel-page`
|
|
309
311
|
// keep their meaning, and `esc` lands back on the overlay row it was opened from.
|
|
310
312
|
const [settingsView, setSettingsView] = useState(false)
|
|
313
|
+
const [settingsPage, setSettingsPage] = useState<SettingsPage>('main')
|
|
314
|
+
const settingsPageRef = useRef<SettingsPage>('main')
|
|
315
|
+
const [limitsDraft, setLimitsDraft] = useState<LimitsDraft | null>(null)
|
|
316
|
+
const limitsDraftRef = useRef<LimitsDraft | null>(null)
|
|
317
|
+
const ruleFieldRef = useRef<'model' | 'count' | null>(null)
|
|
318
|
+
const [settingsDetails, setSettingsDetails] = useState<string[] | null>(null)
|
|
319
|
+
const settingsDetailsRef = useRef<string[] | null>(null)
|
|
320
|
+
const settingsBackRef = useRef<{ page: SettingsPage; focus: number; filter: string; offset: number | null }[]>([])
|
|
311
321
|
const [settingsOrigin, setSettingsOrigin] = useState(0)
|
|
312
322
|
const [settingsFocus, setSettingsFocus] = useState(0)
|
|
313
323
|
const [settingsFilter, setSettingsFilter] = useState('')
|
|
@@ -530,6 +540,7 @@ export function App({
|
|
|
530
540
|
// A cancelled setting edit writes nothing and leaves no audit line (the two-step rule).
|
|
531
541
|
settingRowRef.current = null
|
|
532
542
|
settingConfirmRef.current = null
|
|
543
|
+
ruleFieldRef.current = null
|
|
533
544
|
setSettingConfirm(null)
|
|
534
545
|
}, [])
|
|
535
546
|
|
|
@@ -574,6 +585,28 @@ export function App({
|
|
|
574
585
|
return
|
|
575
586
|
}
|
|
576
587
|
if (mode === 'setting') {
|
|
588
|
+
if (ruleFieldRef.current) {
|
|
589
|
+
const field = ruleFieldRef.current
|
|
590
|
+
const draft = limitsDraftRef.current
|
|
591
|
+
if (!draft) { closeCompose(); return }
|
|
592
|
+
if (field === 'count' && !/^\d+$/.test(text)) {
|
|
593
|
+
setStatus(stringsRef.current.settingsRuleCountInvalid)
|
|
594
|
+
return
|
|
595
|
+
}
|
|
596
|
+
if (field === 'model' && (!text || /\s|=/.test(text))) {
|
|
597
|
+
setStatus(stringsRef.current.settingInvalid.replace('{line}', stringsRef.current.settingsRuleModel))
|
|
598
|
+
return
|
|
599
|
+
}
|
|
600
|
+
const [model, count] = limitFields(draft.tokens[draft.rule])
|
|
601
|
+
const tokens = [...draft.tokens]
|
|
602
|
+
tokens[draft.rule] = field === 'model' ? text + '=' + count : model + '=' + text
|
|
603
|
+
const next = withLimitsTokens(draft, tokens)
|
|
604
|
+
limitsDraftRef.current = next
|
|
605
|
+
setLimitsDraft(next)
|
|
606
|
+
closeCompose()
|
|
607
|
+
setStatus(null)
|
|
608
|
+
return
|
|
609
|
+
}
|
|
577
610
|
// The write is always the owning command's: the first Enter asks for a `--dry-run`
|
|
578
611
|
// validation, the second performs the write with the fingerprint pinned when the editor
|
|
579
612
|
// opened. The console never opens the contract itself.
|
|
@@ -587,8 +620,7 @@ export function App({
|
|
|
587
620
|
setBusy(true)
|
|
588
621
|
try {
|
|
589
622
|
const conf = settingConfirmRef.current
|
|
590
|
-
const timing =
|
|
591
|
-
target.cls === 'restart' ? stringsRef.current.settingTimingRestart : stringsRef.current.settingTimingApply
|
|
623
|
+
const timing = settingTiming(stringsRef.current, target.key, target.category)
|
|
592
624
|
// P232: a category row keeps the same editor, but its write is the CLI's per-category
|
|
593
625
|
// command (`set-task-model`) — the console never composes the pair list.
|
|
594
626
|
const call = (dryRun: boolean, allowDanger: boolean): Promise<{ code: number; line: string }> =>
|
|
@@ -600,7 +632,7 @@ export function App({
|
|
|
600
632
|
? fill(stringsRef.current.settingCategoryWritten, { category: target.category, value: text })
|
|
601
633
|
: target.key === 'TEAM_PM_MODEL'
|
|
602
634
|
? fill(stringsRef.current.settingPmWritten, { value: text })
|
|
603
|
-
: fill(stringsRef.current.settingWritten, { key: target.key, value: text, timing })
|
|
635
|
+
: fill(stringsRef.current.settingWritten, { key: settingLabel(stringsRef.current, target.key), value: text, timing }).replace(/ · $/, '')
|
|
604
636
|
if (!conf) {
|
|
605
637
|
const r = await call(true, false)
|
|
606
638
|
if (r.code === 0) {
|
|
@@ -615,7 +647,7 @@ export function App({
|
|
|
615
647
|
next: text,
|
|
616
648
|
})
|
|
617
649
|
: fill(stringsRef.current.settingConfirm, {
|
|
618
|
-
key: target.key,
|
|
650
|
+
key: settingLabel(stringsRef.current, target.key),
|
|
619
651
|
old: target.value || stringsRef.current.dash,
|
|
620
652
|
next: text,
|
|
621
653
|
timing,
|
|
@@ -993,7 +1025,7 @@ export function App({
|
|
|
993
1025
|
|
|
994
1026
|
/** The view's focusable rows as the last assembly saw them (the walk must match the screen). */
|
|
995
1027
|
const settingsRowsNow = useCallback((): SettingsFocusRow[] => {
|
|
996
|
-
const rows = settingsViewRows(dataRef.current.blocks?.settings, settingsFilterRef.current, stringsRef.current)
|
|
1028
|
+
const rows = settingsViewRows(dataRef.current.blocks?.settings, settingsFilterRef.current, stringsRef.current, settingsPageRef.current, limitsDraftRef.current, settingsDetailsRef.current, settingsWindowRef.current?.width)
|
|
997
1029
|
return rows.filter(settingsRowFocusable)
|
|
998
1030
|
}, [])
|
|
999
1031
|
|
|
@@ -1081,12 +1113,6 @@ export function App({
|
|
|
1081
1113
|
out.push({ value: '', kind: 'free', seed: base })
|
|
1082
1114
|
return out
|
|
1083
1115
|
}
|
|
1084
|
-
if (kind === 'winlist' || kind === 'pattern') {
|
|
1085
|
-
// The token vocabulary: choosing a model seeds the compose editor with `<model>=` at the
|
|
1086
|
-
// insertion point (the current value's end); the number to the right stays free text.
|
|
1087
|
-
const seeded = out.map((e) => (e.kind === 'value' ? { ...e, seed: `${base}${base !== '' && !/\s$/.test(base) ? ' ' : ''}${e.value}=` } : e))
|
|
1088
|
-
return [...seeded, { value: '', kind: 'free', seed: base }]
|
|
1089
|
-
}
|
|
1090
1116
|
out.push({ value: '', kind: 'free', seed: base })
|
|
1091
1117
|
return out
|
|
1092
1118
|
},
|
|
@@ -1102,6 +1128,7 @@ export function App({
|
|
|
1102
1128
|
const choiceTarget = useCallback(
|
|
1103
1129
|
(picker: SettingsChoicePicker): NonNullable<typeof settingRowRef.current> => {
|
|
1104
1130
|
const rows = settingsRowsNow()
|
|
1131
|
+
if (picker.target) return picker.target
|
|
1105
1132
|
const fingerprint = dataRef.current.blocks?.settings?.fingerprint ?? ''
|
|
1106
1133
|
if (picker.category) {
|
|
1107
1134
|
// P232: a category picker writes `set-task-model <category> <model>`; its "current" value is
|
|
@@ -1148,8 +1175,7 @@ export function App({
|
|
|
1148
1175
|
if (sendingRef.current) return
|
|
1149
1176
|
sendingRef.current = true
|
|
1150
1177
|
setBusy(true)
|
|
1151
|
-
const timing =
|
|
1152
|
-
target.cls === 'restart' ? stringsRef.current.settingTimingRestart : stringsRef.current.settingTimingApply
|
|
1178
|
+
const timing = settingTiming(stringsRef.current, target.key, target.category)
|
|
1153
1179
|
// P232: a category accept writes through the CLI's per-category command; a key accept keeps
|
|
1154
1180
|
// the contract-set path. Both are the owning command's subprocess — never a direct write.
|
|
1155
1181
|
const call = (dryRun: boolean, allowDanger: boolean): Promise<{ code: number; line: string }> =>
|
|
@@ -1161,7 +1187,7 @@ export function App({
|
|
|
1161
1187
|
? fill(stringsRef.current.settingCategoryWritten, { category: target.category, value })
|
|
1162
1188
|
: target.key === 'TEAM_PM_MODEL'
|
|
1163
1189
|
? fill(stringsRef.current.settingPmWritten, { value })
|
|
1164
|
-
: fill(stringsRef.current.settingWritten, { key: target.key, value, timing })
|
|
1190
|
+
: fill(stringsRef.current.settingWritten, { key: settingLabel(stringsRef.current, target.key), value, timing }).replace(/ · $/, '')
|
|
1165
1191
|
try {
|
|
1166
1192
|
const danger = choiceDangerRef.current
|
|
1167
1193
|
const dangerAccept = Boolean(danger && danger.key === target.key && danger.value === value)
|
|
@@ -1227,37 +1253,75 @@ export function App({
|
|
|
1227
1253
|
[api],
|
|
1228
1254
|
)
|
|
1229
1255
|
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1256
|
+
const enterSettingsPage = useCallback((next: SettingsPage, details: string[] | null = null) => {
|
|
1257
|
+
settingsBackRef.current.push({ page: settingsPageRef.current, focus: settingsFocusRef.current,
|
|
1258
|
+
filter: settingsFilterRef.current, offset: settingsOffsetRef.current })
|
|
1259
|
+
settingsPageRef.current = next
|
|
1260
|
+
setSettingsPage(next)
|
|
1261
|
+
settingsDetailsRef.current = details
|
|
1262
|
+
setSettingsDetails(details)
|
|
1263
|
+
settingsFocusRef.current = 0
|
|
1264
|
+
setSettingsFocus(0)
|
|
1265
|
+
settingsOffsetRef.current = null
|
|
1266
|
+
setSettingsOffset(null)
|
|
1267
|
+
settingsFilterRef.current = ''
|
|
1268
|
+
setSettingsFilter('')
|
|
1269
|
+
setStatus(null)
|
|
1270
|
+
}, [])
|
|
1271
|
+
|
|
1272
|
+
const saveLimits = useCallback(async () => {
|
|
1273
|
+
const draft = limitsDraftRef.current
|
|
1274
|
+
if (!draft || sendingRef.current) return
|
|
1275
|
+
sendingRef.current = true
|
|
1276
|
+
setBusy(true)
|
|
1277
|
+
const value = limitsValue(draft)
|
|
1278
|
+
const opts = { fingerprint: draft.target.fingerprint, allowDanger: Boolean(draft.confirm?.danger) }
|
|
1279
|
+
try {
|
|
1280
|
+
const result = await api.setSetting('TEAM_MODEL_LIMITS', value, { ...opts, dryRun: !draft.confirm })
|
|
1281
|
+
if (!draft.confirm && (result.code === 0 || result.code === 3 || result.code === 7)) {
|
|
1282
|
+
const next = { ...draft, confirm: { danger: result.code === 7 } }
|
|
1283
|
+
limitsDraftRef.current = next
|
|
1284
|
+
setLimitsDraft(next)
|
|
1285
|
+
settingsFocusRef.current = 0
|
|
1286
|
+
setSettingsFocus(0)
|
|
1287
|
+
settingsOffsetRef.current = null
|
|
1288
|
+
setSettingsOffset(null)
|
|
1289
|
+
setStatus(result.code === 7 ? fill(stringsRef.current.settingDanger, { reason: result.line })
|
|
1290
|
+
: result.code === 3 ? stringsRef.current.settingConflict : stringsRef.current.settingsConfirmHint)
|
|
1291
|
+
} else if (result.code === 0) {
|
|
1292
|
+
limitsDraftRef.current = null
|
|
1293
|
+
setLimitsDraft(null)
|
|
1294
|
+
const back = settingsBackRef.current.pop()
|
|
1295
|
+
settingsPageRef.current = back?.page ?? 'main'
|
|
1296
|
+
setSettingsPage(settingsPageRef.current)
|
|
1297
|
+
settingsFocusRef.current = back?.focus ?? 0
|
|
1298
|
+
setSettingsFocus(settingsFocusRef.current)
|
|
1299
|
+
settingsFilterRef.current = back?.filter ?? ''
|
|
1300
|
+
setSettingsFilter(settingsFilterRef.current)
|
|
1301
|
+
settingsOffsetRef.current = back?.offset ?? null
|
|
1302
|
+
setSettingsOffset(settingsOffsetRef.current)
|
|
1303
|
+
setStatus(fill(stringsRef.current.settingWritten, { key: stringsRef.current.label_TEAM_MODEL_LIMITS, value, timing: '' }).replace(/ · $/, ''))
|
|
1304
|
+
api.refreshSettingsSoon()
|
|
1305
|
+
} else {
|
|
1306
|
+
setStatus(result.code === 3 ? stringsRef.current.settingConflict
|
|
1307
|
+
: fill(result.code === 4 ? stringsRef.current.settingInvalid : result.code === 5 ? stringsRef.current.settingRefused : stringsRef.current.settingWriteError, { line: result.line }))
|
|
1308
|
+
if (result.code === 3) {
|
|
1309
|
+
const next = { ...draft, confirm: undefined }
|
|
1310
|
+
limitsDraftRef.current = next
|
|
1311
|
+
setLimitsDraft(next)
|
|
1312
|
+
api.refreshSettingsSoon()
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
} finally {
|
|
1316
|
+
sendingRef.current = false
|
|
1317
|
+
setBusy(false)
|
|
1247
1318
|
}
|
|
1248
|
-
|
|
1249
|
-
choicePickerRef.current = null
|
|
1250
|
-
if (at >= 0) setSettingsFocus(at)
|
|
1251
|
-
setReceipt(null)
|
|
1252
|
-
setStatus(
|
|
1253
|
-
at >= 0 ? stringsRef.current.settingsCategoryMapHint : stringsRef.current.settingsCategoryMapEmpty,
|
|
1254
|
-
)
|
|
1255
|
-
}, [settingsRowsNow])
|
|
1319
|
+
}, [api])
|
|
1256
1320
|
|
|
1257
1321
|
/**
|
|
1258
|
-
* One picker choice (M65/D10): a value entry validates and writes on this accept;
|
|
1259
|
-
*
|
|
1260
|
-
*
|
|
1322
|
+
* One picker choice (M65/D10): a value entry validates and writes on this accept; free text
|
|
1323
|
+
* opens the compose editor with its validation and confirmation; a rule field changes only
|
|
1324
|
+
* the unsaved whole-value draft. Keep-unset cancels. A click on an entry that does not carry
|
|
1261
1325
|
* the cursor only moves it — a click on the cursor's entry accepts it like `enter` does.
|
|
1262
1326
|
*/
|
|
1263
1327
|
const chooseChoiceOption = useCallback(
|
|
@@ -1281,6 +1345,24 @@ export function App({
|
|
|
1281
1345
|
choicePickerRef.current = null
|
|
1282
1346
|
return
|
|
1283
1347
|
}
|
|
1348
|
+
if (picker.ruleField) {
|
|
1349
|
+
setChoicePicker(null)
|
|
1350
|
+
choicePickerRef.current = null
|
|
1351
|
+
if (entry.kind === 'free') {
|
|
1352
|
+
ruleFieldRef.current = 'model'
|
|
1353
|
+
openCompose('setting', entry.seed ?? '')
|
|
1354
|
+
} else {
|
|
1355
|
+
const draft = limitsDraftRef.current
|
|
1356
|
+
if (draft) {
|
|
1357
|
+
const tokens = [...draft.tokens]
|
|
1358
|
+
tokens[draft.rule] = entry.value + '=' + limitFields(tokens[draft.rule])[1]
|
|
1359
|
+
const next = withLimitsTokens(draft, tokens)
|
|
1360
|
+
limitsDraftRef.current = next
|
|
1361
|
+
setLimitsDraft(next)
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
return
|
|
1365
|
+
}
|
|
1284
1366
|
const target = choiceTarget(picker)
|
|
1285
1367
|
settingRowRef.current = target
|
|
1286
1368
|
if (entry.kind === 'free' || entry.seed !== undefined) {
|
|
@@ -1320,6 +1402,11 @@ export function App({
|
|
|
1320
1402
|
overlayIndexRef.current = origin
|
|
1321
1403
|
setSettingsView(true)
|
|
1322
1404
|
settingsViewRef.current = true
|
|
1405
|
+
settingsPageRef.current = 'main'
|
|
1406
|
+
setSettingsPage('main')
|
|
1407
|
+
settingsBackRef.current = []
|
|
1408
|
+
settingsDetailsRef.current = null
|
|
1409
|
+
setSettingsDetails(null)
|
|
1323
1410
|
setSettingsFocus(0)
|
|
1324
1411
|
settingsFocusRef.current = 0
|
|
1325
1412
|
setSettingsFilter('')
|
|
@@ -1334,6 +1421,31 @@ export function App({
|
|
|
1334
1421
|
)
|
|
1335
1422
|
|
|
1336
1423
|
const closeSettingsView = useCallback(() => {
|
|
1424
|
+
if (settingsFilterRef.current) {
|
|
1425
|
+
settingsFilterRef.current = ''
|
|
1426
|
+
setSettingsFilter('')
|
|
1427
|
+
settingsFocusRef.current = 0
|
|
1428
|
+
setSettingsFocus(0)
|
|
1429
|
+
settingsOffsetRef.current = null
|
|
1430
|
+
setSettingsOffset(null)
|
|
1431
|
+
return
|
|
1432
|
+
}
|
|
1433
|
+
const back = settingsBackRef.current.pop()
|
|
1434
|
+
if (back) {
|
|
1435
|
+
if (settingsPageRef.current === 'limits') { limitsDraftRef.current = null; setLimitsDraft(null) }
|
|
1436
|
+
settingsPageRef.current = back.page
|
|
1437
|
+
setSettingsPage(back.page)
|
|
1438
|
+
settingsFocusRef.current = back.focus
|
|
1439
|
+
setSettingsFocus(back.focus)
|
|
1440
|
+
settingsOffsetRef.current = back.offset
|
|
1441
|
+
setSettingsOffset(back.offset)
|
|
1442
|
+
settingsFilterRef.current = back.filter
|
|
1443
|
+
setSettingsFilter(back.filter)
|
|
1444
|
+
settingsDetailsRef.current = null
|
|
1445
|
+
setSettingsDetails(null)
|
|
1446
|
+
setStatus(null)
|
|
1447
|
+
return
|
|
1448
|
+
}
|
|
1337
1449
|
setSettingsView(false)
|
|
1338
1450
|
settingsViewRef.current = false
|
|
1339
1451
|
// D5: the wheel's offset does not survive the view (reopening starts at the top).
|
|
@@ -1392,6 +1504,41 @@ export function App({
|
|
|
1392
1504
|
const at = index < 0 ? settingsFocusRef.current : index
|
|
1393
1505
|
const row = rows[at]
|
|
1394
1506
|
if (!row) return
|
|
1507
|
+
if (limitsDraftRef.current?.confirm) { void saveLimits(); return }
|
|
1508
|
+
if (row.kind === 'nav') { enterSettingsPage(row.page); return }
|
|
1509
|
+
if (row.kind === 'info') {
|
|
1510
|
+
if (!settingsDetailsRef.current) enterSettingsPage(settingsPageRef.current, [row.text])
|
|
1511
|
+
return
|
|
1512
|
+
}
|
|
1513
|
+
if (row.kind === 'rule') {
|
|
1514
|
+
const draft = limitsDraftRef.current
|
|
1515
|
+
if (!draft) return
|
|
1516
|
+
if (row.action === 'save') { void saveLimits(); return }
|
|
1517
|
+
if (row.action === 'select' || row.action === 'add') {
|
|
1518
|
+
const next = row.action === 'add' ? { ...draft, tokens: [...draft.tokens, '=0'], changed: true, rule: draft.tokens.length }
|
|
1519
|
+
: { ...draft, rule: row.index }
|
|
1520
|
+
limitsDraftRef.current = next
|
|
1521
|
+
setLimitsDraft(next)
|
|
1522
|
+
enterSettingsPage('rule')
|
|
1523
|
+
} else if (row.action === 'delete') {
|
|
1524
|
+
const next = withLimitsTokens(draft, draft.tokens.filter((_, i) => i !== draft.rule))
|
|
1525
|
+
limitsDraftRef.current = next
|
|
1526
|
+
setLimitsDraft(next)
|
|
1527
|
+
closeSettingsView()
|
|
1528
|
+
} else if (row.action === 'count') {
|
|
1529
|
+
ruleFieldRef.current = 'count'
|
|
1530
|
+
openCompose('setting', limitFields(draft.tokens[draft.rule])[1])
|
|
1531
|
+
} else {
|
|
1532
|
+
const [model] = limitFields(draft.tokens[draft.rule])
|
|
1533
|
+
const entries: SettingsChoiceEntry[] = [...new Set([model, ...(dataRef.current.blocks?.settings?.models?.known ?? [])])]
|
|
1534
|
+
.filter(Boolean).map((value) => ({ kind: 'value', value }))
|
|
1535
|
+
entries.push({ kind: 'free', value: '', seed: model })
|
|
1536
|
+
const picker: SettingsChoicePicker = { row: at, key: 'TEAM_MODEL_LIMITS', kind: 'model', entries, index: 0, interval: null, ruleField: true }
|
|
1537
|
+
choicePickerRef.current = picker
|
|
1538
|
+
setChoicePicker(picker)
|
|
1539
|
+
}
|
|
1540
|
+
return
|
|
1541
|
+
}
|
|
1395
1542
|
if (row.kind === 'category') {
|
|
1396
1543
|
const entries = buildCategoryEntries(row.category)
|
|
1397
1544
|
const picker: SettingsChoicePicker = {
|
|
@@ -1402,6 +1549,7 @@ export function App({
|
|
|
1402
1549
|
index: 0,
|
|
1403
1550
|
interval: null,
|
|
1404
1551
|
category: true,
|
|
1552
|
+
target: { row: at, key: row.category.category, value: row.category.model, cls: 'apply', fingerprint: dataRef.current.blocks?.settings?.fingerprint ?? '', category: row.category.category, kind: 'model' },
|
|
1405
1553
|
}
|
|
1406
1554
|
choiceDangerRef.current = null
|
|
1407
1555
|
setChoicePicker(picker)
|
|
@@ -1411,12 +1559,7 @@ export function App({
|
|
|
1411
1559
|
return
|
|
1412
1560
|
}
|
|
1413
1561
|
if (row.kind === 'assignment' || row.kind === 'pm-launch') {
|
|
1414
|
-
|
|
1415
|
-
// console offers no editor for it (and never a "restart this seat" action).
|
|
1416
|
-
setReceipt(null)
|
|
1417
|
-
setChoicePicker(null)
|
|
1418
|
-
choicePickerRef.current = null
|
|
1419
|
-
setStatus(row.kind === 'assignment' ? stringsRef.current.settingsAssignmentHint : stringsRef.current.settingsPmLaunchHint)
|
|
1562
|
+
enterSettingsPage('records', settingsRecordDetails(row, stringsRef.current))
|
|
1420
1563
|
return
|
|
1421
1564
|
}
|
|
1422
1565
|
const key = row.key
|
|
@@ -1428,16 +1571,22 @@ export function App({
|
|
|
1428
1571
|
setStatus(`${named}${key.route || key.warning || stringsRef.current.settingsRefusedRoute}`)
|
|
1429
1572
|
return
|
|
1430
1573
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1574
|
+
if (key.name === 'TEAM_MODEL_LIMITS' && !key.warning) {
|
|
1575
|
+
const original = effectiveSetting(key)
|
|
1576
|
+
const tokens = limitsTokens(original)
|
|
1577
|
+
if (tokens) {
|
|
1578
|
+
const next: LimitsDraft = { original, tokens, changed: false, rule: 0, target: { row: at, key: key.name, value: original, cls: key.class, fingerprint: dataRef.current.blocks?.settings?.fingerprint ?? '', kind: key.kind, choices: key.choices } }
|
|
1579
|
+
limitsDraftRef.current = next
|
|
1580
|
+
setLimitsDraft(next)
|
|
1581
|
+
enterSettingsPage('limits')
|
|
1582
|
+
return
|
|
1583
|
+
}
|
|
1435
1584
|
}
|
|
1436
1585
|
// M65/D11: the editor opens on the `settings` block already on screen — no `config list` or
|
|
1437
1586
|
// `__panel-data` stands between the keystroke and the frame that answers it. The fingerprint
|
|
1438
1587
|
// is that block's, so a contract changed underneath is the owning command's conflict verdict
|
|
1439
1588
|
// (CAS), not a reason to re-read before every action.
|
|
1440
|
-
if (hasChoiceEditor(key)) {
|
|
1589
|
+
if (key.name !== 'TEAM_MODEL_LIMITS' && hasChoiceEditor(key)) {
|
|
1441
1590
|
const entries = buildChoiceEntries(key)
|
|
1442
1591
|
if (entries.length) {
|
|
1443
1592
|
const kind = String(key.kind ?? '')
|
|
@@ -1445,6 +1594,7 @@ export function App({
|
|
|
1445
1594
|
row: at,
|
|
1446
1595
|
key: key.name,
|
|
1447
1596
|
kind,
|
|
1597
|
+
target: { row: at, key: key.name, value: effectiveSetting(key), cls: key.class, fingerprint: dataRef.current.blocks?.settings?.fingerprint ?? '', kind, choices: key.choices },
|
|
1448
1598
|
entries,
|
|
1449
1599
|
index: 0,
|
|
1450
1600
|
interval: NUMERIC_KINDS.has(kind) ? { min: String(key.choices?.min ?? ''), max: String(key.choices?.max ?? '') } : null,
|
|
@@ -1460,7 +1610,7 @@ export function App({
|
|
|
1460
1610
|
settingRowRef.current = {
|
|
1461
1611
|
row: at,
|
|
1462
1612
|
key: key.name,
|
|
1463
|
-
value: key
|
|
1613
|
+
value: effectiveSetting(key),
|
|
1464
1614
|
cls: key.class,
|
|
1465
1615
|
fingerprint: dataRef.current.blocks?.settings?.fingerprint ?? '',
|
|
1466
1616
|
kind: String(key.kind ?? ''),
|
|
@@ -1469,13 +1619,9 @@ export function App({
|
|
|
1469
1619
|
settingConfirmRef.current = null
|
|
1470
1620
|
setSettingConfirm(null)
|
|
1471
1621
|
openCompose('setting', key.set || key.value !== '' ? key.value : key.default)
|
|
1472
|
-
|
|
1473
|
-
// The visible fallback (R3): the kind defines no choice set and the command still validates
|
|
1474
|
-
// the write. The line rides the editor's own hint row, so it stays on screen while typing.
|
|
1475
|
-
setStatus(fill(stringsRef.current.settingsChoiceNoChoice, { kind: String(key.kind ?? '') }))
|
|
1476
|
-
}
|
|
1622
|
+
|
|
1477
1623
|
},
|
|
1478
|
-
[buildCategoryEntries, buildChoiceEntries, openCompose,
|
|
1624
|
+
[buildCategoryEntries, buildChoiceEntries, openCompose, enterSettingsPage, saveLimits, closeSettingsView, settingsRowsNow],
|
|
1479
1625
|
)
|
|
1480
1626
|
|
|
1481
1627
|
/** The detail view's file tabs: `←`/`→` clamp at the ends (no wrap — the row shows the order). */
|
|
@@ -1766,7 +1912,7 @@ export function App({
|
|
|
1766
1912
|
const bottom: string[] = []
|
|
1767
1913
|
if (!composing) {
|
|
1768
1914
|
const notice = receipt ? receiptLine(receipt, strings) : status
|
|
1769
|
-
if (notice) bottom.push(notice)
|
|
1915
|
+
if (notice) bottom.push(...notice.split('\n'))
|
|
1770
1916
|
}
|
|
1771
1917
|
const boxed = composing && settings.density === 'comfortable'
|
|
1772
1918
|
const inputWidth = boxed ? Math.max(1, size.columns - 2) : size.columns
|
|
@@ -1783,7 +1929,8 @@ export function App({
|
|
|
1783
1929
|
? strings.composeStandbyTitle
|
|
1784
1930
|
: mode === 'filter'
|
|
1785
1931
|
? strings.settingFilterTitle
|
|
1786
|
-
:
|
|
1932
|
+
: ruleFieldRef.current ? ruleFieldRef.current === 'model' ? strings.settingsRuleModel : strings.settingsRuleCount
|
|
1933
|
+
: settingRowRef.current ? settingLabel(strings, settingRowRef.current.key) : strings.settingsViewTitle
|
|
1787
1934
|
const input = boxed
|
|
1788
1935
|
? [composeTrayTop(trayTitle, size.columns), ...rawInput.map((line) => `${TRAY_V} ${line}`)]
|
|
1789
1936
|
: rawInput
|
|
@@ -1792,7 +1939,7 @@ export function App({
|
|
|
1792
1939
|
// The setting/filter editor's own receipt (the confirmation line, the danger warning, the
|
|
1793
1940
|
// command's refusal) rides the hint row *above* the input so the input line stays last
|
|
1794
1941
|
// (the IME cursor anchor rule) while the editor stays open with its draft.
|
|
1795
|
-
...(status && (mode === 'setting' || mode === 'filter') ?
|
|
1942
|
+
...(status && (mode === 'setting' || mode === 'filter') ? status.split('\n') : []),
|
|
1796
1943
|
// P249: a message send that could not settle cleanly (the error class, or a draft file the
|
|
1797
1944
|
// console could not empty) keeps the compose open, so its receipt rides the same row — the
|
|
1798
1945
|
// words and the reason are visible together.
|
|
@@ -1801,7 +1948,8 @@ export function App({
|
|
|
1801
1948
|
? strings.composeHint
|
|
1802
1949
|
: mode === 'reason'
|
|
1803
1950
|
? strings.composeReasonHint
|
|
1804
|
-
: strings.
|
|
1951
|
+
: ruleFieldRef.current ? strings.settingsFieldHint : settingConfirm ? strings.settingsConfirmHint
|
|
1952
|
+
: isSecondsSetting(settingRowRef.current?.key ?? '') ? strings.settingsSecondsEditHint : strings.settingsEditHint,
|
|
1805
1953
|
]
|
|
1806
1954
|
: []
|
|
1807
1955
|
// The in-flight-send row is part of the pane too: counting it keeps the rendered output at the
|
|
@@ -1828,6 +1976,10 @@ export function App({
|
|
|
1828
1976
|
detailIndex,
|
|
1829
1977
|
detailScroll,
|
|
1830
1978
|
settings: settingsView,
|
|
1979
|
+
settingsEditing: composing,
|
|
1980
|
+
settingsPage,
|
|
1981
|
+
limitsDraft,
|
|
1982
|
+
settingsDetails,
|
|
1831
1983
|
settingsFocus,
|
|
1832
1984
|
settingsFilter,
|
|
1833
1985
|
settingsOffset,
|
|
@@ -1881,6 +2033,9 @@ export function App({
|
|
|
1881
2033
|
detailIndex,
|
|
1882
2034
|
detailScroll,
|
|
1883
2035
|
settingsView,
|
|
2036
|
+
settingsPage,
|
|
2037
|
+
limitsDraft,
|
|
2038
|
+
settingsDetails,
|
|
1884
2039
|
settingsFocus,
|
|
1885
2040
|
settingsFilter,
|
|
1886
2041
|
settingsOffset,
|