-
Notifications
You must be signed in to change notification settings - Fork 578
Description
Describe the feature
I’ve observed that when scanning large folders (e.g., 100+ photos), the frontend remains stuck on “No Images to Display” until the entire process completes — even though the backend is actively processing images (confirmed via debug logs).
This creates a poor user experience, as users have no feedback that work is in progress and may assume the app has frozen or crashed.
Root Cause
The current flow:
- Frontend calls POST /scan → waits for full JSON response.
- Backend uses ProcessPoolExecutor → processes images in parallel.
- No intermediate progress is streamed → UI stays static until completion.
Proposed Solution: Server-Sent Events (SSE)
Add an SSE endpoint /scan/progress/{scan_id} that streams real-time updates like:
{"processed": 42, "total": 500}
Frontend will use EventSource to listen and update a progress indicator dynamically.
Benefits:
- No UI freeze — user sees live progress.
- Zero changes to Tauri/Rust layer — leverages existing HTTP architecture.
- Lightweight & simple — no WebSocket complexity.
- Scalable — works for 10 or 10,000 photos.
Implementation Plan (Minimal Scope)
1. Backend (FastAPI):
- Add POST /start-scan → returns scan_id.
- Add GET /scan/progress/{scan_id} → SSE stream of {processed, total}.
- Use shared state (e.g., multiprocessing.Manager().dict()) to track progress from ProcessPoolExecutor.
2. Frontend (React):
- Create hook useScanProgress(scanId) using EventSource.
- Display progress bar + text (“Processed 42/500”) during scan.
- Gracefully handle disconnects/retries.
Let me know:
- Is SSE preferred over WebSocket or polling?
- Any naming conventions for endpoints?
I’ve already readied with the setup and am ready to implement this — give me the green light!
Added Proof of Issue
This is the behaviour of 100 photos:
https://github.com/user-attachments/assets/bbdf16cd-3c35-42b9-9762-b7993d61827f
This is the behaviour of 650 photos: (took 2+ minutes)
https://github.com/user-attachments/assets/b21667c0-b7a7-4160-89d1-a386b26b7e7d
Record
- I agree to follow this project's Code of Conduct
- I want to work on this issue
Checklist before Submitting.
- Have you updated docs for it?.
- Have you added unit tests?.
- Have you made sure unit tests pass?
- Have you made sure code formatting is correct?
- Does it contain any style related issues?