fix(sockets): move debounce to server side#1265
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR implements a significant architectural change that moves debouncing logic from client-side to server-side for subblock and variable updates in a collaborative workflow editing system. The change addresses a critical user experience issue where rapid typing was causing the last few characters to be dropped due to client-side operation queue congestion.
Key Changes:
-
Server-side debouncing implementation: New handlers in
subblocks.tsandvariables.tsimplement 25ms server-side debouncing with operation coalescing. Multiple rapid updates to the same subblock/variable are batched together and written to the database as a single operation. -
Client-side simplification: The operation queue store removes all debouncing logic and timeouts, replacing them with immediate coalescing that keeps only the latest pending operation for each unique field. This prevents queue buildup while maintaining deduplication.
-
Enhanced socket management: A new
emitToWorkflowmethod is added toRoomManagerto provide clean type-safe broadcasting. The handlers exclude sender sockets from broadcasts to prevent local state conflicts during collaborative editing. -
Component cleanup: Input components (
LongInput,ShortInput) remove manual flush operations on blur since server-side debouncing eliminates the need for client-side flush logic. -
Improved retry logic: Different retry strategies are implemented - longer timeouts and more retries for text operations vs structural operations, improving reliability during network issues.
This change integrates with the existing workflow state management system by maintaining the same external API while fundamentally changing how updates are persisted. The server-side approach ensures data integrity in collaborative scenarios and prevents the queue clogging that was causing character loss.
Confidence score: 4/5
- This PR addresses a critical UX issue with a well-architected solution that should significantly improve reliability
- Score reflects the complexity of real-time collaborative editing changes and potential edge cases with socket management
- Pay close attention to the socket handler files and operation queue store for proper error handling and edge cases
9 files reviewed, 5 comments
* fix(sockets): move debounce to server side * remove comments / unused onBlur
Summary
Move subblock / variable debounces to the server side. Client queue was getting clogged and last few characters were getting dropped.
Type of Change
Testing
Manually
Checklist