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

Open
#1,505 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@anurag-sinha04 is already working on this.

Since Aug 24, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend, desktop

Research direction

Start with backend/app/routes/folders.py and backend/app/database/folders.py, then trace post_folder_add_sequence(), post_AI_tagging_enabled_sequence(), image_util_process_folder_images(), and image_util_process_untagged_images(). Add backend tests for cooperative cancel behavior; done means the UI can cancel an active job, indexing becomes interrupted, completed work remains, and the app stays stable.

Written by the indexing model from the issue text.

Description

enhancement
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
  • I agree to follow this project's Code of Conduct
  • I want to work on this issue
Dominant language
Python
Stars
322
Forks
793
Avg merge
6d 10h
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/PictoPy

All issues in AOSSIE-Org/PictoPy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.