From fdeebf178f60f911435d4ef48b08a867b9cbc3bc Mon Sep 17 00:00:00 2001 From: Robert DeLuca Date: Wed, 11 Feb 2026 12:10:14 -0600 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Fix=20TDD=20SSE=20perf?= =?UTF-8?q?ormance=20by=20splitting=20heavy=20comparison=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/reporter/src/api/client.js | 9 ++ .../comparison/fullscreen-viewer.jsx | 6 +- .../views/comparison-detail-view.jsx | 25 ++- .../src/hooks/queries/use-tdd-queries.js | 10 ++ src/reporter/src/lib/query-keys.js | 1 + src/server/handlers/tdd-handler.js | 110 ++++++++++--- src/server/routers/dashboard.js | 55 ++++++- tests/server/handlers/tdd-handler.test.js | 63 +++++++- tests/server/routers/dashboard.test.js | 147 ++++++++++++++++++ 9 files changed, 395 insertions(+), 31 deletions(-) diff --git a/src/reporter/src/api/client.js b/src/reporter/src/api/client.js index 4995d6e2..b9a99cdf 100644 --- a/src/reporter/src/api/client.js +++ b/src/reporter/src/api/client.js @@ -48,6 +48,15 @@ export const tdd = { return fetchJson('/api/report-data'); }, + /** + * Get full comparison details (lightweight + heavy fields) + * @param {string} id - Comparison ID, signature, or name + * @returns {Promise} + */ + async getComparison(id) { + return fetchJson(`/api/comparison/${encodeURIComponent(id)}`); + }, + /** * Accept a single baseline * @param {string} id - Comparison ID diff --git a/src/reporter/src/components/comparison/fullscreen-viewer.jsx b/src/reporter/src/components/comparison/fullscreen-viewer.jsx index dfe3395b..9bbb3722 100644 --- a/src/reporter/src/components/comparison/fullscreen-viewer.jsx +++ b/src/reporter/src/components/comparison/fullscreen-viewer.jsx @@ -540,7 +540,8 @@ function FullscreenViewerInner({ {/* Regions toggle - only show if comparison has regions */} - {comparison?.confirmedRegions?.length > 0 && ( + {(comparison?.confirmedRegions?.length > 0 || + comparison?.hasConfirmedRegions) && ( {/* Regions toggle - mobile */} - {comparison?.confirmedRegions?.length > 0 && ( + {(comparison?.confirmedRegions?.length > 0 || + comparison?.hasConfirmedRegions) && (