constellation-analyzer/IMPLEMENTATION_CHECKLIST.md
Jan-Henrik Bruhn 28f8224284 feat: add timeline system for multi-state constellation analysis
Implements a comprehensive timeline system that enables documents to contain
multiple constellation states with branching timelines. This allows users to
create different versions of their analysis for temporal evolution, alternative
scenarios, or what-if analysis.

Core Features:
- Timeline store managing multiple states per document with branching structure
- Visual timeline panel with React Flow-based state graph visualization
- State management: create, switch, rename, duplicate (parallel/series), delete
- Per-state undo/redo history (max 50 actions per state)
- Context menu for timeline node operations
- Collapsible timeline panel (always visible, moved toolbar to panel header)

Architecture Changes:
- Document structure: removed top-level graph field, states now only in timeline
- Global types: nodeTypes and edgeTypes are now global per document, not per state
- State graphs: only contain nodes and edges, types inherited from document
- Persistence: full timeline serialization/deserialization with all states
- History system: converted from document-level to per-state independent stacks

Timeline Components:
- TimelineView: main timeline visualization with state nodes and edges
- BottomPanel: collapsible container with timeline controls in header
- StateNode: custom node component showing state info and active indicator
- CreateStateDialog: dialog for creating new timeline states
- RenameStateDialog: dialog for renaming existing states
- Context menu: right-click operations (rename, duplicate parallel/series, delete)

Document Management:
- Documents always have timeline (initialized with root state on creation)
- Timeline persisted with document in localStorage
- Export/import includes complete timeline with all states
- Migration support for legacy single-state documents

Store Updates:
- timelineStore: manages timelines, states, and timeline operations
- historyStore: per-state history with independent undo/redo stacks
- workspaceStore: saves/loads timeline data, handles global types
- panelStore: added timeline panel visibility state
- useActiveDocument: syncs timeline state with graph editor

Context Menu Improvements:
- Smart viewport edge detection to prevent overflow
- Click-outside detection for React Flow panes
- Consistent styling across application

Files Added:
- src/types/timeline.ts - Timeline type definitions
- src/stores/timelineStore.ts - Timeline state management
- src/components/Timeline/TimelineView.tsx - Main timeline component
- src/components/Timeline/BottomPanel.tsx - Timeline panel container
- src/components/Timeline/StateNode.tsx - State node visualization
- src/components/Timeline/CreateStateDialog.tsx - State creation dialog
- src/components/Timeline/RenameStateDialog.tsx - State rename dialog

Files Removed:
- src/stores/persistence/middleware.ts - Obsolete persistence middleware

Documentation:
- Added comprehensive timeline feature documentation
- Implementation checklists and quick reference guides
- Temporal analysis concepts and UX guidelines

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-11 22:00:34 +02:00

21 KiB

Temporal & Scenario Analysis - Implementation Checklist

Phase 1: Core State Management (Week 1-2)

Data Model Setup

  • Create /src/types/temporal.ts

    • Define StateType enum
    • Define TemporalMetadata interface
    • Define ScenarioMetadata interface
    • Define StateRelationship interface
    • Define AnalysisState interface
    • Define StateDiff interface
    • Define ActorJourney interface
    • Define Timeline interface
    • Define ScenarioTree interface
  • Update /src/stores/persistence/types.ts

    • Add states property to ConstellationDocument
    • Add supportsStates to document metadata
    • Ensure backward compatibility
  • Create migration helper

    • Function to enable states for existing documents
    • Function to create initial state from current graph
    • Test migration with sample documents

State Store Implementation

  • Create /src/stores/stateStore.ts
    • Basic store structure with Zustand
    • State CRUD operations
      • createState()
      • loadState()
      • deleteState()
      • updateStateMetadata()
    • State retrieval
      • getState()
      • getAllStates()
      • getStatesByType()
    • Navigation helpers
      • getNextState()
      • getPreviousState()

Snapshot Functionality

  • Create /src/utils/stateSnapshot.ts
    • captureCurrentGraph() - serialize current graph state
    • restoreGraphFromState() - load state into graph
    • validateStateData() - ensure data integrity
    • Handle edge cases (empty graph, large graphs)

