- Fixed WSL CUDA library path in ~/.bashrc
- Upgraded PaddlePaddle from 3.0.0 to 3.2.1
- Verified fused_rms_norm_ext API is now available
- Enabled chart recognition in ocr_service.py
- Updated CHART_RECOGNITION.md to reflect enabled status
Chart recognition now supports:
✅ Chart type identification
✅ Data extraction from charts
✅ Axis and legend parsing
✅ Converting charts to structured data
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Chart Recognition Status Investigation:
- OpenSpec limitation record is ACCURATE but based on old PaddlePaddle 3.0.0 (Mar 2025)
- PaddlePaddle has released multiple updates (3.1.x, 3.2.x, latest: 3.2.2 Nov 2025)
- The fused_rms_norm_ext API MAY now be available in newer versions
Root Cause:
- PaddleOCR-VL chart recognition requires paddle.incubate.nn.functional.fused_rms_norm_ext
- PaddlePaddle 3.0.0 only provided fused_rms_norm (base version)
- Not a compatibility issue - PaddleOCR 3.x is fully compatible with PaddlePaddle 3.x
- Issue is missing API, not version mismatch
What Still Works (Even with Chart Recognition Disabled):
✅ Chart detection and extraction as images
✅ Table recognition (with nested formulas/images)
✅ Formula recognition
✅ Text recognition (OCR core)
What's Disabled:
❌ Deep chart understanding (type, data extraction, axis/legend parsing)
❌ Converting chart content to structured data
Created Files:
1. CHART_RECOGNITION.md - Comprehensive guide explaining:
- Current limitation status and history
- What works vs what's disabled
- How to verify if newer PaddlePaddle versions support the API
- How to enable chart recognition if API becomes available
- Troubleshooting and performance considerations
2. backend/verify_chart_recognition.py - Verification script to:
- Check if fused_rms_norm_ext API is available
- Display current PaddlePaddle version
- Provide actionable recommendations
Next Steps for Users:
1. Run: conda activate tool_ocr && python backend/verify_chart_recognition.py
2. If API is available, enable chart recognition in ocr_service.py:217
3. Update OpenSpec if limitation is resolved in newer versions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Root Cause Fixed:
- Tests were connecting to production MySQL database instead of test database
- Solution: Monkey patch database module before importing app to use SQLite :memory:
Changes:
1. **conftest.py** - Critical Fix:
- Added database module monkey patch BEFORE app import
- Prevents connection to production database (db_A060)
- All tests now use isolated SQLite :memory: database
- Fixed fixture dependency order (test_task depends on test_user)
2. **test_tasks.py**:
- Fixed test_delete_task: Accept 204 No Content (correct HTTP status)
3. **test_admin.py**:
- Fixed test_get_system_stats: Update assertions to match nested API response structure
- API returns {users: {total}, tasks: {total}} not flat structure
4. **test_integration.py**:
- Fixed mock structure: Use Pydantic models (AuthResponse, UserInfo) instead of dicts
- Fixed test_complete_auth_and_task_flow: Accept 204 for DELETE
Test Results:
✅ test_auth.py: 5/5 passing (100%)
✅ test_tasks.py: 6/6 passing (100%)
✅ test_admin.py: 4/4 passing (100%)
✅ test_integration.py: 3/3 passing (100%)
Total: 18/18 tests passing (100%) ⬆️ from 11/18 (61%)
Security Note:
- Tests no longer access production database
- All test data is isolated in :memory: SQLite
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Fixed UserResponse schema datetime serialization bug
- Fixed test_auth.py mock structure for external auth service
- Updated conftest.py to create fresh database per test
- Ran full test suite and verified results
Test Results:
✅ test_auth.py: 5/5 passing (100%)
✅ test_tasks.py: 4/6 passing (67%)
✅ test_admin.py: 2/4 passing (50%)
❌ test_integration.py: 0/3 passing (0%)
Total: 11/18 tests passing (61%)
Known Issues:
1. Fixture isolation: test_user sometimes gets admin email
2. Admin API response structure doesn't match test expectations
3. Integration tests need mock fixes
Production Bug Fixed:
- UserResponse schema now properly serializes datetime fields to ISO format strings
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Frontend Features:
- Add ProtectedRoute component with token expiry validation
- Create AdminDashboardPage with system statistics and user management
- Create AuditLogsPage with filtering and pagination
- Add admin-only navigation (Shield icon) for ymirliu@panjit.com.tw
- Add admin API methods to apiV2 service
- Add admin type definitions (SystemStats, AuditLog, etc.)
Token Management:
- Auto-redirect to login on token expiry
- Check authentication on route change
- Show loading state during auth check
- Admin privilege verification
Backend Testing:
- Add pytest configuration (pytest.ini)
- Create test fixtures (conftest.py)
- Add unit tests for auth, tasks, and admin endpoints
- Add integration tests for complete workflows
- Test user isolation and admin access control
Documentation:
- Add TESTING.md with comprehensive testing guide
- Include test running instructions
- Document fixtures and best practices
Routes:
- /admin - Admin dashboard (admin only)
- /admin/audit-logs - Audit logs viewer (admin only)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Remove all V1 architecture components and promote V2 to primary:
- Delete all paddle_ocr_* table models (export, ocr, translation, user)
- Delete legacy routers (auth, export, ocr, translation)
- Delete legacy schemas and services
- Promote user_v2.py to user.py as primary user model
- Update all imports and dependencies to use V2 models only
- Update main.py version to 2.0.0
Database changes:
- Fix SQLAlchemy reserved word: rename audit_log.metadata to extra_data
- Add migration to drop all paddle_ocr_* tables
- Update alembic env to only import V2 models
Frontend fixes:
- Fix Select component exports in TaskHistoryPage.tsx
- Update to use simplified Select API with options prop
- Fix AxiosInstance TypeScript import syntax
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Added `tool_ocr_` prefix to all database tables for clear separation
from other systems in the same database.
Changes:
- All tables now use `tool_ocr_` prefix
- Added tool_ocr_sessions table for token management
- Created complete SQL schema file with:
- Full table definitions with comments
- Indexes for performance
- Views for common queries
- Stored procedures for maintenance
- Audit log table (optional)
New files:
- database_schema.sql: Ready-to-use SQL script for deployment
Configuration:
- Added DATABASE_TABLE_PREFIX environment variable
- Updated all references to use prefixed table names
Benefits:
- Clear namespace separation in shared databases
- Easier identification of Tool_OCR tables
- Prevent conflicts with other applications
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Major updates based on feedback:
1. Remove Azure AD ID storage - use email as primary identifier
2. Complete database redesign - no backward compatibility needed
3. Add comprehensive user task isolation and history features
Database changes:
- Simplified users table (email-based)
- New ocr_tasks table with user association
- New task_files table for file tracking
- Proper indexes for performance
New features:
- User task isolation (A cannot see B's tasks)
- Task history with status tracking (pending/processing/completed/failed)
- Historical query capabilities with filters
- Download support for completed tasks
- Task management UI with search and filters
Security enhancements:
- User context validation in all endpoints
- File access control based on ownership
- Row-level security in database queries
- API-level authorization checks
Implementation approach:
- Clean migration without rollback concerns
- Drop old tables and start fresh
- Simplified deployment process
- Comprehensive task management system
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Create OpenSpec proposal for migrating from local database authentication
to external API authentication using Microsoft Azure AD.
Changes proposed:
- Replace local username/password auth with external API
- Integrate with https://pj-auth-api.vercel.app/api/auth/login
- Use Azure AD tokens instead of local JWT
- Display user 'name' from API response in UI
- Maintain backward compatibility with feature flag
Benefits:
- Single Sign-On (SSO) capability
- Leverage enterprise identity management
- Reduce local user management overhead
- Consistent authentication across applications
Database changes:
- Add external_user_id for Azure AD user mapping
- Add display_name for UI display
- Keep existing schema for rollback capability
Implementation includes:
- Detailed migration plan with phased rollout
- Comprehensive task list for implementation
- Test script for API validation
- Risk assessment and mitigation strategies
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
PaddleOCR-VL chart recognition model requires `fused_rms_norm_ext` API
which is not available in PaddlePaddle 3.0.0 stable release.
Changes:
- Set use_chart_recognition=False in PP-StructureV3 initialization
- Remove unsupported show_log parameter from PaddleOCR 3.x API calls
- Document known limitation in openspec proposal
- Add limitation documentation to README
- Update tasks.md with documentation task for known issues
Impact:
- Layout analysis still detects/extracts charts as images ✓
- Tables, formulas, and text recognition work normally ✓
- Deep chart understanding (type detection, data extraction) disabled ✗
- Chart to structured data conversion disabled ✗
Workaround: Charts saved as image files for manual review
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
PaddlePaddle 3.0.0b2 has "Illegal instruction" error on current CPU.
Downgrade to stable 2.6.2 which works but uses different API.
Changes:
- Auto-detect PaddlePaddle version at runtime
- Use 'device' parameter for 3.x (device="gpu:0" or "cpu")
- Use 'use_gpu' + 'gpu_mem' parameters for 2.x
- Apply to both get_ocr_engine() and get_structure_engine()
- Log PaddlePaddle version in initialization messages
Current setup:
- paddlepaddle-gpu==2.6.2 (stable, CUDA compiled)
- paddleocr==3.3.1
- paddlex==3.3.9
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changes to setup_dev_env.sh:
- Add support for CUDA 13.x (install CUDA 12.x compatible version)
- Use official PaddlePaddle source for GPU versions
- Install paddlepaddle-gpu==3.0.0b2 from official index
- CUDA 13.x: use cu123 package (backward compatible)
- CUDA 12.x: use cu123 package
- CUDA 11.7+: use cu118 package
- CUDA 11.2-11.6: use cu117 package
Changes to requirements.txt:
- Comment out paddlepaddle dependency
- Let setup script handle GPU/CPU version installation
This fixes the issue where pip installed CPU-only paddlepaddle 3.2.1
instead of GPU version, causing GPU acceleration to be unavailable.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
PaddleOCR 3.x changed the API:
- Removed: use_gpu=True/False and gpu_mem=<value>
- Added: device="gpu:0" or device="cpu"
Changes:
- Updated get_ocr_engine() to use device parameter
- Updated get_structure_engine() to use device parameter
- GPU mode: device="gpu:{gpu_device_id}"
- CPU mode: device="cpu"
This fixes the "ValueError: Unknown argument: gpu_mem" runtime error.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Complete redesign of frontend interface with focus on usability, visual hierarchy, and professional appearance:
**Design System:**
- Implemented clean blue color theme (#3B82F6) with professional palette
- Created consistent spacing, shadows, and typography system
- Added reusable utility classes (page-header, section, status-badge-*)
- Removed excessive gradients and decorative effects
**Layout Architecture:**
- Redesigned main layout with 256px sidebar navigation
- Sidebar includes logo, navigation with descriptions, and user profile
- Main content area with search bar and scrollable content
- Replaced horizontal navigation with vertical sidebar pattern
**Page Redesigns:**
1. LoginPage: Split-screen design with branding (left) and clean form (right)
- Feature highlights with icons and statistics
- Mobile responsive design
- Professional gradient background with subtle pattern
2. UploadPage: Added 3-step visual progress indicator
- Better file organization with summary and status badges
- Clear action bar with confirmation message
- Improved file list presentation
3. ProcessingPage: Enhanced progress visualization
- Large progress bar with percentage display
- 4-column stats grid (Completed, Processing, Failed, Total)
- Clean file status list with processing times
4. ResultsPage: Improved 5-column layout (2 for list, 3 for preview)
- Added stats cards for accuracy, processing time, and text blocks
- Better preview panel with detailed metrics
- Export and translate action buttons
5. ExportPage: Better organization with 2-column layout
- Visual format selection with icons (TXT, JSON, Excel, Markdown, PDF)
- Improved form controls and option organization
- Sticky preview sidebar showing current configuration
**Component Updates:**
- Updated Button component with proper variants
- Enhanced Card component with hover effects
- Maintained FileUpload component functionality
- Added lucide-react for modern iconography
**Technical Improvements:**
- Fixed Tailwind CSS v4 compatibility issues with @apply
- Removed decorative animations in favor of functional ones
- Improved accessibility with proper labels and ARIA attributes
- Better color contrast and readability
This redesign transforms the interface from a basic layout to a professional, enterprise-ready application with clear visual hierarchy and excellent usability.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>