- Changed the iteration over model types to use a reference, improving performance by avoiding unnecessary cloning.
- Enhanced code clarity by reducing potential overhead in the synchronization process.
- Updated the `query_for_sync` method to accept an optional `device_id` parameter, allowing for filtering of entries based on device ownership.
- Implemented logic to retrieve and filter entries by their associated locations, ensuring only relevant data is synchronized for the specified device.
- Improved logging to clarify the filtering process and its importance for device-owned data synchronization.
- Updated the catch-up logic to trigger only when our resource count is less than the peer's actual count, ensuring efficient synchronization.
- Enhanced comments to clarify the rationale behind the count comparison, emphasizing the importance of accurate state management in synchronization processes.
- Updated the backfill logic to parse HLC from string watermarks, allowing for incremental backfill of shared resources instead of a full backfill.
- Enhanced the catch-up process in PeerSync to preserve the shared watermark, ensuring efficient synchronization by avoiding unnecessary backfills of shared resources.
- Improved logging to clarify the nature of the backfill operations, emphasizing surgical backfill for device-owned resources while maintaining shared state integrity.
- Added logic to determine the initial synchronization state based on the presence of watermarks in sync.db, setting the state to Ready if watermarks exist and Uninitialized if not.
- Enhanced logging to provide clear insights into the initial state determination process, improving visibility for debugging and monitoring synchronization behavior.
- Updated the logic for detecting count mismatches to prioritize count validation over watermark comparisons, ensuring more reliable synchronization.
- Improved logging to provide clearer insights into count discrepancies and the associated watermark differences.
- Simplified the mismatch reporting format for better readability and understanding of synchronization issues.
- Modified the `start` and `start_periodic_watermark_check` methods to accept `self` as an `Arc<Self>`, enhancing memory management and preventing potential dangling references.
- Updated logging messages to reflect changes in watermark exchange handling, ensuring clarity in the synchronization process.
- Improved the handling of connected sync partners by utilizing the upgraded weak reference pattern for better stability during periodic checks.
- Simplified the processing of WatermarkExchangeResponse messages to ensure they are only handled via the bidirectional stream.
- Added a warning log for unexpected responses, improving visibility into potential misuse of the sync request mechanism.
- Removed unnecessary parameters from the response handling, enhancing code clarity and maintainability.
- Updated the watermark exchange process to utilize a request/response pattern, enhancing synchronization reliability.
- Enhanced logging to provide clearer insights into the request and response lifecycle during watermark exchanges.
- Added error handling for unexpected message types in the response, improving robustness.
- Clarified comments to better describe the asynchronous nature of the watermark exchange process.
- Revised the catch-up logic to make the sync loop passive, driven by watermark exchanges and reconnection events.
- Enhanced comments to clarify the new approach, focusing on edge cases where retry states indicate a stuck condition.
- Removed the previous time-based sync checks in favor of a more robust failure tracking mechanism.
- Updated the entry count query to utilize the entry_closure table for more accurate counting of entries associated with device locations.
- Enhanced comments to clarify the purpose of the query and the use of closure tables in the synchronization process.
- Changed logging from info to debug for various library operations to reduce log verbosity.
- Updated the periodic watermark check interval from 5 minutes to 1 minute for more frequent synchronization checks.
- Commented out the ContentBreakdown component in the Overview route for potential future use.
- Updated the watermark exchange methods to accept a database connection, enabling retrieval of peer resource counts during synchronization.
- Enhanced logging to provide visibility into the resource counts being exchanged, improving debugging and monitoring capabilities.
- Addressed potential issues with resource count availability by ensuring counts are fetched correctly during static exchanges.
- Introduced new functionality to validate resource counts during watermark exchanges, improving synchronization accuracy.
- Added methods to retrieve device-owned resource counts for gap detection, ensuring that discrepancies are identified and addressed.
- Updated the `SyncMessage` structure to include actual resource counts, facilitating better tracking of synchronization state.
- Enhanced the `PeerSync` implementation to clear watermarks for mismatched resources, allowing for surgical recovery in case of count mismatches.
- Improved logging for better visibility into synchronization processes and potential issues.
- Introduced a new `DataAvailableNotification` message type to notify peers of new data availability, triggering immediate watermark exchanges for synchronization.
- Enhanced the `PeerSync` implementation to handle notifications and manage real-time activity tracking per peer, improving synchronization efficiency.
- Updated the `SyncProtocolHandler` to process the new notification type and initiate catch-up logic accordingly.
- Implemented periodic watermark checks to ensure timely synchronization and prevent missed events during idle periods.
- Added support for per-resource watermarks in the synchronization process, allowing for fine-grained comparison and catch-up logic.
- Implemented new configuration options for real-time batching, including maximum entries before flush and flush interval in milliseconds.
- Enhanced the `apply_state_change` function to check for tombstoned records, preventing the resurrection of deleted entries.
- Updated various components to utilize the new watermark and batching features, improving synchronization efficiency and robustness.
- Updated the submodule reference in the landing app.
- Added a statistics recalculation listener in the LibraryManager to monitor resource changes.
- Included clipboard permissions in the capabilities configuration for enhanced functionality.
- Improved the LibraryInfoOutput struct to implement the Identifiable trait for better resource management.
- Added clipboard permissions for reading and writing text in the default capabilities configuration.
- Enhanced the sync test harness to capture job lifecycle events, improving tracking of indexing completion and orphaned file management.
- Implemented checks for orphaned files during synchronization, ensuring robust handling of incomplete sync scenarios.
- Updated the submodule reference in `workbench`.
- Added debug logging in `ResourceManager` to track resource event emissions and virtual resource mappings.
- Improved the `PeerSync` implementation to emit resource events in a non-blocking manner, enhancing UI reactivity and ensuring proper resource formatting.
- Updated integration tests to include new resource types and refined synchronization checks for stability.
- Updated the foreign key mapping logic in `fk_mapper.rs` to return an error when a referenced record is missing, instead of setting the foreign key to NULL. This change ensures that sync dependencies are properly managed and allows for retrying when dependencies are resolved.
- Enhanced the error handling in `peer.rs` to buffer state changes that depend on missing foreign keys, improving the robustness of the synchronization process and preventing data loss during updates.
- Updated the `Library` implementation to generate HLCs, append to the peer log, and emit real-time events for instant synchronization.
- Introduced a mechanism to collect entries for real-time broadcasts, ensuring immediate updates are sent to peers.
- Added a yield point in the content phase to prevent foreign key orphaning by ensuring content identity events are emitted before entry updates.
- Enhanced the `NetworkingService` to cache active connections, allowing for reuse of existing connections and reducing the overhead of establishing new ones.
- Implemented logic to check the status of cached connections before creating new ones, improving efficiency during synchronization and request handling.
- Added detailed logging for connection reuse and creation, aiding in monitoring and debugging network interactions.
- Introduced a batching mechanism in `PeerSync` to accumulate state change events, improving network efficiency by processing up to 100 entries at once or flushing every 50ms.
- Added a new method `flush_state_change_batch` to handle the processing of batched state changes, enhancing overall synchronization performance.
- Updated event handling logic to support batching, reducing the frequency of individual state change processing and improving throughput.
- Added a mechanism in `PeerSync` to check for active real-time broadcasts, allowing the system to skip catch-up if real-time sync is ongoing.
- Introduced a new field `last_realtime_activity` to track the timestamp of the last real-time broadcast, enhancing synchronization efficiency.
- Updated the catch-up logic in `SyncService` to incorporate the real-time sync status, improving the overall synchronization process and preventing data duplication.
- Updated the synchronization logic in `PeerSync` to avoid buffering state changes originating from the local device, addressing a critical data loss issue during backfill requests.
- Enhanced logging to clarify the nature of the broadcasted state change events, improving traceability of local changes.
- Updated `sync_depends_on` in the entry model to include `content_identity` and `user_metadata`, ensuring foreign key references are validated before entries are processed.
- Enhanced the synchronization process in `PeerSync` to broadcast buffered state and shared changes to peers after local application, addressing a critical data loss issue.
- Added logging for the number of processed state and shared changes to improve monitoring of synchronization activities.
- Introduced a new field `unique_content_count` in `LibraryStatistics` to track the number of unique content identities.
- Updated various components to calculate and display unique content count, enhancing library statistics output.
- Modified the CLI and interface to reflect the new unique content metric, improving user insights into library data.
- Adjusted serialization and API responses to include the unique content count for better data consistency across the system.
- Updated `get_min_acked_hlc` to exclude self-ACKs from the minimum acknowledged HLC calculation, ensuring stale self-ACKs do not block pruning.
- Enhanced `on_ack_received` to ignore ACKs from the local device, adding defensive logging to catch potential bugs.
- Modified backfill logic to skip sending ACKs for changes created by the local device, improving efficiency during synchronization.
- Updated submodule references for 'workbench' and 'landing' to their latest commits.
- Enhanced database connection pooling in `mod.rs` to support higher concurrency, adjusting max connections to a configurable pool size.
- Introduced batch processing functions in `fk_mapper.rs` for efficient UUID lookups and foreign key mappings, reducing database load during synchronization.
- Added new utility functions for batch processing in `sync/mod.rs` to streamline foreign key resolution and improve sync performance.
- Updated logging statements in volume detection and APFS parsing to use debug level instead of warn, improving log clarity and reducing noise.
- This change enhances the debugging process without affecting the functionality of volume detection.
- Introduced a dedicated sync event bus to improve coordination for sync events, preventing starvation from high-volume events.
- Updated TransactionManager to utilize both sync and general event buses for better event handling.
- Refactored PeerSync to listen for sync events, ensuring proper handling of state change and shared change events.
- Adjusted LibraryManager and related components to support the new sync event bus.
This change enhances the responsiveness and reliability of the synchronization process across the system.
Backend (Tauri):
- Add AppState with current_library_id and selected_file_ids
- Persist library ID to disk for app restarts
- Add Tauri commands: get/set_current_library_id, get/set_selected_file_ids
- Emit library-changed and selected-files-changed events to all windows
- Inject window globals to all windows (not just main)
Platform abstraction:
- Add library ID methods: getCurrentLibraryId, setCurrentLibraryId, onLibraryIdChanged
- Add window management: showWindow, closeWindow, onWindowEvent, getCurrentWindowLabel
- Add selected files methods: getSelectedFileIds, setSelectedFileIds, onSelectedFilesChanged
- Implement all methods in Tauri platform layer
App layer:
- Query library ID on window mount from platform state
- Listen for library-changed events and update client
- Fix event emission to trigger hooks (emitEvent: true)
- Remove direct Tauri imports from App.tsx
This enables:
✅ Library ID persists across app restarts
✅ All windows (main, inspector, quick preview) sync library ID
✅ Inspector receives selected files from main window in real-time
✅ Popout windows get current state on mount
✅ Clean platform abstraction - zero Tauri code in interface
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add emitEvent parameter to setCurrentLibrary() to prevent event loops
- Make library ID reactive in useNormalizedCache with useState
- Listen for library-changed events and update state to trigger re-renders
- Remove manual refetch - TanStack Query auto-refetches when queryKey changes
- Clean up debug logging from useNormalizedCache and client.execute()
This enables proper library switching without infinite event loops while
maintaining reactivity across all hooks.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Backend changes:
- Modify libraries.info query to return cached stats immediately if available
- Detect empty/stale stats and calculate synchronously on first load
- Trigger background recalculation on every query to keep cache fresh
- Emit ResourceChanged events (resource_type: library) when stats update
- Add job completion hooks to trigger stats recalculation after every job
Frontend changes:
- Add library-changed event emission when setCurrentLibrary() is called
- Listen for library-changed events in useNormalizedCache to auto-refetch
- Support instant cache updates via ResourceChanged event listeners
This enables:
✅ Immediate load of cached stats (0ms after first time)
✅ Real-time updates when jobs complete
✅ Background recalculation to keep stats fresh
✅ Event-driven cache updates via normalizedCache pattern