5.8 KiB
5.8 KiB
Instructions for AI Agent: Auto-Recording Feature Integration
🎯 Task Overview
Update the React application to support the new auto-recording feature that has been added to the USDA Vision Camera System backend.
📋 What You Need to Know
System Context
- Camera 1 monitors the vibratory conveyor (conveyor/cracker cam)
- Camera 2 monitors the blower separator machine
- Auto-recording automatically starts when machines turn ON and stops when they turn OFF
- The system includes retry logic for failed recording attempts
- Manual recording always takes precedence over auto-recording
New Backend Capabilities
The backend now supports:
- Automatic recording triggered by MQTT machine state changes
- Retry mechanism for failed recording attempts (configurable retries and delays)
- Status tracking for auto-recording state, failures, and attempts
- API endpoints for enabling/disabling and monitoring auto-recording
🔧 Required React App Changes
1. Update TypeScript Interfaces
Add these new fields to existing CameraStatusResponse:
interface CameraStatusResponse {
// ... existing fields
auto_recording_enabled: boolean;
auto_recording_active: boolean;
auto_recording_failure_count: number;
auto_recording_last_attempt?: string;
auto_recording_last_error?: string;
}
Add new response types:
interface AutoRecordingConfigResponse {
success: boolean;
message: string;
camera_name: string;
enabled: boolean;
}
interface AutoRecordingStatusResponse {
running: boolean;
auto_recording_enabled: boolean;
retry_queue: Record<string, any>;
enabled_cameras: string[];
}
2. Add New API Endpoints
// Enable auto-recording for a camera
POST /cameras/{camera_name}/auto-recording/enable
// Disable auto-recording for a camera
POST /cameras/{camera_name}/auto-recording/disable
// Get overall auto-recording system status
GET /auto-recording/status
3. UI Components to Add/Update
Camera Status Display
- Add auto-recording status badge/indicator
- Show auto-recording enabled/disabled state
- Display failure count if > 0
- Show last error message if any
- Distinguish between manual and auto-recording states
Auto-Recording Controls
- Toggle switch to enable/disable auto-recording per camera
- System-wide auto-recording status display
- Retry queue information
- Machine state correlation display
Error Handling
- Clear display of auto-recording failures
- Retry attempt information
- Last attempt timestamp
- Quick retry/reset actions
4. Visual Design Guidelines
Status Priority (highest to lowest):
- Manual Recording (red/prominent) - user initiated
- Auto-Recording Active (green) - machine ON, recording
- Auto-Recording Enabled (blue) - ready but machine OFF
- Auto-Recording Disabled (gray) - feature disabled
Machine Correlation:
- Show machine name next to camera (e.g., "Vibratory Conveyor", "Blower Separator")
- Display machine ON/OFF status
- Alert if machine is ON but auto-recording failed
🎨 Specific Implementation Tasks
Task 1: Update Camera Cards
- Add auto-recording status indicators
- Add enable/disable toggle controls
- Show machine state correlation
- Display failure information when relevant
Task 2: Create Auto-Recording Dashboard
- Overall system status
- List of enabled cameras
- Active retry queue display
- Recent events/errors
Task 3: Update Recording Status Logic
- Distinguish between manual and auto-recording
- Show appropriate controls based on recording type
- Handle manual override scenarios
Task 4: Add Error Handling
- Display auto-recording failures clearly
- Show retry attempts and timing
- Provide manual retry options
📱 User Experience Requirements
Key Behaviors
- Non-Intrusive: Auto-recording status shouldn't clutter the main interface
- Clear Hierarchy: Manual controls should be more prominent than auto-recording
- Informative: Users should understand why recording started/stopped
- Actionable: Clear options to enable/disable or retry failed attempts
Mobile Considerations
- Auto-recording controls should work well on mobile
- Status information should be readable on small screens
- Consider collapsible sections for detailed information
🔍 Testing Requirements
Ensure the React app correctly handles:
- Toggling auto-recording on/off per camera
- Displaying real-time status updates
- Showing error states and retry information
- Manual recording override scenarios
- Machine state changes and correlation
- Mobile interface functionality
📚 Reference Files
Key files to review for implementation details:
AUTO_RECORDING_FEATURE_GUIDE.md- Comprehensive technical detailsapi-endpoints.http- API endpoint documentationconfig.json- Configuration structureusda_vision_system/api/models.py- Response type definitions
🎯 Success Criteria
The React app should:
- Display auto-recording status for each camera clearly
- Allow users to enable/disable auto-recording per camera
- Show machine state correlation and recording triggers
- Handle error states and retry scenarios gracefully
- Maintain existing manual recording functionality
- Provide clear visual hierarchy between manual and auto-recording
💡 Implementation Tips
- Start Small: Begin with basic status display, then add controls
- Use Existing Patterns: Follow the current app's design patterns
- Test Incrementally: Test each feature as you add it
- Consider State Management: Update your state management to handle new data
- Mobile First: Ensure mobile usability from the start
The goal is to seamlessly integrate auto-recording capabilities while maintaining the existing user experience and adding valuable automation features for the camera operators.