Editor has no 'auto-name' for paths based on shape — user creating a closed polygon gets 'Path 1', a circle gets 'Path 2', no semantic naming, makes the path list harder to navigate #327

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

Finding

grep -rn 'autoName\|detectShape\|suggestName' src/components/editor/ returns 0. The editor doesn't auto-detect path shapes.

A user creates paths:

  • "Path 1" (a circle, 8 nodes)
  • "Path 2" (a square, 4 nodes)
  • "Path 3" (a triangle, 3 nodes)
  • "Path 4" (a star, 10 nodes)

The names don't tell them anything. Auto-naming would suggest:

  • "Path 1" → "Closed Path" (closed)
  • "Path 2" → "Closed Path" (closed, rectangular)
  • "Path 3" → "Closed Path" (closed, triangular)
  • "Path 4" → "Open Path" (open, star-like)

Or more specifically:

  • "Path 1" → "Circle (8 nodes)"
  • "Path 2" → "Rectangle (4 nodes)"
  • "Path 3" → "Triangle (3 nodes)"

Where

  • handleFinishPath: src/pages/Editor.tsx (where the path is created)
  • No auto-name: grep -rn 'autoName' src/components/editor/ returns 0

Suggested fix shape

  1. Algorithm: a suggestPathName(nodes: PathNode[]): string function:
function suggestPathName(nodes: PathNode[]): string {
  if (nodes.length === 0) return 'Path';
  if (nodes.length === 1) return 'Point';
  if (nodes.length === 2) return 'Line';
  if (nodes.length === 3) return 'Triangle';
  if (nodes.length === 4) return 'Rectangle';
  if (nodes.length > 4) {
    // Detect regularity: a path with all-equal-length segments is likely a regular polygon (circle, etc.)
    const lengths = nodes.slice(1).map((n, i) => distance(n, nodes[i]));
    const avg = lengths.reduce((a, b) => a + b, 0) / lengths.length;
    const variance = lengths.reduce((sum, l) => sum + (l - avg) ** 2, 0) / lengths.length;
    if (variance < avg * 0.1) return `Regular Polygon (${nodes.length} sides)`;
    return `Closed Path (${nodes.length} nodes)`;
  }
  return 'Path';
}
  1. UI: when creating a path, the suggested name is used:
