fix: persist admin-chosen default model across redeploys#55
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The zero server re-seeds its model table from
server/config/models.jsonon every startup. For existing rows the upsert appliedis_default = excluded.is_default, andmodels.jsonmarks only Kimi with"default": true. So when an admin picked a different default (persisted viaupdateModel/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)is_defaultonON CONFLICT— existing rows keep the admin's chosen default. New DBs still get the seed default through theINSERTpath. Mirrors the existing handling ofpi_provider/pi_model_id, which already avoid clobbering admin edits.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 byclearDefault.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