Skip to content

fix(hydration): duplicate overlay after idle + subblocks race condition#1246

Merged
icecrasher321 merged 6 commits intostagingfrom
fix/hydration-bugs
Sep 4, 2025
Merged

fix(hydration): duplicate overlay after idle + subblocks race condition#1246
icecrasher321 merged 6 commits intostagingfrom
fix/hydration-bugs

Conversation

@icecrasher321
Copy link
Collaborator

Summary

  1. Duplicate overlay showing up after some idle time due to merge state logic.
  2. Subblock Loading race condition fix attempt.

Type of Change

  • Bug fix

Testing

Manually

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 Sep 4, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Sep 4, 2025 10:07pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 4, 2025 10:07pm

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 fixes two critical hydration issues in the workflow management system: duplicate overlay problems after idle time and subblock loading race conditions.

The main changes involve replacing merge-based state synchronization with direct replacement logic in the socket context handlers. Previously, the 'copilot-workflow-edit' and 'workflow-state' socket events merged incoming server state with existing local state to preserve optimistic updates. Now, these handlers completely replace the local state with authoritative server state using useWorkflowStore.setState() and useSubBlockStore.setState(). This eliminates merge conflicts that were causing duplicate overlays to appear after periods of inactivity.

Additionally, the PR adds initialization safety checks in the workflow component to ensure subblock values are properly initialized before marking workflows as ready. When blocks exist but corresponding subblock values are missing, the code now initializes them synchronously from the block structure. This prevents race conditions where the workflow UI would render before subblock values were fully loaded.

The changes integrate with the existing state management architecture where workflows maintain separate stores for block definitions (useWorkflowStore) and dynamic values (useSubBlockStore). The fix ensures these stores remain synchronized and that server state always takes precedence over potentially stale local state.

Confidence score: 3/5

  • This PR addresses real issues but introduces trade-offs that could impact user experience and system reliability
  • Score reflects concerns about losing optimistic updates, potential performance implications, and the complexity of direct state mutations in effects
  • Pay close attention to the socket context changes and workflow initialization logic for potential edge cases

2 files reviewed, 3 comments

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs September 4, 2025 21:38 Inactive
@vercel vercel bot temporarily deployed to Preview – docs September 4, 2025 21:59 Inactive
@vercel vercel bot temporarily deployed to Preview – docs September 4, 2025 22:04 Inactive
@icecrasher321 icecrasher321 merged commit 0f7dfe0 into staging Sep 4, 2025
5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/hydration-bugs branch September 5, 2025 05:50
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…on (simstudioai#1246)

* fix(hydration): duplicate overlay after idle + subblocks race condition

* remove random timeout

* re-use correct helper

* remove redundant check

* add check

* remove third init func
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