Editor → Workspace round-trip silently drops user edits: Editor never writes its mutated paths back to sessionStorage.tc_workspace_snapshot or to the Workspace state #110
Labels
No labels
blocked:commit-ready-failed
blocked:gate-fetch
blocked:gate-lint
blocked:gate-plan
blocked:gate-research
blocked:needs-attention
blocked:needs-decision
blocked:needs-human
blocked:no-changes
blocked:verify-failed
bug
deferred
feature-request
in-progress
needs-decompose
needs-triage
quickfix
security/medium
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/Kimi_Agent_Brother_10_Digitizing_App#110
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug: Editor → Workspace round-trip loses user edits — Editor never writes its mutated
pathsback to sessionStorageReproduction
cd ~/Projects/Kimi_Agent_Brother_10_Digitizing_App && npm run devhttp://localhost:3000/./editor.sessionStorage.tc_workspace_snapshotand loads the paths./workspace).Expected
Either of:
pathsback tosessionStorage.tc_workspace_snapshoton every change, so returning to Workspace re-hydrates the latest state.useState.Actual
src/pages/Editor.tsx:29definesSNAPSHOT_STORAGE_KEY = 'tc_workspace_snapshot'.src/pages/Editor.tsx:32-72reads from it on mount vialoadInitialPaths().src/pages/Editor.tsxnever callssessionStorage.setItem(SNAPSHOT_STORAGE_KEY, ...)anywhere. Verified bygrep -nE 'setItem.*SNAPSHOT|setItem.*workspace' src/pages/Editor.tsx src/components/editor/*.tsx— zero hits.src/components/editor/EditorHeader.tsxhas "Export PES", "Undo", "Redo", "Settings — coming soon" — no "Save" or "Apply" button.grep -rnE 'addDesign|saveDesigns' src/components/editor/returns zero hits — Editor never persists to Gallery.useWorkspace.ts:764saveCurrentDesignreads fromstate.stitchObjects(React useState), not from sessionStorage. So Editor's edits are invisible to the Save flow even if you go back to Workspace first.Why this matters
The user-story is: upload → digitize → refine in editor → save. The middle step (refine in editor) is silently dropped. A user who spends 10 minutes tweaking stitch colors and node positions in the Editor loses everything when they return to the Workspace to save. The only way to persist Editor edits is to click "Export PES" inside the Editor, which is a separate action that doesn't touch the Workspace's Gallery save flow.
Related prior art
addDesign({ ... snapshot })so a Gallery save persists the geometry that Workspace can reload. So the Gallery → Workspace and Workspace → Editor bridges exist; only Editor → Workspace (the write-back half) is missing.Suggested fix scope
Option A (minimum invasive): Editor writes to sessionStorage on every path mutation:
Then in
useWorkspace.ts, on mount, hydratestate.stitchObjectsfromsessionStorage.tc_workspace_snapshotif present (similar to how Gallery'sLOAD_DESIGN_STORAGE_KEYis handled inuseWorkspace.ts:loadDesignFromSessionStorage).Option B (preferred): Move
pathsstate to a shared Zustand/context/store that both Editor and Workspace read from. Add a real "Apply" button in the Editor that explicitly writes the merged state back to the workspace store, and a clear UX signal ("Edits applied to workspace at 2:34pm").Labels
Severity
High. User-data loss in the primary workflow. A user refining a digitized design in the Editor and clicking "Save to Gallery" loses every edit. This breaks the core "upload → digitize → refine → save → export" user story. Every embroiderer who uses the Editor will hit this.
Fixed in commit
ce57a37on main.Root cause: Editor.tsx mutated
pathsin local React state but never wrote back tosessionStorage.tc_workspace_snapshot, so returning to /workspace silently reverted to the pre-editor geometry. Additionally, Workspace.tsx never re-hydrated from that key on mount even if a write existed.Fix:
paths+filenameintotc_workspace_snapshoton every change. Shape matchescommitDigitizedResult's payload.tc_workspace_snapshotif present and dispatches LOAD_DESIGN, mirroring the Gallery → Workspace bridge fortc_load_design_snapshot. Snapshot is not removed on consume so re-entering the Editor still sees the latest state.Tests (all 367 pass; lint + tsc -b + vite build clean):
Repro now passes: editing in /editor → "Back to Workspace" re-hydrates the latest paths; "Save to Gallery" captures the edited state, not the original.
selectedPathIdis local useState, the right panel re-renders with no selection on remount #162