Skip to content

Clamp auto-size to the supported grid range - #16

Merged
1Richter merged 3 commits into
mainfrom
fix/clamp-autosize-grid
Aug 4, 2026
Merged

Clamp auto-size to the supported grid range#16
1Richter merged 3 commits into
mainfrom
fix/clamp-autosize-grid

Conversation

@1Richter

@1Richter 1Richter commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Draft PR opened for review. Branch: fix/clamp-autosize-grid.

Leon Richter and others added 3 commits August 1, 2026 21:24
The grid sliders cap at 10u and the backend rejects anything outside
1-10u (validate_grid), but auto-size computed grid_x/grid_y purely from
tool bounds. A tool wider than 420mm drove the bin past the cap, which
broke the 2D canvas grid and the partial-bin matrix and made the save
fail on the backend.

Both auto-size paths now go through a shared clampGrid() helper, and the
bin page shows a banner when a tool needed more room than the maximum
bin can offer. The 1-10u limits live in constants.ts next to GRID_UNIT
so the sliders and the clamp cannot drift apart.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The gridClamped flag was written from both auto-size and handleAddTool and
cleared from neither of the paths that matter. Deleting the last tool made
the auto-size effect return early, so the banner stayed on screen over an
empty bin; adding a small tool to an already-clamped 10u bin computed
max(10, small) == 10, which is not over the limit, so it wrongly cleared a
banner that was still true.

Compute it instead from the tool bounds, where it cannot go stale. That
needed the "grid units to fit this span" maths in one place, so it moves to
lib/binGrid.ts along with the bounds walk both call sites had inlined.

The banner now also says that the overflowing geometry is cut off, which is
what actually happens once the grid stops growing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The banner reads from the union bounds of every placed tool, so "a tool needs
more room" is wrong whenever two tools together overflow a bin that either
would fit alone, and "move that tool into a bin of its own" is impossible
advice when one tool really is longer than 420mm. Say both things.

It also fired with auto-size off, describing a grid that had stopped growing
when nothing was growing it. Gate on autoSize.

handleAddTool dropped a tool with no points rather than adding it un-centred.
Unreachable for a traced tool, but silently discarding what the user asked for
is the wrong failure.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1Richter added a commit that referenced this pull request Aug 4, 2026
Brings together every open self-host PR (#2-#16) on top of upstream 0.8.0+7:

  #2  fix/half-grid-cell-placement       #10 feat/custom-bin-size-mm
  #3  feat/split-multi-part              #11 feat/cutout-line
  #4  feat/preview-bed-size-grid         #12 feat/dashboard-hide-project-bins
  #5  fix/split-parts-3mf-export         #13 feat/persist-tracer-selection
  #6  feat/always-export-3mf             #14 feat/tool-quantity-duplicates
  #7  ci/run-frontend-tests              #15 feat/unload-idle-models
  #8  feat/bin-editor-cutout-depth-cap   #16 fix/clamp-autosize-grid
  #9  feat/bin-editor-cutout-editing

Verified: 401 backend tests, 189 frontend tests, ruff and tsc clean.
@1Richter
1Richter merged commit db4e8ea into main Aug 4, 2026
4 checks passed
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.

1 participant