feat(tables): propagate shared saved-view changes to collaborators live - #6100
Conversation
Table views (named filter/sort/layout presets) are table-wide shared state — every reader sees every view — but view create/update/delete had no realtime signal, so a collaborator only saw another user's view changes on their own staleTime/focus refetch. Add a 'views' table event kind + signalTableViewsChanged, emitted from the views service (createTableView/updateTableView/deleteTableView, on real success only), and a client handler that invalidates the views query alone (no rows/definition refetch — a view is presentation state on the loaded table). Mirrors how row/schema/metadata changes already propagate.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Adds a Reviewed by Cursor Bugbot for commit ad5eead. Configure here. |
Greptile SummaryAdds live propagation of shared saved-view mutations.
Confidence Score: 5/5The PR appears safe to merge with no actionable correctness or security issues identified. The new event is emitted after successful persisted mutations, passes through the generic table-event transport, and invalidates the same table-scoped query key used by saved-view consumers.
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table-event-stream.ts | Handles the new table-scoped event by invalidating the exact saved-view query family used by active consumers. |
| apps/sim/lib/table/events.ts | Extends the generic table-event contract with a value-less views event and a sibling fire-and-forget signaling helper. |
| apps/sim/lib/table/views/service.ts | Signals collaborators only after successful create, update, or delete persistence operations. |
Sequence Diagram
sequenceDiagram
participant A as Collaborator A
participant API as Views Service
participant Log as Table Event Log
participant B as Collaborator B
participant Cache as Views Query Cache
A->>API: Create/update/delete saved view
API->>API: Persist successful mutation
API->>Log: Emit table-scoped views event
Log-->>B: Deliver event over table stream
B->>Cache: Invalidate tableKeys.views(tableId)
Cache->>API: Refetch saved views
Reviews (1): Last reviewed commit: "feat(tables): propagate shared saved-vie..." | Re-trigger Greptile
Summary
viewstable event kind +signalTableViewsChanged, emitted from the views service (createTableView/updateTableView/deleteTableView, on real success only — a no-op PATCH/DELETE on a missing view signals nothing).tableKeys.views) — no rows/definition refetch, since a view is presentation state layered on the already-loaded table.edit), schema, metadata, and definition changes already propagate to collaborators.Context
Found during a wiring audit after merging staging into
realtime-rooms: the new v2 table surface's views feature was the only mutating table surface not propagated live. Rows/schema/metadata/table-CRUD and the async background runners (import/update/backfill viajobevents) were already covered.Type of Change
Testing
Tested manually. tsc clean, lint clean,
check:api-validationpasses (no route change), 61 table/events/views/hook tests pass. No dedicated wrapper test added — consistent with the sibling signals (edit/schema/metadata/definition), which are type-checked and trivial; the views service test deliberately avoids DB mocking.Checklist