teamsmith 0.4.6 → 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.
Files changed (91) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +35 -0
  4. package/skills/teamsmith/SKILL.md +43 -30
  5. package/skills/teamsmith/extension/team-bg.ts +5 -3
  6. package/skills/teamsmith/extension/team-inbox-watch.ts +14 -3
  7. package/skills/teamsmith/extension/team-notify.ts +20 -13
  8. package/skills/teamsmith/extension/team-remind.ts +189 -0
  9. package/skills/teamsmith/extension/team-reply.ts +4 -7
  10. package/skills/teamsmith/references/config.md +11 -12
  11. package/skills/teamsmith/references/migration.md +101 -0
  12. package/skills/teamsmith/references/openspec.md +43 -27
  13. package/skills/teamsmith/references/protocol.md +26 -15
  14. package/skills/teamsmith/references/reminders.md +153 -161
  15. package/skills/teamsmith/references/troubleshooting.md +12 -7
  16. package/skills/teamsmith/references/workflows.md +84 -31
  17. package/skills/teamsmith/scripts/lib/cmd-agents.sh +10 -4
  18. package/skills/teamsmith/scripts/lib/cmd-project.sh +88 -6
  19. package/skills/teamsmith/scripts/lib/cmd-remind.sh +88 -2
  20. package/skills/teamsmith/scripts/lib/cmd-review.sh +61 -35
  21. package/skills/teamsmith/scripts/lib/cmd-watch.sh +48 -11
  22. package/skills/teamsmith/scripts/lib/common.sh +83 -13
  23. package/skills/teamsmith/scripts/panel/README.md +35 -33
  24. package/skills/teamsmith/scripts/panel/panel.js +217 -199
  25. package/skills/teamsmith/scripts/panel/src/App.tsx +221 -66
  26. package/skills/teamsmith/scripts/panel/src/data.ts +71 -15
  27. package/skills/teamsmith/scripts/panel/src/layout.ts +159 -310
  28. package/skills/teamsmith/scripts/panel/src/main.tsx +83 -21
  29. package/skills/teamsmith/scripts/panel/src/project-settings.ts +46 -0
  30. package/skills/teamsmith/scripts/panel/src/strings/en.ts +71 -205
  31. package/skills/teamsmith/scripts/panel/src/strings/index.ts +3 -5
  32. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +72 -204
  33. package/skills/teamsmith/scripts/panel/src/types.ts +23 -4
  34. package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
  35. package/skills/teamsmith/scripts/remind-store.mjs +55 -24
  36. package/skills/teamsmith/scripts/remind-tick.mjs +5 -2
  37. package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
  38. package/skills/teamsmith/scripts/state-authority.mjs +72 -6
  39. package/skills/teamsmith/scripts/strings/commands.tsv +1 -1
  40. package/skills/teamsmith/scripts/team +1 -0
  41. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +18 -8
  42. package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
  43. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
  44. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
  45. package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
  46. package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -25
  47. package/skills/teamsmith/templates/report.md.tmpl +33 -0
  48. package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
  49. package/skills/teamsmith/tests/bg-ledger.sh +24 -10
  50. package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
  51. package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
  52. package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
  53. package/skills/teamsmith/tests/help-surface.sh +78 -12
  54. package/skills/teamsmith/tests/install-shape.sh +7 -7
  55. package/skills/teamsmith/tests/isolation-ledger.sh +6 -2
  56. package/skills/teamsmith/tests/key-replies-ui.sh +64 -5
  57. package/skills/teamsmith/tests/key-replies.sh +307 -106
  58. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +2 -0
  59. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +255 -90
  60. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +181 -61
  61. package/skills/teamsmith/tests/lib/model-routing-roles.sh +125 -67
  62. package/skills/teamsmith/tests/lib/reply-fixture.sh +14 -9
  63. package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
  64. package/skills/teamsmith/tests/lib/tmp-root.sh +1 -1
  65. package/skills/teamsmith/tests/loop-inventory.tsv +3 -0
  66. package/skills/teamsmith/tests/panel-b2.sh +91 -31
  67. package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
  68. package/skills/teamsmith/tests/panel-p21.sh +607 -1162
  69. package/skills/teamsmith/tests/panel-strings.mjs +21 -113
  70. package/skills/teamsmith/tests/remind-adversarial-faults.mjs +190 -0
  71. package/skills/teamsmith/tests/remind-adversarial-faults.sh +78 -0
  72. package/skills/teamsmith/tests/remind-adversarial-real.sh +28 -0
  73. package/skills/teamsmith/tests/remind-cli.sh +108 -3
  74. package/skills/teamsmith/tests/remind-delivery-node.mjs +13 -0
  75. package/skills/teamsmith/tests/remind-delivery.sh +123 -35
  76. package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
  77. package/skills/teamsmith/tests/remind-pulse.sh +199 -0
  78. package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
  79. package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
  80. package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
  81. package/skills/teamsmith/tests/remind-tool-real.mjs +801 -0
  82. package/skills/teamsmith/tests/remind-tool-real.sh +180 -0
  83. package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
  84. package/skills/teamsmith/tests/routes.sh +213 -293
  85. package/skills/teamsmith/tests/section-paths.tsv +19 -17
  86. package/skills/teamsmith/tests/smoke.sh +583 -133
  87. package/skills/teamsmith/tests/state-authority.sh +152 -8
  88. package/skills/teamsmith/tests/task-model-routing.sh +57 -26
  89. package/skills/teamsmith/tests/tmp-hygiene.sh +1 -1
  90. package/skills/teamsmith-init/SKILL.md +5 -5
  91. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
@@ -19,6 +19,7 @@
19
19
  // one summary line when the height runs out → blocks collapse entirely, and the minimal tier drops
20
20
  // table columns / abbreviates states. Blocks whose source has no data collapse and yield the space.
21
21
 
22
+ import { MODEL_SETTINGS, CHECK_SETTINGS, COMMAND_SETTINGS, effectiveSetting, isSecondsSetting, settingTiming, settingsPageTitle, limitsTokens, limitFields, limitsValue, limitsDisplay } from './project-settings.js'
22
23
  import { fmtAge, fmtMB, GLYPH, clockOf, shortBranch, sparkline } from './format.js'
23
24
  import { markdownMemo } from './markdown.js'
24
25
  import { fill, keyLabel, OVERLAY_LABEL_W } from './strings/index.js'
