dsh-context-compression-improved 0.7.0-beta.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.json +17 -18
  3. package/packages/selector/dsh.plugin.json +1 -1
  4. package/packages/selector/lib/client.d.ts +44 -0
  5. package/packages/selector/lib/client.js +1007 -13
  6. package/packages/selector/lib/{intent-gate.js → config.js} +799 -136
  7. package/packages/selector/lib/index.d.ts +13 -1
  8. package/packages/selector/lib/index.js +204 -3
  9. package/packages/selector/lib/profiles.d.ts +6 -0
  10. package/packages/selector/lib/pruner.d.ts +6 -0
  11. package/packages/selector/lib/pruner.js +90 -258
  12. package/packages/selector/lib/style.css +42 -0
  13. package/packages/selector/src/client/CompressionProfileControls.tsx +293 -226
  14. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
  15. package/packages/selector/src/client/CompressionProfileSelector.tsx +85 -83
  16. package/packages/selector/src/client/decode.ts +5 -1
  17. package/packages/selector/src/client/index.ts +307 -243
  18. package/packages/selector/src/client/locales/de.ts +43 -0
  19. package/packages/selector/src/client/locales/es.ts +43 -0
  20. package/packages/selector/src/client/locales/fr.ts +43 -0
  21. package/packages/selector/src/client/locales/it.ts +43 -0
  22. package/packages/selector/src/client/locales/ja.ts +43 -0
  23. package/packages/selector/src/client/locales/ko.ts +43 -0
  24. package/packages/selector/src/client/locales/ru.ts +43 -0
  25. package/packages/selector/src/client/locales.ts +282 -196
  26. package/packages/selector/src/client/monitor-fab.ts +336 -0
  27. package/packages/selector/src/client/savings-card.tsx +150 -0
  28. package/packages/selector/src/client/settings-section.tsx +140 -124
  29. package/packages/selector/src/index.ts +207 -5
  30. package/packages/selector/src/profiles.ts +17 -0
  31. package/packages/selector/src/pruner.ts +96 -2
  32. package/packages/selector/src/runtime/config.ts +26 -1
  33. package/packages/selector/src/runtime/monitor.ts +235 -0
  34. package/packages/selector/src/runtime/retrieve.ts +479 -457
  35. package/packages/selector/src/runtime/savings.ts +337 -0
  36. package/packages/selector/src/runtime/types.ts +7 -0
  37. package/packages/selector/tests/code-skeleton.client.spec.ts +2 -2
  38. package/packages/selector/tests/custom-contract.client.spec.ts +2 -2
  39. package/packages/selector/tests/estimator-channel.client.spec.tsx +2 -0
  40. package/packages/selector/tests/estimator-route-registration.host.spec.ts +194 -188
  41. package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
  42. package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
  43. package/packages/selector/tests/runtime/savings.spec.ts +120 -0
  44. package/packages/selector/tests/settings-seat.client.spec.ts +177 -165
  45. package/scripts/packed-install-e2e.mjs +1 -1
  46. package/scripts/verify-release.mjs +1 -1
