⚡️ Fix TDD SSE performance by splitting heavy comparison data#214
⚡️ Fix TDD SSE performance by splitting heavy comparison data#214
Conversation
Split report-data.json into lightweight SSE data and on-demand heavy fields: - report-data.json: Only lightweight comparison fields (broadcast via SSE) - comparison-details.json: Heavy fields like diffClusters, intensityStats, boundingBox, regionAnalysis, hotspotAnalysis, confirmedRegions (persisted, never broadcast) Remove redundant groups array from report-data.json — UI already computes groups client-side via groupComparisons(). Switch to compact JSON serialization. Add GET /api/comparison/:id endpoint that merges lightweight + heavy data on-demand. Frontend fetches full details only when viewer opens via new useComparison hook. Result: 79% reduction in SSE payload (735 KB → 153 KB per update), cumulative broadcast drops from ~97 MB to ~20 MB for 135 comparisons.
This comment has been minimized.
This comment has been minimized.
Code Review - PR #214SummaryThis PR addresses a significant performance issue in TDD mode where SSE broadcasts were sending 735KB per update. The solution splits comparison data into lightweight (SSE-broadcast) and heavy (on-demand) files, achieving a 79% reduction in payload size. The approach is well-architected and the implementation is solid. ✅ StrengthsArchitecture & Design
Implementation Quality
Performance Impact
|
- Add debug logging to readComparisonDetails for consistency - Add empty comparison ID validation in /api/comparison/:id - Add debug logging for details file parse errors in dashboard router
Vizzly - Visual Test ResultsCLI Reporter - 7 changes need review
Changes needing review (7)viewer-slide-mode · Firefox · 1920×1080 · 0.5% diff filter-failed-only · Firefox · 375×703 · 0.2% diff fullscreen-viewer · Firefox · 1920×1080 · 0.1% diff bulk-accept-dialog · Firefox · 1920×1080 · 10.3% diff bulk-accept-dialog · Firefox · 375×667 · 95.2% diff fullscreen-viewer · Firefox · 375×667 · 97.5% diff ...and 1 more in Vizzly.
|






Summary
Fixes #213 — SSE broadcasts in TDD mode were sending the entire
report-data.json(735 KB per update, ~97 MB cumulative for 135 comparisons). Root cause:tdd-handler.jsspread the full comparison object (includingdiffClusters,intensityStats, etc.) into the file, and thegroupsarray duplicated every comparison.report-data.json(lightweight, broadcast via SSE) andcomparison-details.json(heavy fields, persisted but never broadcast)groupsarray fromreport-data.json— UI already computes groups client-side viagroupComparisons()GET /api/comparison/:idendpoint that merges lightweight + heavy data on-demand (supports lookup by id, signature, or name)useComparisonhook — frontend fetches full comparison details only when the fullscreen viewer openscomparison-details.jsonhasDiffClusters,hasConfirmedRegions) so UI can show toggle buttons before heavy data loadsResults (135 comparisons, 68 with diffs)
report-data.jsonon diskFiles changed
src/server/handlers/tdd-handler.js— Split writes, remove groups, compact JSONsrc/server/routers/dashboard.js— New/api/comparison/:idendpointsrc/reporter/src/api/client.js—getComparison(id)methodsrc/reporter/src/lib/query-keys.js— Comparison query keysrc/reporter/src/hooks/queries/use-tdd-queries.js—useComparisonhooksrc/reporter/src/components/views/comparison-detail-view.jsx— On-demand fetch + mergesrc/reporter/src/components/comparison/fullscreen-viewer.jsx— Boolean hint fallbacks for regions toggleTest plan
npm test— all 1882 tests pass/api/comparison/:id(merged data, lookup by signature/name, 404s, no details file)report-data.jsonand present incomparison-details.jsonvizzly tdd runin vizzly project — verified file sizes and data integrity across two runs