fix: recover mobile and sync state after resume

Reconnect sync stream when native mobile app resumes
Materialize incomplete sessions with explicit recovery reasons
Add low-noise debug breadcrumb for scoped recovery
This commit is contained in:
Bohdan Triapitsyn
2026-07-01 18:32:24 +03:00
parent 0a69c4ebab
commit 4b1e05160f
6 changed files with 123 additions and 65 deletions
+7 -1
View File
@@ -23,7 +23,7 @@ function isSyncDebugEnabled(): boolean {
}
return _enabled
}
type SyncDebugCategory = "pipeline" | "reducer" | "dispatch"
type SyncDebugCategory = "pipeline" | "reducer" | "dispatch" | "recovery"
function log(cat: SyncDebugCategory, ...args: unknown[]): void {
if (!isSyncDebugEnabled()) return
@@ -74,4 +74,10 @@ export const syncDebug = {
eventApplied: (eventType: string, sessionID?: string, messageID?: string) =>
log("dispatch", "event → applied", { eventType, sessionID, messageID }),
},
recovery: {
/** A scoped session snapshot fetch is starting because live state looked incomplete. */
materializing: (details: { reason: string; directory: string; sessionID: string; messageID?: string; partID?: string }) =>
log("recovery", "materializing session", details),
},
} as const