Skip to content

feat: Sketch to CAD - #46

Open
uswii wants to merge 12 commits into
mainfrom
feat/sketch-to-cad
Open

feat: Sketch to CAD#46
uswii wants to merge 12 commits into
mainfrom
feat/sketch-to-cad

Conversation

@uswii

@uswii uswii commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace the CAD to Catalog card in CAD Studio with a Sketch to CAD entry (PenTool icon, /sketch-to-cad route, no longer comingSoon)
  • New multi-sketch upload page (SketchToCAD.tsx): grid layout, max 10 sketches per batch, per-sketch expandable hint input, live credit estimate, mobile-responsive sticky footer
  • sketch_generate_v1 workflow: base64 data URI sent directly as reference_image -- no Azure pre-upload (backend handles CAS normalization)
  • use-sketch-to-cad-generation.ts: credit preflight (backend /api/credits/estimate first, 85cr fallback), base64 read, poll + parse GLB artifact, refreshCredits() on success (Rule 6)
  • SketchLeftPanel.tsx + SketchUploadScreen.tsx: workspace panel components for sketch mode
  • Feature gate: isSketchToCadEnabled() via VITE_SKETCH_TO_CAD_ALLOWLIST_EMAILS
  • PostHog: trackSketchToCadCompleted event
  • 6 Vitest tests covering workflow payload shape and return nodes -- all passing

Test plan

  • npx vitest run src/lib/sketch-to-cad-workflows.test.ts -- all 6 pass
  • Navigate to /studio-cad -- card shows "Sketch to CAD" with PenTool icon, not "CAD to Catalog"
  • Navigate to /sketch-to-cad -- upload page loads, drag/click to add sketches (up to 10)
  • Add a hint to a sketch -- chevron toggles input, dot indicator appears when hint set
  • Credit estimate updates as sketches are added/removed
  • Sticky footer visible on mobile with correct credit total
  • Generate -- credit preflight fires, workflow POSTs to /api/run/sketch_generate_v1 with reference_image as data URI
  • Poll progresses through generate_from_sketch, build_initial, build_retry, validate_against_sketch, build_corrected
  • On success, GLB loads in CAD viewport (identical to TextToCAD -- hard rule)

uswii added 12 commits April 16, 2026 23:38
- Replace CAD to Catalog card in CADStudio with Sketch to CAD (PenTool icon, /sketch-to-cad route)
- Add /sketch-to-cad route in App.tsx behind ProtectedRoute + CADGate
- sketch-to-cad-workflows.ts: workflow constants and buildSketchToCadStartBody for sketch_generate_v1
- use-sketch-to-cad-generation.ts: credit preflight, base64 data URI upload, poll + parse GLB result
- SketchToCAD.tsx: multi-sketch upload page (max 10), per-sketch hint, credit estimate, mobile-responsive sticky footer
- SketchLeftPanel.tsx + SketchUploadScreen.tsx: workspace components for sketch mode
- posthog-events.ts: trackSketchToCadCompleted event
- feature-flags.ts: isSketchToCadEnabled gate (allowlist, owner uswa@raresense.so)
- credits-api.ts: sketch_generate_v1 fallback cost (85 credits)
- sketch-to-cad-workflows.test.ts: 6 tests covering payload shape and return nodes
- Move sketchSessionStore to src/lib/sketch-session-store.ts
- Add mode=sketch handler in TextToCAD: skips InitialPromptScreen and auto-starts sketch generation workflow
- Add generate_from_sketch/validate_against_sketch labels to GenerationProgress
- Redesign SketchToCAD upload screen: two-column layout, Diamond icon with pulse, guide panel, matching photo studio aesthetic
- Add explanation to eslint-disable in SketchToCAD.tsx (Rule 9)
- Replace ternary statement with if/else in onClick handler (lint error)
- Remove unused eslint-disable directive in use-sketch-to-cad-generation.ts
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