Skip to content

fix(sockets): add sockets event for tag / env var dropdown selections#844

Merged
icecrasher321 merged 7 commits intostagingfrom
fix/sockets-dropdown-select
Aug 1, 2025
Merged

fix(sockets): add sockets event for tag / env var dropdown selections#844
icecrasher321 merged 7 commits intostagingfrom
fix/sockets-dropdown-select

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Tag dropdown / Env Var selections were going through debounce system and were getting overwritten occasionally. Making it a atomic op by adding socket event.

Type of Change

  • Bug fix

Testing

Pick out variables from tag dropdown / environment variable selection drop downs and refresh quickly -- should always persist.

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 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 10:23pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Aug 1, 2025 10:23pm

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 introduces a socket-based approach for handling tag dropdown and environment variable selections to solve race conditions caused by the debounced operation system. The change adds a new useTagSelection hook that immediately updates the local store and emits a dedicated tag-selection socket event, bypassing the normal debounced workflow operations that were causing user selections to be overwritten.

The implementation spans multiple components across the codebase:

  • New hook: useTagSelection provides a callback that performs dual operations - immediate local store updates for instant UI feedback and socket emission for server persistence
  • Component updates: Seven UI components (code.tsx, long-input.tsx, short-input.tsx, combobox.tsx, document-tag-entry.tsx) replace setStoreValue calls with emitTagSelection calls in their dropdown selection handlers
  • Socket infrastructure: The socket context adds the new emitTagSelection method, and a new server handler processes tag-selection events with immediate database persistence and client broadcasting

The change specifically targets dropdown selection scenarios where users expect immediate feedback and persistence, distinguishing these from regular text input that can safely use debounced operations. This ensures that rapid dropdown interactions followed by page refreshes don't result in data loss, which was the core issue being addressed.

Confidence score: 3/5

  • This PR addresses a legitimate user experience issue but introduces significant technical debt through code duplication
  • Score reflects concerns about the server-side handler duplicating most of the existing subblock-update logic without operation tracking mechanisms
  • Pay close attention to the socket handler implementation in subblocks.ts which lacks proper error handling and creates a parallel event system

8 files reviewed, 6 comments

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs August 1, 2025 21:38 Inactive
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@vercel vercel bot temporarily deployed to Preview – docs August 1, 2025 22:20 Inactive
@icecrasher321 icecrasher321 merged commit 3bd7a6c into staging Aug 1, 2025
3 of 4 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/sockets-dropdown-select branch August 2, 2025 22:17
waleedlatif1 pushed a commit that referenced this pull request Aug 5, 2025
…#844)

* fix(sockets): add sockets event for tag / env var dropdown selections to be unit op

* do not bypass op queue for tag selections

* Update apps/sim/socket-server/handlers/subblocks.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* prevent race cond between subblock update event and tag selection

* refactor

* reduce debounce time to 50ms

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…simstudioai#844)

* fix(sockets): add sockets event for tag / env var dropdown selections to be unit op

* do not bypass op queue for tag selections

* Update apps/sim/socket-server/handlers/subblocks.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* prevent race cond between subblock update event and tag selection

* refactor

* reduce debounce time to 50ms

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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