Issue: When refreshing the page after selecting a client, saved files
would not display because init() was called without await, causing a
race condition where loadSavedFiles() could execute before selectedClient
was properly set.
Fix: Added await to init() call in DOMContentLoaded handler (line 3280)
to ensure init() completes before continuing. This guarantees that
loadSavedFiles() is called after selectedClient is properly set.
Also added debug logging to trace selectedClient value through the
initialization process for easier troubleshooting.
Testing: After this fix, refreshing the page should properly restore
the selected client and display their saved files.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Created 4 new "_general" QC check modules optimized for digital static assets:
- visual_hierarchy_general: Digital hierarchy assessment (removed POS/physical viewing distances)
- product_visibility_general: Digital product presentation (removed POS terminology)
- logo_visibility_general: Digital logo prominence (removed 3m/1m viewing distance requirements)
- call_to_action_general: Digital CTA effectiveness (added clickability and mobile considerations)
Updated Static General profile (static_general.json):
- Now includes 10 AI vision-focused checks
- Even weighting: 1.0 per check for 100-point scale
- Total weight: 10.0 for proper scoring calculation
- All checks assigned to Gemini LLM
- Updated description to clarify focus on AI vision capabilities
Profile focuses exclusively on checks that only AI vision models can perform,
excluding physical file properties that Twist system handles (file size, format,
resolution, naming, aspect ratio, bleed, crop marks, etc.).
10 checks in Static General profile:
1. text_readability_general
2. background_contrast_general
3. language_consistency
4. visual_hierarchy_general (NEW)
5. element_alignment
6. product_visibility_general (NEW)
7. logo_visibility_general (NEW)
8. call_to_action_general (NEW)
9. accessibility
10. inclusive
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The refreshSavedFilesAfterAnalysis() function was correctly filtering
the initial fetch by client, but the three retry attempts in the loop
were missing the client filter parameter. This caused the first API
call to correctly return only the selected client's files, but the
subsequent three calls to return all files.
Fixed by adding client filter to all refresh attempts in the loop.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Log client_filter parameter received by backend
- Log selectedClient value in frontend
- Log number of files returned
- Help diagnose why all files are showing for all clients
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
After successful Microsoft authentication, force a full page reload to fetch
fresh HTML from the server instead of trying to reinitialize the cached page.
This ensures users see the client selection screen immediately after login
instead of the old cached interface.
Changes:
- Replace init() call with window.location.reload(true) after successful login
- Bypasses browser cache to fetch fresh HTML
- Fixes issue where users had to manually reload to see new interface
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
## New Features
### L'Oréal Static General Profile
- Created new profile with 3 checks optimized for digital marketing assets
- Even weighting (33.3% each) for 100-point scoring scale
- Removed print-specific requirements (3m viewing distance)
- Focus on marketing text vs product packaging distinction
### Multi-File Queue System (web_ui.html)
- Added file queue functionality for batch processing
- Users can now upload and process multiple files simultaneously
- Queue displays file status (pending, analyzing, complete, error)
- Individual file removal and queue clearing options
- Progress tracking for batch operations
### New General QC Checks
1. background_contrast_general
- Optimized for digital assets (no distance requirements)
- Checks logo, product, and marketing text contrast
- Detects overlapping and blending issues
- Provides element-by-element breakdown
2. text_readability_general
- Focus on marketing text only (excludes product packaging)
- Checks for overlapping elements
- Digital readability optimization
- Specific issue identification
3. language_consistency (enhanced)
- Better distinction between marketing and packaging text
- Detailed language detection and reporting
- Lists specific text analyzed
### Usage Tracking System
- Added usage_tracker.py for analysis logging
- Tracks user activity, profile usage, and costs
- Daily log files in JSONL format
- Cost estimation per LLM provider
## Bug Fixes
### Authentication & User Management
- Fixed Flask 'g' import missing issue
- Fixed user info access in background threads
- Pass user_info to threads instead of accessing g.user
- Improved error handling for usage logging
### HTML Report Generation
- Fixed missing analysis details in reports
- Now extracts and displays all JSON fields properly
- Shows comprehensive breakdowns:
- Analysis details
- Elements checked (logo, product, text)
- Marketing text found
- Issues identified
- Specific recommendations
- No more blank "Pass/Fail" results
### Scoring System
- Fixed usage_tracker to handle dict of check results (not list)
- Better handling of model_used field variations
- Skip non-dict check results gracefully
## Configuration Changes
### Model Versions (llm_config.py)
- Fixed invalid GPT-4.1 model ID to gpt-4o
- Added Gemini 3 Pro beta model option
- AVAILABLE_MODELS dict for UI selection
- Model version override support
### Profile Updates
- Static General: 3 checks, total weight 10.0
- Each check: text_readability_general (3.33), background_contrast_general (3.33), language_consistency (3.34)
- Maximum score: 100 points
## Technical Improvements
- Enhanced prompt engineering for consistent LLM outputs
- Mandatory detailed explanations in all checks
- Structured JSON responses with comprehensive fields
- Better error messages and fallback handling
- Client configuration support (client_config.py)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The getBasePath() function was only detecting /ai_qc/ (with trailing slash) but failing when users accessed /ai_qc (without trailing slash). This caused auth endpoints to be called at wrong URLs (/auth/status instead of /ai_qc/auth/status), resulting in 404 errors and JSON parsing failures.
Fix: Updated function to handle both /ai_qc and /ai_qc/ cases consistently.
- Added weight_scale support for profiles (default 100)
- Enhanced /api/profiles endpoint to return detailed profile data
- Includes check weights, LLM assignments, and enabled status
- Matches functionality from root api_server.py for production deployment
Added detailed troubleshooting guide covering critical production issues
encountered during deployment:
1. Web UI 404 Error Fix
- Document absolute path requirement for serve_web_ui()
- Explain why relative paths fail in production environments
- Provide code examples for both root and backend api_server.py
2. Apache ProxyPass Configuration
- Document static directory conflict with ProxyPass rules
- Explain Apache's file-first, proxy-second behavior
- Provide solution: remove conflicting static directories
- Include proper ProxyPass ordering (specific paths before general)
3. MSAL Authentication Error Fix
- Document interaction_in_progress error and root causes
- Explain concurrent sign-in prevention implementation
- Include storage cleanup and proper flag reset patterns
4. Production Deployment Checklist
- Step-by-step deployment verification process
- Backend testing commands
- Apache proxy testing commands
- Browser testing best practices
5. Common Production Issues Table
- Quick reference for troubleshooting
- Check commands for each issue
- Solutions for common problems
This documentation ensures future deployments avoid the same pitfalls
and provides clear guidance for troubleshooting production issues.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Added protection against concurrent sign-in attempts by:
- Adding isSigningIn flag to prevent double-clicks
- Clearing MSAL localStorage/sessionStorage before authentication
- Properly resetting flag in finally block
This resolves the "interaction_in_progress" error that was preventing
users from signing in with Microsoft authentication.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Applied the same web_ui.html path fix to backend/api_server.py that
was previously applied to the root api_server.py. The backend version
needs to reference the parent directory since web_ui.html is located
at /opt/ai_qc/web_ui.html while api_server.py is in /opt/ai_qc/backend/.
This fixes the 404 error when running via Waitress production server.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changed web_ui.html loading in serve_web_ui() to use absolute path
instead of relative path. This resolves 404 errors when Flask is
started from directories other than the project root, which commonly
occurs in production web server deployments.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Added comprehensive migration documentation and configuration files for restructuring the application to split frontend/backend:
New Documentation:
- MIGRATION_GUIDE.md: Complete step-by-step migration instructions
- MIGRATION_SUMMARY.md: Quick reference guide for deployment
- MIGRATION_CHECKLIST.md: Printable checklist for migration day
- DEPLOYMENT_RESTRUCTURE.md: Architecture overview and benefits
New Configuration Files:
- run_api_server.py: Production WSGI server wrapper using Waitress
- ai_qc.service: Systemd service configuration for backend
- apache_config.conf: Apache virtual host configuration template
Updated Files:
- requirements.txt: Added waitress>=2.1.2 for production WSGI server
- README.md: Added deployment documentation section
Migration Overview:
- Split current monolithic structure into separate frontend/backend
- Move backend to /opt/ai_qc/ (following server standards)
- Keep frontend in /var/www/html/ai_qc/ (single index.html)
- Use Apache reverse proxy to connect frontend to backend API
- Implement systemd service for reliable backend process management
Benefits:
- Improved security (backend code not in web root)
- Better separation of concerns
- Follows industry best practices
- Matches existing server app patterns (/opt/veo3, /opt/voice2text)
- Easier independent updates of frontend/backend
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>