Add default bin settings#52
Conversation
jasonmadigan
left a comment
There was a problem hiding this comment.
changes requested
blocker
precedence bug: localStorage trumps project defaults -- projects/[id]/page.tsx always sends bin_config: project.default_bin_config || getDefaultBinDefaults(). Since bin_config is always truthy, the backend fallback req.bin_config or project.default_bin_config in routes.py never reaches project.default_bin_config. Global localStorage defaults silently override server-stored project defaults.
should fix
silent BinDefaults to BinConfig upcast -- _build_bin_from_tools does BinConfig.model_validate(default_config.model_dump()) where default_config is BinDefaults (lacks text_labels). Works because text_labels defaults to [], but if BinConfig gains a field with a non-trivial default this breaks silently. Consider explicit construction.
binDefaultsFromConfig manually enumerates fields -- fragile; adding a field to BinDefaults requires updating this function. Destructure to strip text_labels instead: const { text_labels, ...defaults } = buildBinConfig(config).
defaultsStatus message never clears -- "Defaults saved" / "Defaults reset" persists until navigation. Add a timeout.
no test for project update round-trip -- PUT /api/bin-projects/{id} with default_bin_config is untested.
no guard for localStorage unavailability -- saveDefaultBinConfig and resetDefaultBinConfig call localStorage.setItem with no SSR/private-browsing guard.
nits
dev.ps1(167 lines) is out of scope for a "default bin settings" PR -- should be a separate PR
good contribution overall -- the BinDefaults/BinConfig type split is clean, test coverage is solid, and the feature addresses the request in #49. The precedence bug is the main thing to sort out.
3d4e68f to
ef2e929
Compare
|
Thanks Jason, I’ve pushed an update addressing the review feedback. Changes made:
Validation:
|
There was a problem hiding this comment.
all previous feedback addressed. tests pass, clean security audit. minor suggestions (no-op exclude in routes.py, bed_size validator) can be follow-ups.
thanks again @noobydp!
* Add default bin settings * Address default bin settings review
Fixes #49
Summary
Testing
python -m pytest -qfrombackend- 71 passed.npm exec vitest run srcfromfrontend- 9 passed.npm exec tsc -- --noEmitfromfrontend.npm run buildfromfrontend.Codex disclosure
This draft PR was prepared with assistance from OpenAI Codex.