diff --git a/openspec/changes/code-review-fix/tasks.md b/openspec/changes/code-review-fix/tasks.md index 0947a31..a3a149c 100644 --- a/openspec/changes/code-review-fix/tasks.md +++ b/openspec/changes/code-review-fix/tasks.md @@ -74,7 +74,7 @@ - [x] 8.2 `[sonnet]` Use `chart.applyOptions()` for theme changes instead of re-creating chart (`src/components/CandleChart.tsx:333`) - [x] 8.3 `[sonnet]` Remove `fitContent()` from reconciliation effect, only call on initial load (`src/components/SpanAnnotationManager.tsx:160`) - [x] 8.4 `[opus]` Implement incremental primitive updates in SpanAnnotationManager: update only selection state on selection change, full reconciliation only on annotation list changes (`src/components/SpanAnnotationManager.tsx:104-161`) -- [ ] 8.5 `[sonnet]` Add bounded prediction cache (max 100 entries, FIFO eviction) to `predictionCacheRef` (`src/app/page.tsx:195-199`) +- [x] 8.5 `[sonnet]` Add bounded prediction cache (max 100 entries, FIFO eviction) to `predictionCacheRef` (`src/app/page.tsx:195-199`) - [ ] 8.6 `[sonnet]` Fix hardcoded 1-minute candle interval: detect interval from data, use for span iteration (`src/components/CandleChart.tsx:452`) - [ ] 8.7 `[haiku]` Extract magic numbers (8px, 60s, colors) to named constants in `CandleChart.tsx` - [ ] 8.8 `[haiku]` Move `new Set()` default prop to module-level constant in `CandleChart.tsx:125` diff --git a/src/app/page.tsx b/src/app/page.tsx index 4f741c8..639c833 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -544,9 +544,13 @@ export default function Home() { const data = await response.json(); - // Cache the results + // Cache the results (bounded: max 100 entries, FIFO eviction) if (cacheKey) { - predictionCacheRef.current.set(cacheKey, { + const cache = predictionCacheRef.current; + if (cache.size >= 100) { + cache.delete(cache.keys().next().value); + } + cache.set(cacheKey, { spans: data.spans, predictions: data.predictions, modelVersion: data.model_info.model_version, @@ -668,7 +672,11 @@ export default function Home() { const cacheKey = generateCacheKey(activeChartId, data.model_info.model_version); if (cacheKey) { - predictionCacheRef.current.set(cacheKey, { + const cache = predictionCacheRef.current; + if (cache.size >= 100) { + cache.delete(cache.keys().next().value); + } + cache.set(cacheKey, { spans: data.spans, predictions: data.predictions, modelVersion: data.model_info.model_version,