perf(usage): coalesce session-sync notifications and serialize sync execution

Replace per-insert usage notifications with a single notification per
sync pass, guard all sync entry points (startup backfill, 60s loop,
manual sync) behind a process-wide single-flight tokio mutex, and move
blocking file/DB work onto spawn_blocking with MissedTickBehavior::Skip.

Extend SessionSyncResult with deferredFiles/suspectedDuplicates
observability fields (saturating aggregation) and add a test seam that
counts notifications even without an injected AppHandle.
This commit is contained in:
Jason
2026-07-20 12:15:32 +08:00
parent 01fca69641
commit eb105eae76
8 changed files with 148 additions and 96 deletions
+2
View File
@@ -40,6 +40,8 @@ export interface SessionSyncResult {
imported: number;
skipped: number;
filesScanned: number;
suspectedDuplicates: number;
deferredFiles: number;
errors: string[];
}