fix(sockets): useCollabWorkflow cleanup, variables store logic simplification#1154
fix(sockets): useCollabWorkflow cleanup, variables store logic simplification#1154icecrasher321 merged 2 commits intostagingfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR implements a comprehensive refactoring of the variables persistence system in the collaborative workflow environment. The changes simplify the variables store architecture by removing complex tracking mechanisms and centralizing all variable operations through collaborative workflow hooks.
The key architectural changes include:
Variables Store Simplification: The variables store has been stripped of its async loading infrastructure (loadVariables, resetLoaded) and tracking mechanisms for loaded workflows and recently added variables. The store now operates as a pure client-side state container without direct API calls.
Collaborative Operations Centralization: All variable mutations (add, update, delete, duplicate) now flow exclusively through collaborative workflow hooks (collaborativeAddVariable, collaborativeUpdateVariable, etc.) rather than mixing direct store access with collaborative operations. This ensures all changes are properly synchronized via sockets.
Operation Queue Enhancement: The operation queue now includes coalescing logic that prevents duplicate variable update operations from accumulating in the queue. When debounced variable updates are processed, any existing pending operations for the same variable field are filtered out, ensuring only the latest value is processed.
Room Validation Improvements: The collaborative workflow hook introduces an isInActiveRoom() helper function that prevents operations from executing when users aren't in the correct workflow context. This addresses race conditions that could occur when users rapidly switch between workflows.
Registry-Based Variable Loading: The workflow registry now handles variable hydration directly when fetching workflows from the database, using a cleaner approach that filters out existing workflow variables before adding fresh data.
These changes eliminate the previous dual-path system where variables could be modified through both direct store access and collaborative hooks, which was causing persistence inconsistencies in multi-user environments.
Confidence score: 4/5
- This PR addresses real architectural issues with a well-structured approach that centralizes variable operations through the collaborative system
- Score reflects the comprehensive nature of the changes and potential for edge cases in the collaborative workflow system
- The operation queue coalescing logic and room validation improvements should significantly reduce race conditions and state inconsistencies
9 files reviewed, 1 comment
…fication (simstudioai#1154) * fix(sockets): useCollabWorkflow cleanup, variables store logic simplification * remove unecessary check
Summary
Type of Change
Testing
Screen.Recording.2025-08-27.at.5.02.29.PM.mov
Checklist