Skip to content

Commit 95953cc

Browse files
committed
release: 1.13.6
1 parent a62c17f commit 95953cc

9 files changed

Lines changed: 442 additions & 307 deletions

File tree

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
# Change log
22

3+
## [1.13.6] - 2025-12-04
4+
5+
### Added
6+
7+
- **Toast notification system**
8+
- Visual error notifications for failed undo operations
9+
- Toast appears in bottom-right corner with red error styling
10+
- Auto-dismisses after 5 seconds
11+
- Detailed error logging to console for debugging
12+
- Implemented using Flowbite Svelte Toast component with Iconify icons
13+
14+
### Changed
15+
16+
- **Comprehensive undo system improvements**
17+
- Added undo support for property modifications:
18+
- Circle property edits (radius, depth)
19+
- Rectangle property edits (width, height, depth, rotation)
20+
- Rectangle rotation via keyboard (R key)
21+
- Rectangle dimension flip via keyboard (F key)
22+
- Implemented stack size limit (50 operations) to prevent memory issues
23+
- Added automatic undo stack clearing on project reset
24+
- Only creates undo entries when values actually change (optimization)
25+
- Each rotation/flip creates individual undo entry for granular control
26+
- **Improved error handling**
27+
- Failed undo operations now show toast notification to user
28+
- Detailed console logging with operation name, error details, and stack trace
29+
- Failed operations re-added to stack for retry
30+
31+
### Fixed
32+
33+
- **Cross-project undo contamination**
34+
- Undo stack now clears when resetting project (File > New)
35+
- Prevents accidentally restoring elements from previous project
36+
- No more "ghost undos" after project reset
37+
338
## [1.13.5] - 2025-12-01
439

540
### Changed

CLAUDE.md

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Build outputs to `docs/` directory (configured for GitHub Pages deployment).
7070

