Skip to content

fix(sockets): useCollabWorkflow cleanup, variables store logic simplification#1154

Merged
icecrasher321 merged 2 commits intostagingfrom
fix/sockets-variables
Aug 28, 2025
Merged

fix(sockets): useCollabWorkflow cleanup, variables store logic simplification#1154
icecrasher321 merged 2 commits intostagingfrom
fix/sockets-variables

Conversation

@icecrasher321
Copy link
Collaborator

Summary

  • Some minor cleanup for useCollaborativeWorkflow hook.
  • Fix variables persistence issues.

Type of Change

  • Bug fix

Testing

Screen.Recording.2025-08-27.at.5.02.29.PM.mov

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Aug 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Aug 28, 2025 0:15am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Aug 28, 2025 0:15am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs August 28, 2025 00:07 Inactive
@icecrasher321 icecrasher321 merged commit c720f23 into staging Aug 28, 2025
4 of 5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/sockets-variables branch August 29, 2025 05:01
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…fication (simstudioai#1154)

* fix(sockets): useCollabWorkflow cleanup, variables store logic simplification

* remove unecessary check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant