Skip to content

fix: persist admin-chosen default model across redeploys#55

Merged
Anton-Horn merged 1 commit into
mainfrom
fix/persist-default-model-across-redeploys
Jun 9, 2026
Merged

fix: persist admin-chosen default model across redeploys#55
Anton-Horn merged 1 commit into
mainfrom
fix/persist-default-model-across-redeploys

Conversation

@Anton-Horn

Copy link
Copy Markdown
Contributor

Problem

The zero server re-seeds its model table from server/config/models.json on every startup. For existing rows the upsert applied is_default = excluded.is_default, and models.json marks only Kimi with "default": true. So when an admin picked a different default (persisted via updateModel/clearDefault), it survived plain restarts but was clobbered back to Kimi on a redeploy, when the new image re-ran the seed.

Fix (server/db/index.ts)

  • Stop touching is_default on ON CONFLICT — existing rows keep the admin's chosen default. New DBs still get the seed default through the INSERT path. Mirrors the existing handling of pi_provider/pi_model_id, which already avoid clobbering admin edits.
  • Safety net after the seed — if no row has is_default = 1 (fresh DB edge cases, or the chosen default being dropped from the seed and deleted), fall back to the seed's default model, preserving the single-default invariant enforced by clearDefault.

Notes

This fixes the server/DB-side system default. The web UI keeps a separate per-browser selection in localStorage (web/src/stores/model.ts), which is unrelated to redeploys.

🤖 Generated with Claude Code

The startup model seed in server/db/index.ts re-applied the JSON
seed's is_default flag to existing rows on every boot. An admin-set
default survived restarts but was clobbered back to the models.json
default (Kimi) on redeploy, when a new image re-ran the seed.

Stop touching is_default on conflict so the admin's choice persists;
new DBs still get the seed default via INSERT. Add a safety net that
restores exactly one default if none is set (fresh DB edge cases, or
the chosen default being dropped from the seed).
@Anton-Horn Anton-Horn merged commit 63bb173 into main Jun 9, 2026
1 check passed
@Anton-Horn Anton-Horn deleted the fix/persist-default-model-across-redeploys branch June 9, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant