Skip to content

Commit 4419951

Browse files
authored
feat(realtime): live workspace tables list, sharing one invalidation-room impl (#6053)
* feat(realtime): live workspace tables list, sharing one invalidation-room impl Bring the tables list to parity with the files list: a create/rename/move/delete/ restore now propagates to every viewer live instead of waiting out the 30s staleTime. Following the files pattern, but factoring the two into one shared implementation rather than copy-pasting. - add ROOM_TYPES.WORKSPACE_TABLES + its authz resolver (workspace-id-addressed, reuses the workspace resolver like workspace-files) - extract setupWorkspaceInvalidationRoom (server) and useWorkspaceInvalidationRoom (client) — the presence-free, workspace-scoped live-list room; files and tables now both bind to it, so they can never drift. Event/room names derive from the room type. Replaces the standalone workspace-files handler + hook - notifyWorkspaceTablesChanged fanout fired from the table service (createTable, renameTable, moveTableToFolder, deleteTable, restoreTable) so it covers both the HTTP routes AND copilot, which call the service directly - relay /api/workspace-tables-changed endpoint; wire the hook into the tables page - consolidate the handler test into one suite run against both room types * feat(realtime): live tables list also covers table-folder mutations Fold in the follow-up: a table folder create/rename/move/delete/restore now propagates to the tables list live too, so the browser is fully consistent. - generic notifyFolderResourceChanged(resourceType, workspaceId) dispatches the workspace live-list signal by resource type (a map, not a special-case if), so file/knowledge_base/workflow are no-ops today and gain liveness by adding a map entry when they adopt an invalidation room - fired from the shared folder lifecycle (createFolder/updateFolder/deleteFolder/ restoreFolder), covering routes AND copilot - the tables room hook now invalidates the table folders query too, not just the tables list, since the page renders both * fix(realtime): skip per-table live-list notify during a folder cascade A folder delete/restore already fires one folder-level notifyFolderResourceChanged for the whole subtree, but the cascade also calls deleteTable/restoreTable per table — each awaiting its own notifyWorkspaceTablesChanged. A folder with many tables would run N+1 sequential relay calls (each bounded by NOTIFY_TIMEOUT_MS), blocking the mutation. Add a skipNotify option the cascade passes so only the one folder-level notify fires.
1 parent c639d61 commit 4419951

15 files changed

Lines changed: 548 additions & 370 deletions

File tree

apps/realtime/src/handlers/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ROOM_TYPES } from '@sim/realtime-protocol/rooms'
12
import { setupConnectionHandlers } from '@/handlers/connection'
23
import { setupWorkspaceFileDocHandlers } from '@/handlers/file-doc'
34
import { setupOperationsHandlers } from '@/handlers/operations'
@@ -6,7 +7,7 @@ import { setupSubblocksHandlers } from '@/handlers/subblocks'
67
import { setupTablesHandlers } from '@/handlers/tables'
78
import { setupVariablesHandlers } from '@/handlers/variables'
89
import { setupWorkflowHandlers } from '@/handlers/workflow'
9-
import { setupWorkspaceFilesHandlers } from '@/handlers/workspace-files'
10+
import { setupWorkspaceInvalidationRoom } from '@/handlers/workspace-invalidation-room'
1011
import type { AuthenticatedSocket } from '@/middleware/auth'
1112
import type { IRoomManager } from '@/rooms'
1213

@@ -16,7 +17,9 @@ export function setupAllHandlers(socket: AuthenticatedSocket, roomManager: IRoom
1617
setupSubblocksHandlers(socket, roomManager)
1718
setupVariablesHandlers(socket, roomManager)
1819
setupPresenceHandlers(socket, roomManager)
19-
setupWorkspaceFilesHandlers(socket, roomManager)
20+
// Presence-free, workspace-scoped live-list rooms (share one implementation).
21+
setupWorkspaceInvalidationRoom(socket, roomManager, ROOM_TYPES.WORKSPACE_FILES)
22+
setupWorkspaceInvalidationRoom(socket, roomManager, ROOM_TYPES.WORKSPACE_TABLES)
2023
setupWorkspaceFileDocHandlers(socket, roomManager)
2124
setupTablesHandlers(socket, roomManager)
2225
setupConnectionHandlers(socket, roomManager)

apps/realtime/src/handlers/workspace-files.test.ts

Lines changed: 0 additions & 234 deletions
This file was deleted.

0 commit comments

Comments
 (0)