constellation-analyzer/docs
Jan-Henrik Bruhn 0ef81260cc refactor: centralize snapshot creation logic (Phase 2.1)
Eliminates duplicate snapshot logic between useDocumentHistory and timelineStore.

Problem:
- useDocumentHistory created snapshots reading types from document (correct)
- timelineStore created snapshots reading types from graphStore (incorrect)
- ~30 lines of duplicated snapshot creation logic
- Risk of inconsistent behavior between graph and timeline operations

Solution:
- Created createDocumentSnapshot() in documentUtils.ts
- Single source of truth for snapshot creation
- Always reads types/labels from document (correct source)
- Syncs timeline current state before snapshot (ensures latest data)

Changes:
- Add createDocumentSnapshot() to src/stores/workspace/documentUtils.ts
- Update useDocumentHistory.ts to use centralized helper
- Update timelineStore.ts pushDocumentHistory() to use centralized helper
- Remove duplicate snapshot creation code (~30 lines)

Benefits:
-  Consistent snapshot behavior everywhere
-  Types always read from document (source of truth)
-  Easier to maintain (single implementation)
-  Fixes potential bug where timelineStore had stale types
-  Better code organization

Impact:
- No breaking changes
- Undo/redo behavior unchanged for users
- Timeline operations now have correct type information
- Safer - impossible for snapshot logic to diverge

Testing:
- TypeScript compilation passes
- No runtime behavior changes expected
- Snapshot structure unchanged

Related: Phase 2.1 of STATE_MANAGEMENT_REFACTORING_PLAN.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-20 12:19:58 +02:00
..
DIRECTIONAL_RELATIONSHIPS_UX_SPEC.md feat: add document naming dialog before creation 2025-10-11 12:03:05 +02:00
IMPLEMENTATION_CHECKLIST.md doc: move some plans around 2025-10-11 22:08:53 +02:00
KEYBOARD_SHORTCUTS.md Initial commit 2025-10-10 11:15:51 +02:00
MULTI_FILE_PLAN.md Initial commit 2025-10-10 11:15:51 +02:00
PERSISTENCE_PLAN.md Initial commit 2025-10-10 11:15:51 +02:00
PHASE_1_COMPLETION_SUMMARY.md refactor: centralize snapshot creation logic (Phase 2.1) 2025-10-20 12:19:58 +02:00
PHASE_4_1_COMPLETION_SUMMARY.md refactor: remove legacy persistence code and migration system (Phase 1) 2025-10-20 12:15:25 +02:00
PHASE_4_1_TEST_PLAN.md fix: correct history timing in createGroupWithActors for proper undo behavior 2025-10-20 12:09:09 +02:00
PROJECT_SUMMARY.md Initial commit 2025-10-10 11:15:51 +02:00
SIDE_PANELS_UX_DESIGN.md feat: side panels for properties and tools 2025-10-10 18:13:18 +02:00
STATE_MANAGEMENT_REFACTORING_PLAN.md fix: correct history timing in createGroupWithActors for proper undo behavior 2025-10-20 12:09:09 +02:00
TEMPORAL_ANALYSIS_SUMMARY.md doc: move some plans around 2025-10-11 22:08:53 +02:00
TEMPORAL_QUICK_START.md doc: move some plans around 2025-10-11 22:08:53 +02:00
TEMPORAL_SCENARIO_IMPLEMENTATION_PLAN.md doc: move some plans around 2025-10-11 22:08:53 +02:00
TEMPORAL_SCENARIO_UX_CONCEPT.md doc: move some plans around 2025-10-11 22:08:53 +02:00
UNDO_REDO_IMPLEMENTATION.md refactor: migrate undo/redo from per-state to per-document level 2025-10-11 22:38:23 +02:00
UX_ANALYSIS.md Initial commit 2025-10-10 11:15:51 +02:00
UX_ANALYSIS_ACTOR_TYPE_SETTINGS.md feat: redesign relation type configuration with improved UX 2025-10-16 19:47:12 +02:00
UX_CONCEPT_MULTI_VERSION_GRAPH.md doc: move some plans around 2025-10-11 22:08:53 +02:00
VISUAL_EXAMPLES.md doc: move some plans around 2025-10-11 22:08:53 +02:00
WORKSPACE_PERSISTENCE.md Initial commit 2025-10-10 11:15:51 +02:00