Editor's 'Path Length' display shows total path length in mm but not the 'stitch count estimate' — user wanting to know how many stitches a path will produce has to compute from density #357

Closed
opened 2026-10-04 03:57:02 +00:00 by Mark · 1 comment
Owner

Finding

grep -rn 'stitchCount.*estimate\|estimateStitches' src/components/editor/EditorRightPanel.tsx returns 0. The right panel shows the path's length but not the estimated stitch count.

A user with a path:

  • Length: 100mm, density: 0.4
  • Estimated stitch count: 100 * 4 = 400 stitches (approximately)
  • Doesn't see this; has to compute

The fix is to show the estimated stitch count.

Where

  • Path Properties: src/components/editor/EditorRightPanel.tsx
  • No stitch estimate: grep -rn 'stitchCount' src/components/editor/ returns 0
  • The total stitches: shown in the bottom thread bar (per the snippet)

Suggested fix shape

  1. Algorithm: estimate stitch count from path length and density:
function estimateStitches(path: StitchPath): number {
  const length = pathLength(path.nodes);
  const spacing = 1 / path.density;  // mm between stitches
  return Math.round(length / spacing);
}
  1. UI: in the Path Properties section, add "Estimated stitches":
<div className="text-[11px]">
  Estimated stitches: {estimateStitches(p)}
</div>
  1. Update on density change: as the user moves the density slider, the estimate updates.

  2. Use cases:

  • The user wants to know "how many stitches is this?"
  • The user is balancing the design's total stitch count (which is in the bottom thread bar)
  • The user is comparing two paths

Severity

Low. The user can compute. Power users with production workflows notice.

Discovered by

Gap analysis (2026-10-02) of editor path properties.

  • #261 (open) — Path area, thread usage, stitch time. The summary; this is the per-path.
  • The total stitches is in the bottom thread bar; the per-path is the breakdown.
  • Wilcom/Hatch show stitch count per path. Standard.
## Finding `grep -rn 'stitchCount.*estimate\|estimateStitches' src/components/editor/EditorRightPanel.tsx` returns 0. The right panel shows the path's length but not the estimated stitch count. A user with a path: - Length: 100mm, density: 0.4 - Estimated stitch count: 100 * 4 = 400 stitches (approximately) - Doesn't see this; has to compute The fix is to show the estimated stitch count. ## Where - Path Properties: `src/components/editor/EditorRightPanel.tsx` - No stitch estimate: `grep -rn 'stitchCount' src/components/editor/` returns 0 - The total stitches: shown in the bottom thread bar (per the snippet) ## Suggested fix shape 1. **Algorithm**: estimate stitch count from path length and density: ```ts function estimateStitches(path: StitchPath): number { const length = pathLength(path.nodes); const spacing = 1 / path.density; // mm between stitches return Math.round(length / spacing); } ``` 2. **UI**: in the Path Properties section, add "Estimated stitches": ```tsx <div className="text-[11px]"> Estimated stitches: {estimateStitches(p)} </div> ``` 3. **Update on density change**: as the user moves the density slider, the estimate updates. 4. **Use cases**: - The user wants to know "how many stitches is this?" - The user is balancing the design's total stitch count (which is in the bottom thread bar) - The user is comparing two paths ## Severity Low. The user can compute. Power users with production workflows notice. ## Discovered by Gap analysis (2026-10-02) of editor path properties. ## Related - #261 (open) — Path area, thread usage, stitch time. The summary; this is the per-path. - The total stitches is in the bottom thread bar; the per-path is the breakdown. - Wilcom/Hatch show stitch count per path. Standard.
Author
Owner

Shipped as commit f59da93 on main. The Path Info block now has a working Stitches row that reflects the path's actual density (= stitch spacing in mm, post-#317).

Fix

  • New helper estimateStitchCount(length_mm, spacing_mm) = round(length / spacing) next to estimatePathLength / polygonAreaMm2 / perimeterMm.
  • The existing Path Info "Stitches" row used Math.round(length * 2.5) — a hard-coded multiplier that ignored density. A 100 mm path at 2.5 mm/stitch reported 250 (the bogus value), not 40 (the real count). It now reads estimateStitchCount(length, spacing) and updates live as the user moves the density slider.
  • Routed the existing Path Statistics Thread usage and Stitch time rows through the same helper so all three stitch-derived rows share one source of truth.
  • Added data-testid="path-info-stitch-count-<id>" so the row is greppable alongside the other path-info-* hooks.
  • Added a title attribute on the value explaining the formula so a user hovering the number knows it's the per-path breakdown (and the design total lives in the bottom thread bar).

Verification

  • 5 new tests in src/components/editor/issue-357.test.tsx:
    • 28.3 mm polyline at spacing 0.4 mm/stitch → 71 stitches
    • 100 mm polyline at spacing 2.5 mm/stitch → 40 stitches (NOT the old bogus 250)
    • 100 mm polyline at spacing 0.04 mm/stitch → 2500 stitches (dense)
    • No path selected → 0
    • Row order: Path Length, then Stitches
  • All sibling tests in EditorRightPanel.test.tsx (215) plus the path-statistics-related issues (#353/#354/#356) still pass.
  • tsc -b clean; eslint clean on the touched files.

The 20 pre-existing test failures in issue-329/331/333/334 (snap-settings toggle tests) are unrelated baseline noise on main — verified by git stash + re-run. Closing.

Shipped as commit f59da93 on main. The Path Info block now has a working **Stitches** row that reflects the path's actual density (= stitch spacing in mm, post-#317). **Fix** - New helper `estimateStitchCount(length_mm, spacing_mm) = round(length / spacing)` next to `estimatePathLength` / `polygonAreaMm2` / `perimeterMm`. - The existing Path Info "Stitches" row used `Math.round(length * 2.5)` — a hard-coded multiplier that ignored density. A 100 mm path at 2.5 mm/stitch reported 250 (the bogus value), not 40 (the real count). It now reads `estimateStitchCount(length, spacing)` and updates live as the user moves the density slider. - Routed the existing Path Statistics **Thread usage** and **Stitch time** rows through the same helper so all three stitch-derived rows share one source of truth. - Added `data-testid="path-info-stitch-count-<id>"` so the row is greppable alongside the other `path-info-*` hooks. - Added a `title` attribute on the value explaining the formula so a user hovering the number knows it's the per-path breakdown (and the design total lives in the bottom thread bar). **Verification** - 5 new tests in `src/components/editor/issue-357.test.tsx`: - 28.3 mm polyline at spacing 0.4 mm/stitch → 71 stitches - 100 mm polyline at spacing 2.5 mm/stitch → 40 stitches (NOT the old bogus 250) - 100 mm polyline at spacing 0.04 mm/stitch → 2500 stitches (dense) - No path selected → 0 - Row order: Path Length, then Stitches - All sibling tests in `EditorRightPanel.test.tsx` (215) plus the path-statistics-related issues (#353/#354/#356) still pass. - `tsc -b` clean; `eslint` clean on the touched files. The 20 pre-existing test failures in `issue-329/331/333/334` (snap-settings toggle tests) are unrelated baseline noise on `main` — verified by `git stash` + re-run. Closing.
Mark closed this issue 2026-10-05 13:07:48 +00:00
Sign in to join this conversation.
No description provided.