Folder management Loading state cleanup - #1443
Conversation
WalkthroughThe folder management card now shows combined indexing progress by default, exposes expandable AI tagging and semantic indexing details, and refreshes processing status when the window regains focus or visibility. ChangesFolder Progress Management
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 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: 3
🧹 Nitpick comments (3)
frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx (3)
176-186: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsider memoizing the toggle callback and
FolderProgressto avoid unnecessary re-renders.
onToggleExpanded={() => toggleFolderExpanded(folder.folder_id)}at Lines 268-270 creates a new function identity on every render ofFolderManagementCard. SinceFolderProgressis not wrapped inReact.memo, every parent re-render (for example, fromtaggingStatusupdates for any folder) re-renders every visibleFolderProgressinstance, even folders whose data did not change. WrapFolderProgressinReact.memoand memoizetoggleFolderExpandedwithuseCallbackto limit re-renders to the folders that actually changed.As per path instructions, "Check for proper React hook dependencies and prevent unnecessary re-renders."
Also applies to: 263-271
🤖 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 `@frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx` around lines 176 - 186, Memoize toggleFolderExpanded with useCallback using its stable state setter dependency, and wrap FolderProgress with React.memo. Update the FolderProgress callback usage to preserve stable function identities while retaining the existing folderId behavior, ensuring only folders with changed props re-render.Source: Path instructions
27-186: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd test coverage for the new progress components and toggle/refresh logic.
This diff introduces
ProgressRow,FolderProgress,expandedFoldersstate,toggleFolderExpanded, and the focus/visibility-driven query invalidation effect, but no accompanying tests are included in this review. These are user-facing behavior changes (combined vs. detailed progress display, semantic-availability fallback, refresh-on-focus) called out directly in the PR objectives, so they are good candidates for component tests (for example, verifying thatFolderProgressrenders only "AI Tagging Progress" whensemanticAvailableisfalse, and that the expand/collapse toggle updatesisExpanded).As per path instructions, "Ensure that test code is automated, comprehensive, and follows testing best practices" and "Verify that all critical functionality is covered by tests."
🤖 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 `@frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx` around lines 27 - 186, Add automated component tests covering ProgressRow and FolderProgress: verify percentage rendering and completion styling, the semanticAvailable=false fallback showing only AI Tagging Progress, combined progress with semantic details, and expand/collapse behavior invoking onToggleExpanded with the correct isExpanded state. Add FolderManagementCard tests for toggleFolderExpanded state changes and focus/visibility events invalidating queries, including cleanup behavior for registered listeners.Source: Path instructions
151-151: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the diff-style "NEW" comment.
// --- NEW: Force data refresh when window regains focus or visibility ---describes the change relative to a prior version rather than describing current behavior. This kind of comment becomes stale and confusing once merged. Rephrase it to describe what the effect does now.🤖 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 `@frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx` at line 151, Remove the "NEW:" marker from the comment at line 151 in FolderManagementCard.tsx that describes forcing data refresh on window focus/visibility. Rephrase the comment to describe the current behavior and effect (e.g., what happens when the window regains focus) rather than marking it as a recent change, so the comment remains accurate and useful after the code is merged.
🤖 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`:
- Around line 159-169: Update the visibilitychange listener in the effect around
handleFocus by extracting the inline callback into a named handler, then pass
that same handler reference to both document.addEventListener and
document.removeEventListener. Preserve the existing visible-state check and
handleFocus behavior.
- Around line 35-50: Align the completion status with the displayed rounded
value in the component containing isComplete: compute a roundedPercentage once,
base isComplete on roundedPercentage >= 100, and reuse roundedPercentage for the
percentage label so the checkmark and styling match the displayed value.
- Around line 152-164: Update the handleFocus callback in FolderManagementCard
to invalidate only the relevant folder and model-status queries instead of
calling queryClient.invalidateQueries() globally. Target the existing query keys
['models', 'status'], ['folders'], and ['folders', 'tagging-status'], preserving
the focus and visibility-triggered refresh behavior.
---
Nitpick comments:
In `@frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx`:
- Around line 176-186: Memoize toggleFolderExpanded with useCallback using its
stable state setter dependency, and wrap FolderProgress with React.memo. Update
the FolderProgress callback usage to preserve stable function identities while
retaining the existing folderId behavior, ensuring only folders with changed
props re-render.
- Around line 27-186: Add automated component tests covering ProgressRow and
FolderProgress: verify percentage rendering and completion styling, the
semanticAvailable=false fallback showing only AI Tagging Progress, combined
progress with semantic details, and expand/collapse behavior invoking
onToggleExpanded with the correct isExpanded state. Add FolderManagementCard
tests for toggleFolderExpanded state changes and focus/visibility events
invalidating queries, including cleanup behavior for registered listeners.
- Line 151: Remove the "NEW:" marker from the comment at line 151 in
FolderManagementCard.tsx that describes forcing data refresh on window
focus/visibility. Rephrase the comment to describe the current behavior and
effect (e.g., what happens when the window regains focus) rather than marking it
as a recent change, so the comment remains accurate and useful after the code is
merged.
🪄 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 Plus
Run ID: 9435698b-b51a-4b2f-a0d2-919885d8a121
📒 Files selected for processing (1)
frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx
Addressed Issues:
Fixes #1435 : Improve folder management progress display.(Loading State)
Screenshots/Recordings:
1. When there is only AI tagging process, without Semantic Searching.

2. When Semantic Search is enabled.
3. When Semantic Searching is uninstalled.
Screen.Recording.2026-07-31.at.6.02.10.PM.mov
Additional Notes:
Files Changed : 1
File : FolderManagementCard.tsx:
Implementation of Show more UI/UX:
It elegantly handles a complex UI requirement by splitting a dual-progress tracker into a clean, collapsible accordion view.
Implementation of FolderManagementCard.tsx Refresh when Semantic Searching is deleted:
Added a useEffect that listens for window focus and document visibilitychange events. Whenever the user returns to the app from another tab or window, it triggers queryClient.invalidateQueries(). This ensures the UI instantly fetches the latest background processing status (like semanticAvailable) without requiring a manual refresh. Using query from tanstack.
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 (max), Google Gemini 3 pro.
Checklist
Summary by CodeRabbit
New Features
Bug Fixes