feat: add bulk rotate and background removal actions - #173
Open
bn326160 wants to merge 1 commit into
Open
Conversation
Extends the existing multi-select bulk toolbar (which already had delete/re-analyze) with two new actions mirroring the single-item rotate and remove-background buttons already in the item detail dialog: - POST /items/bulk/rotate: synchronous, like bulk/delete, since rotation is a fast in-process PIL op. - POST /items/bulk/remove-background: queued via the existing arq worker, like bulk/analyze, since background removal is CPU-slow (rembg) and doing 30 of them synchronously in one request risks a timeout. Adds a new remove_item_background_job worker function. Also fixes a bug caught while building this: the new remove-background endpoint set item.status = processing to drive the existing polling spinner, but didn't clear item.ai_started_at like every other "enter processing" call site does. For an already-tagged item this leaked its original tagging timestamp into the frontend's "elapsed analyzing time" display, showing wildly wrong durations for what is actually a multi-second job.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds two new bulk actions to the wardrobe grid's multi-select toolbar, mirroring the two single-item actions already in the item detail dialog (rotate left/right, remove background):
POST /items/bulk/rotate) - applies one chosen direction (cw/ccw) to every selected item, synchronously, following the same pattern as the existingbulk/delete(rotation is a fast in-process PIL op, so no queue is needed).POST /items/bulk/remove-background) - queues one job per selected item via the existing arq worker, following the same pattern as the existingbulk/analyze, since background removal is CPU-heavy (rembg) and doing many of them synchronously in a single request risks a timeout. Adds a newremove_item_background_jobworker function, registered alongsidetag_item_imageon the existingarq:taggingqueue.No new bulk-selection framework was introduced - both endpoints resolve
item_ids/select_all/filters/excluded_idsthe same waybulk/deleteandbulk/analyzealready do.Also includes a small bug fix found while building and manually testing this: the new remove-background endpoint sets
item.status = processingto drive the existing polling spinner, but initially didn't clearitem.ai_started_at- unlike every other call site in the codebase that enters "processing". For an already-tagged item, this leaked its original tagging timestamp into the frontend's "elapsed analyzing time" display, showing wildly wrong durations (tens of minutes) for what is actually a multi-second job. Fixed, and covered by a regression test.Related Issue
None filed beforehand - this came out of a conversation while trying the app out for the first time.
Type of Change
Checklist
Testing
Test Environment
docker-compose.yml+docker-compose.dev.yml)Tests Performed
backend/tests/test_bulk_rotate_and_remove_background.py(13 tests) covering both new endpoints and the new worker job, including a regression test for theai_started_atbug.cd backend && pytest- 515 passed, 0 failed.cd backend && ruff check . && ruff format --check .- clean.python backend/scripts/check_migration_heads.py- OK (no migration needed for this change).cd frontend && npm test- 144 passed.cd frontend && npm run lint- clean (only pre-existing warnings unrelated to this change).cd frontend && npx tsc --noEmit- clean.cd frontend && npm run i18n:check- clean across all 8 locales.original_image_pathgets backed up and the resulting image has the requested solid background.Additional Notes
de/fr/it/ja/ko/zh-CN/zh-TW) to satisfyi18n:check's parity gate, since I'm not a native speaker of those languages - happy to have a translator improve the actual wording.item.statusfield instead of adding a new column, so the existing polling/spinner UI works with no extra frontend plumbing. One accepted tradeoff from this: the spinner's caption during a background-removal job shows the generic "Queued" text rather than something like "Removing background..." (it no longer shows the wrong elapsed-time text after theai_started_atfix, just a generic label). Aprocessing_reasoncolumn would be the natural follow-up if this turns out to be confusing in practice - didn't want to add it preemptively for a cosmetic label.