7171
```
7272
src/
73-
├── stores/ # Svelte stores (projectStore, modalStore, undoStore, libraryStore)
73+
├── stores/ # Svelte stores (projectStore, modalStore, undoStore, toastStore, libraryStore)
7474
├── types/ # Zod schemas, TypeScript types, and type guards
7575
│ ├── typeGuards.ts # Type guard functions (isCircle, isRectangle, isLeg)
7676
│ └── panels/ # Panel-specific type definitions
@@ -392,6 +392,101 @@ Each element type (circle, rectangle, leg) has its own context menu generator:
392392
- Positioned to the right of element using `getClientRect()` to avoid overlap
393393
- Content generated by `getSelectedElementInfo()` in `fineMovement.ts`
394394

395+
## State Management
396+
397+
### Undo System (`src/stores/undoStore.ts`)
398+
399+
**Architecture:**
400+
401+
- Stack-based LIFO (Last In First Out) design
402+
- Maximum 50 operations retained (oldest removed when exceeded)
403+
- Non-persistent (cleared on page refresh)
404+
- Automatically cleared on project reset to prevent cross-project contamination
405+
406+
**Undoable Operations:**
407+
408+
- **Element deletions**: Circles, rectangles, legs (individual or bulk)
409+
- **Property modifications**:
410+
- Circle: radius, depth
411+
- Rectangle: width, height, depth, rotation
412+
- **Keyboard shortcuts**:
413+
- Rectangle rotation (`R` key): each 5° rotation creates undo entry
414+
- Rectangle dimension flip (`F` key): swapping width/height
415+
- **Optimization**: Only creates undo entry if values actually changed
416+
417+
**Implementation Pattern:**
418+
419+
1. Capture previous state in closure before operation
420+
2. Perform the operation (delete, modify, rotate, flip)
421+
3. Add undo action to stack with descriptive name
422+
4. Undo action closure restores captured state when executed
423+
424+
**Error Handling:**
425+
426+
- Failed undo operations show toast notification to user
427+
- Detailed console logging with operation name, error details, and stack trace
428+
- Failed operations re-added to stack to allow retry
429+
430+
**Key Functions:**
431+
432+
- `addUndo(name, action)`: Adds undo entry with stack size enforcement
433+
- `executeLastUndo()`: Pops and executes last undo with error handling
434+
- `clearUndoStack()`: Clears entire stack (called on project reset)
435+
- `undoStoreLastItem`: Derived store providing operation name for UI
436+
437+
**UI Integration:**
438+
439+
- Keyboard: `Ctrl+Z` / `Cmd+Z` (defined in `AppNavigation.svelte`)
440+
- Edit menu: Shows "Undo: {operation name}" when stack not empty
441+
- Disabled when modals are open (except ESC key)
442+
443+
### Toast Notification System (`src/stores/toastStore.ts`)
444+
445+
**Architecture:**
446+
447+
- Array-based store of active toast messages
448+
- Auto-removal via setTimeout after configurable duration
449+
- Each toast has unique UUID for tracking and manual dismissal
450+
- Type-safe toast types: `success`, `error`, `warning`, `info`
451+
452+
**Toast Types and Colors:**
453+
454+
- `success`: Green with check-circle icon
455+
- `error`: Red with alert-circle icon (default 5s duration)
456+
- `warning`: Orange with alert icon
457+
- `info`: Blue with information icon
458+
459+
**Key Functions:**
460+
461+
- `toastStore.push(type, message, duration)`: Add new toast
462+
- `toastStore.error(message, duration)`: Convenience method for error toasts
463+
- `toastStore.remove(id)`: Manually remove toast by UUID
464+
465+
**UI Integration:**
466+
467+
- `ToastContainer.svelte` component subscribes to store
468+
- Fixed position: bottom-right corner with z-50
469+
- Vertical stacking with 2-unit gap spacing
470+
- Uses Flowbite Svelte `Toast` component with Iconify icons
471+
- Dismissable by user click on X button
472+
473+
**Usage Example:**
474+
475+
```typescript
476+
import { toastStore } from '$stores/toastStore';
477+
478+
// Show error toast
479+
toastStore.error('Failed to undo: Delete circle', 5000);
480+
481+
// Show custom toast
482+
toastStore.push('success', 'Operation completed', 3000);
483+
```
484+
485+
**Current Usage:**
486+
487+
- Undo error notifications in `undoStore.ts`
488+
- Can be extended for success confirmations, warnings, etc.
489+
395490
## Testing Workflow
396491

397492
Manual testing only. Key test scenarios:

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ In its current state, it facilitates the installation of circular and oblong com
4141
- Progress bar shows percentage and visual indicator
4242
- UI remains responsive throughout the generation process
4343
- **Measurement Tool**: Press `M` to measure distances in 1/10th millimeter precision
44-
- **Undo/Redo**: Press `Ctrl+Z` to undo component deletions and modifications
44+
- **Comprehensive Undo System**: Press `Ctrl+Z` to undo operations (max 50 actions)
45+
- Component deletions (circles, rectangles, legs)
46+
- Property modifications (radius, depth, width, height, rotation)
47+
- Rectangle rotation (`R` key) and dimension flip (`F` key)
48+
- Visual error notifications for failed undo operations
49+
- Automatic stack clearing on project reset
4550
- **Component Library**: Save and reuse your favorite component configurations
4651
- **Keyboard Shortcuts**: Extensive keyboard shortcuts for efficient workflow
4752
- **Hover Info**: Real-time element information and available shortcuts when hovering
@@ -77,7 +82,7 @@ In its current state, it facilitates the installation of circular and oblong com
7782

7883
### Other
7984

80-
- `Ctrl+Z` / `Cmd+Z` - Undo last action
85+
- `Ctrl+Z` / `Cmd+Z` - Undo last operation (deletions, property edits, rotations, flips)
8186
- `Shift+P` - Project settings
8287
- `D` - Display 3D mesh
8388
- `ESC` - Close modal dialogs
@@ -129,8 +134,8 @@ Use a PLA printer to save time and money. Practice shows that it is enough to pr
129134

130135
### Requirements
131136

132-
- Node.js >= 22.0.0
133-
- npm >= 10.0.0
137+
- Node.js >= 24.0.0
138+
- npm >= 11.0.0
134139

135140
### Local Development
136141

Lines changed: 191 additions & 191 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
property="twitter:image"
4545
content="https://segmentcontroller.github.io/pcb-tht-holder/pcb-board-32.png"
4646
/>
47-
<script type="module" crossorigin src="/pcb-tht-holder/assets/index-BVSmpbfQ.js"></script>
47+
<script type="module" crossorigin src="/pcb-tht-holder/assets/index-CgLiWFUN.js"></script>
4848
<link rel="stylesheet" crossorigin href="/pcb-tht-holder/assets/index-C3KH6t1Q.css">
4949
</head>
5050

docs/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const GHPATH = 'https://segmentcontroller.github.io/pcb-tht-holder/';
22

33
const APP_PREFIX = 'pwa_pcb-tht-holder_';
44

5-
const VERSION = 'v1.13.5';
5+
const VERSION = 'v1.13.6';
66

77
// The files to make available for offline use. make sure to add others to this list
88
const URLS = [

0 commit comments

Comments
 (0)