Skip to content

fix: Mesh Tools items from #34 - #55

Open
Jozkah wants to merge 8 commits into
CNCKitchen:mainfrom
Jozkah:review/mesh-tools
Open

Jozkah wants to merge 8 commits into
CNCKitchen:mainfrom
Jozkah:review/mesh-tools

Conversation

@Jozkah

@Jozkah Jozkah commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

The Mesh Tools items from #34, rebased on 0.9.3, one commit per item, each with a regression test that fails without it:

  • fix: validate the mesh-tools copy map before replacing the session
  • fix: count edits waiting on the mesh-tools copy as session work
  • fix: refuse mesh region vertex numbers past 32 bits
  • fix: read the whole cut offset when naming it in inches
  • fix: repaint the trim piece's gap colours in place
  • fix: show a failed mesh survey with a retry instead of a spinner
  • perf: subscribe mesh tool panels to the fields they read
  • perf: bound the undo history by the memory edited copies hold

Notes:

  • The undo history now has a 1 GiB budget, weighed by the edited copies it holds, and always keeps the newest step. This adds an optional bytes() to HistorySection in src/state/historyStore.ts. There's no notice yet telling the user that older steps went.
  • Not done: moving the edit round-trip (PLY write and parse) into the worker. That changes the main/worker protocol, so it seemed too big for this PR.

Build: npm run build passes. npm test (3102), npm --prefix mcp test (127), the plugin boundary and units checks, and npm run e2e:ci all pass.

The copy map was only checked after the session had been replaced, and a torn map threw from the Int32Array constructor before the length check could run. Prepare now refuses a map that is not whole int32s or holds numbers below -1, and restore refuses numbers past the copy's own vertex count and drops the edits that waited on a copy it could not load.
Edits made on the edited copy stay pending until the copy is taken into use, and holdsWork and holds looked only at the adopted edits, so opening a project or scan dropped a cleaned-up copy without a warning or refusal. Both now count the pending edits too.
Region vertex numbers were turned into a Uint32Array before the worker checked them, so a number of 2^32 or more wrapped round and silently selected another vertex. The schema now caps them and regionVertices refuses one out of range before the conversion.
A cut's label keeps its offset as String() wrote it in mm, which is exponent form for very small or very large offsets, and the pattern that names it again in inches matched only the exponent's digits. The pattern now takes the exponent with the figure.
Each repaint of the piece's gap set a new colour attribute on its geometry, and three frees an attribute's GPU buffer only for those the geometry still holds when it is disposed, so every replaced one stayed uploaded. The piece now keeps one colour attribute and paints over it.
The island, hole and shell surveys set their result to null while being made and only raised a toast when the worker call failed, so the panel kept showing the survey as in flight for ever. A failure is now kept in the store as surveyFailed, the panels show it with a Retry that makes the survey again.
Six tool panels read the Mesh Tools store with no selector, so every write to it rendered them again, the cut preview among them while its offset is dragged. They now pick the fields they use with useShallow, as the other panels already do.
Every Mesh Tools edit captures a whole PLY of the copy and its vertex map in the undo history, which was bounded only by its count of 64 steps, so a large scan could pin several gigabytes. History sections can now weigh their values, the edited copy section does, and the oldest steps are dropped once the values kept pass a 1 GiB budget.

This branch has not been deployed

No deployments
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