Skip to content

Commit a26acb6

Browse files
committed
fix(settings): align mode default and dirty check
1 parent 4970f34 commit a26acb6

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

docs/environment-variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ tool-result interception (§2 Compression); and the embedding-server sidecar (§
6060

6161
| Variable | Type | Default | Description |
6262
|---|---|---|---|
63-
| `HEADROOM_MODE` | enum | `token` | Proxy posture: `token` (compress; history may be rewritten for max savings) or `cache` (freeze prior turns for provider prefix-cache stability). |
63+
| `HEADROOM_MODE` | enum | `cache` | Proxy posture: `token` (compress; history may be rewritten for max savings) or `cache` (freeze prior turns for provider prefix-cache stability). |
6464
| `HEADROOM_OPTIMIZE` | bool | `true` | Master optimization switch. `false` = passthrough (no compression); mirrors `--no-optimize`. |
6565
| `HEADROOM_CACHE_ENABLED` | bool | `true` | Semantic response cache. `false` mirrors `--no-cache`. |
6666
| `HEADROOM_RATE_LIMIT_ENABLED` | bool | `true` | Enforce RPM/TPM limits. `false` mirrors `--no-rate-limit`. |

headroom/dashboard/templates/settings.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ <h3 class="text-xs font-semibold uppercase tracking-wide field-help mb-3" x-text
225225
activePage: '',
226226
advancedOpen: {}, // per-page override of the Advanced collapse (else default rule)
227227
values: {},
228+
initialValues: {},
228229
storedValues: {},
229230
manifestManaged: false, // true on supervised installs (locks manifest fields)
230231
fieldErrors: {},
@@ -247,6 +248,7 @@ <h3 class="text-xs font-semibold uppercase tracking-wide field-help mb-3" x-text
247248
for (const f of this.fields) {
248249
const v = schema.values ? schema.values[f.key] : f.value;
249250
this.values[f.key] = f.type === 'optional-bool' ? this.triValue(v) : v;
251+
this.initialValues[f.key] = this.values[f.key];
250252
this.storedValues[f.key] = f.stored;
251253
}
252254
this.manifestManaged = !!schema.supervised;
@@ -309,18 +311,17 @@ <h3 class="text-xs font-semibold uppercase tracking-wide field-help mb-3" x-text
309311
for (const f of this.fields) {
310312
if (this.isLocked(f)) continue;
311313
if (this.clearedKeys[f.key]) { out[f.key] = null; continue; }
312-
const stored = this.storedValues[f.key];
313314
if (f.type === 'optional-bool') {
314315
const cur = this.triValue(this.values[f.key]);
315-
const base = this.triValue(this.isEmptyValue(stored) ? f.default : stored);
316+
const base = this.triValue(this.initialValues[f.key]);
316317
if (cur === base) continue;
317318
out[f.key] = cur === '' ? null : (cur === 'true');
318319
continue;
319320
}
320321
const v = this.values[f.key];
321-
const baseline = this.isEmptyValue(stored) ? f.default : stored;
322+
const baseline = this.initialValues[f.key];
322323
if (this.isEmptyValue(v)) {
323-
if (!this.isEmptyValue(stored)) out[f.key] = null;
324+
if (!this.isEmptyValue(baseline)) out[f.key] = null;
324325
continue;
325326
}
326327
if (this.normalizedComparable(v) === this.normalizedComparable(baseline)) continue;
@@ -353,6 +354,9 @@ <h3 class="text-xs font-semibold uppercase tracking-wide field-help mb-3" x-text
353354
this.banner = 'Live changes applied; restart required for: ' + restart.join(', ');
354355
}
355356
this.clearedKeys = {};
357+
for (const f of this.fields) {
358+
this.initialValues[f.key] = this.values[f.key];
359+
}
356360
} else if (res.status === 422) {
357361
this.fieldErrors = data.field_errors || {};
358362
this.status = 'Fix the highlighted fields.';

headroom/settings_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def live(self) -> bool:
112112
"Proxy mode",
113113
"Compression",
114114
"enum",
115-
default="token",
115+
default="cache",
116116
choices=("token", "cache"),
117117
help="Proxy posture: token prioritizes compression (history may be rewritten for max "
118118
"savings); cache prioritizes provider prefix-cache stability (prior turns frozen).",

tests/test_settings_pages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class TestProxyModeKnob:
197197
def test_mode_is_a_basic_compression_knob(self):
198198
field = settings_store._BY_KEY["mode"]
199199
assert field.env == "HEADROOM_MODE"
200+
assert field.default == "cache"
200201
assert field.page == "Compression"
201202
assert field.tier == "basic"
202203
assert field.live is False

0 commit comments

Comments
 (0)