-
Notifications
You must be signed in to change notification settings - Fork 0
fix: debounce WebSocket-triggered refetches in agent hooks #876
Copy link
Copy link
Closed
Labels
spec:human-interactionDESIGN_SPEC Section 13 - Human Interaction LayerDESIGN_SPEC Section 13 - Human Interaction Layertype:fixBug fixes and correctionsBug fixes and correctionsv0.5Minor version v0.5Minor version v0.5
Description
Problem
In useAgentDetailData.ts and useAgentsData.ts, every WebSocket message on the subscribed channels triggers a full data refetch. During event bursts (e.g., batch agent updates), this fires many parallel API calls with no debouncing or deduplication.
Additionally, overlapping fetches from WS events and polling can race, with older responses overwriting newer ones since set() is unconditional.
Proposed fix
- Debounce the WebSocket handler (e.g., 300ms) to coalesce burst events into a single refetch
- Consider using a generation counter in the store to discard stale responses from concurrent fetches
Files
web/src/hooks/useAgentDetailData.ts(lines 66-74)web/src/hooks/useAgentsData.ts(lines 51-60)
Found during PR #874 review (silent-failure-hunter agent).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
spec:human-interactionDESIGN_SPEC Section 13 - Human Interaction LayerDESIGN_SPEC Section 13 - Human Interaction Layertype:fixBug fixes and correctionsBug fixes and correctionsv0.5Minor version v0.5Minor version v0.5