fix(swift-ios): recover missing completed thread replies #10759
Closedsaphid(GitHub profile, opens in a new tab)wants to merge 250+ commits into
t3code/rebuild-mobile-app-swift fromrefs/pull/10759/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:XL
- apps/swift-ios/App/NativeFeatureClient.swift lines 5405 to 5413Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -4829,2 +4844,21 @@48294844 }483048454846+ private func repairMissingCompletedTurn(4847+ _ shellThread: OrchestrationThreadShell, sequence: Int, threadID: String4848+ ) {4849+ guard let rawThread = activeRawThread,4850+ sequence >= (activeThreadSequence ?? .min),4851+ let completed = shellThread.latestTurn, completed.state == "completed",4852+ let route = try? threadRoute(for: threadID) else { return }4853+ if let messageID = completed.assistantMessageId {4854+ if let message = rawThread.messages.first(where: { $0.id == messageID }),4855+ !message.streaming {4856+ flushDetailPublish(route)4857+ return4858+ }4859+ } else if rawThread.latestTurn?.turnId == completed.turnId,4860+ rawThread.latestTurn?.state == completed.state,4861+ rawThread.latestTurn?.completedAt == completed.completedAt,4862+ !rawThread.messages.contains(where: {4863+ $0.role == "assistant" && $0.turnId == completed.turnId && $0.streaming4864+ }) {apps/swift-ios/App/NativeFeatureClient.swift line 2085Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1869,4 +1874,7 @@18691874 detail.page = cached.page18701875 markThreadCacheRecentlyUsed(route.uiID)18711876 startDetailStream(route, warmConnectionID: warmConnectionID)1872- return detail1877+ if let shell = shellsByEnvironmentID[environment.id] {1878+ synchronizeActiveDetail(with: shell, environment: environment)1879+ }1880+ return latestDetails[route.uiID] ?? detail
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- @@ -2280,0 +2314,21 @@2314+ guard isKnownClient(client, environmentID: client.environment.id, generation: generation) else {2315+ return2316+ }2317+ if let current = acceptedCommandRefreshes[threadID],2318+ current.client === client, current.generation == generation {2319+ acceptedCommandRefreshes[threadID]?.pending = true2320+ acceptedCommandRefreshes[threadID]?.needsDetail = current.needsDetail || refreshDetail2321+ return2322+ }2323+ cancelAcceptedCommandRefreshes(threadID: threadID)2324+ let id = UUID()2325+ let task = Task { [weak self] in2326+ while self?.isCurrentAcceptedCommandRefresh(threadID: threadID, id: id) == true {2327+ let needsDetail = self?.acceptedCommandRefreshes[threadID]?.needsDetail == true2328+ self?.acceptedCommandRefreshes[threadID]?.needsDetail = false2329+ self?.acceptedCommandRefreshes[threadID]?.pending = false2330+ if needsDetail {2331+ try? await self?.refreshThread(id: threadID, client: client)2332+ }2333+ guard self?.isCurrentAcceptedCommandRefresh(threadID: threadID, id: id) == true else { break }2334+ try? await self?.refresh(client: client)
juliusmarminge added labelsmacroscope-review
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed