refactor(realtime): type the socket event-handler boundary with @sim/realtime-protocol#5208
Conversation
…realtime-protocol Replace the (data: any) event-handler types in socket-provider.tsx with precise broadcast types that mirror the exact payloads emitted by the realtime Socket.IO server (apps/realtime/src/handlers/** and rooms/**). Add @sim/realtime-protocol/events with the canonical wire types for the broadcast/confirmation events the server emits: WorkflowOperationBroadcast, SubblockUpdateBroadcast, VariableUpdateBroadcast, CursorUpdateBroadcast, SelectionUpdateBroadcast, the four workflow-lifecycle broadcasts, and OperationConfirmed/Failed. Typing change only; zero runtime/logic changes. Store-internal any (rehydrate state, subblock map, emit payloads) is left untouched as out of scope.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview All Reviewed by Cursor Bugbot for commit 881caa3. Configure here. |
|
@greptile review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 60e355a. Configure here.
Greptile SummaryThis PR replaces
Confidence Score: 5/5Safe to merge — typing-only change with zero runtime behavior modification. Every declared field in the eleven new broadcast interfaces was verified against the actual server emit call sites in redis-manager.ts, memory-manager.ts, presence.ts, operations.ts, subblocks.ts, and variables.ts. All shapes match exactly: WorkflowDeployedBroadcast correctly omits message; cursor is CursorPosition | null to cover the cursor-leave signal; opaque payload and value fields are unknown; avatarUrl matches UserSession. The subpath export follows the existing pattern. No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "fix(realtime): type cursor-update broadc..." | Re-trigger Greptile |
The client emits 'cursor-update' with { cursor: null } when a remote user's
cursor leaves the canvas, and the server re-broadcasts it verbatim, so receivers
genuinely get cursor: null. Type CursorUpdateBroadcast.cursor as
CursorPosition | null to match the wire. (selection stays non-null — it signals
absence via type: 'none', never null.)
|
@greptile review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 881caa3. Configure here.
Summary
Replaces the
(data: any)socket event-handler types insocket-provider.tsxwith precise wire types, closing the realtime transport boundary that the AI/collaborative editor depends on. Adds a shared, pure-type modulepackages/realtime-protocol/src/events.ts(+ a./eventssubpath export) holding the broadcast shapes, since the realtime server emits them.Typing only — zero logic/behavior change. Each event type was verified against the actual
apps/realtimeemit site AND the consumers (no field declared that the server omits, none missing that a consumer reads).anyin the file dropped 33→11 (the 11 remaining are pre-existing, out-of-scope store internals).Notable correctness details:
cursor-update/selection-updateare flat presence objects;workflow-deployedomitsmessage;workflow-operation.payloadisunknown(consumers dispatch onoperation/target, never deref it untyped).events.tsis distinct fromschemas.ts— it types the outbound broadcast, not the inbound op envelope (no duplication).Type of Change
Testing
check:boundaries+check:realtime-prunepass, 14/14 socket tests.Checklist