All files / apps/web/src/store workflowStore.js

100% Statements 16/16
75% Branches 3/4
100% Functions 15/15
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30    1x       1x       1x   1x       1x 1x     1x   1x   3x       1x  
import { create } from 'zustand'
 
export const useWorkflowStore = create((set, get) => ({
  syntheses: [],
  sseConnections: {},
 
  addSynthesis: (synthesis) => set((state) => ({
    syntheses: [...state.syntheses, synthesis]
  })),
 
  updateSynthesis: (id, updates) => set((state) => ({
    syntheses: state.syntheses.map((s) =>
      s.id === id ? { ...s, ...updates } : s
    )
  })),
 
  removeSynthesis: (id) => set((state) => ({
    syntheses: state.syntheses.filter((s) => s.id !== id)
  })),
 
  getSynthesis: (id) => get().syntheses.find((s) => s.id === id),
  
  clearCompleted: () => set((state) => ({
    syntheses: state.syntheses.filter((s) => 
      s.status !== 'completed' && s.status !== 'failed'
    )
  })),
  
  clearAll: () => set({ syntheses: [] })
}))