⚡ Singleton SSE connection + incremental updates for TDD dashboard#217
⚡ Singleton SSE connection + incremental updates for TDD dashboard#217
Conversation
Fixes the performance issue where each component calling useReportData() opened its own EventSource, resulting in 4 concurrent SSE connections and 4 file watchers on the server. Also eliminates full data re-sends on every file change. - Move SSE management to a React context provider (SSEProvider) that wraps the app once, replacing per-component EventSource instances - Replace useReportDataSSE hook with useSSEState context consumer - Server now diffs report data against last-sent state per connection and sends incremental comparisonUpdate/comparisonRemoved/summaryUpdate events instead of the full comparisons array - Initial connection still receives full reportData for complete state - Polling fallback preserved for reconnection scenarios Closes #213
This comment has been minimized.
This comment has been minimized.
PR Review: ⚡ Singleton SSE connection + incremental updates for TDD dashboardSummaryThis PR successfully addresses critical performance issues in the TDD dashboard's real-time update system. The changes are well-architected and align with React best practices. Overall, this is a strong improvement that reduces network overhead significantly. Strengths ✅Architecture & Design
Code Quality
Issues & Recommendations 🔍Critical: Missing Test Coverage for New Features
|
- Use JSON.stringify for comparison diffing instead of field-by-field checks (catches all field changes, avoids float precision issues) - SSE context default → null with guard in useSSEState to catch accidental usage outside SSEProvider - Add comment clarifying comparisonUpdate sends full comparison objects - Add 5 tests for incremental events: comparisonUpdate (new + changed), comparisonRemoved, summaryUpdate, and no-op when data is unchanged
Vizzly - Visual Test ResultsCLI Reporter - 3 changes need review
Changes needing review (3)fullscreen-viewer · Firefox · 1920×1080 · 5.8% diff viewer-zoomed-100 · Firefox · 1920×1080 · 0.5% diff fullscreen-viewer · Firefox · 375×667 · 197.0% diff CLI TUI - Processing...Build in progress...
|



Summary
Follow-up to #213 (v0.29.2). Addresses two remaining performance issues in the TDD dashboard's real-time update system:
useReportData()was called in 4 components, each creating its ownEventSourceto/api/events(4 concurrent connections + 4 file watchers). Moved SSE management to aSSEProviderReact context that wraps the app once. Components now read connection state viauseSSEState()context consumer.report-data.jsonon every file change. Now it diffs against the last-sent data per connection and sends onlycomparisonUpdate,comparisonRemoved, andsummaryUpdateevents. For a 139-screenshot suite, this reduces per-event payload from ~50-200KB (full array) to ~0.5-2KB (single comparison).reportDatafor complete state. Polling fallback activates when SSE is disconnected.Files changed
src/reporter/src/providers/sse-provider.jsxsrc/reporter/src/hooks/use-sse.jssrc/reporter/src/hooks/queries/use-tdd-queries.jsuseReportDataSSE()→useSSEState()src/reporter/src/main.jsx<SSEProvider>wrapper inside<QueryClientProvider>src/server/routers/events.jsTest plan
npm run build:reporter— reporter builds without errorsnpm run lint+npm run format:check— cleannpm test— all 1882 tests passnpm pack, install in vizzly e2e repo, run full suite (139 screenshots) — dashboard loads and updates correctlyCloses #213