Wire SyncEngine into BrowserCore

Add per-profile sync orchestration to `ely_browser_core`:

- `SyncEngine::for_profile_dir` loads / generates the persistent
  device identity under `<profile_data>/sync/device.json` and reads
  the bearer token from `<profile_data>/sync/bearer.token`.
- `install_bearer` accepts (or clears) the Better Auth session
  token; everything else stays inert until a token is on disk.
- `upload_now(&BrowserCore)` serialises the user's bookmarks into a
  stable JSON snapshot, ships it via `SyncApiClient::upload_snapshot`,
  and remembers the resulting snapshot id / logical clock / device
  for the UI to surface.
- `BrowserCore::visible_bookmarks_for_sync` returns a read-only view
  the engine can iterate without touching the in-memory state.

The shell / settings-page wiring that calls `upload_now` ships
separately so this commit stays a pure model-layer change with no
runtime behaviour difference until the UI plugs in.
This commit is contained in:
2026-05-15 17:10:30 -04:00
parent 2081c6bd88
commit a47fbdc09c
5 changed files with 214 additions and 0 deletions
+2
View File
@@ -1,6 +1,7 @@
mod error;
mod navigation;
mod state;
mod sync_engine;
pub use error::CoreError;
pub use state::{
@@ -10,3 +11,4 @@ pub use state::{
ElySpacePackage, InitialBrowserConfig, InstalledPlugin, LocalDataInventory, PluginAuditAction,
PluginAuditEvent, SiteDataClearance, SpaceImportProfileMapping, TrashedSpace,
};
pub use sync_engine::{SyncEngine, SyncEngineBuilder, SyncOutcome};