PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

Feat: Add cancel button for in-progress folder scan and AI tagging

Open Mansi2007275 opened this issue 3 months ago • 3 comments

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

  1. Add a large folder via Settings → Add Folder
  2. Backend submits post_folder_add_sequence() on indexing_executor (backend/app/routes/folders.py)
  3. UI shows indexing in progress (folder indexing_status = in_progress)
  4. 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_status becomes interrupted (status already exists in backend/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-indexing with { folder_id }
  • Shared cancel flag (e.g. multiprocessing.Manager dict) checked inside image_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 taggingCompleted appropriately 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-folders or 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

Image Image

Record

  • [x] I agree to follow this project's Code of Conduct
  • [x] I want to work on this issue

Mansi2007275 avatar Aug 23 '26 11:08 Mansi2007275

👋 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 :)

github-actions[bot] avatar Aug 23 '26 11:08 github-actions[bot]

Can I work on this ?

anurag-sinha04 avatar Aug 24 '26 04:08 anurag-sinha04

Hi @anurag-sinha04 i am currently working on this issue ........

Mansi2007275 avatar Aug 24 '26 05:08 Mansi2007275