Skip to content

Add default bin settings#52

Merged
jasonmadigan merged 2 commits into
tracefinity:mainfrom
noobydp:codex/default-bin-settings
Jun 4, 2026
Merged

Add default bin settings#52
jasonmadigan merged 2 commits into
tracefinity:mainfrom
noobydp:codex/default-bin-settings

Conversation

@noobydp

@noobydp noobydp commented May 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #49

Summary

  • Add shared bin defaults for standalone and project bin creation.
  • Persist global bin defaults in frontend settings, including magnet diameter/depth and corners-only placement.
  • Add project-level bin defaults and pass them through when creating project bins.
  • Document the API and architecture updates for bin defaults.

Testing

  • python -m pytest -q from backend - 71 passed.
  • npm exec vitest run src from frontend - 9 passed.
  • npm exec tsc -- --noEmit from frontend.
  • npm run build from frontend.
  • I've done basic tests with a few tools and bins.

Codex disclosure

This draft PR was prepared with assistance from OpenAI Codex.

@noobydp
noobydp marked this pull request as ready for review May 31, 2026 15:11

@jasonmadigan jasonmadigan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@noobydp
noobydp force-pushed the codex/default-bin-settings branch from 3d4e68f to ef2e929 Compare June 4, 2026 08:17
@noobydp

noobydp commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks Jason, I’ve pushed an update addressing the review feedback.

Changes made:

  • Fixed the project/default precedence issue by only sending browser-global defaults when the project has no server-side default_bin_config.
  • Made _build_bin_from_tools construct BinConfig explicitly from defaults with text_labels=[].
  • Simplified binDefaultsFromConfig to strip text_labels via destructuring.
  • Added timeout/cleanup for the “Defaults saved/reset” status message.
  • Guarded settings writes so localStorage failures don’t throw.
  • Added backend coverage for updating and clearing project default_bin_config.
  • Changed the project Bin defaults UI into a collapsed-by-default section.
  • Fixed section header height so expand/collapse does not shift the heading text.
  • Cleaned the PR branch so the unrelated Windows launcher commit/files are no longer included.

Validation:

  • python -m pytest -q -> 72 passed
  • npm exec vitest run src -> 20 passed
  • npm exec tsc -- --noEmit
  • npm run build

@jasonmadigan jasonmadigan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@jasonmadigan
jasonmadigan merged commit f7e8be2 into tracefinity:main Jun 4, 2026
1 check passed
shanetinklenberg pushed a commit to shanetinklenberg/tracefinity that referenced this pull request Jun 28, 2026
* Add default bin settings

* Address default bin settings review
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.

Feature: default bin settings

2 participants