Editor is initialized with DEMO_PATHS instead of workspace state — no Workspace → Editor bridge #69

Closed
opened 2026-09-14 03:17:02 +00:00 by Mark · 0 comments
Owner

Where: src/pages/Editor.tsx:13 (useState<StitchPath[]>(DEMO_PATHS)).

Bug:

  • Editor is reached via Confirm & Edit in Workspace (Workspace.tsx:63-66), which calls confirmDigitize() then navigate('/editor').
  • But Editor state is local: useState<StitchPath[]>(DEMO_PATHS) from src/components/editor/constants.ts.
  • Editor.tsx never reads useWorkspace(), never accepts stitchObjects as a prop, never pulls from sessionStorage.
  • EditorHeader.tsx:18 defaults filename to 'flower_design.pes' because the prop is never passed (Editor.tsx:309 is a literal).
  • Result: every "Confirm & Edit" click drops the user on the Editor showing flower_design demo paths, not the design just digitized.

Fix consistent with existing patterns:
Mirror the gallery/data.ts session-persistence approach. Steps:

  1. In useWorkspace.ts's commitDigitizedResult (line 383) — after SET_STITCH_OBJECTS — also write the design to sessionStorage.setItem('tc_workspace_snapshot', JSON.stringify({ stitchObjects, threadStops, designSettings })).
  2. In Editor.tsx:13, replace useState<StitchPath[]>(DEMO_PATHS) with a lazy initializer that reads sessionStorage.getItem('tc_workspace_snapshot') and parses it; fall back to DEMO_PATHS if absent.
  3. Pass the live filename from state.designSettings.fileName into EditorHeader's filename prop (drop the flower_design.pes default).

Acceptance: after auto-digitize, Confirm & Edit opens the Editor with the just-digitized paths and the actual filename.

**Where:** `src/pages/Editor.tsx:13` (`useState<StitchPath[]>(DEMO_PATHS)`). **Bug:** - `Editor` is reached via `Confirm & Edit` in Workspace (`Workspace.tsx:63-66`), which calls `confirmDigitize()` then `navigate('/editor')`. - But `Editor` state is local: `useState<StitchPath[]>(DEMO_PATHS)` from `src/components/editor/constants.ts`. - `Editor.tsx` never reads `useWorkspace()`, never accepts `stitchObjects` as a prop, never pulls from sessionStorage. - `EditorHeader.tsx:18` defaults `filename` to `'flower_design.pes'` because the prop is never passed (`Editor.tsx:309` is a literal). - Result: every "Confirm & Edit" click drops the user on the Editor showing `flower_design` demo paths, not the design just digitized. **Fix consistent with existing patterns:** Mirror the `gallery/data.ts` session-persistence approach. Steps: 1. In `useWorkspace.ts`'s `commitDigitizedResult` (line 383) — after `SET_STITCH_OBJECTS` — also write the design to `sessionStorage.setItem('tc_workspace_snapshot', JSON.stringify({ stitchObjects, threadStops, designSettings }))`. 2. In `Editor.tsx:13`, replace `useState<StitchPath[]>(DEMO_PATHS)` with a lazy initializer that reads `sessionStorage.getItem('tc_workspace_snapshot')` and parses it; fall back to `DEMO_PATHS` if absent. 3. Pass the live filename from `state.designSettings.fileName` into `EditorHeader`'s `filename` prop (drop the `flower_design.pes` default). Acceptance: after auto-digitize, Confirm & Edit opens the Editor with the just-digitized paths and the actual filename.
Mark 2026-09-14 03:17:02 +00:00
Sign in to join this conversation.
No description provided.