From 628f26bdfb7c1b86ef17754b86b9f351b6b2ba77 Mon Sep 17 00:00:00 2001 From: Andrew Blakeslee Moore Date: Sun, 5 Jul 2026 04:29:53 -0700 Subject: [PATCH] Session Sync Repair Nucleic-Session: 0C7BC346-0002-4533-ADDD-3B4C92E58527 Co-authored-by: Nucleic --- .../NucleicRemote/Models/HostConnection.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/NucleicRemote/NucleicRemote/Models/HostConnection.swift b/NucleicRemote/NucleicRemote/Models/HostConnection.swift index 8436ad5..e1f1335 100644 --- a/NucleicRemote/NucleicRemote/Models/HostConnection.swift +++ b/NucleicRemote/NucleicRemote/Models/HostConnection.swift @@ -35,7 +35,20 @@ final class HostConnection { /// The session RemoteStore currently has open on this host, if any — so snapshot/events are only /// forwarded (and deduped) for the transcript on screen. Set by RemoteStore on open/close. - var openSessionID: SessionID? + /// Changing which session is open resets the per-session cursor + dedup set (they only make + /// sense within one transcript). + var openSessionID: SessionID? { + didSet { + guard openSessionID != oldValue else { return } + openMaxSeq = nil + seenSeq = [] + } + } + + /// The highest event `seq` delivered for the open session — the warm-resubscribe cursor. On a + /// reconnect we re-subscribe `sinceSeq: openMaxSeq` so the host replays only what we missed + /// instead of cold-resetting to the 200-event tail (which would truncate a long transcript). + private var openMaxSeq: UInt64? // MARK: Callbacks up to RemoteStore (aggregate concerns)