Commit Graph

5 Commits

Author SHA1 Message Date
Leopoldadmin 39422a4348 fix: layer IDs globally unique - use timestamp-based IDs instead of hardcoded layer-0/1/2/3/4
Root cause: layers.id is TEXT PRIMARY KEY (global unique across all drawings).
Hardcoded IDs layer-0..layer-4 collided when multiple projects tried to create
the same layer IDs. Second project got UNIQUE constraint failed on POST /layers.
Without layers, elements had dangling layer_id refs causing FOREIGN KEY errors.

Fix: makeInitialLayers() generates unique IDs: layer-{timestamp}-{index}.
activeLayerId initialized from first layer, not hardcoded.
activeLayerName uses activeLayerId variable, not hardcoded layer-0.
On project load with existing layers, activeLayerId set from first DB layer.
2026-06-26 20:53:41 +02:00
Leopoldadmin 7ad0e11873 fix: element creation fails with empty layer_id (FOREIGN KEY constraint)
Three fixes:
1. interaction/index.ts: Add layerId to created element in confirmDraw()
2. CanvasArea.tsx: Sync layers to LayerManager via layerManagerRef
3. App.tsx: Fallback to activeLayerId in handleElementCreated if layerId missing

Root cause: LayerManager.activeLayerId was empty because layers were never
synced from React state to the interaction layer LayerManager. New elements
got layer_id="" which failed SQLite FOREIGN KEY constraint.

Also includes Yjs sync race condition fix from previous commit.
2026-06-26 20:31:50 +02:00
Leopoldadmin 7e530dd09a fix: stale closure bug preventing canvas tools from creating elements
- CanvasArea: add useEffect to refresh InteractionEngine callbacks when props change
- App.tsx: handleElementCreated/Deleted/Modified now use functional setElements updates
- Root cause: CanvasArea init useEffect had empty deps, capturing stale callbacks at mount
- handleElementCreated used [...elements, el] with stale elements=[] closure
- Each new element replaced all previous ones instead of appending
- All 343 tests pass, tsc clean
2026-06-26 18:57:09 +02:00
Leopoldadmin 3bec3938d0 fix: ribbon tabs now show per-tab content; add all missing handleRibbonAction handlers
- RibbonBar: conditional rendering per activeTab (start/insert/format/view/tools/ki)
- App.tsx: add onNavigateBack prop for new/open navigation
- App.tsx: implement handlers for new, open, save, copy, paste, zoom-fit, zoom-100, grid, layer, measure, search, plugins, ki, ki-draw, ki-analyze
- App.tsx: implement insert-line, insert-rect, insert-circle, insert-text, insert-freehand, insert-image
- App.tsx: implement format-* placeholder actions
- App.tsx: add clipboard state for copy/paste
- All 343 tests pass, tsc clean
2026-06-26 18:49:16 +02:00
Leopoldadmin 4ec76fe406 feat: initial commit web-cad-neu with docker-compose, frontend and backend 2026-06-26 10:50:24 +02:00