Skip to content

feat(viewer): add source-backed feature editing - #341

Open
amywork777 wants to merge 6 commits into
earthtojake:developfrom
amywork777:amy/viewer-feature-editing
Open

feat(viewer): add source-backed feature editing#341
amywork777 wants to merge 6 commits into
earthtojake:developfrom
amywork777:amy/viewer-feature-editing

Conversation

@amywork777

@amywork777 amywork777 commented Aug 26, 2026

Copy link
Copy Markdown

Summary

  • add a dependency-free, viewer-local AST parser for common build123d construction features
  • show a SolidWorks-style Design tree above the existing read-only Geometry tree
  • add Edit Sketch as a temporary state of the existing 3D viewport—not a second viewer or panel
  • recover static authored sketch planes, offsets, outer/profile Locations, and add/subtract profiles
  • snap normal to the sketch plane, ghost the accepted solid, and draw live dimensions and anchors on the model
  • preserve the exact prior 3D camera, projection, zoom, selection, visibility, and display state
  • keep dimension changes as local drafts; Return to 3D preserves drafts while Cancel/Escape discards them
  • guard source writes with the captured SHA-256 hash, exact source spans, Python syntax validation, and atomic replacement
  • make Apply call the existing canonical POST /__cad/artifact cadgen rebuild path and reload only its accepted artifact
  • keep imported STEP files geometry-only because they do not contain editable construction history

Visual proof

1. Existing Design + Geometry view remains

The source-backed Design tree still lives above the honest read-only Geometry tree. Sketch editing does not remove or replace the original viewer.

Design tree with Boss-Extrude1, nested Sketch1, Hole1, and the extrude dimension

2. Edit Sketch snaps onto the actual model

The same 3D viewport temporarily looks normal to the authored sketch plane. The accepted solid is ghosted and the rectangle, subtractive circle, dimensions, and anchors are projected in model coordinates.

On-model sketch editing with authored profile and dimensions

3. Drafts update on-model without changing the artifact

Changing the width from 50 mm to 54 mm immediately updates the profile and callout. The existing accepted solid remains visible underneath until Apply.

Live 54 mm draft over the accepted solid

4. Cancel/Return restores the original 3D view

Leaving sketch mode restores the exact previous camera, projection, and 100% zoom. The normal Geometry tree and native viewer controls remain available.

Original 3D view restored after leaving sketch mode

Boundary with #340

This PR does not add a regeneration endpoint, worker, cache, artifact chooser, or alternate build path. The source route reads and commits source only. Rebuilding remains owned by the existing cadgen artifact API, whose viewer-facing contract stays stable while #340 improves caching behind it.

This PR also excludes Hardcore conversation/project UI, Emdash/Codeg agent infrastructure, Electron code, and generated demo artifacts.

Verification

  • 218/218 viewer backend tests
  • 380/380 viewer JavaScript tests
  • production viewer build
  • git diff --check
  • live Cancel acceptance: changed 50 mm to 52 mm, pressed Escape, verified no source write, draft cleared, tree remained open, and the 3D camera/100% zoom returned
  • live Apply acceptance: changed the rectangle from 40 mm to 50 mm, rebuilt through the canonical artifact route, verified the accepted model and source metadata reloaded, and confirmed no browser errors or overlapping UI

Review note

Dynamic/face-derived sketch planes remain editable through source-backed dimensions, but viewport sketch mode is disabled when their frame cannot be recovered safely. The viewer never invents a plausible-looking plane. This is source-backed profile editing, not a claim that STEP contains native construction history or a full sketch constraint solver.

@amywork777 amywork777 changed the title design(viewer): define source feature editor boundary feat(viewer): add source-backed feature editing Aug 26, 2026
@amywork777
amywork777 marked this pull request as ready for review August 26, 2026 19:27
@amywork777

Copy link
Copy Markdown
Author

Follow-up: source-backed sketch dragging and constraints

The same on-model sketch mode now supports direct source-backed geometry edits:

  • drag cyan dimension handles to change authored width/height values
  • drag the yellow profile center to update authored Locations(...) offsets
  • edit recovered circle center X/Y values
  • apply Center and Equal as real source changes
  • show honest inferred Horizontal, Vertical, Fixed-by-source, Centered, and Equal state without claiming a general constraint solver

Drag-ready sketch

Sketch with draggable dimension and profile handles

Live width drag

Width handle dragged from 50 mm to 59.681 mm on the model

Additional acceptance

  • width drag: 50 → 59.681 mm
  • profile-center drag: (6, 0) → (11.2166, -2.3703)
  • Equal: rectangle height updated to match width
  • Center: circle X/Y updated to 0, 0
  • Cancel: restored Rectangle(50, 24) and Locations((6, 0)) without writing
  • Return to 3D: preserved a 64 mm draft
  • Apply: rebuilt through the existing canonical artifact route and reloaded the accepted 64 mm source/artifact
  • 383/383 viewer JavaScript tests
  • 9 targeted source parser/backend tests
  • production build and git diff --check

This remains deliberately smaller than a SolidWorks sketch solver: every editable action maps to a known source span, and unsupported relationships stay read-only.

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