fix(swift-ios): retain thread subscriptions across navigation #10764
Closedsaphid(GitHub profile, opens in a new tab)wants to merge 19 commits into
t3code/rebuild-mobile-app-swift fromrefs/pull/10764/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/swift-ios/App/NativeFeatureClient.swift line 1221Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -862,14 +1082,19 @@8621082 }863- let previousClient = client8641083 pollingTask?.cancel()8651084 fallbackPollingTask?.cancel()1085+ shellReconciliationTask?.cancel()8661086 configurationTask?.cancel()867- aggregateRefreshTask?.cancel()8681087 archivedRefreshTask?.cancel()8691088 pollingTask = nil8701089 fallbackPollingTask = nil1090+ shellReconciliationTask = nil8711091 configurationTask = nil8721092 aggregateRefreshTask = nil8731093 aggregateRefreshID = nil8741094 archivedRefreshTask = nil1095+ // A passive snapshot is authoritative for adoption only while its1096+ // exact socket is still current. A replacement socket starts a new epoch.1097+ activeShellConnectionID = adoptedConnectionID1098+ activeShellEpochHasSnapshot = adoptedConnectionID != nil1099+ && shellConnectionIDsByEnvironmentID[environment.id] == adoptedConnectionID8751100 clearEnvironmentState(preserveEnvironmentSnapshots: true)apps/swift-ios/App/NativeFeatureClient.swift line 1204Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -853,12 +1067,17 @@8531067 _ environment: Environment,8541068 client newClient: T3Client855- ) async {1069+ ) async -> Bool {1070+ let bootstrapID = foregroundBootstrapID1071+ let generation = environmentGeneration1072+ let adoptedConnectionID = await newClient.currentConnectionID()1073+ let selectedClient = try? await runtime.activeClient()1074+ guard bootstrapID == foregroundBootstrapID, generation == environmentGeneration,1075+ selectedClient === newClient, selectedClient?.environment == environment else { return false }1076+ cancelAggregateRefresh()8561077 if activeEnvironment?.id == environment.id, client === newClient {8571078 activeEnvironment = environment8581079 environmentClients[environment.id] = newClient8591080 latestShell = shellsByEnvironmentID[environment.id]860- startAggregateRefresh(newClient)861- return1081+ return true8621082 }863- let previousClient = client8641083 pollingTask?.cancel()
- @@ -970,5 +1187,12 @@9701187 private func adoptEnvironment(9711188 _ environment: Environment,9721189 client newClient: T3Client973- ) async {1190+ ) async throws -> Bool {1191+ let bootstrapID = foregroundBootstrapID1192+ let generation = environmentGeneration1193+ let adoptedConnectionID = await newClient.currentConnectionID()1194+ let selectedClient = try await runtime.activeClient()1195+ guard bootstrapID == foregroundBootstrapID, generation == environmentGeneration,1196+ selectedClient === newClient, selectedClient?.environment == environment else { return false }1197+ cancelAggregateRefresh()9741198 if activeEnvironment?.id == environment.id, client === newClient {
- @@ -1823,3 +1921,5 @@18231921 }18241922 pendingCompletionSubmissionIDs.remove(submission.id)18251923 pendingSubmissionsByID.removeValue(forKey: submission.id)1924+ // A transcript that already includes it confirmed delivery; do not retain it.1925+ if serverMessageIDs[submission.threadID]?.contains(submission.identity.messageID) != true {
juliusmarminge closed this
Sign in to join this conversation.

macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed