Setup: keep the dashboard's reasoning setting across an update

cmd_setup rebuilds config.json from the plan, and the reasoning setting isn't
part of the plan -- the dashboard writes it into the same file. So every
`llmhost update` (setup --yes under the hood) silently put every model back to
"Model default", losing a setting the user had chosen in the UI.

Carry it over, minus models that no longer fit. The helper exists so the reason
is on the record rather than implied by a dict literal; its tests cover the
empty and no-longer-fits cases that must not write the key at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Neil Bantoc 2026-11-03 15:01:12 -08:00
parent 8879db44a0
commit e48517b1cf
2 changed files with 29 additions and 0 deletions

View file

@ -111,6 +111,15 @@ def cmd_plan(a):
say("\nNothing fits. " + (p.get("reason") or ""))
def carried_settings(old, names):
"""Settings setup must not reset. The plan is setup's to rebuild, but the reasoning
setting belongs to the dashboard, which writes it into the same file -- without this an
`llmhost update` would quietly put every model back to "Model default". Models that no
longer fit lose their setting along with their plan."""
kept = {k: v for k, v in (old.get("reasoning") or {}).items() if k in names}
return {"reasoning": kept} if kept else {}
def cmd_setup(a):
info = hw.detect()
cat = paths.load_catalog()
@ -169,6 +178,7 @@ def cmd_setup(a):
"models": p["models"], "excluded": p["excluded"], "active": active,
p["backend"]: {**old.get(p["backend"], {}), **backend_info},
}
cfg.update(carried_settings(old, names))
paths.save_config(cfg)
key = paths.api_key(create=True)