Skip to content

Dependent operation cancellation on entity deletion #8

@FuJacob

Description

@FuJacob

Context

When User A deletes a node, User B may have pending operations for that node sitting in their operation queue (not yet sent). Currently these stale ops would be sent and silently fail or cause errors. Sim proactively cancels dependent operations client-side when receiving a deletion broadcast.

What to build

Client-side: Queue purging on remote deletion

When receiving a node_delete or edge_delete broadcast:

  1. Scan the local operation queue for any pending ops targeting the deleted entity
  2. Cancel/remove those ops from the queue (both node-level and sub-entity ops like text edits)
  3. Then apply the deletion to local state

This is more efficient than server-side validation — avoids wasting network requests on ops that would fail anyway.

Cascade logic

  • Node deletion should cancel:
    • All pending ops for that node (move, update, text edits)
    • All pending ops for edges connected to that node
    • All pending CRDT ops for documents owned by that node
  • Edge deletion should cancel:
    • All pending ops for that edge

Server-side: Validate stale ops

Current code references

  • frontend/src/canvas/hooks/useCanvasCollab.ts — inbound event handlers (where deletion broadcasts are received)
  • frontend/src/shared/events.tsnode_delete, edge_delete event types

Acceptance criteria

  • Pending ops for a deleted node are cancelled before sending
  • Connected edge ops are also cancelled on node deletion
  • CRDT ops for deleted node's documents are cancelled
  • Server validates entity existence as safety net
  • No error messages shown for silently cancelled ops

Metadata

Metadata

Assignees

No one assigned

    Labels

    Full-stackFrontend and backend work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions