fix(swift-ios): retain Stop feedback until the session is inactive #10765
Closedsaphid(GitHub profile, opens in a new tab)wants to merge 25 commits into
t3code/rebuild-mobile-app-swift fromrefs/pull/10765/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/Features/Root/FeatureRootModel.swift line 1203Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -792,4 +961,21 @@961+ let phase: FeatureStopPhase = stopRequests[key.threadID]?.canObserveOutcome == true962+ ? .awaitingOutcome : .unconfirmed963+ stopRequests[key.threadID]?.phase = phase964+ }965+ } catch {966+ guard stopRequests[key.threadID]?.token == token else { return }967+ if error is FeatureStopTurnChangedError {968+ stopRequests.removeValue(forKey: key.threadID)969+ } else {970+ stopRequests[key.threadID]?.phase = .unconfirmed971+ }972+ errorMessage = error.localizedDescription973+ }974+ }975+976+ private func cancelClaimedTurn(_ key: StopKey) async throws -> Bool {977+ let threadID = key.threadID792978 if pendingSubmissionsByID.values.contains(where: {793979 $0.threadID == threadID && $0.creation != nil794980 }) {795981 await stopOutboxDrain()
- apps/swift-ios/App/NativeFeatureClient.swift line 1073OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -852,4 +1066,8 @@8521066 private func adoptEnvironment(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()
- @@ -1340,3 +1529,4 @@13401529 pendingRewindRecoveryIDs.remove(thread.id)13411530 rewindErrors[thread.id] = nil13421531 }1532+ for thread in value.threads { reconcileStop(thread) }
- @@ -970,10 +1187,16 @@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 {9751199 activeEnvironment = environment9761200 environmentClients[environment.id] = newClient9771201 latestShell = shellsByEnvironmentID[environment.id]978- startAggregateRefresh(newClient)979- return1202+ return true
- apps/swift-ios/Features/Root/FeatureRootModel.swift lines 1727 to 1727OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1523,4 +1718,10 @@15231718 return true15241719 }152517201721+ private func forgetDeliveredMessages(threadID: String) {1722+ deliveredAwaitingDetail = deliveredAwaitingDetail.filter { $0.value.threadID != threadID }1723+ serverMessageIDs[threadID] = nil1724+ }1725+15261726 private func removeDetail(id: String) {1727+ forgetDeliveredMessages(threadID: id)
- apps/swift-ios/App/NativeFeatureClient.swift line 2604OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2291,3 +2597,8 @@22912597 return snapshot.thread.messages.contains { $0.id == messageID }22922598 }229325992600+ func stopStatus(threadID: String) async throws -> FeatureThread {2601+ let route = try threadRoute(for: threadID)2602+ let generation = environmentGeneration2603+ let bootstrapID = foregroundBootstrapID2604+ try await refresh(client: route.client)
- @@ -268,0 +434,21 @@434+ if socketAuthoritative {435+ shellConnectionIDsByEnvironmentID[client.environment.id] = activeShellConnectionID436+ activeStreamIsAuthoritative = true437+ activeHTTPAuthorityRevision &+= 1438+ activeHydrationPending = false439+ }440+ let removed = Set(shellsByEnvironmentID[client.environment.id]?.threads.map(\.id) ?? [])441+ .subtracting(shell.threads.map(\.id))442+ for id in removed {443+ clearRemovedThreadDetail(FeatureScopedID.thread(environmentID: client.environment.id, wireID: id))444+ }445+ latestShell = shell446+ shellsByEnvironmentID[client.environment.id] = shell447+ environmentConnectionStates[client.environment.id] = .connected448+ environmentConnectionDetails[client.environment.id] = nil449+ rebuildEntityIndexes(environments)450+ synchronizeActiveDetail(with: shell, environment: client.environment)451+ guard let activeEnvironment else { return }452+ publish(makeSnapshot(453+ environments: environments, activeEnvironment: activeEnvironment,454+ connectionState: connectHeader ? .connected : (latestSnapshot?.connection.state ?? .reconnecting),
juliusmarminge closed this
Sign in to join this conversation.






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