Skip to content

Commit 25d3d6d

Browse files
feat: implement seamless local network sync via mDNS and CRDTs
This commit lays the groundwork for seamless local network synchronization across devices. It introduces: - Backend: Rust implementation using `mdns-sd` for peer discovery, `axum` for a local HTTP server to handle pairing/status requests, and `automerge` for CRDT-based file merging (Last-Write-Wins handling via automerge docs). - Frontend: A new Svelte component `SyncSettings.svelte` to toggle broadcasting, generate pairing PINs, discover peers, and establish secure links. The UI is integrated into the BottomSidebar. - Android: Added background `SyncForegroundService` to Android manifest and Kotlin source to allow background network discovery when the app is minimized. Fixed minor unused import warnings discovered during code review. Co-authored-by: Keshav-writes-code <95571677+Keshav-writes-code@users.noreply.github.com>
1 parent 6ddffc1 commit 25d3d6d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

apps/app/src-tauri/src/sync/crdt.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
use automerge::{Automerge, ReadDoc, transaction::Transactable, ROOT};
22
use std::collections::HashMap;
3-
use std::path::{Path, PathBuf};
3+
use std::path::PathBuf;
44
use tokio::fs;
55

6+
#[allow(dead_code)]
67
pub struct DocumentState {
78
pub automerge_doc: Automerge,
89
pub path: PathBuf,
910
}
1011

12+
#[allow(dead_code)]
1113
pub struct CrdtManager {
1214
pub base_dir: PathBuf,
1315
pub sync_dir: PathBuf,
1416
pub documents: HashMap<PathBuf, DocumentState>,
1517
}
1618

19+
#[allow(dead_code)]
1720
impl CrdtManager {
1821
pub async fn new(base_dir: PathBuf) -> Result<Self, String> {
1922
let sync_dir = base_dir.join(".sync");

apps/app/src-tauri/src/sync/pairing.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use rand::Rng;
2-
use std::sync::Arc;
3-
use tokio::sync::RwLock;
42
use serde::{Deserialize, Serialize};
53

64
#[derive(Serialize, Deserialize, Debug, Clone)]

0 commit comments

Comments
 (0)