candle-annotator/openspec/changes/multi-chart-management/specs/label-management/spec.md
Marko Djordjevic 92d3339a48 feat: add charts table schema and migration with data backfill
- Add charts table with id, name (unique), created_at
- Add chart_id FK to candles table with composite unique on (chart_id, time)
- Add chart_id FK to annotations table
- Custom migration handles existing data: creates 'Imported Data' chart and backfills chart_id
- Recreates tables for NOT NULL constraint (SQLite limitation)
2026-02-13 00:12:21 +01:00

62 lines
3.4 KiB
Markdown

## MODIFIED Requirements
### Requirement: Label list in sidebar
The Toolbox SHALL display a collapsible section showing all label annotations for the active chart with interactive controls.
#### Scenario: Display label list section
- **WHEN** Toolbox renders with an active chart selected
- **THEN** system displays "Label Annotations" section below the annotation tools with collapse/expand toggle button, showing only annotations belonging to the active chart
#### Scenario: Label list expanded
- **WHEN** "Label Annotations" section is expanded
- **THEN** system displays scrollable list of label annotations for the active chart sorted by timestamp (newest first), with each entry showing timestamp, label type badge, and delete button
#### Scenario: Label list collapsed
- **WHEN** user clicks collapse button on "Label Annotations" section
- **THEN** system hides the label list but shows count summary "Labels: X break_up, Y break_down" for the active chart
#### Scenario: Empty label list
- **WHEN** no label annotations exist for the active chart
- **THEN** section displays message "No labels yet. Click Break Up or Break Down tools to add labels."
#### Scenario: Label entry format
- **WHEN** displaying a label in the list
- **THEN** each entry shows formatted timestamp (e.g., "Feb 12, 14:30"), colored badge ("BREAK UP" in green or "BREAK DOWN" in red), and trash icon delete button
#### Scenario: Label list updates on chart switch
- **WHEN** user switches to a different chart via the chart selector
- **THEN** the label list clears and reloads with annotations belonging to the newly selected chart
### Requirement: Label count display
The Toolbox SHALL display counts of each label type for the active chart.
#### Scenario: Display label counts
- **WHEN** Toolbox renders and labels exist for the active chart
- **THEN** system displays count summary "Break Up: X | Break Down: Y" at top of label section, reflecting only the active chart's annotations
#### Scenario: Zero labels
- **WHEN** no labels exist for the active chart
- **THEN** count summary displays "Break Up: 0 | Break Down: 0"
#### Scenario: Count updates after delete
- **WHEN** user deletes a label from the active chart
- **THEN** count summary updates immediately to reflect the new totals
#### Scenario: Counts update on chart switch
- **WHEN** user switches to a different chart
- **THEN** count summary updates to reflect the new chart's label counts
### Requirement: Delete all labels with confirmation
The system SHALL provide a "Delete All Labels" button with confirmation dialog. The deletion SHALL only affect labels belonging to the active chart.
#### Scenario: Click Delete All Labels button
- **WHEN** user clicks "Delete All Labels" button in Toolbox
- **THEN** system displays confirmation dialog with message "Delete all label annotations for this chart (Break Up and Break Down)? This cannot be undone." and Cancel/Confirm buttons
#### Scenario: User confirms delete all labels
- **WHEN** confirmation dialog is open and user clicks Confirm button
- **THEN** system deletes only label annotations belonging to the active chart, removes all label markers from chart, clears label list, clears selection state, triggers annotation refresh, and closes dialog
#### Scenario: User cancels delete all labels
- **WHEN** confirmation dialog is open and user clicks Cancel button
- **THEN** system closes dialog without making any API calls or removing any labels