@@ -37,7 +38,6 @@ import type {
37
38
  Frame,
38
39
  FrameInput,
39
40
  Hit,
40
- Impediment,
41
41
  LaneWindow,
42
42
  Line,
43
43
  PageId,
@@ -58,6 +58,8 @@ import type {
58
58
  SettingsKey,
59
59
  SettingsPmLaunch,
60
60
  SettingsWindow,
61
+ SettingsPage,
62
+ LimitsDraft,
61
63
  Tone,
62
64
  ViewState,
63
65
  } from './types.js'
@@ -1343,13 +1345,19 @@ function replyRowLabel(e: ReplyEntry): string {
1343
1345
  return e.available ? `#${e.no} ${e.title}` : ''
1344
1346
  }
1345
1347
 
1346
- /** Reader's local clock, `MM-DD HH:MM`: when a reply was published, in the list itself. */
1347
- function replyTimeLabel(at: string | undefined): string {
1348
+ /** Reader's local clock: compact for rows/summary, full date and actual offset for the viewer. */
1349
+ function replyTimeLabel(at: string | undefined, full = false): string {
1348
1350
  if (!at) return ''
1349
1351
  const when = new Date(at)
1350
1352
  if (Number.isNaN(when.getTime())) return ''
1351
1353
  const pad = (n: number): string => String(n).padStart(2, '0')
1352
- return `${pad(when.getMonth() + 1)}-${pad(when.getDate())} ${pad(when.getHours())}:${pad(when.getMinutes())}`
1354
+ const compact = `${pad(when.getMonth() + 1)}-${pad(when.getDate())} ${pad(when.getHours())}:${pad(when.getMinutes())}`
1355
+ if (!full) return compact
1356
+ const offsetMinutes = -when.getTimezoneOffset()
1357
+ const offsetSign = offsetMinutes >= 0 ? '+' : '-'
1358
+ const absoluteOffset = Math.abs(offsetMinutes)
1359
+ const offset = `${offsetSign}${pad(Math.floor(absoluteOffset / 60))}:${pad(absoluteOffset % 60)}`
1360
+ return `${String(when.getFullYear()).padStart(4, '0')}-${compact} ${offset}`
1353
1361
  }
1354
1362
 
1355
1363
  /** The nav row of page 5: Older / Newer / `r` (the same actions `←`/`→` and `r` fire). */
@@ -1423,12 +1431,13 @@ function replyListBlock(ctx: Ctx): Block | null {
1423
1431
  const active = i === focus
1424
1432
  const cursor = active ? s.settingsCursor : ' '
1425
1433
  const head = ` ${cursor} `
1434
+ const at = e.available ? replyTimeLabel(e.at) : ''
1426
1435
  const bodyLine: Line = e.available
1427
1436
  ? ln(
1428
1437
  seg(head, 'accent'),
1429
1438
  seg(replyRowLabel(e), active ? 'selected' : 'text'),
1430
1439
  seg(` · ${e.from}`, 'dim'),
1431
- ...(replyTimeLabel(e.at) ? [seg(` · ${replyTimeLabel(e.at)}`, 'dim')] : []),
1440
+ ...(at ? [seg(` · ${at}`, 'dim')] : []),
1432
1441
  )
1433
1442
  : ln(
1434
1443
  seg(head, 'accent'),
@@ -1485,9 +1494,11 @@ function replyViewerBlock(ctx: Ctx): Block | null {
1485
1494
  if (data.available === false) {
1486
1495
  return build([nav, { line: truncLine(ln(seg(` ${s.replyBodyMissing}`, 'warn')), innerW) }, backLine], { no, total: 0, visible: 0, offset: 0 })
1487
1496
  }
1497
+ const at = replyTimeLabel(data.at, true)
1498
+ const declared = fill(at ? s.replyDeclared : s.replyDeclaredShort, { from: data.from, at })
1488
1499
  const meta: PlacedLine[] = [
1489
1500
  { line: truncLine(ln(seg(` ${data.title}`, 'heading')), innerW) },
1490
- { line: truncLine(ln(seg(` ${fill(s.replyDeclared, { from: data.from, at: data.at })}`, 'dim')), innerW) },
1501
+ { line: truncLine(ln(seg(` ${declared}`, 'dim')), innerW) },
1491
1502
  { line: truncLine(ln(seg(` ${s.replyBodyHint} · ${data.bytes} B`, 'dim')), innerW) },
1492
1503
  ]
1493
1504
  const doc = markdownMemo(`reply:${no}`, data.display_text ?? '', innerW)
@@ -1523,9 +1534,12 @@ function replySummaryBlock(ctx: Ctx): Block | null {
1523
1534
  line.push(seg(text, 'text'))
1524
1535
  hits.push({ start: x, end: x + dispWidth(text), action: { kind: 'reply-open-latest', no: entry.no } })
1525
1536
  x += dispWidth(text)
1526
- const at = ` · ${entry.at}`
1527
- line.push(seg(at, 'dim'))
1528
- x += dispWidth(at)
1537
+ const at = replyTimeLabel(entry.at)
1538
+ if (at) {
1539
+ const suffix = ` · ${at}`
1540
+ line.push(seg(suffix, 'dim'))
1541
+ x += dispWidth(suffix)
1542
+ }
1529
1543
  } else if (d.state === 'empty') {
1530
1544
  line.push(seg(s.replyEmpty, 'dim'))
1531
1545
  } else {
@@ -1547,105 +1561,20 @@ function replySummaryBlock(ctx: Ctx): Block | null {
1547
1561
 
1548
1562
  // ------------------------------------------------------------------ project settings (P22/B2)
1549
1563
  //
1550
- // The view is a listing of the contract: one row per schema key plus one per key the file carries
1551
- // that the schema does not know, grouped by the functional domain the **command** reports on the
1552
- // row's `group` (P30 — the console owns no second table). Under the keys the view carries the two
1553
- // halves of the model policy the command reports (P232): the **future** policy's category rows
1554
- // (editable, one `set-task-model` per row) and the **committed** assignments plus the PM launch
1555
- // record (read-only). The two halves are rendered under separate headings and never merged: a
1556
- // future category model is never displayed as a seat's actual model.
1557
- //
1558
- // Rows, groups and classes come from the `settings` block's JSON at render time; a key added to the
1559
- // command's schema shows up without rebuilding `panel.js`. The list is windowed against the height
1560
- // the assembly hands over (the bounded-frame rule: more pane means more rows, never more blank).
1561
-
1562
- // The row's identity column is a **label** (M49), not the key name: the table's labels are human
1563
- // sentences, so the column only has to hold the longest of them (zh is the wide language here;
1564
- // a longer en label is cut by `cell()`, the same rule the key names followed).
1565
- const SETTINGS_LABEL_W = 22
1566
- /** P232: the policy migration diagnosis is shown above the audit tail; the rest is counted. */
1567
- const SETTINGS_DIAG_LINES = 2
1568
- /** P232: how many frame lines one diagnosis line may wrap to before it is cut with an ellipsis. */
1569
- const SETTINGS_DIAG_WRAP = 2
1570
- // The tail the block draws under its row window: the focused row's CLI hint and, when the command
1571
- // reports one, the policy migration diagnosis (P266: the audit tail is no longer drawn here — the
1572
- // log stays readable through `team config list`'s own footer and `team config log`, and the console
1573
- // is deliberately not one of its readers), plus `SETTINGS_COUNT_ROWS`, the pessimistic reservation
1574
- // for the two hidden-row counts (`↑n`/`↓n`). Reserving **both** counts is what keeps the block inside
1575
- // the frame once the list is longer than the window: with only the tail reserved, a full window
1576
- // plus a full tail overflowed and the whole view degraded to its one-line summary (measured in
1577
- // M55's pairlist route: the seats block the route had just focused disappeared from the frame).
1578
- //
1579
- // P32 (the user's second report, 2026-09-22): the reservation is a *ceiling*, not a fixed cost. The
1580
- // window spends what the tail does not need (a count line is only drawn when the window really
1581
- // hides rows at that edge), and the block pads its card to the lines it was handed — so the pane's
1582
- // height shows contract rows instead of the page's blank space.
1564
+ // Selected operations use the existing command read; navigation is local to this view.
1565
+ const SETTINGS_LABEL_W = 30
1583
1566
  const SETTINGS_COUNT_ROWS = 2
1584
-
1585
- /**
1586
- * The two pickers' *paged* list bound (M55's calibrated value, kept: a picker covers the row list, so
1587
- * this reservation is its own chrome — title + interval + the two hidden-count lines + blank + hint).
1588
- * A long vocabulary shows a `↑n`/`↓n` window that scrolls instead of flooding the pane, which is what
1589
- * the archived `choices` fixture calibrates its twenty-eight model records against. Their cards still
1590
- * fill (the pad below), so the key band stays the frame's last row.
1591
- */
1592
1567
  const SETTINGS_TAIL_ROWS = SETTINGS_COUNT_ROWS + 6
1593
-
1594
- /** One drawn row of the project-settings view (group headings are not focusable). */
1595
1568
  export type SettingsRow =
1596
1569
  | { kind: 'group'; label: string; tone: Tone }
1597
1570
  | { kind: 'key'; key: SettingsKey }
1598
1571
  | { kind: 'category'; category: SettingsCategory }
1599
1572
  | { kind: 'assignment'; assignment: SettingsAssignment }
1600
1573
  | { kind: 'pm-launch'; launch: SettingsPmLaunch }
1574
+ | { kind: 'nav'; page: 'commands' | 'records'; label: string }
1575
+ | { kind: 'info'; text: string }
1576
+ | { kind: 'rule'; action: 'select' | 'add' | 'save' | 'model' | 'count' | 'delete'; index: number; label: string; value: string }
1601
1577
 
1602
- export function settingsClassLabel(s: Strings, cls: string): string {
1603
- if (cls === 'restart') return s.settingsBadgeRestart
1604
- if (cls === 'refuse') return s.settingsBadgeRefuse
1605
- return s.settingsBadgeApply
1606
- }
1607
-
1608
- /**
1609
- * The effect class's tone (P30/D4): the *badge*'s tone, never the whole row's. `restart` is the one
1610
- * class that warns, `refuse` recedes, and `apply` stays the plain text tone — 48 of 111 rows would
1611
- * shout in green while the user's question is "does this need a restart?". Colour is never the only
1612
- * channel: the badge's word always carries the class (the panel's standing rule).
1613
- */
1614
- /**
1615
- * The declared marker the owning command puts at the start of a fixture-only key's note
1616
- * (`memory-and-deps` owns the marker). The hiding rule reads the read's data and nothing else: no
1617
- * key list is baked into the bundle, so a fixture key added to the schema stays hidden and one whose
1618
- * marker is removed comes back without rebuilding `panel.js`.
1619
- */
1620
- const SETTINGS_FIXTURE_ONLY_MARKER = 'fixture-only: '
1621
-
1622
- function settingsKeyHidden(k: SettingsKey): boolean {
1623
- return String(k.route ?? '').startsWith(SETTINGS_FIXTURE_ONLY_MARKER)
1624
- }
1625
-
1626
- function settingsClassTone(cls: string): Tone {
1627
- if (cls === 'restart') return 'warn'
1628
- if (cls === 'refuse') return 'dim'
1629
- return 'text'
1630
- }
1631
-
1632
- /**
1633
- * A functional group's heading label: `group_<token>` from the tables, falling back to the raw
1634
- * token when the table has none (a schema freshly edited against the committed bundle) — the same
1635
- * visible fallback `keyLabel` uses for an unknown key. Nothing here maps a key to a group.
1636
- */
1637
- function groupLabel(s: Strings, token: string): string {
1638
- const label = s[`group_${token}`]
1639
- return typeof label === 'string' && label.length > 0 ? label : token
1640
- }
1641
-
1642
- /**
1643
- * The CLI's own three source labels (the console invents no fourth state).
1644
- *
1645
- * The committed record's provenance: `selected_via`/`launch_via` are the CLI's own closed tokens
1646
- * (`explicit`/`policy`/`assignment`, plus the legacy spellings it still reports). The console only
1647
- * spells them; it never derives them.
1648
- */
1649
1578
  export function settingsSourceLabel(s: Strings, source: string): string {
1650
1579
  if (source === 'explicit') return s.seatSourceExplicit
1651
1580
  if (source === 'policy') return s.seatSourcePolicy
@@ -1654,117 +1583,82 @@ export function settingsSourceLabel(s: Strings, source: string): string {
1654
1583
  return source || s.dash
1655
1584
  }
1656
1585
 
1657
- /**
1658
- * The view's filtered row list: the contract's keys grouped by the **record's** `group` (P30/D1-D3),
1659
- * in the read's own order, then the future policy's category rows and the committed assignments.
1660
- * Pure and exported: the App walks exactly this list when it moves the focus, so the keys can never
1661
- * disagree with what is on screen.
1662
- *
1663
- * The bundle owns no key→group table and no group list: the walk opens a heading whenever the
1664
- * token changes, so a key (or a whole group) added to the command's schema appears under its
1665
- * reported heading with the committed bundle. Rows whose token is empty — a schema row that
1666
- * declares none, or a key the file carries and the schema does not know — are never dropped: they
1667
- * collect into one visible trailing fallback heading, before the categories block.
1668
- *
1669
- * P232: the categories block (the future policy) comes before the assignments block (the committed
1670
- * records), each with its own heading, so "what the next task will use" and "what is actually
1671
- * running" are never read as the same list. A seat with no complete record still gets a row that
1672
- * says so — it is never filled in from the policy above.
1673
- */
1674
- export function settingsViewRows(block: SettingsBlock | undefined, filter: string, s: Strings): SettingsRow[] {
1586
+ export function settingsViewRows(block: SettingsBlock | undefined, filter: string, s: Strings,
1587
+ page: SettingsPage = 'main', limits?: LimitsDraft | null, details?: string[] | null, detailWidth = 120): SettingsRow[] {
1588
+ if (details) return details.flatMap((line) => line.split('\n').flatMap((text) => diagnoseChunks(text, Math.max(1, detailWidth - 3), Infinity)).map((text) => ({ kind: 'info' as const, text })))
1675
1589
  const out: SettingsRow[] = []
1676
1590
  if (!block || !Array.isArray(block.keys)) return out
1677
- const needle = String(filter ?? '').trim().toLowerCase()
1678
- const match = (...parts: string[]): boolean =>
1679
- needle === '' || parts.some((p) => String(p ?? '').toLowerCase().includes(needle))
1680
- // The label first (what the row shows), then the raw key and the value — the three inputs a
1681
- // user may type into `/` (the label's words, `TEAM_…`, or the value on screen).
1682
- // P266: a key the read marks fixture-only is not a row at all — no row, no heading of its own and
1683
- // no `/` hit (it is dropped before the match, so not even its label or raw name can reach it).
1684
- const shown = block.keys.filter(
1685
- (k) =>
1686
- !settingsKeyHidden(k) &&
1687
- match(keyLabel(s, k.name), k.name, k.value, k.default, k.comment, k.warning, k.route ?? ''),
1688
- )
1689
- const ungrouped: SettingsKey[] = []
1690
- let openToken: string | null = null
1691
- for (const k of shown) {
1692
- const token = String(k.group ?? '')
1693
- if (!token) {
1694
- ungrouped.push(k)
1695
- continue
1696
- }
1697
- if (token !== openToken) {
1698
- out.push({ kind: 'group', label: groupLabel(s, token), tone: 'heading' })
1699
- openToken = token
1591
+ const needle = filter.trim().toLowerCase()
1592
+ const match = (...parts: string[]): boolean => !needle || parts.some((p) => String(p ?? '').toLowerCase().includes(needle))
1593
+ const keys = (names: readonly string[]): SettingsRow[] => names.flatMap((name) => {
1594
+ const key = block.keys.find((k) => k.name === name)
1595
+ return key && match(keyLabel(s, name), name, effectiveSetting(key)) ? [{ kind: 'key' as const, key }] : []
1596
+ })
1597
+ const group = (label: string, rows: SettingsRow[]): void => {
1598
+ if (rows.length) out.push({ kind: 'group', label, tone: 'heading' }, ...rows)
1599
+ }
1600
+ if ((page === 'limits' || page === 'rule') && limits) {
1601
+ if (limits.confirm) {
1602
+ out.push({ kind: 'group', label: s.settingsOld, tone: 'heading' },
1603
+ ...limitsDisplay(limits.original, s).flatMap((text) => diagnoseChunks(text, Math.max(1, detailWidth - 3), Infinity)).map((text) => ({ kind: 'info' as const, text })),
1604
+ { kind: 'group', label: s.settingsNew, tone: 'heading' },
1605
+ ...limitsDisplay(limitsValue(limits), s).flatMap((text) => diagnoseChunks(text, Math.max(1, detailWidth - 3), Infinity)).map((text) => ({ kind: 'info' as const, text })),
1606
+ { kind: 'rule', action: 'save', index: 0, label: s.settingsSave, value: '' })
1607
+ } else if (page === 'rule') {
1608
+ const [model, count] = limitFields(limits.tokens[limits.rule])
1609
+ out.push(
1610
+ { kind: 'rule', action: 'model', index: limits.rule, label: s.settingsRuleModel, value: model },
1611
+ { kind: 'rule', action: 'count', index: limits.rule, label: s.settingsRuleCount, value: count === '0' ? s.settingsRuleUnlimited : count },
1612
+ { kind: 'rule', action: 'delete', index: limits.rule, label: s.settingsRuleDelete, value: '' })
1613
+ } else {
1614
+ limits.tokens.forEach((token, index) => {
1615
+ const [model, count] = limitFields(token)
1616
+ out.push({ kind: 'rule', action: 'select', index, label: model, value: count === '0' ? s.settingsRuleUnlimited : count })
1617
+ })
1618
+ out.push({ kind: 'rule', action: 'add', index: 0, label: s.settingsRuleAdd, value: '' },
1619
+ { kind: 'rule', action: 'save', index: 0, label: s.settingsSave, value: '' })
1700
1620
  }
1701
- out.push({ kind: 'key', key: k })
1702
- }
1703
- if (ungrouped.length) {
1704
- out.push({ kind: 'group', label: s.settingsGroupUngrouped, tone: 'heading' })
1705
- for (const k of ungrouped) out.push({ kind: 'key', key: k })
1706
- }
1707
- const categories = (block.models?.policy?.categories ?? []).filter((c) =>
1708
- match(fill(s.settingsCategoryRow, { category: c.category }), c.category, c.model),
1709
- )
1710
- if (categories.length) {
1711
- out.push({ kind: 'group', label: s.settingsGroupCategories, tone: 'heading' })
1712
- for (const c of categories) out.push({ kind: 'category', category: c })
1713
- }
1714
- // P266: the command's diagnostic is deliberately not searchable here — it never reaches the
1715
- // screen, so `/` must not find a row for a string the user cannot see anywhere.
1716
- const assignments = (block.models?.assignments ?? []).filter((a) =>
1717
- match(a.agent, a.task, a.category, a.model, a.sid, a.selected_via, a.launch_via),
1718
- )
1719
- const launch = block.models?.pm_launch ?? {}
1720
- const launchShown =
1721
- Object.keys(launch).length > 0 &&
1722
- match(s.settingsPmLaunchLabel, String(launch.model ?? ''), String(launch.mode ?? ''), String(launch.window ?? ''))
1723
- if (assignments.length || launchShown) {
1724
- out.push({ kind: 'group', label: s.settingsGroupAssignments, tone: 'heading' })
1725
- for (const a of assignments) out.push({ kind: 'assignment', assignment: a })
1726
- if (launchShown) out.push({ kind: 'pm-launch', launch })
1621
+ return out
1727
1622
  }
1623
+ if (page === 'records') {
1624
+ for (const assignment of block.models?.assignments ?? []) {
1625
+ if (match(assignment.agent, assignment.task, assignment.category, assignment.model, assignment.sid, assignment.selected_via, assignment.launch_via))
1626
+ out.push({ kind: 'assignment', assignment })
1627
+ }
1628
+ const launch = block.models?.pm_launch ?? {}
1629
+ if (Object.keys(launch).length && match(s.settingsPmLaunchLabel, ...Object.values(launch))) out.push({ kind: 'pm-launch', launch })
1630
+ } else if (page === 'commands') {
1631
+ out.push(...keys(COMMAND_SETTINGS))
1632
+ } else {
1633
+ group(s.settingsGroupCategories, [
1634
+ ...(block.models?.policy?.categories ?? []).filter((c) => match(c.category, c.model)).map((category) => ({ kind: 'category' as const, category })),
1635
+ ...keys(MODEL_SETTINGS)])
1636
+ group(s.settingsChecks, keys(CHECK_SETTINGS))
1637
+ for (const [page, label] of [['commands', s.settingsCommands], ['records', s.settingsRecords]] as const)
1638
+ if (match(label)) out.push({ kind: 'nav', page, label })
1639
+ }
1640
+ // Errors are independent of filtering: hiding keys must not hide genuine diagnostics.
1641
+ const errors = [...String(block.models?.diagnostic ?? '').split('\n').filter(Boolean),
1642
+ ...block.keys.filter((k) => k.warning).map((k) => [k.warning, k.route].filter(Boolean).join('\n'))]
1643
+ if (errors.length) out.push({ kind: 'group', label: s.settingsDiagnosisHeading, tone: 'warn' })
1644
+ for (const text of errors) out.push({ kind: 'info', text })
1728
1645
  return out
1729
1646
  }
1730
-
1731
- /** True for the rows the focus walk may stop on (headings are not focusable). */
1732
1647
  export function settingsRowFocusable(row: SettingsRow): row is Exclude<SettingsRow, { kind: 'group' }> {
1733
1648
  return row.kind !== 'group'
1734
1649
  }
1735
-
1736
- /**
1737
- * The badge + value column shared by a key row and a seat row. The class tone covers the **badge
1738
- * only** (P30/D4): the value beside it stays in the plain text tone, because a class meaning is
1739
- * not a property of the value. A row with no badge (the seats) keeps its single-tone right column.
1740
- */
1741
1650
  function settingsRight(ctx: Ctx, text: string, badge: string, tone: Tone, innerW: number): Line {
1742
- const shown = truncateW(text, Math.max(6, innerW - SETTINGS_LABEL_W - 14))
1743
- return badge === '' ? ln(seg(` ${shown}`, tone)) : ln(seg(` ${shown} · `, 'text'), seg(badge, tone))
1651
+ return ln(seg(' ' + truncateW(text, Math.max(6, innerW - Math.min(SETTINGS_LABEL_W, Math.floor(innerW / 2)) - 4)), tone))
1744
1652
  }
1745
-
1746
1653
  function settingsKeyLine(ctx: Ctx, row: SettingsKey, focused: boolean, innerW: number): PlacedLine {
1747
- const { s } = ctx
1748
- const known = row.known !== false
1749
- const valueText =
1750
- row.set || row.value !== ''
1751
- ? row.value === ''
1752
- ? '\"\"'
1753
- : row.value
1754
- : fill(s.settingsUnset, { value: row.default || s.dash })
1755
- const badge = known ? settingsClassLabel(s, row.class) : s.settingsUnknownBadge
1756
- const tone: Tone = known ? settingsClassTone(row.class) : 'dim'
1757
- const line = ln(
1758
- seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1759
- // The row's main text is the human label; the raw key is not repeated here (it stays in the
1760
- // editor's title, the confirmation line and the view's CLI hint — the places where the user
1761
- // types the key into `team config set`). An unknown key has no label → its raw name (M49).
1762
- seg(cell(keyLabel(s, row.name), SETTINGS_LABEL_W), focused ? 'selected' : known ? 'heading' : 'dim'),
1763
- ...settingsRight(ctx, valueText, badge, tone, innerW).map((x) => x),
1764
- )
1765
- const note = (row.warning || row.route || row.comment || '').trim()
1766
- if (note) line.push(seg(` ${truncateW(note, Math.max(8, innerW - dispWidth(textOf(line)) - 2))}`, row.warning ? 'warn' : row.route && !known ? 'warn' : 'dim'))
1767
- return { line }
1654
+ const value = effectiveSetting(row)
1655
+ const summary = row.name === 'TEAM_MODEL_LIMITS' && limitsTokens(value) !== null
1656
+ ? fill(ctx.s.settingsEntries, { n: String(limitsTokens(value)!.length) })
1657
+ : row.kind === 'bool' && (value === '0' || value === '1') ? value === '1' ? ctx.s.settingsBoolOn : ctx.s.settingsBoolOff
1658
+ : value ? isSecondsSetting(row.name) ? `${value} ${ctx.s.settingsSeconds}` : value : ctx.s.settingsUnfilled
1659
+ return { line: ln(seg(`${focused ? ctx.s.settingsCursor : ' '} `, 'accent'),
1660
+ seg(cell(keyLabel(ctx.s, row.name), Math.min(SETTINGS_LABEL_W, Math.floor(innerW / 2))), focused ? 'selected' : 'heading'),
1661
+ ...settingsRight(ctx, summary, '', 'text', innerW)) }
1768
1662
  }
1769
1663
 
1770
1664
  /**
@@ -1827,70 +1721,45 @@ function diagnoseChunks(text: string, width: number, maxLines: number): string[]
1827
1721
  /**
1828
1722
  * One future-policy category row (P232). The category token is the row's identity (the project
1829
1723
  * defines it; there is no table entry for a project's own vocabulary), the value is the model the
1830
- * next new task of that category will get, and the badge says "new tasks" so the row cannot be
1831
- * read as a running seat. The command line under the list names the one write it offers.
1724
+ * next new task of that category will get. Only the selected operation adds its new-task timing.
1832
1725
  */
1833
1726
  function settingsCategoryLine(ctx: Ctx, cat: SettingsCategory, focused: boolean, innerW: number): PlacedLine {
1834
1727
  const { s } = ctx
1835
1728
  const line = ln(
1836
1729
  seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1837
- seg(cell(fill(s.settingsCategoryRow, { category: cat.category }), SETTINGS_LABEL_W), focused ? 'selected' : 'heading'),
1838
- ...settingsRight(ctx, cat.model || s.dash, s.settingsCategoryBadge, 'text', innerW).map((x) => x),
1730
+ seg(cell(fill(s.settingsCategoryRow, { category: cat.category }), Math.min(SETTINGS_LABEL_W, Math.floor(innerW / 2))), focused ? 'selected' : 'heading'),
1731
+ ...settingsRight(ctx, cat.model || s.dash, '', 'text', innerW).map((x) => x),
1839
1732
  )
1840
1733
  return { line }
1841
1734
  }
1842
1735
 
1843
1736
  /**
1844
- * One read-only committed assignment row (P232): the seat, its actual model, the origin tokens the
1845
- * CLI recorded and — on the note — the task, category and SID. `assigned=false` shows the command's
1846
- * own diagnostic instead of inventing a model from the policy above.
1737
+ * Read-only dispatch facts. Missing and unreadable records remain distinct; the full model,
1738
+ * task, category, session and source fields are available in the selected details.
1847
1739
  */
1740
+ export function settingsRecordDetails(row: Extract<SettingsRow, {kind: 'assignment' | 'pm-launch'}>, s: Strings): string[] {
1741
+ if (row.kind === 'assignment') {
1742
+ const a = row.assignment
1743
+ if (!a.assigned) return [a.record_present === false ? s.settingsAssignmentNone : s.settingsAssignmentUnreadable]
1744
+ return [
1745
+ [s.settingsRecordTask, a.task], [s.settingsRecordCategory, a.category], [s.settingsRecordModel, a.model],
1746
+ [s.settingsRecordSid, a.sid], [s.settingsRecordSelected, settingsSourceLabel(s, a.selected_via)],
1747
+ [s.settingsRecordLaunch, settingsSourceLabel(s, a.launch_via)],
1748
+ ].map(([label, value]) => label + ': ' + (value || s.dash))
1749
+ }
1750
+ return [[s.settingsRecordModel, row.launch.model], [s.settingsRecordTime, row.launch.time],
1751
+ [s.settingsRecordMode, row.launch.mode === 'fresh' ? s.settingsLaunchFresh : row.launch.mode === 'continued' ? s.settingsLaunchContinued : row.launch.mode], [s.settingsRecordWindow, row.launch.window]].filter(([, value]) => value).map(([label, value]) => label + ': ' + value)
1752
+ }
1848
1753
  function settingsAssignmentLine(ctx: Ctx, a: SettingsAssignment, focused: boolean, innerW: number): PlacedLine {
1849
1754
  const { s } = ctx
1850
- const line = ln(
1851
- seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1852
- seg(cell(a.agent, SETTINGS_LABEL_W), focused ? 'selected' : 'heading'),
1853
- ...settingsRight(
1854
- ctx,
1855
- a.assigned ? a.model || s.dash : s.dash,
1856
- s.settingsReadOnlyBadge,
1857
- 'dim',
1858
- innerW,
1859
- ).map((x) => x),
1860
- )
1861
- // P266: the command's diagnostic string never reaches the screen. The two plain reasons are chosen
1862
- // from the read's own fact (`record_present`): no record file at all vs. a record that exists but
1863
- // cannot be read — a seat that was used is never told it never was.
1864
- const note = a.assigned
1865
- ? fill(s.settingsAssignmentNote, {
1866
- task: a.task || s.dash,
1867
- category: a.category || s.dash,
1868
- sid: a.sid || s.dash,
1869
- selected: settingsSourceLabel(s, a.selected_via),
1870
- launch: settingsSourceLabel(s, a.launch_via),
1871
- })
1872
- : a.record_present === false
1873
- ? s.settingsAssignmentNone
1874
- : s.settingsAssignmentUnreadable
1875
- line.push(seg(` ${truncateW(note, Math.max(8, innerW - dispWidth(textOf(line)) - 2))}`, a.assigned ? 'dim' : 'warn'))
1876
- return { line }
1755
+ return { line: ln(seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1756
+ seg(a.agent + ' ', focused ? 'selected' : 'heading'),
1757
+ seg(a.assigned ? a.task + ' ' : '', 'text'),
1758
+ seg(a.assigned ? a.model || s.dash : a.record_present === false ? s.settingsAssignmentNone : s.settingsAssignmentUnreadable, 'text')) }
1877
1759
  }
1878
-
1879
- /** The PM's own last launch record, read-only — never a worker seat and never a policy row. */
1880
1760
  function settingsPmLaunchLine(ctx: Ctx, launch: SettingsPmLaunch, focused: boolean, innerW: number): PlacedLine {
1881
- const { s } = ctx
1882
- const line = ln(
1883
- seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1884
- seg(cell(s.settingsPmLaunchLabel, SETTINGS_LABEL_W), focused ? 'selected' : 'heading'),
1885
- ...settingsRight(ctx, launch.model || s.dash, s.settingsReadOnlyBadge, 'dim', innerW).map((x) => x),
1886
- )
1887
- const note = fill(s.settingsPmLaunchNote, {
1888
- window: launch.window || s.dash,
1889
- mode: launch.mode || s.dash,
1890
- time: launch.time || s.dash,
1891
- })
1892
- line.push(seg(` ${truncateW(note, Math.max(8, innerW - dispWidth(textOf(line)) - 2))}`, 'dim'))
1893
- return { line }
1761
+ return { line: ln(seg(`${focused ? ctx.s.settingsCursor : ' '} `, 'accent'),
1762
+ seg(ctx.s.settingsPmLaunchLabel + ' ', focused ? 'selected' : 'heading'), seg(launch.model || ctx.s.dash, 'text')) }
1894
1763
  }
1895
1764
 
1896
1765
  /**
@@ -1902,19 +1771,12 @@ function settingsPmLaunchLine(ctx: Ctx, launch: SettingsPmLaunch, focused: boole
1902
1771
  * '' when nothing is focusable.
1903
1772
  */
1904
1773
  function settingsCliHint(s: Strings, rows: SettingsRow[], focus: number): string {
1905
- const focusable = rows.filter(settingsRowFocusable)
1906
- const row = focusable[focus]
1907
- if (!row) return ''
1908
- if (row.kind === 'category') return fill(s.settingsCategoryHint, { category: row.category.category })
1909
- if (row.kind === 'assignment') return s.settingsAssignmentHint
1910
- if (row.kind === 'pm-launch') return s.settingsPmLaunchHint
1911
- const key = row.key
1912
- if (key.known === false) return fill(s.settingsUnknownHint, { key: key.name })
1913
- if (key.class === 'refuse') return s.settingsRefusedHint
1914
- // The whole-map row is not composed here: its editor is the categories block, and the command
1915
- // line the requirement names is the per-category one (P232).
1916
- if (String(key.kind ?? '') === 'task-model-map') return s.settingsCategoryMapHint
1917
- return fill(s.settingsCliHint, { key: key.name })
1774
+ const row = rows.filter(settingsRowFocusable)[focus]
1775
+ if (row?.kind === 'category') return s.settingsNewTasks
1776
+ if (row?.kind !== 'key') return ''
1777
+ if (row.key.class === 'refuse') return row.key.route || row.key.warning || s.settingsRefusedRoute
1778
+ if (row.key.name === 'TEAM_PULSE_MAX_RESTARTS' && effectiveSetting(row.key) === '0') return s.settingsNoRecovery
1779
+ return settingTiming(s, row.key.name)
1918
1780
  }
1919
1781
 
1920
1782
  /**
@@ -1932,7 +1794,7 @@ function settingsBlock(ctx: Ctx): Block | null {
1932
1794
  full: true,
1933
1795
  priority: 1,
1934
1796
  separator: 'none',
1935
- title: s.settingsViewTitle,
1797
+ title: settingsPageTitle(s, ctx.view.settingsPage ?? 'main'),
1936
1798
  lines,
1937
1799
  settings,
1938
1800
  summary: { line: truncLine(ln(seg(` ${s.settingsViewTitle}`, 'heading')), ctx.width) },
@@ -1947,7 +1809,7 @@ function settingsBlock(ctx: Ctx): Block | null {
1947
1809
  ),
1948
1810
  ])
1949
1811
  }
1950
- const rows = settingsViewRows(block, ctx.view.settingsFilter ?? '', s)
1812
+ const rows = settingsViewRows(block, ctx.view.settingsFilter ?? '', s, ctx.view.settingsPage, ctx.view.limitsDraft, ctx.view.settingsDetails, width)
1951
1813
  let count = 0
1952
1814
  for (const r of rows) if (settingsRowFocusable(r)) count += 1
1953
1815
  // P32: the block's budget is the **lines** it may draw below the card frame — the assembly hands
@@ -1959,17 +1821,12 @@ function settingsBlock(ctx: Ctx): Block | null {
1959
1821
  const explicitOffset = ctx.view.settingsOffset
1960
1822
  // P232: the command's own policy diagnosis (missing/retired keys, an unmapped category map) is
1961
1823
  // part of the view: a legacy contract must say so, with the CLI route the command itself names.
1962
- const diagnosis = String(block.models?.diagnostic ?? '')
1963
- .split('\n')
1964
- .map((l) => l.trim())
1965
- .filter((l) => l !== '')
1966
- const diagShown = diagnosis.slice(0, SETTINGS_DIAG_LINES)
1967
- const diagRest = diagnosis.length - diagShown.length
1968
- const diagChunks = diagShown.map((d) => diagnoseChunks(d, Math.max(8, width - 3), SETTINGS_DIAG_WRAP))
1969
- const diagLines = diagChunks.length ? diagChunks.reduce((n, c) => n + c.length, 0) + 1 + (diagRest > 0 ? 1 : 0) : 0
1970
- // P266: the tail is the focused row's CLI hint plus the diagnosis when there is one; the audit
1971
- // tail that used to sit here is no longer drawn (and no longer reads the log).
1972
- const tailLines = 1 + diagLines
1824
+ const focusedRow = rows.filter(settingsRowFocusable)[focus]
1825
+ const selectedHint = focusedRow?.kind === 'assignment' || focusedRow?.kind === 'pm-launch'
1826
+ ? settingsRecordDetails(focusedRow, s).join('\n') : settingsCliHint(s, rows, focus)
1827
+ const hintLines = selectedHint.split('\n').filter(Boolean).flatMap((text) => diagnoseChunks(text, Math.max(8, width - 3), Infinity))
1828
+ const shownHint = hintLines.slice(0, Math.max(0, room - 5))
1829
+ const tailLines = shownHint.length
1973
1830
  // The row cap: each row costs at least its own line, and the tail is already spoken for.
1974
1831
  const desired = Math.max(1, Math.min(Math.max(1, count), Math.max(1, room - tailLines)))
1975
1832
  const maxOffset = Math.max(0, count - desired)
@@ -2065,16 +1922,16 @@ function settingsBlock(ctx: Ctx): Block | null {
2065
1922
  const entryLabel = (e: SettingsChoiceEntry): string => {
2066
1923
  const base =
2067
1924
  e.kind === 'keep-unset'
2068
- ? s.settingsChoiceKeepUnset
1925
+ ? choice.entries.some((entry) => entry.kind === 'default') ? s.settingsChoiceKeepUnset : s.settingsKeepEmpty
2069
1926
  : e.kind === 'clear'
2070
1927
  ? s.settingsChoiceClear
2071
1928
  : e.kind === 'free'
2072
- ? s.settingsChoiceFree
1929
+ ? choice.ruleField ? s.settingsRuleOther : s.settingsChoiceFree
2073
1930
  : choice.kind === 'bool' && (e.value === '1' || e.value === '0')
2074
1931
  ? e.value === '1'
2075
1932
  ? s.settingsBoolOn
2076
1933
  : s.settingsBoolOff
2077
- : e.value
1934
+ : isSecondsSetting(choice.key) ? `${e.value} ${s.settingsSeconds}` : e.value
2078
1935
  const marks: string[] = []
2079
1936
  if (e.kind === 'current') marks.push(s.settingsChoiceCurrent)
2080
1937
  if (e.kind === 'default') marks.push(s.settingsChoiceDefault)
@@ -2083,22 +1940,11 @@ function settingsBlock(ctx: Ctx): Block | null {
2083
1940
  }
2084
1941
  return marks.length ? `${base} · ${marks.join(' · ')}` : base
2085
1942
  }
2086
- put(
2087
- ln(
2088
- seg(
2089
- choice.category
2090
- ? ` ${fill(s.settingsCategoryPickerTitle, { category: choice.key })}`
2091
- : ` ${fill(s.settingsChoiceTitle, { label: keyLabel(s, choice.key), key: choice.key })}`,
2092
- 'heading',
2093
- ),
2094
- ),
2095
- )
2096
- if (choice.category) put(ln(seg(` ${s.settingsCategoryPickerHint}`, 'dim')))
2097
1943
  if (choice.interval) {
2098
1944
  put(
2099
1945
  ln(
2100
1946
  seg(
2101
- ` ${fill(s.settingsChoiceInterval, { min: choice.interval.min || '0', max: choice.interval.max || '∞' })}`,
1947
+ ` ${fill(s.settingsChoiceInterval, { min: choice.interval.min || '0', max: choice.interval.max || '∞' })}${isSecondsSetting(choice.key) ? ' ' + s.settingsSeconds : ''}`,
2102
1948
  'dim',
2103
1949
  ),
2104
1950
  ),
@@ -2123,7 +1969,7 @@ function settingsBlock(ctx: Ctx): Block | null {
2123
1969
  // P32: a picker covers the row list, so what its own entries do not use stays inside the card
2124
1970
  // (the fill rule below); a short picker must not leave the pane half blank either.
2125
1971
  while (lines.length < room) put(ln(seg('')))
2126
- return one(lines, { focus: sel, offset: entryOffset, visible: entryVisible, count: entries.length })
1972
+ return { ...one(lines, { focus: sel, offset: entryOffset, visible: entryVisible, count: entries.length, width }), title: choice.ruleField ? s.settingsRuleModel : choice.category ? choice.key : keyLabel(s, choice.key) }
2127
1973
  }
2128
1974
 
2129
1975
  const lines: PlacedLine[] = []
@@ -2147,7 +1993,10 @@ function settingsBlock(ctx: Ctx): Block | null {
2147
1993
  ? settingsCategoryLine(ctx, r.category, focused, width)
2148
1994
  : r.kind === 'assignment'
2149
1995
  ? settingsAssignmentLine(ctx, r.assignment, focused, width)
2150
- : settingsPmLaunchLine(ctx, r.launch, focused, width)
1996
+ : r.kind === 'pm-launch' ? settingsPmLaunchLine(ctx, r.launch, focused, width)
1997
+ : { line: ln(seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1998
+ seg(r.kind === 'info' ? r.text : r.label, focused ? 'selected' : 'text'),
1999
+ seg(r.kind === 'nav' ? ' ›' : r.kind === 'rule' && r.value ? ' ' + r.value : '', 'text')) }
2151
2000
  // The whole row is a target: a click on an unfocused row moves the focus, a second click on
2152
2001
  // the focused row opens it (the kanban's rule).
2153
2002
  const action: Action = focused ? { kind: 'settings-open', index: idx } : { kind: 'settings-focus', index: idx }
@@ -2163,14 +2012,7 @@ function settingsBlock(ctx: Ctx): Block | null {
2163
2012
  if (hiddenBelow > 0) put(ln(seg(` ${fill(s.laneHiddenBelow, { n: String(hiddenBelow) })}`, 'dim')))
2164
2013
 
2165
2014
  // The CLI-alignment line (M49): the row's label is for reading, the raw key is for typing.
2166
- put(ln(seg(` ${settingsCliHint(s, rows, focus)}`, 'dim')))
2167
-
2168
- // The policy's migration diagnosis (P232): visible, and the CLI route it names is the route.
2169
- if (diagShown.length) {
2170
- put(ln(seg(` ${s.settingsDiagnosisHeading}`, 'warn')))
2171
- for (const chunks of diagChunks) for (const d of chunks) put(ln(seg(` ${d}`, 'warn')))
2172
- if (diagRest > 0) put(ln(seg(` ${fill(s.laneHiddenBelow, { n: String(diagRest) })}`, 'dim')))
2173
- }
2015
+ for (const text of shownHint) put(ln(seg(` ${text}`, 'dim')))
2174
2016
 
2175
2017
  // P32 (the bounded-frame rule's last resort, the detail view's own): the space the rows did not
2176
2018
  // use stays **inside** the card, so the card fills the pane it was handed and the key band stays
@@ -2178,7 +2020,7 @@ function settingsBlock(ctx: Ctx): Block | null {
2178
2020
  // a short pane it is what the user read as "the view does not use the window's height".
2179
2021
  while (lines.length < room) put(ln(seg('')))
2180
2022
 
2181
- return one(lines, { focus, offset, visible, count })
2023
+ return one(lines, { focus, offset, visible, count, width })
2182
2024
  }
2183
2025
 
2184
2026
  /**
@@ -2350,7 +2192,7 @@ function decisionsBlock(ctx: Ctx): Block | null {
2350
2192
  // ------------------------------------------------------------------ body blocks (page 3)
2351
2193
 
2352
2194
  function queueBlock(ctx: Ctx): Block | null {
2353
- const { s, blocks, deg, width, view } = ctx
2195
+ const { s, panel, blocks, deg, width, view } = ctx
2354
2196
  const q = blocks.outbox_list
2355
2197
  if (!q && !deg.has('outbox_list')) return null
2356
2198
  if (deg.has('outbox_list') || !q) {
@@ -2373,10 +2215,11 @@ function queueBlock(ctx: Ctx): Block | null {
2373
2215
  }
2374
2216
  const lines: PlacedLine[] = []
2375
2217
  // delivery-truth D2:阻碍是**测量事实**(原因、观察时刻、诊断可否读),不是「有草稿」的暗示。
2376
- const imps: Impediment[] = q.impediments ?? []
2377
- if (q.impeded && q.impeded > 0) {
2218
+ const ob = panel.outbox
2219
+ if (!deg.has('outbox') && ob?.impeded && ob.impeded > 0) {
2220
+ const imps = ob.impediments ?? []
2378
2221
  const reasons = Array.from(new Set(imps.map((i) => i.reason))).join(' · ') || s.dash
2379
- lines.push({ line: truncLine(ln(seg(` ${fill(s.queueImpededLine, { n: q.impeded, reasons })}`, 'warn')), width) })
2222
+ lines.push({ line: truncLine(ln(seg(` ${fill(s.queueImpededLine, { n: ob.impeded, reasons })}`, 'warn')), width) })
2380
2223
  for (const im of imps.slice(0, 3)) {
2381
2224
  const when = im.diagnostic === 'available' && im.last_observed ? im.last_observed : s.queueImpededUnavailable
2382
2225
  lines.push({ line: truncLine(ln(seg(fill(s.queueImpededItem, { entry: im.entry, reason: im.reason, when }), 'warn')), width) })
@@ -2532,8 +2375,12 @@ function demotedPair(ctx: Ctx): { full: string; phase: string } | null {
2532
2375
  }
2533
2376
 
2534
2377
  function keyBandBlock(ctx: Ctx, rowsAvailable = true): Block {
2378
+ // The setting/filter editor already renders its own Enter/Esc hint. Keep no underlying targets.
2379
+ if (ctx.view.settings && ctx.view.settingsEditing) {
2380
+ return { id: 'keys', full: true, priority: 99, lines: [], separator: 'none' }
2381
+ }
2535
2382
  const { s, width } = ctx
2536
- const actions: { text: string; action: Action }[] = [
2383
+ const actions: { text: string; action: Action }[] = ctx.view.settings ? [] : [
2537
2384
  { text: s.keyCompose, action: { kind: 'compose' } },
2538
2385
  { text: s.keyFlush, action: { kind: 'flush' } },
2539
2386
  { text: s.keyStandby, action: { kind: 'standby' } },
@@ -2545,15 +2392,15 @@ function keyBandBlock(ctx: Ctx, rowsAvailable = true): Block {
2545
2392
  const nav: { text: string; action: Action }[] = ctx.view.settings
2546
2393
  ? ctx.view.choicePicker
2547
2394
  ? [
2395
+ { text: s.keySettingsBack, action: { kind: 'choice-close' } },
2548
2396
  { text: s.keyRows, action: { kind: 'choice-move', delta: 1 } },
2549
2397
  { text: s.keyOpen, action: { kind: 'choice-pick', index: -1 } },
2550
- { text: s.keyDetailClose, action: { kind: 'choice-close' } },
2551
2398
  ]
2552
2399
  : [
2400
+ { text: s.keySettingsBack, action: { kind: 'settings-close' } },
2553
2401
  { text: s.keyRows, action: { kind: 'settings-scroll', delta: 1 } },
2554
- { text: s.keyOpen, action: { kind: 'settings-open', index: -1 } },
2402
+ { text: settingsViewRows(ctx.blocks.settings, ctx.view.settingsFilter ?? '', s, ctx.view.settingsPage, ctx.view.limitsDraft, ctx.view.settingsDetails).filter(settingsRowFocusable)[ctx.view.settingsFocus ?? 0]?.kind === 'nav' ? s.keyOpen : s.keyCategoryPick, action: { kind: 'settings-open', index: -1 } },
2555
2403
  { text: s.keyFilter, action: { kind: 'settings-filter' } },
2556
- { text: s.keyDetailClose, action: { kind: 'settings-close' } },
2557
2404
  ]
2558
2405
  : ctx.view.detail
2559
2406
  ? [
@@ -2633,9 +2480,11 @@ function keyBandBlock(ctx: Ctx, rowsAvailable = true): Block {
2633
2480
  }
2634
2481
  push(item.text, item.action, chip, false)
2635
2482
  })
2636
- nav.forEach((item) => {
2637
- line.push(seg(' · ', 'dim'))
2638
- x += 3
2483
+ nav.forEach((item, i) => {
2484
+ if (actions.length || i > 0) {
2485
+ line.push(seg(' · ', 'dim'))
2486
+ x += 3
2487
+ }
2639
2488
  push(item.text, item.action, false, chip)
2640
2489
  })
2641
2490
  // P123: the focused card's demoted pair rides the free width the chips leave — right-aligned,