Feat: Add cancel button for in-progress folder scan and AI tagging
Describe the feature
Summary
PictoPy runs long background jobs when adding/syncing folders and when AI tagging is enabled, but users cannot stop them once started. If a wrong folder is added or tagging begins on a huge library, the user must wait or force-quit the app.
Why this is not a duplicate
I searched for: cancel scan, cancel index, cancel tagging.
- Closest: #811 (scan progress SSE) — shows progress, no cancel
- Closest: #1464 (parallel indexing) — performance, no cancel
- Closest: #1496 (corrupt image aborts batch) — error handling, not user cancel
Current behavior
- Add a large folder via Settings → Add Folder
- Backend submits
post_folder_add_sequence()onindexing_executor(backend/app/routes/folders.py) - UI shows indexing in progress (folder
indexing_status = in_progress) - User has no way to stop the job
Same for AI tagging via post_AI_tagging_enabled_sequence() on the single-worker executor.
Expected behavior
- User sees a Cancel button while indexing/tagging runs
- Cancel stops after the current file (cooperative cancel, not killing the process pool)
- Folder
indexing_statusbecomesinterrupted(status already exists inbackend/app/database/folders.py) - Partially indexed images remain; user can resume via folder sync later
- UI shows clear message: “Indexing cancelled. Sync folder to continue.”
Proposed solution (small scope)
Phase 1 — Folder indexing cancel
POST /folders/cancel-indexingwith{ folder_id }- Shared cancel flag (e.g.
multiprocessing.Managerdict) checked insideimage_util_process_folder_images()loop - On cancel: set
indexing_status = interrupted, return early
Phase 2 — AI tagging cancel
POST /folders/cancel-ai-tagging(or shared/jobs/cancel)- Cooperative flag checked in
image_util_process_untagged_images()/ clustering loop - Set
taggingCompletedappropriately so UI is not stuck forever
Frontend
- Cancel button on folder progress UI / settings folder row when status is
in_progress - Call cancel API, poll
/folders/all-foldersor existing progress hook
Acceptance criteria
- [ ] User can cancel folder indexing mid-run
- [ ] Cancelled folder shows
indexing_status = interrupted - [ ] App remains stable (no orphaned executor crash)
- [ ] Already-indexed images are kept
- [ ] Tests for cancel flag behavior in backend
Environment
- OS: Windows 11
- PictoPy: main (latest)
I want to work on this
Please review and assign. I will wait for maintainer label before opening a PR.
Add ScreenShots
Record
- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue
👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)
Can I work on this ?
Hi @anurag-sinha04 i am currently working on this issue ........