Basic UI Integration

  • Update /src/components/Toolbar/Toolbar.tsx

    • Add "Capture State" button
    • Add current state indicator
    • Add loading/saving state indicators
  • Create /src/components/TemporalAnalysis/StateSelector.tsx

    • Basic dropdown UI
    • List all states
    • Click to load state
    • Show current state indicator
    • Search/filter functionality
  • Create hooks

    • /src/hooks/useStateManagement.ts
    • useCurrentState()
    • useCaptureState()
    • useLoadState()

Integration with Workspace

  • Update /src/stores/workspaceStore.ts
    • Add captureCurrentState() action
    • Add restoreState() action
    • Ensure states saved with document
    • Handle state data in export/import

Testing

  • Test state creation
  • Test state loading
  • Test state persistence
  • Test with empty graphs
  • Test with large graphs (100+ nodes)
  • Test edge cases (missing data, corrupted states)

Phase 2: Temporal Analysis (Week 3-4)

Timeline Data Management

  • Extend /src/stores/stateStore.ts
    • Timeline CRUD operations
      • createTimeline()
      • deleteTimeline()
      • updateTimeline()
    • Timeline state management
      • addStateToTimeline()
      • removeStateFromTimeline()
      • reorderTimeline()
    • Timeline queries
      • getStatesByTimeline()
      • getTimelineStates() (ordered)

Temporal Metadata

  • Create /src/components/TemporalAnalysis/StateMetadataEditor.tsx
    • Temporal metadata form
      • Date/time picker
      • Sequence number input
      • Label input
      • Period range inputs
    • Display format selector
    • Notes/description textarea
    • Tags input

Timeline Panel UI

  • Create /src/components/TemporalAnalysis/TimelinePanel.tsx

    • Horizontal timeline visualization
    • State markers on timeline
    • Click to load state
    • Drag to scrub timeline
    • Zoom in/out on timeline
    • Pan timeline horizontally
    • State creation controls
    • Timeline selector dropdown (multiple timelines)
  • Timeline styling

    • Color-coded state markers
    • Current state highlight
    • Hover effects
    • Responsive design
    • Collapsible panel

Timeline Navigation

  • Add keyboard shortcuts

    • Previous state in timeline
    • Next state in timeline
    • Home First state
    • End Last state
  • Navigation buttons

    • Previous/Next buttons
    • Jump to start/end
    • State counter (e.g., "3 of 12")

Integration

  • Update /src/App.tsx

    • Add TimelinePanel to layout
    • Handle panel visibility toggle
    • Handle panel resize
  • Update /src/components/Menu/MenuBar.tsx

    • Add "States" menu
    • "View Timeline" action
    • "Create Timeline" action

Testing

  • Test timeline creation
  • Test state ordering
  • Test timeline navigation
  • Test keyboard shortcuts
  • Test with multiple timelines
  • Test timeline visualization with many states (20+)

Phase 3: Comparison & Diff Analysis (Week 5-6)

Diff Calculation Engine

  • Create /src/utils/stateDiff.ts

    • calculateStateDiff() function
    • Actor comparison logic
      • Detect added actors
      • Detect removed actors
      • Detect modified actors (label, type, position, metadata)
    • Relation comparison logic
      • Detect added relations
      • Detect removed relations
      • Detect modified relations (type, directionality, strength)
    • Summary statistics calculation
    • Performance optimization for large graphs
  • Create /src/hooks/useStateDiff.ts

    • useComparison() hook
    • useDiffCalculation() hook
    • Memoization for expensive calculations

Visual Diff on Graph

  • Create /src/components/Editor/DiffOverlay.tsx

    • Overlay mode component
    • Color coding for changes
      • Green for added (actors/relations)
      • Red for removed (actors/relations)
      • Yellow/orange for modified
    • Change badges/icons on nodes
    • Toggle overlay on/off
    • Opacity control for overlay
  • Update /src/components/Editor/GraphEditor.tsx

    • Integrate DiffOverlay
    • Apply diff styling to nodes/edges
    • Animated transitions for diff highlights