const newPath: StitchPath = {
  // ... existing fields
  name: suggestPathName(newNodes),
};
  1. User override: the user can rename (per #310). The auto-name is the default.

  2. Open vs closed: detect by checking if the last node is near the first. If yes, "Closed Path"; if no, "Open Path."

Severity

Low. The user can rename. Power users with many paths notice.

Discovered by

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

  • #310 (open) — Rename. The user can change the auto-name.
  • The path's geometry is the source of the name; the algorithm is the addition.
  • Figma's auto-named layers (e.g., "Rectangle 1") is the parallel.
## Finding `grep -rn 'autoName\|detectShape\|suggestName' src/components/editor/` returns 0. The editor doesn't auto-detect path shapes. A user creates paths: - "Path 1" (a circle, 8 nodes) - "Path 2" (a square, 4 nodes) - "Path 3" (a triangle, 3 nodes) - "Path 4" (a star, 10 nodes) The names don't tell them anything. Auto-naming would suggest: - "Path 1" → "Closed Path" (closed) - "Path 2" → "Closed Path" (closed, rectangular) - "Path 3" → "Closed Path" (closed, triangular) - "Path 4" → "Open Path" (open, star-like) Or more specifically: - "Path 1" → "Circle (8 nodes)" - "Path 2" → "Rectangle (4 nodes)" - "Path 3" → "Triangle (3 nodes)" ## Where - handleFinishPath: `src/pages/Editor.tsx` (where the path is created) - No auto-name: `grep -rn 'autoName' src/components/editor/` returns 0 ## Suggested fix shape 1. **Algorithm**: a `suggestPathName(nodes: PathNode[]): string` function: ```ts function suggestPathName(nodes: PathNode[]): string { if (nodes.length === 0) return 'Path'; if (nodes.length === 1) return 'Point'; if (nodes.length === 2) return 'Line'; if (nodes.length === 3) return 'Triangle'; if (nodes.length === 4) return 'Rectangle'; if (nodes.length > 4) { // Detect regularity: a path with all-equal-length segments is likely a regular polygon (circle, etc.) const lengths = nodes.slice(1).map((n, i) => distance(n, nodes[i])); const avg = lengths.reduce((a, b) => a + b, 0) / lengths.length; const variance = lengths.reduce((sum, l) => sum + (l - avg) ** 2, 0) / lengths.length; if (variance < avg * 0.1) return `Regular Polygon (${nodes.length} sides)`; return `Closed Path (${nodes.length} nodes)`; } return 'Path'; } ``` 2. **UI**: when creating a path, the suggested name is used: ```ts const newPath: StitchPath = { // ... existing fields name: suggestPathName(newNodes), }; ``` 3. **User override**: the user can rename (per #310). The auto-name is the default. 4. **Open vs closed**: detect by checking if the last node is near the first. If yes, "Closed Path"; if no, "Open Path." ## Severity Low. The user can rename. Power users with many paths notice. ## Discovered by Gap analysis (2026-10-02) of editor path naming. ## Related - #310 (open) — Rename. The user can change the auto-name. - The path's geometry is the source of the name; the algorithm is the addition. - Figma's auto-named layers (e.g., "Rectangle 1") is the parallel.
Author
Owner

Fixed in commit 3372789 (feat #327).

suggestShapeName(nodes, closed) produces:

  • 1 node → "Point"
  • 2 nodes → "Line"
  • 3 nodes → "Triangle"
  • 4 nodes → "Rectangle"
  • ≥5 with low segment-length variance → "Regular Polygon (n sides)"
  • ≥5 otherwise → "Open Path (n nodes)" or "Closed Path (n nodes)"

autoNameForPath(stitchType, paths, shapeDescriptor) joins with em-dash, e.g. "Satin 1 — Triangle". Descriptor-suffixed names don't pin a slot (the index scan is end-anchored on <Type> <n>), preserving the #210 rule that any non-canonical name is treated as user-renamed. User can still rename via the existing #310 path.

Gates:

  • 26/26 vitest tests (16 new in src/pages/issue-327.test.ts, 10 existing in src/pages/issue-210.test.ts — no regression)
  • tsc --noEmit clean
  • eslint clean on touched files
  • Pushed to origin/main as commit 3372789

Note: CI status row on 3372789 reports "Waiting to run" referencing /actions/runs/301/jobs/0 which 404s — the actions runner queue appears empty/disabled for this repo (not a CI gate failure on this commit). The local gates above are the truthful verification.

Fixed in commit 3372789 (feat #327). `suggestShapeName(nodes, closed)` produces: - 1 node → "Point" - 2 nodes → "Line" - 3 nodes → "Triangle" - 4 nodes → "Rectangle" - ≥5 with low segment-length variance → "Regular Polygon (n sides)" - ≥5 otherwise → "Open Path (n nodes)" or "Closed Path (n nodes)" `autoNameForPath(stitchType, paths, shapeDescriptor)` joins with em-dash, e.g. "Satin 1 — Triangle". Descriptor-suffixed names don't pin a slot (the index scan is end-anchored on `<Type> <n>`), preserving the #210 rule that any non-canonical name is treated as user-renamed. User can still rename via the existing #310 path. Gates: - 26/26 vitest tests (16 new in src/pages/issue-327.test.ts, 10 existing in src/pages/issue-210.test.ts — no regression) - tsc --noEmit clean - eslint clean on touched files - Pushed to origin/main as commit 3372789 Note: CI status row on 3372789 reports "Waiting to run" referencing /actions/runs/301/jobs/0 which 404s — the actions runner queue appears empty/disabled for this repo (not a CI gate failure on this commit). The local gates above are the truthful verification.
Mark closed this issue 2026-10-05 01:49:10 +00:00
Sign in to join this conversation.
No description provided.