feat(ui): add prediction state management and PredictionPanel component

- Create prediction type definitions in src/types/predictions.ts
- Add prediction state management to page.tsx with caching
- Implement PredictionPanel component with:
  - Master visibility toggle
  - Model info display (name, version, type, metrics)
  - Action buttons (Run on Visible, Predict All)
  - Confidence threshold slider
  - Label filter checkboxes with per-class metrics
  - Disagreement filter toggle
  - Prediction summary display
  - Model server offline banner
- Add on-demand and batch prediction fetching
- Implement prediction caching by chart and model version
- Add health polling for inference API (30s interval when offline)
- Ensure annotation tools work independently of prediction API

Tasks completed: 9.1-9.5, 12.1-12.3 (59/78 total)
This commit is contained in:
Marko Djordjevic 2026-02-15 16:20:07 +01:00
parent bb1b6d573f
commit 28ebe2c5d1
4 changed files with 608 additions and 8 deletions

View file

@ -78,11 +78,11 @@
## 9. Prediction UI — State & Controls
- [ ] 9.1 Create `src/types/predictions.ts` — PredictionSpan, PredictionState, ModelInfoResponse interfaces
- [ ] 9.2 Create prediction state management in page.tsx (or dedicated context) — spans, isLoading, error, modelInfo, visible, confidenceThreshold, selectedLabels, autoPredict
- [ ] 9.3 Create `src/components/PredictionPanel.tsx` — controls panel with master toggle, model info display, action buttons, confidence slider, label checkboxes with metrics
- [ ] 9.4 Implement on-demand prediction fetching — "Run on Visible" sends visible candles to /api/predict, "Predict All" sends batch request
- [ ] 9.5 Implement prediction caching — Map keyed by pair_timeframe_range_modelVersion, invalidate on model version change
- [x] 9.1 Create `src/types/predictions.ts` — PredictionSpan, PredictionState, ModelInfoResponse interfaces
- [x] 9.2 Create prediction state management in page.tsx (or dedicated context) — spans, isLoading, error, modelInfo, visible, confidenceThreshold, selectedLabels, autoPredict
- [x] 9.3 Create `src/components/PredictionPanel.tsx` — controls panel with master toggle, model info display, action buttons, confidence slider, label checkboxes with metrics
- [x] 9.4 Implement on-demand prediction fetching — "Run on Visible" sends visible candles to /api/predict, "Predict All" sends batch request
- [x] 9.5 Implement prediction caching — Map keyed by pair_timeframe_range_modelVersion, invalidate on model version change
## 10. Prediction UI — Chart Rendering
@ -103,9 +103,9 @@
## 12. Inference API Connection & Error Handling
- [ ] 12.1 Implement inference API health polling — poll /api/model/info every 30 seconds when API unavailable, auto-reconnect
- [ ] 12.2 Show "Model server offline" banner when inference API unavailable, disable prediction controls
- [ ] 12.3 Ensure annotation tools work independently — prediction API errors never block human annotation
- [x] 12.1 Implement inference API health polling — poll /api/model/info every 30 seconds when API unavailable, auto-reconnect
- [x] 12.2 Show "Model server offline" banner when inference API unavailable, disable prediction controls
- [x] 12.3 Ensure annotation tools work independently — prediction API errors never block human annotation
- [ ] 12.4 Add loading states for prediction fetching — skeleton/shimmer overlay during prediction requests
## 13. Documentation & Deployment