Offer health data through websocket#43
Conversation
📝 WalkthroughWalkthroughThe app refactors health metrics from REST polling intervals to real-time Socket.IO events, updating the health store contract to accept a Socket connection, wiring the socket from App.vue, and adjusting the system view display. Additionally, Monaco's Device interface is updated to declare setAttribute as async. ChangesSocket.IO Health Metrics
Monaco Device Interface Type
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/App.vue (1)
26-34:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAvoid stacking
healthMetricslisteners on Socket.IO reconnects.
src/App.vuecallshealthStore.init(io)inside theio.on("connect", ...)handler, so every reconnect re-runs it. Insrc/stores/health.ts,init(socket)registerssocket.on("healthMetrics", ...)and there’s nosocket.off("healthMetrics", ...)cleanup in place, so listeners can accumulate.Proposed fix
if (backendStore.backendUrl) { const io = useSocketIO() as Socket; + healthStore.init(io); io.on("connect", () => { backendStore.setServerOnline(true); @@ settingsStore.init(); automationStore.init(); devicesStore.init(); - healthStore.init(io); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/App.vue` around lines 26 - 34, App.vue is re-calling healthStore.init(io) on every Socket.IO "connect", and healthStore.init(socket) attaches socket.on("healthMetrics", ...) without removing prior listeners, causing listener accumulation on reconnects; modify healthStore.init(socket) to avoid duplicate handlers by either moving the healthStore.init(io) call outside the io.on("connect", ...) handler in App.vue so it runs once, or change healthStore.init to first remove any existing listener (call socket.off("healthMetrics", handler) or socket.off("healthMetrics") before socket.on) or keep a single stored handler reference in healthStore (e.g., this._healthHandler) and use socket.off with that reference before re-attaching to ensure only one "healthMetrics" listener is registered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/App.vue`:
- Around line 26-34: App.vue is re-calling healthStore.init(io) on every
Socket.IO "connect", and healthStore.init(socket) attaches
socket.on("healthMetrics", ...) without removing prior listeners, causing
listener accumulation on reconnects; modify healthStore.init(socket) to avoid
duplicate handlers by either moving the healthStore.init(io) call outside the
io.on("connect", ...) handler in App.vue so it runs once, or change
healthStore.init to first remove any existing listener (call
socket.off("healthMetrics", handler) or socket.off("healthMetrics") before
socket.on) or keep a single stored handler reference in healthStore (e.g.,
this._healthHandler) and use socket.off with that reference before re-attaching
to ensure only one "healthMetrics" listener is registered.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 79109e6e-ec60-420d-af12-42f5292027b3
📒 Files selected for processing (4)
src/App.vuesrc/components/automation/MonacoEditor.vuesrc/stores/health.tssrc/views/SystemHealthView.vue
Summary by CodeRabbit
Release Notes