Seed the movies demo once instead of on every boot - #5
Open
tamohannes wants to merge 1 commit into
Open
Conversation
`init` set the whole shelf unconditionally, so starting the demo a second time replaced everything the user had logged with the four sample rows. The About page in that same demo says "Every row lives in rocksdb. Restart, everything is still there." Guard the seed on `State.total.missing()` so it fires only against a store that has never been written. `selected` stays unconditional: it is a cursor into the detail page, not user data. Same change in both copies, `examples/movies.py` and the bundled `nu demo movies`. Co-Authored-By: Claude Opus 5 (1M context) <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.
nu demo moviesthrows away everything you log the moment you restart it.initran on every boot and set the whole shelf unconditionally:So the second start overwrites the store with the four samples. The About page inside that same demo says "Every row lives in rocksdb. Restart, everything is still there," which makes it the worst place for this to happen: persistence is the claim the demo exists to make.
Fix
Guard the seed on
State.total.missing()so it fires only against a store that has never been written.selectedstays an unconditional set, since it is a cursor into the detail page rather than user data. Both copies get the change,examples/movies.pyand the bundlednu demo movies.Why not
.init()That was the first attempt, since
counter,sampledandtelegram_echoall seed with.init()and it reads better. On an empty store it left the shelf empty: the item leaves seeded, andState.movies.init(_SEED_MOVIES)wrote nothing, soMissingon aShapesListRefseems to be false even before anything is written. Might be intended for collection Forms, might be worth its own look. Guarding on one item leaf sidesteps it and has the nicer property of making the seed all or nothing.Verification
Store wiped between runs, then:
_SEED_MOVIESEditing the seed list is a stand in for a row you logged yourself: it proves whether boot number two writes over what is already there.
🤖 Generated with Claude Code