From 2cc7eeb2b1034cb91fbfed9b8cf551ea855db17f Mon Sep 17 00:00:00 2001 From: Andrew Blakeslee Moore Date: Sun, 5 Jul 2026 19:27:45 -0700 Subject: [PATCH] Fetch Historical Transcript Data Nucleic-Session: 11465D90-A8F3-43AA-A1DC-37EA1EC1B909 Co-authored-by: Nucleic --- .../NucleicRemote/Models/HostConnection.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/NucleicRemote/NucleicRemote/Models/HostConnection.swift b/NucleicRemote/NucleicRemote/Models/HostConnection.swift index f5ba00b..8587ad9 100644 --- a/NucleicRemote/NucleicRemote/Models/HostConnection.swift +++ b/NucleicRemote/NucleicRemote/Models/HostConnection.swift @@ -630,6 +630,21 @@ final class HostConnection { Task { await client.send(msg) } } + /// Pull the open session's *full* transcript via mesh full-transcript sync and merge it into the + /// transcript on screen. The cold `subscribe` only returns the host's 200-event tail, so without + /// this the phone shows nothing from before it connected. `afterSeq: 0` asks for the whole history + /// (overlap with the tail is deduped on arrival). Idempotent per open — guarded by + /// `didStartFullFetch` — and a no-op when the host predates `canSyncTranscripts` (the tail still + /// shows) or the connection isn't live yet (the reconnect handler retries once it is). + func fetchFullTranscript(_ sessionID: SessionID) { + guard sessionID == openSessionID, !didStartFullFetch, + capabilities.canSyncTranscripts, client != nil else { return } + didStartFullFetch = true + let requestID = UUID().uuidString + transcriptFetchRequestID = requestID + send(.fetchTranscript(TranscriptFetch(requestID: requestID, sessionID: sessionID, afterSeq: 0))) + } + /// The device's network path changed (Wi-Fi ⇄ cellular, joined/left a network). React now rather /// than waiting for a zombie LAN socket to time out or the reconnect backoff to elapse — this is /// what makes the transport switch feel immediate. Only reconnect-managed hosts (a pinned host)