Files
OCR/openspec/changes/archive/2025-11-17-fix-v2-api-ui-issues/tasks.md
egg 012da1abc4 fix: migrate UI to V2 API and fix admin dashboard
Backend fixes:
- Fix markdown generation using correct 'markdown_content' key in tasks.py
- Update admin service to return flat data structure matching frontend types
- Add task_count and failed_tasks fields to user statistics
- Fix top users endpoint to return complete user data

Frontend fixes:
- Migrate ResultsPage from V1 batch API to V2 task API with polling
- Create TaskDetailPage component with markdown preview and download buttons
- Refactor ExportPage to support multi-task selection using V2 download endpoints
- Fix login infinite refresh loop with concurrency control flags
- Create missing Checkbox UI component

New features:
- Add /tasks/:taskId route for task detail view
- Implement multi-task batch export functionality
- Add real-time task status polling (2s interval)

OpenSpec:
- Archive completed proposal 2025-11-17-fix-v2-api-ui-issues
- Create result-export and task-management specifications

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 08:55:50 +08:00

1.8 KiB

Implementation Tasks

1. Backend Fixes

  • 1.1 Fix markdown generation in OCR service to produce non-empty content
  • 1.2 Verify download endpoints (/tasks/{id}/download/json, markdown, pdf) work correctly
  • 1.3 Verify admin API endpoints (/admin/stats, /admin/users, /admin/users/top) exist and work
  • 1.4 Test markdown file generation with sample task

2. Frontend - Results Page Migration

  • 2.1 Remove V1 API imports from ResultsPage.tsx
  • 2.2 Replace getBatchStatus(batchId) with V2 task API calls
  • 2.3 Update component to work with task data structure instead of batch
  • 2.4 Test Results page displays task information correctly

3. Frontend - Task Detail Page

  • 3.1 Create TaskDetailPage.tsx component
  • 3.2 Add route /tasks/:taskId in App.tsx
  • 3.3 Implement task detail view with markdown preview
  • 3.4 Add download buttons for JSON, Markdown, PDF
  • 3.5 Test navigation from Task History page

4. Frontend - Export Page Refactor

  • 4.1 Replace V1 apiClient.exportResults with V2 download endpoints
  • 4.2 Add task selection UI (replace single batch ID input)
  • 4.3 Implement multi-task download functionality
  • 4.4 Update export button handlers to use V2 APIs
  • 4.5 Test all export formats (TXT, JSON, Excel, Markdown, PDF)

5. Admin Dashboard Verification

  • 5.1 Test admin page with admin user credentials
  • 5.2 Verify API calls return data successfully
  • 5.3 Check permission requirements in ProtectedRoute component
  • 5.4 Fix any permission or API issues discovered

6. Testing

  • 6.1 Test complete workflow: Upload → Process → View Results → Download
  • 6.2 Verify markdown files contain actual OCR content
  • 6.3 Test task detail navigation and display
  • 6.4 Test multi-format exports from Export page
  • 6.5 Test Admin Dashboard with admin account