feat: unified WS event bus, v2Hosts data model, real diff stats
Merged
SA
7mo ago+6658+6658+0123456789012345678901234567890123456789-847-847-012345678901234567890123456789
Summary
- Unified WS event bus: Single
/eventsWebSocket endpoint on host-service replacing per-workspace filesystem WS connections. Carriesgit:changed(auto-pushed for all workspaces) andfs:events(on-demand per client request). Client-side connection manager with reconnection and ref-counting. - v2Hosts/v2Clients data model: Replaced
v2Devices/v2DevicePresence/v2UsersDeviceswithv2Hosts(machineId NOT NULL, lastSeenAt),v2Clients(machineId, userId, type: desktop/mobile/web),v2UsersHosts(owner/member).v2Workspaces.deviceId→hostId. - Real diff stats: Left sidebar chips show actual
+N / -Nfromgit.getStatus, triggered bygit:changedevents instead of polling. Multi-host routing ready (local → localhost, remote → proxy URL pattern). - GIT_OPTIONAL_LOCKS=0: Prevents index.lock contention between host-service git reads and user git operations.
- Changes tab fix: Header stats now update when switching the filter dropdown (all/uncommitted/commit).
- PR polling: Bumped to 10s (was 15s on client, 30s on host-service).
Test plan
- Left sidebar diff stats show real data matching
git diff --shortstat - Making code changes updates the diff stats chip (git watcher fires)
- File tree still works (filesystem events over unified event bus)
- Network tab shows single
/eventsWS connection per host -
git checkout/git commitin terminal doesn't hit index.lock errors - Changes tab header stats update when switching filter dropdown
- Cloud workspaces show no diff stats chip
-
bun run lint:fix && bun run typecheckpasses
Summary by cubic
Unifies host-service events behind a single /events WebSocket and completes the v2Hosts/v2Clients migration, delivering live diff stats and an event‑driven Changes tab. Reduces connections, improves multi‑host routing, and avoids git lock conflicts.
-
New Features
- Single
/eventsWS per host emitsgit:changed(auto) andfs:events(opt‑in); one shared connection with reconnection and ref‑counting. - Real diff stats (+N/−N) via
useDiffStatsanduseWorkspaceEvent; dedupes by path to avoid double‑counting; Changes tab invalidates status/commits ongit:changed(no polling). - Data model:
v2Hosts,v2Clients,v2UsersHosts; workspaces now usehostId.ensureV2Host(machineId)and newensureV2Client.
- Single
-
Bug Fixes
- More reliable host URL resolution and multi‑host routing (local service when present, else proxy
api/v2-hosts/:hostId/trpc). - Event bus fixes: ref‑counted
watchFs/unwatchFs; 300ms per‑workspace debounce in GitWatcher; removed legacy FS event bridge inworkspace-client. - Set
GIT_OPTIONAL_LOCKS=0to avoid index.lock contention. - PR polling set to 10s; small UI polish (diff‑stats pill sizing,
LuFolderGit2, editor width); cleanup of stale DB enums; re‑exported FS types from@superset/workspace-fs/client.
- More reliable host URL resolution and multi‑host routing (local service when present, else proxy
Summary by CodeRabbit
-
New Features
- Real-time event bus and client hooks for git and filesystem events; workspace components now subscribe to live git/fs notifications.
- Live diff stats in the workspace sidebar (replacing mocked values).
-
Refactor
- Platform model migrated from device→host: host-based selection, local vs remote detection, routing, and workspace metadata updated.
- Host-focused UI: pickers, icons, and workspace forms reflect host/cloud semantics.
-
Performance
- More responsive updates: reduced polling intervals and event-driven invalidation replacing frequent polling.