diff --git a/src/app/page.tsx b/src/app/page.tsx index 639c833..4c7a857 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -14,6 +14,7 @@ import KeyboardShortcutsModal from '@/components/KeyboardShortcutsModal'; import { useTheme } from 'next-themes'; import { Settings, Tag, Layers } from 'lucide-react'; import type { PredictionState, PredictionSpan, ModelInfoResponse, Disagreement, DisagreementType, PredictionSummary } from '@/types/predictions'; +import type { SpanAnnotation, SpanLabelType } from '@/types'; /** * Calculate overlap between two time ranges @@ -120,46 +121,25 @@ function detectDisagreements( }; } +// SpanAnnotation, SpanLabelType are imported from @/types above. +// Chart: kept local because shared Chart.created_at is Date|number but local usage expects number. interface Chart { id: number; name: string; created_at: number; } +// Annotation: kept local because shared Annotation has geometry: Geometry|null but local usage passes geometry: any. interface Annotation { id: number; chart_id: number; timestamp: number; label_type: string; + color: string | null; geometry: any; created_at: number; } -interface SpanAnnotation { - id: number; - chart_id: number; - start_time: number; - end_time: number; - label: string; - confidence: number | null; - outcome: string | null; - notes: string | null; - sub_spans: any; - color: string; - created_at: number; -} - -interface SpanLabelType { - id: number; - name: string; - display_name: string; - color: string; - hotkey: string | null; - is_active: boolean; - sort_order: number; - created_at: number; -} - export default function Home() { const { theme, setTheme } = useTheme(); const [settingsOpen, setSettingsOpen] = useState(false); diff --git a/src/components/CandleChart.tsx b/src/components/CandleChart.tsx index c2207d2..6289646 100644 --- a/src/components/CandleChart.tsx +++ b/src/components/CandleChart.tsx @@ -7,6 +7,7 @@ import SpanAnnotationManager from './SpanAnnotationManager'; import { TrendLine } from '@/plugins/trend-line'; import { RectangleDrawingPrimitive, RectanglePoint } from '@/plugins/rectangle-drawing'; import type { PerCandlePrediction, PredictionSpan, ModelInfoResponse, PredictionSummary } from '@/types/predictions'; +import type { Candle, Annotation, AnnotationType, SpanAnnotation, SpanLabelType } from '@/types'; // === Magic Number Constants === const ENDPOINT_CLICK_TOLERANCE_PX = 8; @@ -72,62 +73,7 @@ interface Point { price: number; } -interface Candle { - time: number; - open: number; - high: number; - low: number; - close: number; -} - -interface Annotation { - id: number; - timestamp: number; - label_type: string; - color: string | null; - geometry: { - startTime?: number; - startPrice?: number; - endTime?: number; - endPrice?: number; - } | null; - created_at: number; -} - -type AnnotationType = { - id: number; - name: string; - display_name: string; - color: string; - category: string; - icon: string | null; - is_active: boolean; -}; - -interface SpanAnnotation { - id: number; - chart_id: number; - start_time: number; - end_time: number; - label: string; - confidence: number | null; - outcome: string | null; - notes: string | null; - sub_spans: any; - color: string; - created_at: number; -} - -interface SpanLabelType { - id: number; - name: string; - display_name: string; - color: string; - hotkey: string | null; - is_active: boolean; - sort_order: number; - created_at: number; -} +// Candle, Annotation, AnnotationType, SpanAnnotation, SpanLabelType are imported from @/types above. interface CandleChartProps { activeTool: string | null; diff --git a/src/components/SpanAnnotationList.tsx b/src/components/SpanAnnotationList.tsx index d633c38..106dfcf 100644 --- a/src/components/SpanAnnotationList.tsx +++ b/src/components/SpanAnnotationList.tsx @@ -2,31 +2,9 @@ import { useState } from 'react'; import { Trash2, ChevronDown } from 'lucide-react'; +import type { SpanAnnotation, SpanLabelType } from '@/types'; -interface SpanAnnotation { - id: number; - chart_id: number; - start_time: number; - end_time: number; - label: string; - confidence: number | null; - outcome: string | null; - notes: string | null; - sub_spans: any; - color: string; - created_at: number; -} - -interface SpanLabelType { - id: number; - name: string; - display_name: string; - color: string; - hotkey: string | null; - is_active: boolean; - sort_order: number; - created_at: number; -} +// SpanAnnotation, SpanLabelType are imported from @/types above. interface SpanAnnotationListProps { spanAnnotations: SpanAnnotation[]; diff --git a/src/components/SpanAnnotationManager.tsx b/src/components/SpanAnnotationManager.tsx index 8f559bc..5d4281e 100644 --- a/src/components/SpanAnnotationManager.tsx +++ b/src/components/SpanAnnotationManager.tsx @@ -4,39 +4,9 @@ import { useEffect, useState, useRef, useCallback } from 'react'; import { IChartApi, ISeriesApi, Time } from 'lightweight-charts'; import { SpanRectanglePrimitive, SpanData } from './SpanRectanglePrimitive'; import SpanPopover from './SpanPopover'; +import type { Candle, SpanAnnotation, SpanLabelType } from '@/types'; -interface Candle { - time: number; - open: number; - high: number; - low: number; - close: number; -} - -interface SpanAnnotation { - id: number; - chart_id: number; - start_time: number; - end_time: number; - label: string; - confidence: number | null; - outcome: string | null; - notes: string | null; - sub_spans: any; - color: string; - created_at: number; -} - -interface SpanLabelType { - id: number; - name: string; - display_name: string; - color: string; - hotkey: string | null; - is_active: boolean; - sort_order: number; - created_at: number; -} +// Candle, SpanAnnotation, SpanLabelType are imported from @/types above. interface SpanAnnotationManagerProps { chart: IChartApi | null; diff --git a/src/components/SpanPopover.tsx b/src/components/SpanPopover.tsx index 24ab61e..d941d22 100644 --- a/src/components/SpanPopover.tsx +++ b/src/components/SpanPopover.tsx @@ -21,17 +21,9 @@ import { } from '@/components/ui/dialog'; import { Label } from '@/components/ui/label'; import { Slider } from '@/components/ui/slider'; +import type { SpanLabelType } from '@/types'; -interface SpanLabelType { - id: number; - name: string; - display_name: string; - color: string; - hotkey: string | null; - is_active: boolean; - sort_order: number; - created_at: number; -} +// SpanLabelType is imported from @/types above. interface SpanData { start_time: number; diff --git a/src/components/Toolbox.tsx b/src/components/Toolbox.tsx index d29f457..b014091 100644 --- a/src/components/Toolbox.tsx +++ b/src/components/Toolbox.tsx @@ -3,52 +3,12 @@ import { useState, useEffect } from 'react'; import { ArrowUpCircle, ArrowDownCircle, TrendingUp, Trash2, ChevronDown, ChevronUp, RectangleHorizontal, Layers, Minus } from 'lucide-react'; import { Input } from '@/components/ui/input'; +import type { AnnotationType, Annotation, SpanAnnotation, SpanLabelType } from '@/types'; + +// AnnotationType, Annotation, SpanAnnotation, SpanLabelType are imported from @/types above. export type Tool = string | 'delete' | null; -type AnnotationType = { - id: number; - name: string; - display_name: string; - color: string; - category: string; - icon: string | null; - is_active: boolean; -}; - -interface Annotation { - id: number; - timestamp: number; - label_type: string; - geometry: any; - created_at: number; -} - -interface SpanAnnotation { - id: number; - chart_id: number; - start_time: number; - end_time: number; - label: string; - confidence: number | null; - outcome: string | null; - notes: string | null; - sub_spans: any; - color: string; - created_at: number; -} - -interface SpanLabelType { - id: number; - name: string; - display_name: string; - color: string; - hotkey: string | null; - is_active: boolean; - sort_order: number; - created_at: number; -} - interface ToolboxProps { activeTool: Tool; onToolChange: (tool: Tool) => void;