Skip to content

Conversation

@hjamet
Copy link
Contributor

@hjamet hjamet commented Sep 8, 2025

feat(obsidian): Enhance Sync Experience with Progress Bars and Bug Fixes

This pull request significantly improves the content synchronization experience for Obsidian users by fixing a critical bug and introducing new UI elements for better feedback and monitoring.

The previous implementation could fail with 403 Forbidden errors when syncing a large number of files due to server-side rate limiting. This update addresses that issue and provides users with clear, real-time feedback on storage usage and sync progress.


Key Changes

  • 🐛 Bug Fix: Sync Robustness (Resolves 403 Errors)
    The core sync logic in updateContentIndex has been refactored. Instead of sending all file updates at once, the process is now chunked. Files are grouped by type (markdown, pdf, image) and uploaded in sequential batches. This respects server rate limits and ensures that large vaults can be indexed reliably without triggering 403 errors.

  • ✨ New Feature: Cloud Storage Usage Bar
    A progress bar has been added to the settings page to display cloud storage usage.

    • Total Limit: The storage limit (10 MB for free, 500 MB for premium) is now reliably determined by the is_active flag returned from the /api/v1/user endpoint, eliminating fragile client-side heuristics.
    • Used Space: The used space is calculated via a client-side estimation of all files configured for synchronization. This provides a clear and immediate indicator of the vault's storage footprint.
  • ✨ New Feature: Real-time Sync Progress Bar
    When a manual sync is triggered via the "Force Sync" button, a second progress bar now appears, providing real-time feedback on the operation.

    • It displays the number of files processed against the total number of files to be indexed or deleted.
    • This is implemented using a callback mechanism (onProgress) to cleanly communicate progress from the sync logic (utils.ts) to the UI (settings.ts) without coupling them.
  • 🔄 UX Improvement: Auto-refresh After Sync
    The Cloud Storage Usage bar is now automatically refreshed upon the completion of a "Force Sync". This ensures the user immediately sees the updated storage estimation without needing to reopen the settings panel.

  • 🛠️ DX Improvement: esbuild Development Workflow
    The esbuild.config.mjs has been enhanced to automatically copy the built main.js and manifest.json files to a specified Obsidian plugin directory during development, streamlining the testing and iteration cycle.


Visuals

image

hjamet and others added 5 commits September 8, 2025 16:10
- Introduced `deleteContentByType` to delete content of a specified type from the Khoj server.
- Added `uploadContentBatch` to handle batch uploads of files to the Khoj content endpoint.
- Updated `updateContentIndex` to utilize the new API functions for content deletion and batch uploads, improving error handling and file processing logic.
- Introduced a new setting for displaying estimated cloud storage usage based on files configured for sync.
- Implemented a progress indicator and text display for the estimation process.
- Added a utility function to calculate used and total storage bytes based on user plan (free or premium).
- Enhanced error handling for storage estimation failures.
- Added a progress indicator and text display for the sync operation in the settings.
- Modified the `updateContentIndex` function to accept an optional progress callback, allowing real-time updates on file processing.
- Implemented error handling for progress updates to ensure robustness during sync operations.
- Created a new progress bar for the Force Sync operation, improving user feedback during lengthy processes.
- Updated the sync progress UI to include a display for the current content type being synced (e.g., Images, PDFs, Markdowns).
- Modified the `onProgress` callback in `updateContentIndex` to accept an optional `contentType` parameter for better user feedback during sync operations.
- Added error handling for the `updateStorageDisplay` method to ensure robustness during setting changes.
- Improved the overall user experience by providing clearer sync progress information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant