Skip to content

Refactor frontend websocket#72

Merged
MaddieWright merged 2 commits intomainfrom
frontend/websocket-refactor
Mar 11, 2026
Merged

Refactor frontend websocket#72
MaddieWright merged 2 commits intomainfrom
frontend/websocket-refactor

Conversation

@MaddieWright
Copy link
Collaborator

@MaddieWright MaddieWright commented Mar 11, 2026

Websocket refactor

What?

refactored the websocket architecture to use a shared connection across all nodes, and fixed several related issues: filter cutoff values not being applied, chart time axis showing raw ISO timestamps, and chart data clearing when streaming is paused.


How?

Shared WebSocket context (WebSocketContext.tsx):

  • previously useWebsocket created a separate connection per node
  • the filter node had its own connection to send processing config, and the signal graph had its own connection to receive data; so config was never applied to the data stream
  • now a single WebSocketProvider owns the one connection for the entire application
  • it uses a pub/sub pattern: nodes subscribe to receive data points, and the filter node dispatches a processing-config-update custom event that the provider picks up and forwards to the backend

Additionally:

  • useNodeData.ts replaces useWebsocket for nodes -> it subscribes to the shared data stream and windows/buffers data at the node's own rate (chartSize, batchesPerSecond), with no websocket logic of its own
  • filter cutoff fix (combo-box.tsx): the lowCutoff/highCutoff/setLowCutoff/setHighCutoff props were declared in the interface but never destructured, so the sliders updated internal local state that was never passed back to the parent's buildConfig() -> fixed by making the component fully controlled
  • buffer management (useNodeData.ts): buffer is cleared on stream start/stop to prevent backlog buildup and renderData is never cleared so the chart holds its last frame when paused and new data naturally replaces it on resume
  • time formatting (WebSocketContext.tsx): backend sends ISO 8601 timestamps (2026-03-11T03:55:22Z) -> formatted to HH:MM:SS in normalizeBatch so both the chart axis and data table show readable times.

Testing

  • verified Docker build succeeds for websocket-server
  • confirmed only one websocket connection opens in browser console when streaming starts
  • confirmed chart renders data with Source to Chart View pipeline
  • confirmed filter config is sent on stream start with Source to Filter to Chart View pipeline
  • confirmed changing filter type/cutoff while streaming dispatches updated config (visible in backend logs)
  • confirmed chart holds last frame when stream is paused and resumes correctly
  • confirmed time axis shows HH:MM:SS instead of full ISO timestamp
Screenshot 2026-03-10 at 9 02 27 PM Screenshot 2026-03-10 at 9 08 08 PM

@MaddieWright MaddieWright merged commit 16478c0 into main Mar 11, 2026
1 check failed
@MaddieWright MaddieWright deleted the frontend/websocket-refactor branch March 11, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant