4221 Commits

Author SHA1 Message Date
Jamie Pine
a7438f3d50 refactor: optimize model type iteration in PeerSync
- 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.
2025-11-16 10:59:00 -08:00
Jamie Pine
30538c6189 refactor: enhance device-specific entry synchronization in query_for_sync
- 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.
2025-11-16 10:57:07 -08:00
Jamie Pine
8c0d3d4b13 refactor: refine catch-up logic in PeerSync for count comparison
- 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.
2025-11-16 10:34:47 -08:00
Jamie Pine
2412ee01bc refactor: enable incremental shared backfill in BackfillManager
- 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.
2025-11-16 10:12:21 -08:00
Jamie Pine
ad7740bde4 refactor: initialize sync state based on existing watermarks in PeerSync
- 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.
2025-11-16 09:30:49 -08:00
Jamie Pine
e2ec1905e9 refactor: enhance count mismatch handling in PeerSync
- 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.
2025-11-16 09:11:24 -08:00
Jamie Pine
2eab49a68d refactor: update PeerSync methods to use Arc for improved memory safety
- 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.
2025-11-16 08:51:23 -08:00
Jamie Pine
fe97fc2390 refactor: streamline handling of WatermarkExchangeResponse in SyncProtocolHandler
- 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.
2025-11-16 08:40:02 -08:00
Jamie Pine
be33d4a6b9 refactor: improve watermark exchange handling in PeerSync
- 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.
2025-11-16 08:31:53 -08:00
Jamie Pine
a037af577e refactor: update catch-up logic in SyncService for improved synchronization handling
- 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.
2025-11-16 08:07:16 -08:00
Jamie Pine
1d078206f6 refactor: improve entry count query in PeerSync for location ownership
- 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.
2025-11-16 07:59:40 -08:00
Jamie Pine
56b57a27d3 chore: update logging levels and adjust periodic watermark check interval
- 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.
2025-11-16 07:38:27 -08:00
Jamie Pine
8c5543b8b2 fix: include database connection in watermark exchange for resource count retrieval
- 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.
2025-11-16 07:10:58 -08:00
Jamie Pine
680585a02f feat: enhance watermark synchronization with resource count validation
- 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.
2025-11-16 06:39:59 -08:00
James Pine
a842826555 fix size view loading 2025-11-16 05:49:54 -08:00
Jamie Pine
08d5e7badf feat: add DataAvailableNotification for proactive data sync notifications
- 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.
2025-11-16 05:40:30 -08:00
Jamie Pine
a33ca1e884 feat: enhance synchronization with per-resource watermark tracking and batching configuration
- 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.
2025-11-16 04:56:41 -08:00
Jamie Pine
d93d1efaaa chore: update submodule and add statistics listener for library management
- 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.
2025-11-16 03:38:54 -08:00
Jamie Pine
b4e5212b60 feat: enhance clipboard capabilities and improve sync event tracking
- 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.
2025-11-16 02:49:45 -08:00
Jamie Pine
a067dd5cbb chore: update submodule and enhance logging in ResourceManager and PeerSync
- 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.
2025-11-16 02:25:05 -08:00
Jamie Pine
8305d7d235 feat: working sync test, sick log analyzer, cleanup 2025-11-16 01:53:35 -08:00
Jamie Pine
8693faf5c1 fix: improve foreign key handling in synchronization process
- 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.
2025-11-15 09:22:26 -08:00
Jamie Pine
a7586b3bf7 feat: enhance real-time synchronization and event broadcasting
- 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.
2025-11-15 08:46:37 -08:00
James Pine
2f887a41fa yay 2025-11-15 08:35:07 -08:00
Jamie Pine
eb4e1db688 feat: implement connection caching for improved network performance
- 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.
2025-11-15 07:42:29 -08:00
Jamie Pine
15821e581a feat: implement real-time batching for state change events in PeerSync
- 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.
2025-11-15 07:30:13 -08:00
Jamie Pine
9303b37692 feat: implement real-time sync lock mechanism to prevent catch-up duplication
- 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.
2025-11-15 06:52:52 -08:00
Jamie Pine
d5020cc37e fix: prevent buffering of local state changes during synchronization
- 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.
2025-11-15 06:24:36 -08:00
Jamie Pine
8cdf878b38 fix: improve entry dependency handling and synchronization broadcasting
- 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.
2025-11-15 06:09:42 -08:00
Jamie Pine
c647ee8452 feat: add unique content count to library statistics
- 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.
2025-11-15 04:55:20 -08:00
Jamie Pine
e73ba2342a fix: prevent self-ACKs in synchronization process
- 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.
2025-11-15 03:34:49 -08:00
Jamie Pine
dfe7fa64f9 chore: update submodule references and enhance database connection pooling
- 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.
2025-11-15 02:36:25 -08:00
Jamie Pine
ed9f0ae845 refactor: change logging level from warn to debug for volume detection and parsing
- 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.
2025-11-15 02:17:29 -08:00
Jamie Pine
cf3eb78530 feat: enhance sync architecture with dedicated event bus
- 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.
2025-11-14 22:24:19 -08:00
Jamie Pine
0e880497f3 remove markdown 2025-11-14 21:42:24 -08:00
Jamie Pine
ddcefe2495 docs 2025-11-14 21:40:49 -08:00
James Pine
6354d34204 remove apps and extensions from language meme 2025-11-14 21:34:40 -08:00
James Pine
f7d7468bce remove submodules 2025-11-14 21:31:21 -08:00
James Pine
998d85a511 fix text language stats and add tauri icons 2025-11-14 21:24:54 -08:00
James Pine
62fd347e64 feat: implement cross-window library ID and selected files synchronization
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>
2025-11-14 21:20:39 -08:00
James Pine
5ac99017b2 feat: add library-changed event emission control and reactive library ID tracking
- 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>
2025-11-14 21:20:15 -08:00
James Pine
b1d0fbe296 feat: implement cache-first library statistics with background updates
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
2025-11-14 20:26:25 -08:00
Jamie Pine
76b17cc332 refactor: optimize event handling and backfill logic by improving timestamp tracking 2025-11-14 18:59:03 -08:00
Jamie Pine
6f331a1b90 feat: retrieve database ID for Entry model to include directory path in sync JSON 2025-11-14 08:53:17 -08:00
Jamie Pine
9ad57dfd0a refactor: enhance resource event emission by utilizing ResourceManager for proper formatting and error handling 2025-11-14 08:44:44 -08:00
Jamie Pine
7f01cf3c1c feat: update resource watermark after successful backfill to prevent re-syncing of already backfilled data 2025-11-14 08:11:50 -08:00
Jamie Pine
eef817d4ab feat: add unique constraint to volumes UUID for improved data integrity; implement migration for index creation and removal 2025-11-14 07:47:04 -08:00
Jamie Pine
24aa4d9798 fix: specify response type for layout query in spaces module to ensure proper JSON handling 2025-11-14 07:28:19 -08:00
Jamie Pine
41476d13dd refactor: streamline device and sync management by removing unused watermark fields; implement per-resource watermark tracking for improved sync reliability 2025-11-14 07:23:34 -08:00
Jamie Pine
1ae1bcea6b refactor: improve code readability and consistency in sync watermark tests; format and organize test setup and logging for better clarity 2025-11-14 06:52:29 -08:00