pantheon-opencode 2.0.0-beta.3 → 2.0.0-beta.5

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.
@@ -16,7 +16,9 @@
16
16
  */
17
17
  import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
18
18
  import { dirname, join } from 'node:path'
19
- import type { SettingsRow, SettingsSection } from './pantheon-settings-state.ts'
19
+ import type { SettingsRow, SettingsTab } from './pantheon-settings-state.ts'
20
+
21
+ export const DECISION_ENABLED_CYCLE: readonly string[] = Object.freeze(['enabled', 'disabled'])
20
22
 
21
23
  export const DECISION_CONFIG_SCHEMA_VERSION = 2
22
24
 
@@ -203,40 +205,41 @@ export function writeDecisionRouterConfig(
203
205
  chmodSync(path, 0o600)
204
206
  }
205
207
 
206
- export function buildDecisionSection(read: DecisionConfigRead): SettingsSection {
208
+ export function buildDecisionTab(read: DecisionConfigRead): SettingsTab {
207
209
  const { config, corrupt } = read
208
210
  const rows: SettingsRow[] = [
209
211
  {
210
212
  id: 'decision.enabled',
211
- title: `Decision router: ${config.enabled ? 'enabled' : 'disabled'}`,
212
- description: corrupt
213
- ? 'config file unreadable/invalid — the runtime fail-closes to disabled'
214
- : 'the runtime re-reads this file on every gated call — applies live',
215
- disabled: !config.enabled,
213
+ name: 'Router',
214
+ value: config.enabled ? 'enabled' : 'disabled',
215
+ // Corrupt config → read-only; the notice (glue) carries the remedy.
216
+ ...(corrupt ? {} : { cycle: DECISION_ENABLED_CYCLE }),
217
+ note: corrupt
218
+ ? 'config unreadable/invalid — runtime fail-closes; repair via `decision-router setup-model`'
219
+ : 'applies live — the runtime re-reads this on every gated call',
216
220
  },
217
221
  {
218
222
  id: 'decision.selection',
219
- title: `Selection: ${config.selection.mode}${config.selection.provider ? ` · ${config.selection.provider}` : ''}`,
220
- description: 'local routes on-device; auto/explicit pick a remote decision model',
221
- selectable: false,
223
+ name: 'Selection',
224
+ value: `${config.selection.mode}${config.selection.provider ? ` · ${config.selection.provider}` : ''}`,
225
+ note: 'local routes on-device; auto/explicit pick a remote decision model',
222
226
  },
223
227
  ]
224
228
  if (config.enabled_candidates.length > 0) {
225
229
  rows.push({
226
230
  id: 'decision.candidates',
227
- title: `Candidates: ${config.enabled_candidates.map((candidate) => `${candidate.provider}/${candidate.model}`).join(', ')}`,
228
- description: config.egress_consent
229
- ? 'egress consent granted'
231
+ name: 'Candidates',
232
+ value: String(config.enabled_candidates.length),
233
+ note: config.egress_consent
234
+ ? config.enabled_candidates
235
+ .map((candidate) => `${candidate.provider}/${candidate.model}`)
236
+ .join(', ')
230
237
  : 'egress consent NOT granted — remote routes fail closed',
231
- selectable: false,
232
238
  })
233
239
  }
234
240
  return {
235
241
  id: 'decision',
236
- title: 'Decision Model',
237
- rows,
238
- hint: corrupt
239
- ? 'repair via `decision-router setup-model` — writes refused on an invalid file'
240
- : 'enter: enable/disable · consent and candidates via `decision-router setup-model`',
242
+ title: 'Decision',
243
+ groups: [{ title: 'Decision router', rows }],
241
244
  }
242
245
  }
@@ -19,7 +19,7 @@ import type { OverridesLoad } from './pantheon-settings-state.ts'
19
19
  import {
20
20
  SETTINGS_BEHAVIORS,
21
21
  type SettingsRow,
22
- type SettingsSection,
22
+ type SettingsTab,
23
23
  } from './pantheon-settings-state.ts'
24
24
  import { comparePantheonVersions } from './update-notice.ts'
25
25
 
@@ -122,77 +122,86 @@ export interface DoctorSectionInput {
122
122
  env?: Record<string, string | undefined>
123
123
  }
124
124
 
125
- export function buildDoctorSection(input: DoctorSectionInput): SettingsSection {
125
+ export function buildDoctorTab(input: DoctorSectionInput): SettingsTab {
126
126
  const env = input.env ?? process.env
127
127
  const rows: SettingsRow[] = []
128
128
 
129
129
  const version = classifyInstallVersion(input.runningVersion, env)
130
130
  rows.push({
131
131
  id: 'doctor.version',
132
- title:
132
+ name: 'Install version',
133
+ value:
133
134
  version.status === 'ok'
134
- ? `Installed version: v${version.installed} — matches`
135
+ ? `v${version.installed} — matches`
135
136
  : version.status === 'older'
136
- ? `Installed v${version.installed} is older than the runtime v${input.runningVersion}`
137
+ ? `v${version.installed} older`
137
138
  : version.status === 'newer'
138
- ? `Installed v${version.installed} is newer than the runtime v${input.runningVersion}`
139
- : 'Installed version: unknown (no install-state)',
140
- description:
139
+ ? `v${version.installed} newer`
140
+ : 'unknown',
141
+ note:
141
142
  version.status === 'older'
142
143
  ? 'refresh with `pantheon-opencode update`'
143
144
  : 'read from <config>/opencode/.pantheon/install-state.json',
144
- marker: version.status === 'ok' ? '[✓]' : version.status === 'older' ? '[!]' : '[i]',
145
- selectable: false,
146
145
  })
147
146
 
148
147
  const nodeOk = isSupportedNodeFloor(input.nodeVersion)
149
148
  rows.push({
150
149
  id: 'doctor.node',
151
- title: `Node runtime: ${input.nodeVersion.replace(/^v/, '')}`,
152
- description: nodeOk
150
+ name: 'Node runtime',
151
+ value: input.nodeVersion.replace(/^v/, ''),
152
+ note: nodeOk
153
153
  ? `meets the >= ${MIN_SUPPORTED_NODE_VERSION} floor`
154
154
  : `below the >= ${MIN_SUPPORTED_NODE_VERSION} floor — tooling may refuse`,
155
- marker: nodeOk ? '[✓]' : '[!]',
156
- selectable: false,
157
155
  })
158
156
 
159
157
  const overrides = classifyOverridesHealth(input.load)
160
158
  rows.push({
161
159
  id: 'doctor.overrides',
162
- title:
160
+ name: 'Overrides',
161
+ value:
163
162
  overrides.status === 'clean'
164
- ? 'Overrides: valid'
163
+ ? 'valid'
165
164
  : overrides.status === 'corrupt'
166
- ? 'Overrides: global file unreadable'
167
- : `Overrides: ${overrides.unknownIds.length} unknown id(s)`,
168
- description:
165
+ ? 'unreadable'
166
+ : `${overrides.unknownIds.length} unknown id(s)`,
167
+ note:
169
168
  overrides.status === 'unknown-ids'
170
169
  ? `${overrides.unknownIds.join(', ')} — harmless; repair with doctor --fix`
171
170
  : overrides.status === 'corrupt'
172
171
  ? 'writes are refused until repaired (doctor --fix)'
173
172
  : 'both files parse against the behavior registry',
174
- marker: overrides.status === 'clean' ? '[✓]' : overrides.status === 'corrupt' ? '[✗]' : '[!]',
175
- selectable: false,
176
173
  })
177
174
 
178
175
  const decision = classifyDecisionConfigHealth(env)
179
176
  rows.push({
180
177
  id: 'doctor.decision',
181
- title:
182
- decision.status === 'ok'
183
- ? 'Decision config: valid'
184
- : decision.status === 'corrupt'
185
- ? 'Decision config: unreadable — runtime fail-closes'
186
- : 'Decision config: absent (local defaults)',
187
- description: 'read from <config>/pantheon/decision-router.json',
188
- marker: decision.status === 'corrupt' ? '[✗]' : '[✓]',
189
- selectable: false,
178
+ name: 'Decision config',
179
+ value:
180
+ decision.status === 'ok' ? 'valid' : decision.status === 'corrupt' ? 'corrupt' : 'absent',
181
+ note:
182
+ decision.status === 'corrupt'
183
+ ? 'runtime fail-closes to disabled · read from <config>/pantheon/decision-router.json'
184
+ : 'read from <config>/pantheon/decision-router.json',
190
185
  })
191
186
 
192
187
  return {
193
188
  id: 'doctor',
194
189
  title: 'Doctor',
195
- rows,
196
- hint: 'file checks only — the full doctor (MCP smoke, venv, git) is `pantheon-opencode doctor`',
190
+ groups: [
191
+ {
192
+ title: 'Health (file-derived)',
193
+ rows,
194
+ },
195
+ {
196
+ rows: [
197
+ {
198
+ id: 'doctor.cli',
199
+ name: 'Full check',
200
+ value: '`pantheon-opencode doctor`',
201
+ note: 'MCP smoke, venv pins, git stay in the CLI',
202
+ },
203
+ ],
204
+ },
205
+ ],
197
206
  }
198
207
  }
@@ -24,8 +24,13 @@ import {
24
24
  MODEL_USAGE_SESSION_LIMIT,
25
25
  MODEL_USAGE_VISIBLE_CEILING,
26
26
  } from './model-usage-limits'
27
- import { maybeShowPantheonSettings } from './pantheon-settings'
27
+ import {
28
+ openPantheonSettings,
29
+ pantheonSettingsBlocking,
30
+ setupPantheonSettings,
31
+ } from './pantheon-settings'
28
32
  import { cellWidth, GRAPHEMES, SIDEBAR_CONTENT_WIDTH } from './sidebar-width'
33
+ import { initTuiPrefs, tuiPrefs } from './tui-prefs'
29
34
  import { nextCheckState, pickUpdateNotice, type UpdateCheckState } from './update-notice.ts'
30
35
  import { maybeShowWhatsNewV2 } from './whats-new'
31
36
 
@@ -682,10 +687,12 @@ export type ContextBlockRows = {
682
687
  * `$<spent> spent`. The percentage row carries the only semantic tone, the
683
688
  * gauge bar (12 cells) and is omitted entirely when the percentage is
684
689
  * unavailable (never `undefined%`). A block with neither tokens nor cost
685
- * yields null. Pure. */
690
+ * yields null. `gaugeStyle` (the TUI tab's pref) picks the percent-row
691
+ * shape: `both` (default), `bar`, `percent`, or `off` (row omitted). Pure. */
686
692
  export function contextBlockRows(
687
693
  usage: ContextUsage | null,
688
694
  cost: number | null | undefined,
695
+ gaugeStyle: 'both' | 'bar' | 'percent' | 'off' = 'both',
689
696
  ): ContextBlockRows | null {
690
697
  const spentValue = formatSpent(cost)
691
698
  const spent: ContextRow | null =
@@ -703,16 +710,30 @@ export function contextBlockRows(
703
710
  const percentValue = numberOrNull(usage.percent)
704
711
  const window = formatContextWindow(usage.limit)
705
712
  const bar = contextBar(percentValue)
706
- const percent: ContextRow | null =
707
- bar === null || percentValue === null
708
- ? null
709
- : {
710
- lead: bar.filled,
711
- value: ` ${Math.round(percentValue)}%`,
712
- tail: bar.empty,
713
- suffix: window === null ? null : ` of ${window}`,
714
- tone: contextUsageTone(percentValue),
715
- }
713
+ let percent: ContextRow | null = null
714
+ if (gaugeStyle !== 'off' && bar !== null && percentValue !== null) {
715
+ const suffix = window === null ? null : ` of ${window}`
716
+ const tone = contextUsageTone(percentValue)
717
+ if (gaugeStyle === 'bar') {
718
+ percent = { lead: bar.filled, value: '', tail: bar.empty, suffix, tone }
719
+ } else if (gaugeStyle === 'percent') {
720
+ percent = {
721
+ lead: null,
722
+ value: ` ${Math.round(percentValue)}%`,
723
+ tail: null,
724
+ suffix: null,
725
+ tone,
726
+ }
727
+ } else {
728
+ percent = {
729
+ lead: bar.filled,
730
+ value: ` ${Math.round(percentValue)}%`,
731
+ tail: bar.empty,
732
+ suffix,
733
+ tone,
734
+ }
735
+ }
736
+ }
716
737
 
717
738
  if (tokens === null && percent === null && spent === null) return null
718
739
  return { tokens, percent, spent }
@@ -3788,16 +3809,23 @@ export function createSidebarModel(
3788
3809
 
3789
3810
  // Which blocks render, and where a blank line goes. The conditions mirror the
3790
3811
  // ones in the view's own `<Show>`s — both read these same memos, so a spacer
3791
- // can never outlive the block it separates.
3812
+ // can never outlive the block it separates. The TUI tab's prefs gate first
3813
+ // (a disabled block never renders, and the spacer math already tolerates
3814
+ // absence), then the content conditions.
3792
3815
  const blocks = createMemo(() => {
3816
+ const prefs = tuiPrefs()
3793
3817
  const present: SidebarBlockKey[] = []
3794
3818
  // Context also owns the spend line, so the stats totals alone keep it up.
3795
- if (contextBlockRows(contextUsage(), cost()) !== null || contextSpendLine(spend()) !== null) {
3819
+ if (
3820
+ prefs.sidebar.blocks.context &&
3821
+ (contextBlockRows(contextUsage(), cost(), prefs.sidebar.context.gauge) !== null ||
3822
+ (prefs.sidebar.context.localSpend && contextSpendLine(spend()) !== null))
3823
+ ) {
3796
3824
  present.push('context')
3797
3825
  }
3798
- if (branch() !== null || gitLine() !== null) present.push('git')
3799
- if (todo().visible.length > 0) present.push('todo')
3800
- if (dispatch() !== null) present.push('dispatch')
3826
+ if (prefs.sidebar.blocks.git && (branch() !== null || gitLine() !== null)) present.push('git')
3827
+ if (prefs.sidebar.blocks.todo && todo().visible.length > 0) present.push('todo')
3828
+ if (prefs.sidebar.blocks.dispatch && dispatch() !== null) present.push('dispatch')
3801
3829
  return withBlockSpacers(present)
3802
3830
  })
3803
3831
 
@@ -3990,12 +4018,27 @@ function Sidebar(props: SidebarProps): JSX.Element {
3990
4018
  /* Read the flag live (not through a captured entry) so a block that becomes
3991
4019
  * the first one loses its spacer instead of keeping a stale blank line. */
3992
4020
  const spacer = (key: SidebarBlockKey) => block(key)?.spacer === true
3993
- const usageRows = () => modelUsageRows(model.modelUsage().visible)
3994
4021
  const usageHidden = () =>
3995
4022
  hiddenModelUsageText(model.modelUsage().hidden, model.modelUsage().hiddenCost)
3996
- const contextRows = () => contextBlockRows(model.contextUsage(), model.cost())
3997
- const spendLine = () => contextSpendLine(model.spend())
3998
- const performanceLine = () => contextPerformanceLine(model.performance())
4023
+ // The TUI tab's prefs gate the context rows: gauge style shapes the percent
4024
+ // row; the token/spent lines drop entirely (the prefs live in the reactive
4025
+ // host store, so a flip in /pantheon-settings re-renders here instantly).
4026
+ const contextRows = () => {
4027
+ const prefs = tuiPrefs()
4028
+ const rows = contextBlockRows(model.contextUsage(), model.cost(), prefs.sidebar.context.gauge)
4029
+ if (rows === null) return null
4030
+ return {
4031
+ tokens: prefs.sidebar.context.tokens ? rows.tokens : null,
4032
+ percent: rows.percent,
4033
+ spent: prefs.sidebar.context.spent ? rows.spent : null,
4034
+ }
4035
+ }
4036
+ const spendLine = () =>
4037
+ tuiPrefs().sidebar.context.localSpend ? contextSpendLine(model.spend()) : null
4038
+ const performanceLine = () =>
4039
+ tuiPrefs().sidebar.context.performance ? contextPerformanceLine(model.performance()) : null
4040
+ const usageRows = () =>
4041
+ tuiPrefs().sidebar.context.modelUsage ? modelUsageRows(model.modelUsage().visible) : []
3999
4042
  /* Filled cells and the percent value resolve through the same stage, so the
4000
4043
  * bar and its number can never disagree. */
4001
4044
  const gaugeFg = (row: ContextRow) => contextProgressColor(row.tone ?? 'warning', context.theme)
@@ -4006,16 +4049,27 @@ function Sidebar(props: SidebarProps): JSX.Element {
4006
4049
  }
4007
4050
  const failedSuffix = () => failedSuffixText(dispatchView()?.failures)
4008
4051
 
4052
+ // The fixed header lines are prefs-gated too (TUI tab): version, preset and
4053
+ // session each drop independently; nothing reflows — the column just shortens.
4054
+ const header = () => tuiPrefs().sidebar.header
4009
4055
  return (
4010
4056
  <box flexDirection="column" width="100%" padding={1}>
4011
- <text fg={text()} attributes={1}>{`Pantheon v${__PANTHEON_VERSION__}`}</text>
4057
+ <Show when={header().version}>
4058
+ <text fg={text()} attributes={1}>{`Pantheon v${__PANTHEON_VERSION__}`}</text>
4059
+ </Show>
4012
4060
  {/* Preset plus the provider of the model in use — both derived from host
4013
4061
  state. The provider is dropped when nothing resolves, so the row is
4014
4062
  never a placeholder. */}
4015
- <text fg={muted()}>{presetHeaderLine(model.preset().name ?? '', model.provider())}</text>
4063
+ <Show when={header().preset}>
4064
+ <text fg={muted()}>{presetHeaderLine(model.preset().name ?? '', model.provider())}</text>
4065
+ </Show>
4016
4066
  <Show
4017
- when={model.activeSessionID() !== '' && model.session()}
4018
- fallback={<text fg={muted()}>{sidebarPlaceholder(props.sessionID)}</text>}
4067
+ when={header().session && model.activeSessionID() !== '' && model.session()}
4068
+ fallback={
4069
+ <Show when={header().session} fallback={<box height={0} />}>
4070
+ <text fg={muted()}>{sidebarPlaceholder(props.sessionID)}</text>
4071
+ </Show>
4072
+ }
4019
4073
  >
4020
4074
  {(current: any) => (
4021
4075
  <text fg={text()}>{`Sessão: ${truncateLabel(current().title || current().id)}`}</text>
@@ -4056,7 +4110,7 @@ function Sidebar(props: SidebarProps): JSX.Element {
4056
4110
  numbers right-aligned; the gauge above remains the block's
4057
4111
  single accent. When no message carries cost this loop is empty
4058
4112
  and the block keeps its original token/spend rows. */}
4059
- <Show when={usageRows().length > 0}>
4113
+ <Show when={tuiPrefs().sidebar.context.modelUsage && usageRows().length > 0}>
4060
4114
  <text fg={muted()}>Sessão · custo reportado</text>
4061
4115
  <text fg={muted()}>
4062
4116
  {'Modelo'.padEnd(MODEL_USAGE_MODEL_WIDTH) +
@@ -4253,7 +4307,12 @@ export function dispatchPanelKeymapLayer(
4253
4307
  panel: Pick<PanelInput, 'focused' | 'close' | 'toggleFullscreen'>,
4254
4308
  model: DispatchPanelModel,
4255
4309
  ): KeymapLayer {
4256
- const focused = () => panel.focused === true
4310
+ // The dialog-suspension gate mirrors the host's own convention (global
4311
+ // session layers sleep while a dialog holds the stack): `panel.focused`
4312
+ // stays sticky after a `show()` blur-to-nothing, so without this gate the
4313
+ // dispatch panel stole the settings window's up/down/enter (beta.2 field
4314
+ // report — "navigation stopped working").
4315
+ const focused = () => panel.focused === true && !pantheonSettingsBlocking()
4257
4316
  return {
4258
4317
  mode: 'global',
4259
4318
  enabled: focused,
@@ -4408,7 +4467,7 @@ function PantheonSettingsCommandLayer(props: { context: any }) {
4408
4467
  palette: true,
4409
4468
  slash: { name: 'pantheon-settings' },
4410
4469
  run: () => {
4411
- void maybeShowPantheonSettings(props.context)
4470
+ void openPantheonSettings(props.context)
4412
4471
  },
4413
4472
  },
4414
4473
  ],
@@ -4423,9 +4482,11 @@ function HomeStatus(props: { context: any }) {
4423
4482
  const preset = useActivePreset(props.context).preset
4424
4483
  const muted = () => props.context.theme?.text?.muted ?? props.context.theme?.text?.base
4425
4484
  return (
4426
- <text
4427
- fg={muted()}
4428
- >{`Pantheon v${__PANTHEON_VERSION__}${preset().name ? ` ${PRESET_MARKER} ${preset().name}` : ''}`}</text>
4485
+ <Show when={tuiPrefs().footer.home}>
4486
+ <text
4487
+ fg={muted()}
4488
+ >{`Pantheon v${__PANTHEON_VERSION__}${preset().name ? ` ${PRESET_MARKER} ${preset().name}` : ''}`}</text>
4489
+ </Show>
4429
4490
  )
4430
4491
  }
4431
4492
 
@@ -4486,7 +4547,7 @@ function PromptFooter(props: { context: any; sessionID?: string | undefined }) {
4486
4547
  const model = createFooterModel(props.context, () => props.sessionID)
4487
4548
  const muted = () => props.context.theme?.text?.muted ?? props.context.theme?.text?.base
4488
4549
  return (
4489
- <Show when={model.running() > 0}>
4550
+ <Show when={tuiPrefs().footer.prompt && model.running() > 0}>
4490
4551
  <text fg={muted()}>
4491
4552
  {`${PRESET_MARKER}${model.preset().name ?? 'default'} · ✦${model.running()} ativos`}
4492
4553
  </text>
@@ -4503,6 +4564,11 @@ const plugin = Plugin.define({
4503
4564
  if (globalState[SINGLETON]) return
4504
4565
  globalState[SINGLETON] = true
4505
4566
 
4567
+ // The durable TUI prefs store — created before any consumer (sidebar,
4568
+ // footers, dispatch panel, settings) reads it, so their first reactive
4569
+ // read hits the live store instead of the defaults.
4570
+ initTuiPrefs(context)
4571
+
4506
4572
  const location = resolveLocation(context)
4507
4573
  // Eager load/sync at setup so the cache is warm before the slot's first
4508
4574
  // render (Known Issue: empty sidebar before the first prompt).
@@ -4554,6 +4620,15 @@ const plugin = Plugin.define({
4554
4620
  append: 'app',
4555
4621
  render: () => <PantheonSettingsCommandLayer context={context} />,
4556
4622
  })
4623
+ // The settings window surfaces: the full-screen router page (primary),
4624
+ // the legacy-host dialog fallback, and their keymap layers — registered
4625
+ // ONCE here with priority 1 so a stale same-bind layer can never win
4626
+ // while the window is open.
4627
+ try {
4628
+ setupPantheonSettings(context)
4629
+ } catch {
4630
+ /* settings unavailable on this host — the command toasts/fails open */
4631
+ }
4557
4632
  // One-time "What's new" window (per Pantheon version) — fire-and-forget:
4558
4633
  // resolves the running version and the shipped CHANGELOG.md, then opens a
4559
4634
  // host dialog when the version changed since the last dismissal. Fail-open;
@@ -10,7 +10,7 @@
10
10
  * writes, and the section says so. A file surface is a runtime-plugin change
11
11
  * (beta.3 candidate), not a window change.
12
12
  */
13
- import type { SettingsRow, SettingsSection } from './pantheon-settings-state.ts'
13
+ import type { SettingsTab } from './pantheon-settings-state.ts'
14
14
 
15
15
  export const J1_FLAG_ENV = 'PANTHEON_J1_RISK_SCORE'
16
16
  export const J1_THRESHOLD_ENV = 'PANTHEON_J1_ENFORCE_THRESHOLD'
@@ -44,10 +44,10 @@ const MODE_DESCRIPTION: Record<J1Mode, string> = {
44
44
  enforce: 'high-risk scores DENY the tool call (fail-open on gate unavailability)',
45
45
  }
46
46
 
47
- export function buildJ1Section(
47
+ export function buildJ1Tab(
48
48
  env: Record<string, string | undefined>,
49
49
  disabledByOverride: boolean,
50
- ): SettingsSection {
50
+ ): SettingsTab {
51
51
  const mode = j1ModeFromEnv(env)
52
52
  const threshold = j1ThresholdFromEnv(env)
53
53
  const gateState = disabledByOverride
@@ -55,31 +55,33 @@ export function buildJ1Section(
55
55
  : mode === 'off'
56
56
  ? 'off (env unset)'
57
57
  : 'active'
58
- const rows: SettingsRow[] = [
59
- {
60
- id: 'j1.mode',
61
- title: `Mode: ${mode}`,
62
- description: MODE_DESCRIPTION[mode],
63
- ...(disabledByOverride ? { marker: '[!]' } : {}),
64
- selectable: false,
65
- },
66
- {
67
- id: 'j1.threshold',
68
- title: `Enforce threshold: ${threshold}`,
69
- description: 'deny at or above; 0..1, default 0.8',
70
- selectable: false,
71
- },
72
- {
73
- id: 'j1.gate',
74
- title: `Gate: ${gateState}`,
75
- description: 'the runtime plugin reads this once at startup',
76
- selectable: false,
77
- },
78
- ]
79
58
  return {
80
59
  id: 'j1',
81
- title: 'J1 Risk Gate',
82
- hint: `set ${J1_FLAG_ENV} / ${J1_THRESHOLD_ENV} — restart applies`,
83
- rows,
60
+ title: 'J1',
61
+ groups: [
62
+ {
63
+ title: 'Ladder (env-only — never written here)',
64
+ rows: [
65
+ {
66
+ id: 'j1.mode',
67
+ name: 'Mode',
68
+ value: mode,
69
+ note: `${MODE_DESCRIPTION[mode]} · restart applies`,
70
+ },
71
+ {
72
+ id: 'j1.threshold',
73
+ name: 'Enforce threshold',
74
+ value: String(threshold),
75
+ note: 'deny at or above · 0..1 · default 0.8',
76
+ },
77
+ {
78
+ id: 'j1.gate',
79
+ name: 'Gate',
80
+ value: gateState,
81
+ note: `${J1_FLAG_ENV} / ${J1_THRESHOLD_ENV} · read once at startup`,
82
+ },
83
+ ],
84
+ },
85
+ ],
84
86
  }
85
87
  }