Fix #1373: Resolve empty folder issue on instant AI tagging#1380
Fix #1373: Resolve empty folder issue on instant AI tagging#1380Takitxt wants to merge 6 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe PR adds persistent folder indexing states, exposes them through the backend and OpenAPI schema, updates folder-add workflow transitions, and adds frontend polling with an indexing indicator. It also adds a reusable spinner and adjusts ChangesFolder indexing status flow
Frontend cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant FolderManagementCard
participant foldersQuery
participant get_all_folders
participant db_get_all_folder_details
FolderManagementCard->>foldersQuery: request folder details
foldersQuery->>get_all_folders: fetch folders
get_all_folders->>db_get_all_folder_details: read indexing_status
db_get_all_folder_details-->>get_all_folders: return folder status
get_all_folders-->>foldersQuery: return FolderDetails
foldersQuery-->>FolderManagementCard: refresh displayed status
FolderManagementCard->>FolderManagementCard: show indexing spinner when in_progress
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
backend/app/database/folders.py (1)
460-461: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove redundant comment.
As per path instructions, point out redundant obvious comments that do not add clarity to the code. The function name and its docstring clearly explain its purpose.
♻️ Proposed fix
-#for tracking indexing status of folders def db_update_folder_indexing_status(folder_id: str, status: str) -> None:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/app/database/folders.py` around lines 460 - 461, Remove the redundant “for tracking indexing status of folders” comment immediately above db_update_folder_indexing_status; retain the function and its existing docstring unchanged.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx`:
- Line 97: Update the Badge className in FolderManagementCard to use valid
Tailwind arbitrary-value syntax for the OKLCH background color, replacing spaces
within the bracketed value with underscores, or use an equivalent predefined
background utility. Preserve the existing text and hover styling.
---
Nitpick comments:
In `@backend/app/database/folders.py`:
- Around line 460-461: Remove the redundant “for tracking indexing status of
folders” comment immediately above db_update_folder_indexing_status; retain the
function and its existing docstring unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e113a8ba-c532-4cb8-b144-26ff635fd468
📒 Files selected for processing (10)
backend/app/database/folders.pybackend/app/routes/folders.pybackend/app/schemas/folders.pybackend/tests/test_folders.pydocs/backend/backend_python/openapi.jsonfrontend/src/components/Media/ZoomableImage.tsxfrontend/src/components/ui/spinner.tsxfrontend/src/hooks/useFolderOperations.tsxfrontend/src/pages/SettingsPage/components/FolderManagementCard.tsxfrontend/src/types/Folder.ts
|
@rohan-pandeyy can you review this PR and tell me if you need any changes. I did run the black app/database/folder.py but it still shows error and on my local machines it dosen't show any problem. |
|
@rohan-pandeyy can you please again review this PR and suggest changes. |
There was a problem hiding this comment.
Can we not use "import { Loader2 } from 'lucide-react';" rather than creating this spinner component?
There was a problem hiding this comment.
i mean we can but the project already uses shadCN so i did it using shadCN. if you want me to update i can.?? ( i have not created a spinner component i have taken it from shadCN library just like other components badge for example ).
Addressed Issues:
Fix : #1373 Temporary empty folder state during AI Tagging just after uploading a Folder.
Problem:
When a user adds a large folder containing many images, indexing takes some time in the beginning.
If AI Tagging is enabled just after uploading the folder, when the uploading and indexing is in process,
the application displays the folder as empty before the images are loaded and tagging begins.
Proposed Solutions:
Solution:
Backend: Added an indexing_status field ('not_started' | 'in_progress' | 'completed') to FolderDetails and related Pydantic/TypeScript schemas to track the background job state.
Frontend UI: Updated the folder.ts logic to evaluate indexing_status. The UI now displays a loading spinner while indexing is in_progress. It only displays "Folder is Empty" if indexing_status is completed AND image_count becomes 0.
Steps to Test:
Navigate to Folder Management.
Add a large folder containing a significant number of images.
Immediately enable AI Tagging and observe that the folder should display a loading spinner instead of the "Folder is Empty" text.
Screenshots/Recordings:
Pictopy Before:
PICTOPY_BEFORE.mov
Pictopy After:
Pictopy_AFTER.mov
Changes Made:
1. Frontend:
File - 1 : /pages/settings/components/folderManagementCsrd.tsx
Added a spinner.
File - 2: /types/folder.ts: Added the indexing_status interface.
File - 3 : hooks/folderOperations.tsx: checking the indexing_status every second to show AI tagging once it completes.
File -4 : /database/folder.py:
Added the db_update_folder_indexing_status helper function to handle SQLite database updates for the newly introduced indexing_status field on folders.
This is a required backend component to resolve the "Folder is Empty" bug. Background tasks or indexing scripts need a reliable way to update a folder's state (not_started -> in_progress -> completed) in the database as they process images.
File - 5 : routes/folder.py: Implemented indexing_status lifecycle in folder routes:
File - 6 : schemes/folder.py: Added the indexing_status scheme in folderDetails
File - 7 : tests/test_folders.py: Added indexing_status details.
📝 Conclusion
This completely resolves the false positive "Folder is empty" state issue while indexing.#1373
Tests Performed:
Frontend:
Backend:
AI Usage Disclosure:
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.
Check one of the checkboxes below:
I have used the following AI models and tools: Claude Sonnet 5 / Google Gemini 3 pro / my own LLM.
Checklist
Summary by CodeRabbit
Summary by CodeRabbit
New Features
not_started,in_progress, andcompleted.indexing_status, and the UI shows an “Indexing Folder...” indicator with a loading spinner duringin_progress.Bug Fixes
Documentation
indexing_statusfield.Tests
indexing_status.