|
| 1 | +<!-- 5ddf541b-8e90-4e85-9152-c52f39be9149 f7f98f98-6fab-4b10-9382-4948916b84e2 --> |
| 2 | +# Agentic Correction UI Improvements |
| 3 | + |
| 4 | +## Overview |
| 5 | + |
| 6 | +Transform the correction UI to be mobile-first with visual duration indicators, inline correction actions, and category-based metrics specifically designed for agentic AI workflows. |
| 7 | + |
| 8 | +## Core Changes |
| 9 | + |
| 10 | +### 1. Visual Duration Indicators for Words |
| 11 | + |
| 12 | +Transform the Corrected Transcription view to show word durations at a glance. |
| 13 | + |
| 14 | +**File: `lyrics_transcriber/frontend/src/components/TranscriptionView.tsx`** |
| 15 | + |
| 16 | +- Add toggle mode: "Text View" (current) vs "Duration View" (new) |
| 17 | +- In Duration View, render each line as a timeline bar similar to TimelineEditor |
| 18 | +- Each word rendered as a colored bar with width proportional to duration |
| 19 | +- Color coding: |
| 20 | + - Normal words: light gray |
| 21 | + - Corrected words (agentic): green with original word shown above in small gray text |
| 22 | + - Uncorrected gaps: orange/red |
| 23 | + - Anchors: blue |
| 24 | +- Show time ruler above each line |
| 25 | +- Flag abnormally long words (>2 seconds) with warning indicator |
| 26 | +- Mobile-optimized: Scrollable horizontally if needed, bars tall enough for touch |
| 27 | + |
| 28 | +**Implementation approach:** |
| 29 | + |
| 30 | +- Create new component `DurationTimelineView.tsx` based on TimelineEditor logic |
| 31 | +- Reuse `timeToPosition` calculation from TimelineEditor |
| 32 | +- Group words by segment/line |
| 33 | +- Show original word above corrected word: `<Box sx={{fontSize: '0.6rem', color: 'text.secondary'}}>{originalWord}</Box>` |
| 34 | + |
| 35 | +### 2. Inline Correction Actions |
| 36 | + |
| 37 | +Add touch-friendly action buttons directly on corrected words. |
| 38 | + |
| 39 | +**File: `lyrics_transcriber/frontend/src/components/shared/components/Word.tsx`** |
| 40 | + |
| 41 | +Current implementation only shows tooltip. Enhance to: |
| 42 | + |
| 43 | +- When a word has a correction, render with action buttons |
| 44 | +- Position buttons in a small action bar that appears inline (not on hover, always visible on mobile) |
| 45 | +- Actions: |
| 46 | + - Undo icon (revert to original) |
| 47 | + - Edit icon (open edit modal) |
| 48 | + - Checkmark icon (accept/approve) |
| 49 | +- On mobile: Buttons always visible, adequate size (44px touch target) |
| 50 | +- On desktop: Can show on hover for cleaner look |
| 51 | +- Style: Subtle, icon-only buttons in a compact horizontal strip |
| 52 | +- Use Material-UI IconButton with small size |
| 53 | + |
| 54 | +**New component: `CorrectedWordWithActions.tsx`** |
| 55 | + |
| 56 | +```tsx |
| 57 | +interface CorrectedWordWithActionsProps { |
| 58 | + word: string |
| 59 | + originalWord: string |
| 60 | + correction: CorrectionInfo |
| 61 | + onRevert: () => void |
| 62 | + onEdit: () => void |
| 63 | + onAccept: () => void |
| 64 | + isMobile: boolean |
| 65 | +} |
| 66 | +``` |
| 67 | + |
| 68 | +### 3. Transform Correction Handlers to Category Metrics |
| 69 | + |
| 70 | +Replace handler toggles with agentic-specific category breakdown. |
| 71 | + |
| 72 | +**File: `lyrics_transcriber/frontend/src/components/Header.tsx`** |
| 73 | + |
| 74 | +When agentic mode detected (check if AgenticCorrector exists in handlers): |
| 75 | + |
| 76 | +- Replace handler toggles with category breakdown |
| 77 | +- Show gap categories from `GapCategory` enum: |
| 78 | + - SOUND_ALIKE (5) |
| 79 | + - PUNCTUATION_ONLY (2) |
| 80 | + - BACKGROUND_VOCALS (1) |
| 81 | + - etc. |
| 82 | +- Sort by count descending |
| 83 | +- Make clickable to filter/highlight those corrections in view |
| 84 | +- Add quick filter chips: "Low Confidence" (<60%), "High Confidence" (>80%) |
| 85 | +- Show average confidence score for all agentic corrections |
| 86 | + |
| 87 | +**Implementation:** |
| 88 | + |
| 89 | +- Add function to aggregate corrections by `gap_category` field from reason string |
| 90 | +- Parse reason field: extract text between `[` and `]` for category |
| 91 | +- Create new component `AgenticCorrectionMetrics.tsx` |
| 92 | + |
| 93 | +### 4. Enhanced Correction Detail View |
| 94 | + |
| 95 | +Replace cramped tooltip with rich, touch-friendly correction card. |
| 96 | + |
| 97 | +**New component: `CorrectionDetailCard.tsx`** |
| 98 | + |
| 99 | +Triggered by clicking on a corrected word (not hover): |
| 100 | + |
| 101 | +- Modal or slide-up panel on mobile (bottom sheet style) |
| 102 | +- Popover on desktop |
| 103 | +- Content: |
| 104 | + - Large display of original → corrected |
| 105 | + - Category badge with icon |
| 106 | + - Confidence meter (progress bar) |
| 107 | + - Full reasoning text (multi-line, readable) |
| 108 | + - Reference context snippet (if available) |
| 109 | + - Action buttons (large, clear labels): |
| 110 | + - "Revert to Original" |
| 111 | + - "Edit Correction" |
| 112 | + - "Mark as Correct" |
| 113 | + - "Report Issue" (future: submit to feedback API) |
| 114 | +- Swipe to dismiss on mobile |
| 115 | +- Escape key to close on desktop |
| 116 | + |
| 117 | +### 5. Update Data Types |
| 118 | + |
| 119 | +**File: `lyrics_transcriber/frontend/src/types.ts`** |
| 120 | + |
| 121 | +Add: |
| 122 | + |
| 123 | +```typescript |
| 124 | +export interface CorrectionAction { |
| 125 | + type: 'revert' | 'edit' | 'accept' | 'reject' |
| 126 | + correctionId: string |
| 127 | + wordId: string |
| 128 | +} |
| 129 | + |
| 130 | +export interface GapCategoryMetric { |
| 131 | + category: string |
| 132 | + count: number |
| 133 | + avgConfidence: number |
| 134 | +} |
| 135 | +``` |
| 136 | + |
| 137 | +### 6. State Management for Correction Actions |
| 138 | + |
| 139 | +**File: `lyrics_transcriber/frontend/src/components/LyricsAnalyzer.tsx`** |
| 140 | + |
| 141 | +Add handlers: |
| 142 | + |
| 143 | +- `handleRevertCorrection(wordId: string)`: Restore original word |
| 144 | +- `handleEditCorrection(wordId: string)`: Open edit modal with original word |
| 145 | +- `handleAcceptCorrection(wordId: string)`: Mark as approved (future: track in annotation system) |
| 146 | + |
| 147 | +Implement revert: |
| 148 | + |
| 149 | +- Find correction by word_id or corrected_word_id |
| 150 | +- Find segment containing corrected word |
| 151 | +- Replace corrected word with original word from correction.original_word |
| 152 | +- Update data state |
| 153 | +- Add to undo history |
| 154 | + |
| 155 | +### 7. Mobile Responsiveness |
| 156 | + |
| 157 | +**Files: Multiple component files** |
| 158 | + |
| 159 | +Ensure all new components: |
| 160 | + |
| 161 | +- Use Material-UI breakpoints for responsive layout |
| 162 | +- Touch targets minimum 44x44px |
| 163 | +- No hover-only interactions |
| 164 | +- Swipe gestures where appropriate (detail cards) |
| 165 | +- Bottom sheet modals on mobile instead of center modals |
| 166 | +- Adequate spacing for fat-finger taps |
| 167 | +- Test on mobile viewport (375px width minimum) |
| 168 | + |
| 169 | +## Implementation Order |
| 170 | + |
| 171 | +1. Duration visualization (most impactful for catching long words) |
| 172 | +2. Category metrics panel (replaces confusing handler toggles) |
| 173 | +3. Inline action buttons (enables quick revert/edit) |
| 174 | +4. Detail card modal (replaces cramped tooltip) |
| 175 | +5. Action handlers and state management (makes buttons functional) |
| 176 | +6. Mobile polish and testing |
| 177 | + |
| 178 | +## Files to Modify |
| 179 | + |
| 180 | +- `lyrics_transcriber/frontend/src/components/TranscriptionView.tsx` - Add duration view toggle |
| 181 | +- Create `lyrics_transcriber/frontend/src/components/DurationTimelineView.tsx` - New visualization |
| 182 | +- Create `lyrics_transcriber/frontend/src/components/CorrectedWordWithActions.tsx` - Inline actions |
| 183 | +- `lyrics_transcriber/frontend/src/components/shared/components/Word.tsx` - Integrate actions |
| 184 | +- Create `lyrics_transcriber/frontend/src/components/CorrectionDetailCard.tsx` - Rich detail view |
| 185 | +- Create `lyrics_transcriber/frontend/src/components/AgenticCorrectionMetrics.tsx` - Category breakdown |
| 186 | +- `lyrics_transcriber/frontend/src/components/Header.tsx` - Switch to category metrics when agentic |
| 187 | +- `lyrics_transcriber/frontend/src/components/LyricsAnalyzer.tsx` - Add action handlers |
| 188 | +- `lyrics_transcriber/frontend/src/types.ts` - Add new type definitions |
| 189 | + |
| 190 | +## Key Design Decisions |
| 191 | + |
| 192 | +- Mobile-first: All interactions work without hover |
| 193 | +- Always-visible duration bars catch timing issues immediately |
| 194 | +- Original word shown above corrected word for quick comparison |
| 195 | +- Category-based metrics more useful than handler toggles for agentic workflow |
| 196 | +- Inline actions minimize taps for common tasks (revert, edit) |
| 197 | +- Rich detail card for when user needs full context |
| 198 | +- Future-proof: Action handlers can integrate with annotation/feedback API later |
| 199 | + |
| 200 | +### To-dos |
| 201 | + |
| 202 | +- [ ] Create gap classification schemas and update CorrectionProposal model |
| 203 | +- [ ] Build classification prompt template with few-shot examples from gaps_review.yaml |
| 204 | +- [ ] Implement category-specific handler classes for each gap type |
| 205 | +- [ ] Update AgenticCorrector to use two-step classification workflow |
| 206 | +- [ ] Update LyricsCorrector to pass metadata and handle FLAG actions |
| 207 | +- [ ] Define CorrectionAnnotation schema and related types |
| 208 | +- [ ] Implement FeedbackStore with JSONL storage |
| 209 | +- [ ] Add annotation API endpoints to review server |
| 210 | +- [ ] Create CorrectionAnnotationModal component |
| 211 | +- [ ] Integrate annotation collection into edit workflow |
| 212 | +- [ ] Create annotation analysis script |
| 213 | +- [ ] Build few-shot example generator from annotations |
| 214 | +- [ ] Update classifier to load dynamic few-shot examples |
| 215 | +- [ ] Write comprehensive tests for all new components |
| 216 | +- [ ] Document the human feedback loop and improvement process |
0 commit comments