improvement(sockets): duplicate op should let addBlock take subblock values instead of separate looped op#836
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Greptile Summary
This PR optimizes the block duplication workflow by eliminating the batch subblock update mechanism in favor of passing subblock values directly during the initial block creation operation. The changes remove the entire batch-subblock-update infrastructure across multiple layers of the application:
- Socket Layer: Removes the
batch-subblock-updatehandler fromsubblocks.tsthat processed multiple subblock updates in a single database transaction - Operation Queue: Eliminates
emitBatchSubblockUpdatefunction and its registration from the operation queue store - Socket Context: Removes
emitBatchSubblockUpdateandonBatchSubblockUpdatemethods from the socket context interface - Collaborative Workflow Hook: Modifies
collaborativeDuplicateBlockto merge subblock values directly into the block payload before sending to the server
The key improvement is in the use-collaborative-workflow.ts file where the duplicate operation now:
- Retrieves existing subblock values from the store
- Merges them with the source block's subblock structure
- Includes the merged subblocks directly in the duplicate operation payload
- Applies values locally for immediate UI feedback
This change transforms the duplication process from a two-step operation (create block + batch update subblocks) into a single atomic operation, reducing network overhead and eliminating potential race conditions in collaborative editing scenarios. The approach aligns with existing patterns used in collaborativeAddBlock and leverages the existing mergeSubblockState utility function for consistent state management.
Confidence score: 4/5
- This change should improve performance and reliability by reducing socket operations and eliminating race conditions
- The implementation follows established patterns and maintains backward compatibility
- The removal of batch functionality could impact other use cases that relied on bulk subblock updates, though none are immediately apparent in the changed files
4 files reviewed, 5 comments
| subblockValues: Record<string, any>, | ||
| operationId?: string | ||
| ) => void | ||
|
|
There was a problem hiding this comment.
style: Empty line left after removing emitBatchSubblockUpdate - consider removing for cleaner formatting
| emitSubblockUpdate: ( | |
| blockId: string, | |
| subblockId: string, | |
| value: any, | |
| operationId?: string | |
| ) => void | |
| emitCursorUpdate: (cursor: { x: number; y: number }) => void |
| onWorkflowOperation: (handler: (data: any) => void) => void | ||
| onSubblockUpdate: (handler: (data: any) => void) => void | ||
| onBatchSubblockUpdate: (handler: (data: any) => void) => void | ||
|
|
There was a problem hiding this comment.
style: Empty line left after removing onBatchSubblockUpdate - consider removing for cleaner formatting
| onSubblockUpdate: (handler: (data: any) => void) => void | |
| onCursorUpdate: (handler: (data: any) => void) => void |
| workflowOperation?: (data: any) => void | ||
| subblockUpdate?: (data: any) => void | ||
| batchSubblockUpdate?: (data: any) => void | ||
|
|
There was a problem hiding this comment.
style: Empty line left in eventHandlers type definition after removing batchSubblockUpdate property
| const eventHandlers = useRef<{ | |
| workflowOperation?: (data: any) => void | |
| subblockUpdate?: (data: any) => void | |
| cursorUpdate?: (data: any) => void |
| emitWorkflowOperation, | ||
| emitSubblockUpdate, | ||
| emitBatchSubblockUpdate, | ||
|
|
There was a problem hiding this comment.
style: Empty line left in context provider value after removing emitBatchSubblockUpdate
| emitSubblockUpdate, | |
| emitCursorUpdate, |
| onWorkflowOperation, | ||
| onSubblockUpdate, | ||
| onBatchSubblockUpdate, | ||
|
|
There was a problem hiding this comment.
style: Empty line left in context provider value after removing onBatchSubblockUpdate
| onSubblockUpdate, | |
| onCursorUpdate, |
…values instead of separate looped op (#836) * improvement(sockets): addBlock can accept subblock values * cleanup unused code
…n, deployed chat improvements (#843) * fix(domain): fix telemetry endpoint, only add redirects for hosted version (#822) * fix(otel): change back telemetry endpoint * only add redirects for hosted version --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> * fix(search-modal): fixed search modal keyboard nav (#823) * fixed search modal keyboard nav * break down file --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> * improvement(docs): add base exec charge info to docs (#826) * improvement(doc-tags-subblock): use table for doc tags subblock in create_document tool for KB (#827) * improvement(doc-tags-subblock): use table for doc tags create doc tool in KB block * enforce max tags * remove red warning text * fix(bugs): fixed rb2b csp, fixed overly-verbose logs, fixed x URLs (#828) Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> * feat(wand): subblock level wand configuration + migrate old wand usage to this (#829) * feat(wand): subblock level wand configuration + migrate old wand usage to this * fix build issue * Update apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/wand-prompt-bar/wand-prompt-bar.tsx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * remove optional param * remove unused test file * address greptile comments * change to enum for gen type * fix caching issue --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * feat(tools): added hunter.io tools/block, added default values of first option in dropdowns to avoid operation selector issue, added descriptions & param validation & updated docs (#825) * feat(tools): added hunter.io tools/block, added default values of first option in dropdowns to avoid operation selector issue * fix * added description for all outputs, fixed param validation for tools * cleanup * add dual validation, once during serialization and once during execution * improvement(docs): add base exec charge info to docs (#826) * improvement(doc-tags-subblock): use table for doc tags subblock in create_document tool for KB (#827) * improvement(doc-tags-subblock): use table for doc tags create doc tool in KB block * enforce max tags * remove red warning text * fix(bugs): fixed rb2b csp, fixed overly-verbose logs, fixed x URLs (#828) Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> * fixed serialization errors to appear like execution errors, also fixed contrast on cmdk modal * fixed required for tools, added tag dropdown for kb tags * fix remaining tools with required fields * update utils * update docs * fix kb tags * fix types for exa * lint * updated contributing guide + pr template * Test pre-commit hook with linting * Test pre-commit hook again * remove test files * fixed wealthbox tool * update telemetry endpoints --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> Co-authored-by: Vikhyath Mondreti <vikhyathvikku@gmail.com> * fix(deployed-chat): trigger blocks should not interfere with deployed chat exec (#832) * fix(deployed-chat): allow non-streaming responses in deployed chat, allow partial failure responses in deployed chat (#833) * fix(deployed-chat): allow non-streaming responses in deployed chat, allow partial failure responses in deployed chat * fix(csp): runtime variable resolution for CSP * cleanup --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> * fix(sockets): duplicate block op should go through debounced path (#834) * improvement(sockets): add batch subblock updates for duplicate to clear queue faster (#835) * improvement(sockets): duplicate op should let addBlock take subblock values instead of separate looped op (#836) * improvement(sockets): addBlock can accept subblock values * cleanup unused code * fix(deploy-modal): break down deploy modal into separate components (#837) Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> * fix(kb-tags): docs page kb tags ui (#838) * fix(kb-tags): docs page kb tags ui * remove console logs * remove console error * fix(chat-deploy): fixed form submission access patterns, fixed kb block filters (#839) * fix(chat-deploy): fixed form submission access patterns * fix(kb-block): fix tag filters component, removed unused component * fixed kb block subcomponents --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> * fix(kb-tags): ui fixes, delete persistence for doc page header (#841) * fix deletion of tags + refactor next slot calc * fix kb tag filters count ui * fix(chat-deploy): added new image upload component, fixed some state issues with success view (#842) * fix(chat-deploy): added new image upload component, fixed some state issues with success view * cleanup --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> * feat(deploy-chat): added a logo upload for the chat, incr font size * fix(deploy-modal): break down deploy modal into separate components (#837) Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local> Co-authored-by: Vikhyath Mondreti <vikhyathvikku@gmail.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…values instead of separate looped op (#836) * improvement(sockets): addBlock can accept subblock values * cleanup unused code
…values instead of separate looped op (simstudioai#836) * improvement(sockets): addBlock can accept subblock values * cleanup unused code
Description
Fixing duplicate op to pass in subblock values directly on the add block operation instead of doing batched update.
Type of change
Checklist:
bun run test)Security Considerations: