task 9.7: replace duplicate interfaces with @/types imports

Replace locally-defined duplicate interfaces in page.tsx,
CandleChart.tsx, SpanAnnotationManager.tsx, Toolbox.tsx,
SpanAnnotationList.tsx, and SpanPopover.tsx with imports from @/types.

- SpanAnnotation, SpanLabelType: replaced in all 6 files
- Candle, AnnotationType: replaced in CandleChart.tsx, SpanAnnotationManager.tsx, Toolbox.tsx
- Annotation (with geometry): replaced in CandleChart.tsx and Toolbox.tsx
- Chart: kept local in page.tsx (shared type has created_at: Date|number vs local number)
- Annotation in page.tsx: kept local (geometry: any) but added missing color field for compatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marko Djordjevic 2026-02-18 15:49:30 +01:00
parent 28a0d0790e
commit 5c5701b080
6 changed files with 16 additions and 190 deletions

View file

@ -14,6 +14,7 @@ import KeyboardShortcutsModal from '@/components/KeyboardShortcutsModal';
import { useTheme } from 'next-themes'; import { useTheme } from 'next-themes';
import { Settings, Tag, Layers } from 'lucide-react'; import { Settings, Tag, Layers } from 'lucide-react';
import type { PredictionState, PredictionSpan, ModelInfoResponse, Disagreement, DisagreementType, PredictionSummary } from '@/types/predictions'; import type { PredictionState, PredictionSpan, ModelInfoResponse, Disagreement, DisagreementType, PredictionSummary } from '@/types/predictions';
import type { SpanAnnotation, SpanLabelType } from '@/types';
/** /**
* Calculate overlap between two time ranges * 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 { interface Chart {
id: number; id: number;
name: string; name: string;
created_at: number; created_at: number;
} }
// Annotation: kept local because shared Annotation has geometry: Geometry|null but local usage passes geometry: any.
interface Annotation { interface Annotation {
id: number; id: number;
chart_id: number; chart_id: number;
timestamp: number; timestamp: number;
label_type: string; label_type: string;
color: string | null;
geometry: any; geometry: any;
created_at: number; 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() { export default function Home() {
const { theme, setTheme } = useTheme(); const { theme, setTheme } = useTheme();
const [settingsOpen, setSettingsOpen] = useState(false); const [settingsOpen, setSettingsOpen] = useState(false);

View file

@ -7,6 +7,7 @@ import SpanAnnotationManager from './SpanAnnotationManager';
import { TrendLine } from '@/plugins/trend-line'; import { TrendLine } from '@/plugins/trend-line';
import { RectangleDrawingPrimitive, RectanglePoint } from '@/plugins/rectangle-drawing'; import { RectangleDrawingPrimitive, RectanglePoint } from '@/plugins/rectangle-drawing';
import type { PerCandlePrediction, PredictionSpan, ModelInfoResponse, PredictionSummary } from '@/types/predictions'; import type { PerCandlePrediction, PredictionSpan, ModelInfoResponse, PredictionSummary } from '@/types/predictions';
import type { Candle, Annotation, AnnotationType, SpanAnnotation, SpanLabelType } from '@/types';
// === Magic Number Constants === // === Magic Number Constants ===
const ENDPOINT_CLICK_TOLERANCE_PX = 8; const ENDPOINT_CLICK_TOLERANCE_PX = 8;
@ -72,62 +73,7 @@ interface Point {
price: number; price: number;
} }
interface Candle { // Candle, Annotation, AnnotationType, SpanAnnotation, SpanLabelType are imported from @/types above.
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;
}
interface CandleChartProps { interface CandleChartProps {
activeTool: string | null; activeTool: string | null;

View file

@ -2,31 +2,9 @@
import { useState } from 'react'; import { useState } from 'react';
import { Trash2, ChevronDown } from 'lucide-react'; import { Trash2, ChevronDown } from 'lucide-react';
import type { SpanAnnotation, SpanLabelType } from '@/types';
interface SpanAnnotation { // SpanAnnotation, SpanLabelType are imported from @/types above.
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 SpanAnnotationListProps { interface SpanAnnotationListProps {
spanAnnotations: SpanAnnotation[]; spanAnnotations: SpanAnnotation[];

View file

@ -4,39 +4,9 @@ import { useEffect, useState, useRef, useCallback } from 'react';
import { IChartApi, ISeriesApi, Time } from 'lightweight-charts'; import { IChartApi, ISeriesApi, Time } from 'lightweight-charts';
import { SpanRectanglePrimitive, SpanData } from './SpanRectanglePrimitive'; import { SpanRectanglePrimitive, SpanData } from './SpanRectanglePrimitive';
import SpanPopover from './SpanPopover'; import SpanPopover from './SpanPopover';
import type { Candle, SpanAnnotation, SpanLabelType } from '@/types';
interface Candle { // Candle, SpanAnnotation, SpanLabelType are imported from @/types above.
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;
}
interface SpanAnnotationManagerProps { interface SpanAnnotationManagerProps {
chart: IChartApi | null; chart: IChartApi | null;

View file

@ -21,17 +21,9 @@ import {
} from '@/components/ui/dialog'; } from '@/components/ui/dialog';
import { Label } from '@/components/ui/label'; import { Label } from '@/components/ui/label';
import { Slider } from '@/components/ui/slider'; import { Slider } from '@/components/ui/slider';
import type { SpanLabelType } from '@/types';
interface SpanLabelType { // SpanLabelType is imported from @/types above.
id: number;
name: string;
display_name: string;
color: string;
hotkey: string | null;
is_active: boolean;
sort_order: number;
created_at: number;
}
interface SpanData { interface SpanData {
start_time: number; start_time: number;

View file

@ -3,52 +3,12 @@
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { ArrowUpCircle, ArrowDownCircle, TrendingUp, Trash2, ChevronDown, ChevronUp, RectangleHorizontal, Layers, Minus } from 'lucide-react'; import { ArrowUpCircle, ArrowDownCircle, TrendingUp, Trash2, ChevronDown, ChevronUp, RectangleHorizontal, Layers, Minus } from 'lucide-react';
import { Input } from '@/components/ui/input'; 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; 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 { interface ToolboxProps {
activeTool: Tool; activeTool: Tool;
onToolChange: (tool: Tool) => void; onToolChange: (tool: Tool) => void;