fix(mac): route the server's no-admin refusal back to the setup wizard - #236
Merged
Conversation
Deleting ~/.cix/data does not stay a "missing database" for long: the very next start attempt recreates an empty cix.db (the server runs migrations before bootstrapAuth refuses), so needsFirstRun's file-existence check answers false from then on, and Start showed the raw refusal from cix-server.err instead of offering setup. The reliable signal for "no accounts" is the server's own refusal text, so recognise it: isBootstrapRefusal matches the two bootstrapAuth messages a user-less database produces, and toggleServer routes a matching died-on-start log to the same set-up-again offer as a missing database. Other startup failures still show the log tail — a port clash is not a reason to offer re-setup. Also prefill the wizard's email prompt with the address already in server.env, since a re-run almost always wants the same one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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
After
rm -rf ~/.cix/data, clicking Start showed the rawcix-server.errtail ("incomplete bootstrap configuration…") instead of the setup wizard.The mechanism: the first start attempt recreates an empty
cix.db— the server runsMkdirAll+ migrations beforebootstrapAuthrefuses. From that momentneedsFirstRun()'s file-existence check answers false, so the wizard branch added in #235 never fires and the user gets the log dump.Fix
The one thing that still knows the database has no accounts is the server itself, so recognise its refusal:
isBootstrapRefusal(logTail)matches the twobootstrapAuthmessages a user-less database produces ("incomplete bootstrap configuration", "no users in database").toggleServerroutes a matching died-on-start log to the same "Set cix up again?" offer as a missing database (extracted intoofferSetupAgain). Other startup failures — port clash, unreadable DB file — still show the log tail; they are not reasons to offer re-setup.server.env, since a re-run almost always wants the same one.Testing
TestIsBootstrapRefusalpins both refusal strings (copied frombootstrap.go) and rejects unrelated failures; existing launcher tests green.cix.db, retired bootstrap password, refusal in the log tail. A fresh DMG is built for end-to-end verification.🤖 Generated with Claude Code