Comparison View UI

  • Create /src/components/TemporalAnalysis/ComparisonView.tsx

    • Modal/panel for comparison
    • State selectors (From/To)
    • Comparison mode selector
      • Side-by-side
      • Overlay
      • Tabbed
    • Graph visualization for both states
    • Synchronized panning/zooming
    • Difference highlighting
    • Summary statistics panel
  • Create /src/components/TemporalAnalysis/StateDiffViewer.tsx

    • List of changes (actors/relations)
    • Filter by change type (added/removed/modified)
    • Click to highlight on graph
    • Export changes as report

Change Summary

  • Create /src/components/TemporalAnalysis/ChangeSummary.tsx
    • Statistics dashboard
      • Total actors (before/after)
      • Total relations (before/after)
      • Added/removed/modified counts
    • Change breakdown by type
    • Visual charts (pie chart, bar chart)
    • Export to CSV/JSON

Quick Compare

  • Add to TimelinePanel

    • "Compare" button on state markers
    • Right-click context menu "Compare with..."
    • Select two states to compare
  • Add to state selector

    • Checkbox mode to select multiple states
    • "Compare Selected" button

Export Comparison Report

  • Report generation
    • PDF export with diff summary
    • JSON export of diff data
    • HTML report with interactive visualization
    • Include screenshots of both states

Testing

  • Test diff calculation accuracy
  • Test with various graph sizes
  • Test comparison view UI
  • Test visual diff overlay
  • Test export functionality
  • Performance test with large diffs

Phase 4: Scenario Branching (Week 7-8)

Scenario Data Model

  • Extend /src/stores/stateStore.ts
    • Scenario tree management
      • createScenarioBranch()
      • addStateToScenario()
      • deleteScenarioBranch()
    • Scenario queries
      • getStatesByScenario()
      • getScenarioTree()
      • getScenarioBranches()

Scenario Creation UI

  • Create /src/components/TemporalAnalysis/ScenarioCreator.tsx
    • "Branch from here" button/dialog
    • Scenario metadata form
      • Label input
      • Description textarea
      • Assumptions list input
      • Probability/confidence selector
      • Color picker for branch
    • Parent state selection
    • Create and switch to scenario

Scenario Tree Visualization

  • Extend TimelinePanel for scenarios

    • Vertical branching layout
    • Branch lines/connectors
    • Branch labels
    • Branch color coding
    • Collapse/expand branches
    • Scenario navigation controls
  • Alternative: Tree view component

    • Hierarchical tree visualization
    • Collapsible nodes
    • Click to load state
    • Branch context menu (edit, delete, compare)

Scenario Metadata Editor

  • Update StateMetadataEditor
    • Scenario-specific fields
    • Assumptions editor (add/remove/edit)
    • Probability slider
    • Confidence level selector
    • Branch color picker

Scenario Navigation

  • Scenario switcher

    • Dropdown to select branch
    • Filter timeline by scenario
    • Visual indicator of current branch
  • Branch comparison

    • "Compare branches" action
    • Select multiple scenarios
    • Side-by-side comparison
    • Outcome analysis

Integration

  • Update menu bar

    • "Create Scenario" menu item
    • "Manage Scenarios" menu item
  • Update state selector

    • Group states by scenario
    • Scenario branch indicators

Testing

  • Test scenario creation
  • Test branch visualization
  • Test scenario navigation
  • Test with multiple branches
  • Test nested scenarios (if supported)
  • Test scenario deletion

Phase 5: Actor Tracking & Journeys (Week 9-10)

Journey Calculation

  • Create /src/utils/actorJourney.ts

    • getActorJourney() function
    • Track actor across states
    • Detect first/last appearance
    • Calculate property changes
    • Track relationship evolution
    • Performance optimization
  • Create /src/hooks/useActorJourney.ts

    • useActorJourney() hook
    • useMultiActorJourney() hook
    • Memoization

Journey Viewer UI

  • Create /src/components/TemporalAnalysis/ActorJourneyViewer.tsx
    • Actor selection interface
      • Dropdown or autocomplete
      • Search by label
      • Select from graph click
    • Timeline visualization
      • Horizontal timeline
      • Actor appearance markers
      • Property change indicators
    • Property evolution display
      • Label changes
      • Type changes
      • Position changes
    • Relationship changes display
      • Relations added/removed
      • Relation type changes
      • Relation strength changes

Multi-Actor Comparison

  • Select multiple actors
  • Overlay journeys on same timeline
  • Compare property evolution
  • Compare relationship dynamics
  • Identify interaction points

