diff --git a/openspec/changes/code-review-fix/tasks.md b/openspec/changes/code-review-fix/tasks.md index a3a149c..69766f4 100644 --- a/openspec/changes/code-review-fix/tasks.md +++ b/openspec/changes/code-review-fix/tasks.md @@ -75,7 +75,7 @@ - [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`) - [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`) +- [x] 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/components/CandleChart.tsx b/src/components/CandleChart.tsx index 7128fe6..791f3d9 100644 --- a/src/components/CandleChart.tsx +++ b/src/components/CandleChart.tsx @@ -472,11 +472,14 @@ const CandleChart = forwardRef( // Build candle price lookup for histogram values const candleMap = new Map(candles.map((c) => [c.time, c])); + // Detect candle interval from data (fall back to 60s if fewer than 2 candles) + const candleInterval = candles.length >= 2 ? candles[1].time - candles[0].time : 60; + // Build a map from prediction time to its span for disagreement lookup const predictionTimeToSpan = new Map(); predictionSpans.forEach((span) => { // Associate all times in the span with the span object - for (let t = span.start_time; t <= span.end_time; t += 60) { // Assuming 1-minute candles, adjust if needed + for (let t = span.start_time; t <= span.end_time; t += candleInterval) { predictionTimeToSpan.set(t, span); } });