Skip to content

Refactor: Remove activeWorkflow and use single source of truth (nodes/edges) #389

@breaking-brake

Description

@breaking-brake

Background

Currently, the workflow state is duplicated in two places:

  1. nodes / edges in workflow-store - Updated when canvas changes
  2. activeWorkflow in workflow-store - Updated only at specific points (load, open panel, AI success)

This dual-state architecture has caused synchronization issues:

Current State (After #384 and #388)

Both issues are fixed by adding useEffect hooks that sync:

  • refinementStore.conversationHistoryactiveWorkflow.conversationHistory
  • nodes/edgesactiveWorkflow

While functional, this approach maintains two sources of truth with synchronization logic.

Proposed Refactoring

Remove activeWorkflow entirely and use nodes/edges as the single source of truth:

Changes Required

  1. Remove activeWorkflow from workflow-store
  2. Add missing metadata fields to the store:
    • workflowId (currently only in activeWorkflow)
    • workflowVersion (currently only in activeWorkflow)
    • workflowCreatedAt / workflowUpdatedAt (currently only in activeWorkflow)
  3. Update all consumers (7 files, 65 occurrences):
    • App.tsx
    • Toolbar.tsx
    • RefinementChatPanel.tsx
    • DescriptionPanel.tsx
    • SubAgentFlowDialog.tsx
    • SlackShareDialog.tsx
    • workflow-store.ts
  4. Serialize workflow on-demand when needed (save, export, AI refinement)

Benefits

  • Single source of truth
  • No synchronization issues
  • Simpler mental model
  • Reduced risk of stale data bugs

Considerations

  • Larger refactoring effort (~65 occurrences)
  • Need to ensure all metadata is preserved
  • May require migration logic for existing workflows

Priority

Low - The current sync approach works correctly. This is a code quality improvement.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions