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)