fix: harden folder watch feature with file hash dedup, mtime seeding, and stable spinner#1185
fix: harden folder watch feature with file hash dedup, mtime seeding, and stable spinner#1185AnishSarkar22 wants to merge 21 commits intoMODSetter:devfrom
Conversation
testing backend test CI workflow
…ype in folder.types
…ion.div properties in SidebarSlideOutPanel
…ring folder synchronization
…hance watched folder ID retrieval in DocumentsSidebar
…in FolderTreeView
…ion during local folder indexing
…lder structure handling in UI components
…val and optimizing empty folder cleanup process
…and enhance UI component styling for folder selection
|
@AnishSarkar22 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Review by RecurseML
🔍 Review performed on b8d6cd4..f3aa514
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (23)
• surfsense_backend/app/db.py
• surfsense_backend/app/routes/documents_routes.py
• surfsense_backend/app/tasks/celery_tasks/document_tasks.py
• surfsense_backend/app/tasks/connector_indexers/local_folder_indexer.py
• surfsense_desktop/src/ipc/channels.ts
• surfsense_desktop/src/ipc/handlers.ts
• surfsense_desktop/src/modules/folder-watcher.ts
• surfsense_desktop/src/preload.ts
• surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx
• surfsense_web/components/assistant-ui/connector-popup/tabs/all-connectors-tab.tsx
• surfsense_web/components/documents/FolderNode.tsx
• surfsense_web/components/documents/FolderTreeView.tsx
• surfsense_web/components/layout/ui/dialogs/CreateSearchSpaceDialog.tsx
• surfsense_web/components/layout/ui/shell/LayoutShell.tsx
• surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx
• surfsense_web/components/layout/ui/sidebar/SidebarSlideOutPanel.tsx
• surfsense_web/components/sources/FolderWatchDialog.tsx
• surfsense_web/contracts/types/folder.types.ts
• surfsense_web/hooks/use-folder-sync.ts
• surfsense_web/lib/apis/documents-api.service.ts
• surfsense_web/lib/folder-sync-upload.ts
• surfsense_web/types/window.d.ts
• surfsense_web/zero/schema/folders.ts
…e for improved document organization
… process and enhance related test coverage
…or document upload and folder watch functionalities
Description
folderUploadFilesandfolderNotifyUnlinkedAPI endpoints for upload-based file indexing and deletion.seedFolderMtimesIPC API to populate the Electron mtime store after initial folder scans, preventing the Chokidar watcher from re-emitting redundant "add" events for already-indexed files.acknowledgeFileEventsto persist file modification times on acknowledgment, ensuring accurate change detection across app restarts.asyncio.to_threadto avoid blocking the event loop.indexing_in_progressflag on the folder metadata, set at batch start and cleared in afinallyblock, synced to the frontend via Zero for a stable processing indicator.metadataJSONB column in the Zero schema to enable real-time sync of folder-level state to the UI.DocumentsSidebarto fall back to backend data when the Electron store is empty.Motivation and Context
FIX #
Screenshots
API Changes
Change Type
Testing Performed
Checklist
High-level PR Summary
This PR refactors the folder watch feature to support remote backend deployments by replacing direct filesystem scanning with an upload-based approach. The desktop app now reads files locally and uploads them to the backend via new API endpoints (
/folder-mtime-check,/folder-upload,/folder-unlink,/folder-sync-finalize), enabling the feature to work across cloud, self-hosted remote, and local deployment modes. Key improvements include optimized mtime-based change detection to skip unchanged files, raw file hash comparison as a pre-filter before expensive content extraction, passive delete cascade for document versions, batch upload with concurrency control, and progress tracking with cancellation support in the UI.⏱️ Estimated Review Time: 1-3 hours
💡 Review Order Suggestion
surfsense_backend/app/db.pysurfsense_desktop/src/ipc/channels.tssurfsense_desktop/src/ipc/handlers.tssurfsense_desktop/src/modules/folder-watcher.tssurfsense_desktop/src/preload.tssurfsense_web/lib/apis/documents-api.service.tssurfsense_web/lib/folder-sync-upload.tssurfsense_web/hooks/use-folder-sync.tssurfsense_web/components/sources/FolderWatchDialog.tsxsurfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsxsurfsense_backend/app/routes/documents_routes.pysurfsense_backend/app/tasks/connector_indexers/local_folder_indexer.pysurfsense_backend/app/tasks/celery_tasks/document_tasks.pysurfsense_web/zero/schema/folders.tssurfsense_web/contracts/types/folder.types.tssurfsense_web/components/documents/FolderNode.tsxsurfsense_web/components/documents/FolderTreeView.tsxsurfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsxsurfsense_web/components/assistant-ui/connector-popup/tabs/all-connectors-tab.tsxsurfsense_web/components/layout/ui/dialogs/CreateSearchSpaceDialog.tsxsurfsense_web/components/layout/ui/shell/LayoutShell.tsxsurfsense_web/components/layout/ui/sidebar/SidebarSlideOutPanel.tsxsurfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsxsurfsense_web/components/assistant-ui/connector-popup/tabs/all-connectors-tab.tsxsurfsense_web/components/layout/ui/dialogs/CreateSearchSpaceDialog.tsxsurfsense_web/components/layout/ui/shell/LayoutShell.tsxsurfsense_web/components/layout/ui/sidebar/SidebarSlideOutPanel.tsx