Journey Export

  • Export journey data
    • CSV export
    • JSON export
    • PDF report with visualizations
  • Include:
    • Actor metadata
    • State sequence
    • Property changes
    • Relationship changes
    • Summary statistics

Integration

  • Add to right panel

    • "View Journey" button on actor selection
    • Quick journey view
  • Add to menu bar

    • "Actor Journeys" menu item
    • Keyboard shortcut (Ctrl+J)

Testing

  • Test journey calculation
  • Test with various actor types
  • Test with actors that appear/disappear
  • Test multi-actor comparison
  • Test export functionality

Phase 6: Animation & Presentation (Week 11-12)

Animation Engine

  • Create /src/utils/stateAnimation.ts

    • interpolateStates() function
    • Position interpolation
    • Opacity interpolation (fade in/out)
    • Size interpolation
    • Color interpolation
    • Easing functions (linear, ease-in-out, etc.)
  • Create /src/hooks/useStateAnimation.ts

    • useAnimation() hook
    • Animation state management
    • Frame rate control
    • Performance optimization

Animation Controls

  • Create /src/components/TemporalAnalysis/StateAnimator.tsx

    • Play/pause button
    • Step forward/backward buttons
    • Speed control slider
    • Loop toggle
    • Progress bar
    • Frame counter
    • Quality settings (performance vs. smoothness)
  • Integrate with TimelinePanel

    • Animation controls bar
    • Visual playhead on timeline
    • Click timeline to jump to state

Animation Modes

  • Sequential (state A → B → C)
  • Comparison (fade between two states)
  • Journey (follow actor across states)
  • Custom sequence (user-selected states)

Presentation Mode

  • Create /src/components/TemporalAnalysis/PresentationMode.tsx
    • Full-screen mode
    • Slideshow interface
    • State sequence selector
    • Auto-advance with timer
    • Manual navigation (arrow keys)
    • Annotation overlays
      • Title for each state
      • Notes/narration text
      • Key insights callouts
    • Exit presentation (Esc key)

Export Capabilities (Stretch Goal)

  • Export animation
    • Animated GIF export
    • Video export (WebM/MP4) - may require server-side
    • Frame sequence export (PNG images)
    • Interactive HTML export

Integration

  • Add to menu bar

    • "Animate Timeline" menu item
    • "Presentation Mode" menu item
    • Keyboard shortcut (Ctrl+Shift+P)
  • Add to timeline panel

    • Play button
    • Presentation mode button

Testing

  • Test animation smoothness
  • Test with various animation speeds
  • Test with large state transitions
  • Test presentation mode navigation
  • Performance test with complex graphs
  • Test on different screen sizes

Phase 7: ChromaDB Integration (Week 13-14)

ChromaDB Setup

  • Install ChromaDB dependencies

    • Add to package.json
    • Configure ChromaDB client
  • Create /src/utils/chromaIntegration.ts

    • Initialize ChromaDB client
    • Connection management
    • Error handling

Collection Setup

  • Create collections

    • constellation_states - state metadata
    • actor_journeys - actor trajectories
    • state_comparisons - cached comparisons
    • annotations - user notes and insights
  • Define schemas

    • Metadata fields
    • Embedding strategies
    • Query filters

State Indexing

  • Create indexing functions

    • indexState() - index single state
    • batchIndexStates() - index multiple states
    • updateStateIndex() - update existing index
    • removeStateIndex() - remove from index
  • Generate embeddings

    • Combine label, description, notes, assumptions
    • Use ChromaDB's built-in embedding
    • Handle long text (truncation/summarization)
  • Create search functions

    • searchStates() - general search
    • findSimilarStates() - similarity search
    • searchByTags() - tag-based search
    • searchByTimeRange() - temporal search
  • Create /src/components/TemporalAnalysis/StateSearch.tsx

    • Search input
    • Search filters (type, timeline, scenario, tags)
    • Results list
    • Click to load state
    • Relevance scoring display

Pattern Recognition

  • Implement pattern detection

    • Identify similar network structures
    • Find recurring patterns
    • Detect anomalies
    • Trend analysis
  • Create pattern visualization

    • Display pattern clusters
    • Highlight similar states
    • Generate insights