@@ -1,226 +1,293 @@
1
- /**
2
- * CompressionProfileControls: dropdown selector for compression profiles,
3
- * plus AutoCompactThresholdControls and CodeSkeletonControls sub-components.
4
- *
5
- * Extracted from CompressionProfileSelector.tsx to reduce god-module size.
6
- *
7
- * @module dsh-context-compression-improved/client/CompressionProfileControls
8
- */
9
-
10
- import { useEffect, useId, useState } from 'react'
11
- import { IconChevronDownOutlineMedium, Menu } from '@deepseek-ai/dsh-client-ui-primitives'
12
- import type { ContextCompressionLocaleKey } from './locales.ts'
13
- import css from './CompressionProfileSelector.module.css'
14
- import {
15
- AUTO_COMPACT_THRESHOLD_LIMITS,
16
- COMPRESSION_PROFILES,
17
- isValidAutoCompactThresholdPercent,
18
- type CompressionProfile,
19
- type CustomCompressionPolicyV3,
20
- } from '../profiles.ts'
21
- import type { CompressionProfileSelectorProps } from './CompressionProfileSelector.tsx'
22
- import { CustomPolicyEditor, editableCustom } from './CustomPolicyEditor.tsx'
23
-
24
- export function CompressionProfileControls({
25
- useCompression, select, saveCustom, resetCustom, t, showCustomEditor,
26
- }: CompressionProfileSelectorProps & { showCustomEditor: boolean }) {
27
- const state = useCompression(snapshot => snapshot)
28
- // Harness 0.1.5 dropped browser-side agentPreset from session summaries; see
29
- // the section component note. Only Minimal used to block initial
30
- // configuration, and that signal is no longer available client-side.
31
- const contextCompressionAvailable = true
32
- const [open, setOpen] = useState(false)
33
- const [saving, setSaving] = useState(false)
34
- const [saveError, setSaveError] = useState<string | null>(null)
35
- const [draft, setDraft] = useState<CustomCompressionPolicyV3 | null>(null)
36
- const unavailableId = useId()
37
- const current = state.value?.profile ?? 'balanced'
38
- useEffect(() => {
39
- if (state.status === 'ready' && state.writable && contextCompressionAvailable) return
40
- setOpen(false)
41
- }, [contextCompressionAvailable, state.status, state.writable])
42
- useEffect(() => {
43
- const custom = state.value?.custom
44
- setDraft(current === 'custom' && custom !== undefined ? editableCustom(custom) : null)
45
- }, [current, state.value?.custom])
46
- if (state.status === 'unavailable') return null
47
- const busy = state.status === 'loading' || saving
48
- const label = busy ? t('status.loading') : t(`profile.${current}`)
49
- return (
50
- <div className={css.root}>
51
- <Menu
52
- open={open && contextCompressionAvailable}
53
- onClose={() => { setOpen(false) }}
54
- selectedId={current}
55
- items={COMPRESSION_PROFILES.map(profile => ({
56
- id: profile,
57
- label: (
58
- <span className={css.menuCopy}>
59
- <span className={css.menuTitle}>{t(`profile.${profile}`)}</span>
60
- <span className={css.menuDetail}>{t(`detail.${profile}`)}</span>
61
- </span>
62
- ),
63
- }))}
64
- onSelect={(id) => {
65
- setOpen(false)
66
- if (id === current || !COMPRESSION_PROFILES.includes(id as CompressionProfile)) return
67
- setSaveError(null)
68
- setSaving(true)
69
- void select(id as CompressionProfile).then(
70
- () => { setSaving(false) },
71
- (error: unknown) => {
72
- setSaving(false)
73
- setSaveError(error instanceof Error && error.message !== '' ? error.message : t('status.saveFailed'))
74
- },
75
- )
76
- }}
77
- align="start"
78
- portal
79
- anchor={(
80
- <button
81
- type="button"
82
- className={css.button}
83
- aria-haspopup="menu"
84
- aria-expanded={open && contextCompressionAvailable}
85
- aria-describedby={contextCompressionAvailable ? undefined : unavailableId}
86
- disabled={busy || !state.writable || !contextCompressionAvailable}
87
- onClick={() => { setOpen(value => !value) }}
88
- >
89
- <span className={css.copy}>
90
- <span className={css.label}>{t('label')}</span>
91
- <span className={css.value}>{label}</span>
92
- </span>
93
- <IconChevronDownOutlineMedium className={css.chevron} />
94
- </button>
95
- )}
96
- />
97
- {contextCompressionAvailable ? null : (
98
- <div id={unavailableId} className={css.unavailable} role="status">
99
- {t('status.minimalUnavailable')}
100
- </div>
101
- )}
102
- <div className={css.pricing}>{t('pricing.disclosure')}</div>
103
- <div className={css.settingsHint}>
104
- {t('autoCompact.summaryHint').replace('{percent}', String(state.value?.autoCompact?.thresholdPercent ?? AUTO_COMPACT_THRESHOLD_LIMITS.default))}
105
- </div>
106
- {current !== 'custom' || showCustomEditor ? null : (
107
- <div className={css.settingsHint}>{t('custom.settingsHint')}</div>
108
- )}
109
- {current !== 'custom' || draft === null || !showCustomEditor ? null : (
110
- <CustomPolicyEditor
111
- value={draft}
112
- disabled={busy || !state.writable || !contextCompressionAvailable}
113
- setValue={setDraft}
114
- save={() => saveCustom(structuredClone(draft))}
115
- reset={resetCustom}
116
- settle={(operation) => {
117
- setSaveError(null)
118
- setSaving(true)
119
- void operation().then(
120
- () => { setSaving(false) },
121
- (error: unknown) => {
122
- setSaving(false)
123
- setSaveError(error instanceof Error && error.message !== '' ? error.message : t('status.saveFailed'))
124
- },
125
- )
126
- }}
127
- t={t}
128
- />
129
- )}
130
- {saveError === null ? null : <div className={css.error} role="alert">{saveError}</div>}
131
- </div>
132
- )
133
- }
134
-
135
- interface AutoCompactThresholdControlsProps {
136
- value: number
137
- disabled: boolean
138
- save: (thresholdPercent: number) => Promise<void>
139
- settle: (operation: () => Promise<void>) => void
140
- t: (key: ContextCompressionLocaleKey) => string
141
- }
142
-
143
- /**
144
- * The authoritative Auto Compact threshold editor for the context-compression
145
- * section. A typed number input and its save path are kept deliberately simple;
146
- * values outside the recommended 70–85 band warn without blocking.
147
- */
148
- export function AutoCompactThresholdControls({ value, disabled, save, settle, t }: AutoCompactThresholdControlsProps) {
149
- const [draft, setDraft] = useState(String(value))
150
- useEffect(() => { setDraft(String(value)) }, [value])
151
- const parsed = Number(draft)
152
- // Number inputs legally produce value-equivalent drafts such as '8e1';
153
- // only the parsed value needs to be a valid threshold.
154
- const valid = isValidAutoCompactThresholdPercent(parsed)
155
- const risk = !valid
156
- ? 'autoCompact.invalid'
157
- : parsed < 70 ? 'autoCompact.riskLow'
158
- : parsed > 85 ? 'autoCompact.riskHigh'
159
- : undefined
160
- return (
161
- <section className={css.autoCompact} aria-labelledby="context-compression-autocompact-title">
162
- <h3 id="context-compression-autocompact-title" className={css.autoCompactTitle}>{t('autoCompact.title')}</h3>
163
- <p className={css.customNote}>{t('autoCompact.description')}</p>
164
- <label className={css.field}>
165
- <span>{t('autoCompact.inputLabel')}</span>
166
- <input
167
- type="number"
168
- value={draft}
169
- min={AUTO_COMPACT_THRESHOLD_LIMITS.min}
170
- max={AUTO_COMPACT_THRESHOLD_LIMITS.max}
171
- step={AUTO_COMPACT_THRESHOLD_LIMITS.step}
172
- disabled={disabled}
173
- aria-invalid={!valid}
174
- onChange={(event) => { setDraft(event.currentTarget.value) }}
175
- />
176
- </label>
177
- {risk === undefined ? null : (
178
- <div className={risk === 'autoCompact.invalid' ? css.error : css.autoCompactRisk} role={risk === 'autoCompact.invalid' ? 'alert' : 'note'}>
179
- {t(risk)}
180
- </div>
181
- )}
182
- <div className={css.actions}>
183
- <button
184
- type="button"
185
- disabled={disabled || !valid || parsed === value}
186
- onClick={() => { settle(() => save(parsed)) }}
187
- >
188
- {t('autoCompact.save')}
189
- </button>
190
- </div>
191
- </section>
192
- )
193
- }
194
-
195
- interface CodeSkeletonControlsProps {
196
- value: boolean
197
- disabled: boolean
198
- save: (enabled: boolean) => Promise<void>
199
- settle: (operation: () => Promise<void>) => void
200
- t: (key: ContextCompressionLocaleKey) => string
201
- }
202
-
203
- /**
204
- * The authoritative code-skeleton reducer gate for the context-compression
205
- * section. Deliberately minimal — an on/off select plus its own save path —
206
- * because the gate is orthogonal to every profile and carries no parameters.
207
- */
208
- export function CodeSkeletonControls({ value, disabled, save, settle, t }: CodeSkeletonControlsProps) {
209
- return (
210
- <section className={css.autoCompact} aria-labelledby="context-compression-codeskeleton-title">
211
- <h3 id="context-compression-codeskeleton-title" className={css.autoCompactTitle}>{t('codeSkeleton.title')}</h3>
212
- <p className={css.customNote}>{t('codeSkeleton.description')}</p>
213
- <label className={css.field}>
214
- <span>{t('codeSkeleton.enabled')}</span>
215
- <select
216
- value={value ? 'on' : 'off'}
217
- disabled={disabled}
218
- onChange={(event) => { settle(() => save(event.currentTarget.value === 'on')) }}
219
- >
220
- <option value="on">{t('codeSkeleton.enabled.on')}</option>
221
- <option value="off">{t('codeSkeleton.enabled.off')}</option>
222
- </select>
223
- </label>
224
- </section>
225
- )
226
- }
1
+ /**
2
+ * CompressionProfileControls: dropdown selector for compression profiles,
3
+ * plus AutoCompactThresholdControls and CodeSkeletonControls sub-components.
4
+ *
5
+ * Extracted from CompressionProfileSelector.tsx to reduce god-module size.
6
+ *
7
+ * @module dsh-context-compression-improved/client/CompressionProfileControls
8
+ */
9
+
10
+ import { useEffect, useId, useState } from 'react'
11
+ import { IconChevronDownOutlineMedium, Menu } from '@deepseek-ai/dsh-client-ui-primitives'
12
+ import type { ContextCompressionLocaleKey } from './locales.ts'
13
+ import css from './CompressionProfileSelector.module.css'
14
+ import {
15
+ AUTO_COMPACT_THRESHOLD_LIMITS,
16
+ COMPRESSION_PROFILES,
17
+ isValidAutoCompactThresholdPercent,
18
+ type CompressionProfile,
19
+ type CustomCompressionPolicyV3,
20
+ } from '../profiles.ts'
21
+ import type { CompressionProfileSelectorProps } from './CompressionProfileSelector.tsx'
22
+ import { CustomPolicyEditor, editableCustom } from './CustomPolicyEditor.tsx'
23
+
24
+ export function CompressionProfileControls({
25
+ useCompression, select, saveCustom, resetCustom, t, showCustomEditor,
26
+ }: CompressionProfileSelectorProps & { showCustomEditor: boolean }) {
27
+ const state = useCompression(snapshot => snapshot)
28
+ // Harness 0.1.5 dropped browser-side agentPreset from session summaries; see
29
+ // the section component note. Only Minimal used to block initial
30
+ // configuration, and that signal is no longer available client-side.
31
+ const contextCompressionAvailable = true
32
+ const [open, setOpen] = useState(false)
33
+ const [saving, setSaving] = useState(false)
34
+ const [saveError, setSaveError] = useState<string | null>(null)
35
+ const [draft, setDraft] = useState<CustomCompressionPolicyV3 | null>(null)
36
+ const unavailableId = useId()
37
+ const current = state.value?.profile ?? 'balanced'
38
+ useEffect(() => {
39
+ if (state.status === 'ready' && state.writable && contextCompressionAvailable) return
40
+ setOpen(false)
41
+ }, [contextCompressionAvailable, state.status, state.writable])
42
+ useEffect(() => {
43
+ const custom = state.value?.custom
44
+ setDraft(current === 'custom' && custom !== undefined ? editableCustom(custom) : null)
45
+ }, [current, state.value?.custom])
46
+ if (state.status === 'unavailable') return null
47
+ const busy = state.status === 'loading' || saving
48
+ const label = busy ? t('status.loading') : t(`profile.${current}`)
49
+ return (
50
+ <div className={css.root}>
51
+ <Menu
52
+ open={open && contextCompressionAvailable}
53
+ onClose={() => { setOpen(false) }}
54
+ selectedId={current}
55
+ items={COMPRESSION_PROFILES.map(profile => ({
56
+ id: profile,
57
+ label: (
58
+ <span className={css.menuCopy}>
59
+ <span className={css.menuTitle}>{t(`profile.${profile}`)}</span>
60
+ <span className={css.menuDetail}>{t(`detail.${profile}`)}</span>
61
+ </span>
62
+ ),
63
+ }))}
64
+ onSelect={(id) => {
65
+ setOpen(false)
66
+ if (id === current || !COMPRESSION_PROFILES.includes(id as CompressionProfile)) return
67
+ setSaveError(null)
68
+ setSaving(true)
69
+ void select(id as CompressionProfile).then(
70
+ () => { setSaving(false) },
71
+ (error: unknown) => {
72
+ setSaving(false)
73
+ setSaveError(error instanceof Error && error.message !== '' ? error.message : t('status.saveFailed'))
74
+ },
75
+ )
76
+ }}
77
+ align="start"
78
+ portal
79
+ anchor={(
80
+ <button
81
+ type="button"
82
+ className={css.button}
83
+ aria-haspopup="menu"
84
+ aria-expanded={open && contextCompressionAvailable}
85
+ aria-describedby={contextCompressionAvailable ? undefined : unavailableId}
86
+ disabled={busy || !state.writable || !contextCompressionAvailable}
87
+ onClick={() => { setOpen(value => !value) }}
88
+ >
89
+ <span className={css.copy}>
90
+ <span className={css.label}>{t('label')}</span>
91
+ <span className={css.value}>{label}</span>
92
+ </span>
93
+ <IconChevronDownOutlineMedium className={css.chevron} />
94
+ </button>
95
+ )}
96
+ />
97
+ {contextCompressionAvailable ? null : (
98
+ <div id={unavailableId} className={css.unavailable} role="status">
99
+ {t('status.minimalUnavailable')}
100
+ </div>
101
+ )}
102
+ <div className={css.pricing}>{t('pricing.disclosure')}</div>
103
+ <div className={css.settingsHint}>
104
+ {t('autoCompact.summaryHint').replace('{percent}', String(state.value?.autoCompact?.thresholdPercent ?? AUTO_COMPACT_THRESHOLD_LIMITS.default))}
105
+ </div>
106
+ {current !== 'custom' || showCustomEditor ? null : (
107
+ <div className={css.settingsHint}>{t('custom.settingsHint')}</div>
108
+ )}
109
+ {current !== 'custom' || draft === null || !showCustomEditor ? null : (
110
+ <CustomPolicyEditor
111
+ value={draft}
112
+ disabled={busy || !state.writable || !contextCompressionAvailable}
113
+ setValue={setDraft}
114
+ save={() => saveCustom(structuredClone(draft))}
115
+ reset={resetCustom}
116
+ settle={(operation) => {
117
+ setSaveError(null)
118
+ setSaving(true)
119
+ void operation().then(
120
+ () => { setSaving(false) },
121
+ (error: unknown) => {
122
+ setSaving(false)
123
+ setSaveError(error instanceof Error && error.message !== '' ? error.message : t('status.saveFailed'))
124
+ },
125
+ )
126
+ }}
127
+ t={t}
128
+ />
129
+ )}
130
+ {saveError === null ? null : <div className={css.error} role="alert">{saveError}</div>}
131
+ </div>
132
+ )
133
+ }
134
+
135
+ interface AutoCompactThresholdControlsProps {
136
+ value: number
137
+ disabled: boolean
138
+ save: (thresholdPercent: number) => Promise<void>
139
+ settle: (operation: () => Promise<void>) => void
140
+ t: (key: ContextCompressionLocaleKey) => string
141
+ }
142
+
143
+ /**
144
+ * The authoritative Auto Compact threshold editor for the context-compression
145
+ * section. A typed number input and its save path are kept deliberately simple;
146
+ * values outside the recommended 70–85 band warn without blocking.
147
+ */
148
+ export function AutoCompactThresholdControls({ value, disabled, save, settle, t }: AutoCompactThresholdControlsProps) {
149
+ const [draft, setDraft] = useState(String(value))
150
+ useEffect(() => { setDraft(String(value)) }, [value])
151
+ const parsed = Number(draft)
152
+ // Number inputs legally produce value-equivalent drafts such as '8e1';
153
+ // only the parsed value needs to be a valid threshold.
154
+ const valid = isValidAutoCompactThresholdPercent(parsed)
155
+ const risk = !valid
156
+ ? 'autoCompact.invalid'
157
+ : parsed < 70 ? 'autoCompact.riskLow'
158
+ : parsed > 85 ? 'autoCompact.riskHigh'
159
+ : undefined
160
+ return (
161
+ <section className={css.autoCompact} aria-labelledby="context-compression-autocompact-title">
162
+ <h3 id="context-compression-autocompact-title" className={css.autoCompactTitle}>{t('autoCompact.title')}</h3>
163
+ <p className={css.customNote}>{t('autoCompact.description')}</p>
164
+ <label className={css.field}>
165
+ <span>{t('autoCompact.inputLabel')}</span>
166
+ <input
167
+ type="number"
168
+ value={draft}
169
+ min={AUTO_COMPACT_THRESHOLD_LIMITS.min}
170
+ max={AUTO_COMPACT_THRESHOLD_LIMITS.max}
171
+ step={AUTO_COMPACT_THRESHOLD_LIMITS.step}
172
+ disabled={disabled}
173
+ aria-invalid={!valid}
174
+ onChange={(event) => { setDraft(event.currentTarget.value) }}
175
+ />
176
+ </label>
177
+ {risk === undefined ? null : (
178
+ <div className={risk === 'autoCompact.invalid' ? css.error : css.autoCompactRisk} role={risk === 'autoCompact.invalid' ? 'alert' : 'note'}>
179
+ {t(risk)}
180
+ </div>
181
+ )}
182
+ <div className={css.actions}>
183
+ <button
184
+ type="button"
185
+ disabled={disabled || !valid || parsed === value}
186
+ onClick={() => { settle(() => save(parsed)) }}
187
+ >
188
+ {t('autoCompact.save')}
189
+ </button>
190
+ </div>
191
+ </section>
192
+ )
193
+ }
194
+
195
+ interface IntentSummaryControlsProps {
196
+ value: boolean
197
+ disabled: boolean
198
+ save: (enabled: boolean) => Promise<void>
199
+ settle: (operation: () => Promise<void>) => void
200
+ t: (key: ContextCompressionLocaleKey) => string
201
+ }
202
+
203
+ /**
204
+ * The turn-tail intent summary fold gate. Same deliberately minimal shape as
205
+ * the code-skeleton gate: an on/off select with its own save path; the fold
206
+ * itself is gated by the growth constants and the per-session /ctx-summary
207
+ * override, none of which belong in this card.
208
+ */
209
+ export function IntentSummaryControls({ value, disabled, save, settle, t }: IntentSummaryControlsProps) {
210
+ return (
211
+ <section className={css.autoCompact} aria-labelledby="context-compression-intentsummary-title">
212
+ <h3 id="context-compression-intentsummary-title" className={css.autoCompactTitle}>{t('intentSummary.title')}</h3>
213
+ <p className={css.customNote}>{t('intentSummary.description')}</p>
214
+ <label className={css.field}>
215
+ <span>{t('intentSummary.enabled')}</span>
216
+ <select
217
+ value={value ? 'on' : 'off'}
218
+ disabled={disabled}
219
+ onChange={(event) => { settle(() => save(event.currentTarget.value === 'on')) }}
220
+ >
221
+ <option value="on">{t('intentSummary.enabled.on')}</option>
222
+ <option value="off">{t('intentSummary.enabled.off')}</option>
223
+ </select>
224
+ </label>
225
+ </section>
226
+ )
227
+ }
228
+
229
+ interface MonitorPanelControlsProps {
230
+ value: boolean
231
+ disabled: boolean
232
+ save: (enabled: boolean) => Promise<void>
233
+ settle: (operation: () => Promise<void>) => void
234
+ t: (key: ContextCompressionLocaleKey) => string
235
+ }
236
+
237
+ /**
238
+ * Visibility switch of the floating compression-monitor panel (FAB). The
239
+ * panel itself is a body-level overlay driven by the monitor route; this card
240
+ * only decides whether it mounts.
241
+ */
242
+ export function MonitorPanelControls({ value, disabled, save, settle, t }: MonitorPanelControlsProps) {
243
+ return (
244
+ <section className={css.autoCompact} aria-labelledby="context-compression-monitorpanel-title">
245
+ <h3 id="context-compression-monitorpanel-title" className={css.autoCompactTitle}>{t('monitorPanel.title')}</h3>
246
+ <p className={css.customNote}>{t('monitorPanel.description')}</p>
247
+ <label className={css.field}>
248
+ <span>{t('monitorPanel.enabled')}</span>
249
+ <select
250
+ value={value ? 'on' : 'off'}
251
+ disabled={disabled}
252
+ onChange={(event) => { settle(() => save(event.currentTarget.value === 'on')) }}
253
+ >
254
+ <option value="on">{t('monitorPanel.enabled.on')}</option>
255
+ <option value="off">{t('monitorPanel.enabled.off')}</option>
256
+ </select>
257
+ </label>
258
+ </section>
259
+ )
260
+ }
261
+
262
+ interface CodeSkeletonControlsProps {
263
+ value: boolean
264
+ disabled: boolean
265
+ save: (enabled: boolean) => Promise<void>
266
+ settle: (operation: () => Promise<void>) => void
267
+ t: (key: ContextCompressionLocaleKey) => string
268
+ }
269
+
270
+ /**
271
+ * The authoritative code-skeleton reducer gate for the context-compression
272
+ * section. Deliberately minimal — an on/off select plus its own save path —
273
+ * because the gate is orthogonal to every profile and carries no parameters.
274
+ */
275
+ export function CodeSkeletonControls({ value, disabled, save, settle, t }: CodeSkeletonControlsProps) {
276
+ return (
277
+ <section className={css.autoCompact} aria-labelledby="context-compression-codeskeleton-title">
278
+ <h3 id="context-compression-codeskeleton-title" className={css.autoCompactTitle}>{t('codeSkeleton.title')}</h3>
279
+ <p className={css.customNote}>{t('codeSkeleton.description')}</p>
280
+ <label className={css.field}>
281
+ <span>{t('codeSkeleton.enabled')}</span>
282
+ <select
283
+ value={value ? 'on' : 'off'}
284
+ disabled={disabled}
285
+ onChange={(event) => { settle(() => save(event.currentTarget.value === 'on')) }}
286
+ >
287
+ <option value="on">{t('codeSkeleton.enabled.on')}</option>
288
+ <option value="off">{t('codeSkeleton.enabled.off')}</option>
289
+ </select>
290
+ </label>
291
+ </section>
292
+ )
293
+ }