fix(swift-ios): compact consecutive tool groups with relative ages #10767
Closedsaphid(GitHub profile, opens in a new tab)wants to merge 31 commits into
t3code/rebuild-mobile-app-swift fromrefs/pull/10767/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
- @@ -0,0 +190,21 @@190+ (["• \(callLabels[key] ?? "Tool activity")"] + (callDetails[key] ?? []))191+ .joined(separator: "\n")192+ }193+ var message = FeatureMessage(194+ id: "work-log-\(groupID)",195+ role: .tool,196+ text: lines.joined(separator: "\n"),197+ createdAt: createdAt,198+ state: .complete,199+ toolName: callOrder.count > 1 ? "\(callOrder.count) tool calls" : title,200+ workLogImagePaths: imagePaths.isEmpty ? nil : imagePaths,201+ activeWorkLabel: activeOrder.last.flatMap { activeEntries[$0] }202+ )203+ if callOrder.count == 1 {204+ message.toolPresentation = activeOrder.last.flatMap { activePresentations[$0] } ?? toolPresentation205+ }206+ return message207+ }208+209+ private static func lifecycleKey(_ activity: OrchestrationActivity) -> String {210+ if let id = activity.payload["toolCallId"]?.stringValueapps/swift-ios/Features/Root/FeatureRootModel.swift line 1206Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1010,4 +1182,21 @@1182+ let phase: FeatureStopPhase = stopRequests[key.threadID]?.canObserveOutcome == true1183+ ? .awaitingOutcome : .unconfirmed1184+ stopRequests[key.threadID]?.phase = phase1185+ }1186+ } catch {1187+ guard stopRequests[key.threadID]?.token == token else { return }1188+ if error is FeatureStopTurnChangedError {1189+ stopRequests.removeValue(forKey: key.threadID)1190+ } else {1191+ stopRequests[key.threadID]?.phase = .unconfirmed1192+ }1193+ errorMessage = error.localizedDescription1194+ }1195+ }1196+1197+ private func cancelClaimedTurn(_ key: StopKey) async throws -> Bool {1198+ let threadID = key.threadID10101199 if pendingSubmissionsByID.values.contains(where: {10111200 $0.threadID == threadID && $0.creation != nil10121201 }) {10131202 await stopOutboxDrain()
- apps/swift-ios/Features/Root/FeatureRootModel.swift line 1739OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1523,4 +1730,10 @@15231730 return true15241731 }152517321733+ private func forgetDeliveredMessages(threadID: String) {1734+ deliveredAwaitingDetail = deliveredAwaitingDetail.filter { $0.value.threadID != threadID }1735+ serverMessageIDs[threadID] = nil1736+ }1737+15261738 private func removeDetail(id: String) {1739+ forgetDeliveredMessages(threadID: id)
- @@ -4095,0 +4709,21 @@4709+ $0.projects.map(\.id) != previous?.projects.map(\.id)4710+ || $0.threads.map(\.id) != previous?.threads.map(\.id)4711+ } ?? false4712+ if replacingEpoch, let shell { owner.shellsByEnvironmentID[environment.id] = shell }4713+ owner.applyEnvironmentLoad(EnvironmentShellLoad(4714+ environment: environment, client: client, shell: shell, config: nil4715+ ))4716+ if membershipChanged { owner.rebuildEntityIndexes(saved) }4717+ owner.publishAggregateSnapshot(saved, changedEnvironmentIDs: [environment.id])4718+ guard let shell else { return failureInterval }4719+ return changed || NativeFeatureClient.shellNeedsFrequentAggregateRefresh(shell)4720+ ? fastInterval : idleInterval4721+ }4722+4723+ func refreshCatalogue(_ environment: Environment) async {4724+ while isCurrent && owner?.serverConfigsByEnvironmentID[environment.id] == nil {4725+ do {4726+ guard try await currentEnvironments(for: environment) != nil else { return }4727+ // Never disconnect the shared client if this peer becomes selected.4728+ let probe = await runtime.ephemeralClient(for: environment)4729+ let config = try? await probe.serverConfig()@@ -2280,0 +2531,21 @@2531+ private func scheduleAcceptedCommandRefresh(2532+ threadID: String, client: T3Client, generation: Int, refreshDetail: Bool = true2533+ ) {2534+ guard isKnownClient(client, environmentID: client.environment.id, generation: generation) else {2535+ return2536+ }2537+ if let current = acceptedCommandRefreshes[threadID],2538+ current.client === client, current.generation == generation {2539+ acceptedCommandRefreshes[threadID]?.pending = true2540+ acceptedCommandRefreshes[threadID]?.needsDetail = current.needsDetail || refreshDetail2541+ return2542+ }2543+ cancelAcceptedCommandRefreshes(threadID: threadID)2544+ let id = UUID()2545+ let task = Task { [weak self] in2546+ while self?.isCurrentAcceptedCommandRefresh(threadID: threadID, id: id) == true {2547+ let needsDetail = self?.acceptedCommandRefreshes[threadID]?.needsDetail == true2548+ self?.acceptedCommandRefreshes[threadID]?.needsDetail = false2549+ self?.acceptedCommandRefreshes[threadID]?.pending = false2550+ if needsDetail {2551+ try? await self?.refreshThread(id: threadID, client: client) { [weak self] in@@ -5119,4 +5936,20 @@5936+ guard let lastKnown = users.lastIndex(where: { retainedIDs.contains($0.id) }) else { return nil }5937+ return users.distance(from: users.index(after: lastKnown), to: users.endIndex)5938+ }5939+ var snapshot = try await client.threadSnapshot(51195940 id: route.wireID,5120- turnLimit: supportsPagination ? Self.initialThreadUserTurnLimit : nil,5941+ turnLimit: supportsPagination ? turnLimit : nil,51215942 timeoutInterval: threadSnapshotTimeoutInterval51225943 )5944+ guard !Task.isCancelled,5945+ expectedStreamGeneration.map({ isCurrentDetail(route, generation: $0) }) ?? true,5946+ isKnownClient(client, environmentID: environment.id, generation: generation) else {5947+ throw CancellationError()5948+ }5949+ guard ownsReconciliationExtent() else { return }5950+ // A later delivered cursor does not prove that every earlier row arrived.5951+ // Independent HTTP repair must compare content, even at an equal watermark.5952+ if reconcile, pendingHistory == nil, let current = activeRawThread,5953+ snapshot.snapshotSequence >= (activeThreadSequence ?? 0),5954+ snapshot.thread == current {5955+ return
juliusmarminge closed this
Sign in to join this conversation.




Macroscope has since reviewed this pull request. An earlier review was skipped by a cost limit; a review has now completed, so that notice no longer applies.