Annotation Storage

  • Store annotations in ChromaDB

    • Link to specific states
    • Link to specific changes
    • Support rich text
    • Support tags
  • Create annotation search

    • Search within annotations
    • Find states by annotation content

Caching Strategy

  • Cache diff calculations

    • Store diff results in ChromaDB
    • Retrieve cached diffs
    • Invalidate cache on state changes
  • Cache journey calculations

    • Store journey data
    • Update on relevant state changes

Integration

  • Add to state store

    • indexStateForSearch() action
    • searchStates() action
  • Add to UI

    • Search box in state selector
    • "Find similar" button on states
    • Pattern insights panel

Testing

  • Test indexing performance
  • Test search accuracy
  • Test similarity detection
  • Test caching effectiveness
  • Test with large state collections (100+ states)

Phase 8: Advanced Features (Week 15-16)

Automatic State Capture

  • Implement auto-capture

    • Periodic snapshots (e.g., every 10 minutes)
    • Significant change detection (threshold-based)
    • User-configurable triggers
    • Auto-cleanup of old snapshots
  • Settings UI

    • Enable/disable auto-capture
    • Configure frequency
    • Configure retention policy

State Templates

  • Template creation

    • Save state as template
    • Template metadata (name, description, category)
    • Template preview
  • Template application

    • Browse template library
    • Apply template to create new state
    • Customize template on application
  • Template management

    • Edit templates
    • Delete templates
    • Import/export templates

Collaborative Features (Stretch Goal)

  • Sharing

    • Export shareable link to timeline
    • Export shareable link to scenario
    • Embed code for presentations
  • Comments

    • Comment on specific states
    • Reply to comments
    • @mentions
    • Resolve comments
  • Approvals (Stretch Goal)

    • Submit state for review
    • Approve/reject states
    • Review workflow

Advanced Analytics

  • Network metrics over time

    • Density evolution
    • Centrality changes
    • Clustering coefficient
    • Path lengths
  • Statistical analysis

    • Correlation analysis
    • Regression models
    • Predictive analytics
  • Export to analysis tools

    • Export time-series data
    • Export to CSV for Excel/R/Python
    • API for external tools

Testing

  • Test auto-capture functionality
  • Test template system
  • Test collaborative features
  • Test analytics calculations
  • Integration testing with all phases

Final Polish & Documentation

Performance Optimization

  • Profile performance bottlenecks
  • Optimize diff calculation
  • Optimize rendering for many states
  • Lazy loading for large timelines
  • Implement virtualization where needed

Error Handling

  • Graceful degradation for missing data
  • User-friendly error messages
  • Rollback on failed operations
  • Data validation throughout

Accessibility

  • Keyboard navigation for all features
  • Screen reader support
  • High contrast mode support
  • Focus indicators
  • ARIA labels

Documentation

  • User guide (see TEMPORAL_QUICK_START.md)

    • Getting started tutorial
    • Feature walkthroughs
    • Best practices
    • FAQ
  • Developer documentation

    • API reference
    • Type definitions
    • Architecture overview
    • Extension guide
  • Video tutorials

    • Overview video
    • Feature-specific videos
    • Advanced use cases

Testing

  • Unit tests for all utilities
  • Integration tests for stores
  • Component tests for UI
  • E2E tests for workflows
  • Performance benchmarks
  • User acceptance testing

Release

  • Version bump
  • Changelog
  • Migration guide for existing users
  • Announcement post/blog
  • Update README

Success Metrics

Track these metrics post-release:

  • Feature adoption rate

    • % of users who enable states
    • % of documents with states
    • Average states per document
  • Usage patterns

    • Temporal vs. scenario usage
    • Most used features (comparison, animation, journeys)
    • Average session time with states
  • Performance

    • State creation time
    • Diff calculation time
    • Animation frame rate
    • ChromaDB query latency
  • User satisfaction

    • User feedback/ratings
    • Support tickets related to states
    • Feature requests

Notes

  • Each phase builds on the previous one
  • Test thoroughly before moving to next phase
  • Gather user feedback early and often
  • Iterate based on actual usage patterns
  • Keep performance in mind throughout
  • Document as you go

Current Status: Not started Next Step: Begin Phase 1 - Core State Management