From 638845e150d46809a69bd183e27b7809793e1ce0 Mon Sep 17 00:00:00 2001 From: Natalie Date: Fri, 15 May 2026 23:40:58 -0700 Subject: [PATCH] =?UTF-8?q?fix(imessage):=20=F0=9F=90=9B=20fix=20empty-ser?= =?UTF-8?q?ver=20initial-load=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../imessage/Sources/IMessageSync/SyncManager.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/@packages/imessage/Sources/IMessageSync/SyncManager.swift b/@packages/imessage/Sources/IMessageSync/SyncManager.swift index 8809415..4db7313 100644 --- a/@packages/imessage/Sources/IMessageSync/SyncManager.swift +++ b/@packages/imessage/Sources/IMessageSync/SyncManager.swift @@ -195,8 +195,13 @@ final class SyncManager: BaseSyncManager { // Initial-load path: server has nothing, stream a metadata-only batch // import (attachments without blob bytes). Subsequent cycles use the // standard incremental path with full attachment data. - if isInitialLoad && stats.messageCount == 0 { - log.info("Initial load detected - using batch sync") + // Re-enter performInitialSync whenever the server is empty. The previous + // gate flipped `isInitialLoad = false` after the first run regardless of + // success — a partial-failure run would then route to the incremental + // path on the next cycle even though the server still had zero messages, + // making the missing data unrecoverable without a manual restart. + if stats.messageCount == 0 { + log.info("Server empty — entering initial-batch sync path") activityLog.info("First sync detected - using optimized batch endpoint") await performInitialSync() isInitialLoad = false