feat: Add async background part import queue

Implements non-blocking part import to prevent UI freezing when scanning unknown parts.

Features:
- Background import worker thread processes unknown parts
- New "Pending Imports" UI section shows import progress
- User can continue scanning other parts while imports run
- Automatic retry on failure (up to 3 attempts)
- Parts automatically processed when import completes

Changes:
- Added PendingPart and ImportResult data structures
- Added PartImportWorker background thread class
- Replaced blocking find_or_import_part() with async find_part()
- Added pending parts queue UI with status display
- Added _on_import_complete() callback handler
- Added _update_pending_parts_ui() for real-time updates
- Added proper cleanup on window close

Benefits:
- No more 30+ second UI freezes during part imports
- Can scan multiple unknown parts in quick succession
- Visual feedback showing import status for each part
- Automatic error handling and retry logic

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-29 11:07:50 +07:00
parent 9c742af585
commit 0fdc319774
3 changed files with 398 additions and 41 deletions

View File

@@ -8,6 +8,7 @@ A comprehensive barcode scanning application for InvenTree inventory management.
- **Stock Updates**: Update existing stock levels
- **Stock Checking**: Check current stock levels
- **Part Location**: Find where parts are stored
- **Async Part Import**: Non-blocking background import for unknown parts
- **Server Connection Monitoring**: Real-time connection status
- **Barcode Command Support**: Control the app via barcode commands
@@ -61,6 +62,22 @@ token: your-api-token-here
2. **Select Mode**: Choose operation mode (Add Stock, Update Stock, Check Stock, or Locate Part)
3. **Scan Parts**: Scan part barcodes to perform operations
### Async Part Import (New!)
When you scan a part that doesn't exist in the system:
1. **Part is automatically queued** for background import
2. **Continue scanning other parts** - no waiting required!
3. **Watch the "Pending Imports" section** to see import progress
4. **Part is automatically processed** when import completes
5. **Failed imports retry automatically** (up to 3 attempts)
**Benefits**:
- No more UI freezing when importing parts
- Scan multiple unknown parts in quick succession
- Visual feedback showing import progress
- Automatic error handling and retry logic
### Barcode Commands
The application supports special barcode commands for quick mode switching: