feat(canvas): CommunicationOverlay → ACTIVITY_LOGGED subscriber (#61 stage 1) #69
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/canvas-comm-overlay-ws-subscribe"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stage 1 of #61. Closes the first leg of the poll-fan-out reduction:
CommunicationOverlayno longer polls/workspaces/:id/activityon a 30s interval; it bootstraps once on mount and subscribes toACTIVITY_LOGGEDvia the existinguseSocketEventbus for live updates.What this PR changes
The singleton
ReconnectingSocketincanvas/src/store/socket.tsalready owns reconnect + backoff + health-check; routing the overlay throughuseSocketEventinherits all of those for free without opening a new WebSocket per panel.SSOT decision
useSocketEventis the single subscription primitive — same hookChatTab.tsxandAgentCommsPanel.tsxalready use. No new abstraction. The HTTP bootstrap path reuses the same/workspaces/:id/activity?limit=5shape the previous polling code used; the only delta is its triggering condition (mount + visibility re-open instead of every 30s).Tests
canvas/src/components/__tests__/CommunicationOverlay.test.tsx— 9 tests, all PASS:Full canvas suite: 1393 passing, 0 failing.
pnpm tsc --noEmitclean.Mutation tests
if (!visible) returnin both useEffect and useSocketEvent handler)Each verifies an actual production-code branch is exercised; no tautologies.
Security check
ChatTabandAgentCommsPanelalready trust. The overlay treats every payload field as optional/coercible —activity_type,source_id,target_id,summary,status,created_atall guard for missing or wrong type. No XSS surface (everything renders through React's text-content path; nodangerouslySetInnerHTML).socket-events.ts).Versioning + backwards compat
/workspaces/:id/activityHTTP endpoint unchanged (still used for bootstrap).ACTIVITY_LOGGEDunchanged; consumed in the same shapeAgentCommsPanelalready uses.Hostile self-review — three weakest spots
socket.tsaggressively reconnects (5s health-check, exponential backoff). For users who care about freshness during a sustained outage, the visibility-toggle re-bootstrap is one click away.nodesvianodesRefrather than re-subscribing on node-list changes. Same pattern A2ATopologyOverlay's comment warns about — re-subscribing on every store update would tear down + re-arm the bus listener every render. Stable subscription with ref-based current-state lookup is the right shape.Rollout / rollback
git revertthe merge — overlay falls back to the 30s polling shape.Out of scope (still tracked under #61)
A2ATopologyOverlay(60s × N workspaces, 500-row windowed query — separate PR)ActivityTab(5s × 1 active workspace — separate PR)🤖 Generated with Claude Code
Cross-persona review (devops-engineer ↔ claude-ceo-assistant author): five-axes pass per SOP. Tests: full local suite green at each stage; mutation tests caught targeted regressions. Security: no auth/data/access changes. Approved.