Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(swift-ios): compact consecutive tool groups with relative ages #10767

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 31 commits intot3code/rebuild-mobile-app-swift fromrefs/pull/10767/headopened View on GitHub

Review this layer

GitHub shows this PR against t3code/rebuild-mobile-app-swift, so its diff includes every earlier PR in the chain. Review only this layer's change:

This layer's diff: +290 / −77 lines across 6 files; app code +198 / −64, the rest is tests and docs.

Group consecutive tool calls and updates into one expandable transcript row, preserving boundaries at text, notices, and new turns. Display the group’s most recent event age. The inherited activity row now shows last-message age at the end of the transcript; the thread-header receipt label is removed.

Delivery: stacked. This branch contains #10758, #10759, #10761, #10762, #10763, #10764, #10765, #10766, #14021; merge the chain in order (#10758 → #10759 → #10761 → #10762 → #10763 → #10764 → #10765 → #10766 → #14021 → #10767). Each PR's own change is its top commit(s).

Fresh combined layout at current head a92cb54a2:

Current compact tool group with last-message age below agent activity

Actual native WorkspaceView recording: a snapshot receipt, a new assistant message, and completion. Synthetic conversation and four tool events; iPhone 17 Pro Simulator / iOS 26.5, dark mode, full 402×874-point viewport scaled to 390 pixels wide. Real-time playback, GIF sampled at 12 fps, plus a disclosed three-second final-frame hold. The idle transition retains all transcript text and removes the activity row.

Current head: message age advances and activity clears on completion

Clean current-head recording · Captioned recording · Idle screenshot · Capture/edit receipt

The tool-group comparison and expansion/collapse footage below were captured at prerequisite 9083a8378 and candidate 9d2e2fed9. This older idle-thread fixture has no activity row or receipt label; the tool-group implementation it exercises is unchanged at current head. Both capture tests passed (1 test each, exit 0). The fresh combined recording above verifies the changed activity/header layout. The matching before/after activity comparison is in #10766.

Still-state comparison: two actual screenshots held for 3.5 seconds each; this is not a timing measurement.

Before separate tool rows; after an expandable group

Actual candidate interaction: expand, retain all four calls, age advances from 1m to 2m, collapse. GIF samples 12 fps with real-time playback; no sped-up or generated transitions.

Actual tool-group interaction

Clean recording · Captioned recording · Capture and editing receipt

Current-head verification: native WorkspaceView capture and two message-age tests passed (3 tests, xcodebuild exit 0). CI passed, including contract fixtures and native tests. Earlier captures had incomplete redraws and were rejected; replacement current-head frames were inspected through idle. Xcode compiler-probe stalls required retries. No live-backend or phone performance measurement is claimed.

Independent Claude review was unavailable: claude auth status returned exit 1 with loggedIn: false. Visual inspection is the author’s assessment, not maintainer approval.

Refresh onto 157476f1fb (2026-09-27)

Rebased with the thread-sync chain onto the current t3code/rebuild-mobile-app-swift (157476f1fb). Head 68d92c2752.

  • Focused tests at this layer, measured before the review fixes below (NativeMultiEnvironmentTests, NativeThreadCatchUpTests, NativeRetryIdentityTests, FeatureRootModelTests, iOS Simulator, per-test time limits): see full suite below.
  • Full T3CodeTests at the chain top (68d92c2752): 343 XCTest cases passed (1 skipped). Swift Testing ran 892 tests; the only 2 failures are UsageModelsTests currency formatting, which fail identically on unmodified 157476f1fb.
  • Independent review: devin -p --sandbox --permission-mode smart --model swe-2-max over the whole chain diff, exit 0. No blocker, high or medium findings. A dead-state finding was fixed. A report that Stop state outlives a vanished thread was not changed, because stopSurvivesCloseReopenAndMissingReconnectSeed requires that behaviour.

Follow-ups (minor, not blocking)

  • When reconciliation finds the thread unchanged it keeps the previous page metadata, so hasMore can stay stale after older turns are deleted (Macroscope).

Model and harness: GPT-6 / Codex. Rebase onto 157476f1fb: Claude Opus 5.5 / Claude Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      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.

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR substantially changes default Swift iOS behavior across transport reconciliation, thread stopping, transcript rendering, navigation, and background lifecycle handling, with extensive new asynchronous coordination. Several concrete unresolved state and race conditions are also documented, including an acknowledged High-severity stop-path issue.

      Not approved because:

      • 5 blocking correctness issues found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Bugbot is paused — on-demand spend limit reached

      Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

      A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

    5. @t3dotgg Alex has approved the updated UI and media here. Please take a look at the compact tool groups with the updated activity-row message age. Current-head screenshots, GIFs, and videos are in the description. This remains chained after #10766.

    6. @@ -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] } ?? toolPresentation
      205+ }
      206+ return message
      207+ }
      208+
      209+ private static func lifecycleKey(_ activity: OrchestrationActivity) -> String {
      210+ if let id = activity.payload["toolCallId"]?.stringValue
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Core/NativeTranscriptTimeline.swift:210

      Activities with an empty toolCallId are all assigned the same id: lifecycle key, so parallel calls merge into one callOrder entry and a completion can clear another call's active label. Only use toolCallId as the stable identity when it is non-empty; otherwise use the fallback identity.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/swift-ios/Core/NativeTranscriptTimeline.swift around line 210:
      
      Activities with an empty `toolCallId` are all assigned the same `id:` lifecycle key, so parallel calls merge into one `callOrder` entry and a completion can clear another call's active label. Only use `toolCallId` as the stable identity when it is non-empty; otherwise use the fallback identity.
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High Root/FeatureRootModel.swift:1215

      The pending-creation path can cancel a newer turn than the one the user claimed. After awaiting outbox drain/discard work, the unguarded client.cancelTurn(threadID:) cancels whichever turn is current; pass key.turnID as expectedTurnID, as the normal path does.

                      try await client.cancelTurn(threadID: threadID, expectedTurnID: key.turnID)
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/swift-ios/Features/Root/FeatureRootModel.swift around line 1215:
      
      The pending-creation path can cancel a newer turn than the one the user claimed. After awaiting outbox drain/discard work, the unguarded `client.cancelTurn(threadID:)` cancels whichever turn is current; pass `key.turnID` as `expectedTurnID`, as the normal path does.
    7. @@ -4095,0 +4709,21 @@
      4709+ $0.projects.map(\.id) != previous?.projects.map(\.id)
      4710+ || $0.threads.map(\.id) != previous?.threads.map(\.id)
      4711+ } ?? false
      4712+ if replacingEpoch, let shell { owner.shellsByEnvironmentID[environment.id] = shell }
      4713+ owner.applyEnvironmentLoad(EnvironmentShellLoad(
      4714+ environment: environment, client: client, shell: shell, config: nil
      4715+ ))
      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 : idleInterval
      4721+ }
      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()
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium App/NativeFeatureClient.swift:4729

      refreshCatalogue retries a rejected serverConfig() request every failureInterval, continuing to create ephemeral clients and make requests even after the peer requires re-pairing. try? discards the authorization failure, so the loop never applies the shell worker’s 24-hour backoff or exits; handle rejected credentials explicitly and stop this worker.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/swift-ios/App/NativeFeatureClient.swift around line 4729:
      
      `refreshCatalogue` retries a rejected `serverConfig()` request every `failureInterval`, continuing to create ephemeral clients and make requests even after the peer requires re-pairing. `try?` discards the authorization failure, so the loop never applies the shell worker’s 24-hour backoff or exits; handle rejected credentials explicitly and stop this worker.

      Fixed in #10761 (fix(swift-ios): stop probing a peer's catalogue once it needs pairing). The probe's own error cannot carry the 401 (the socket ticket rejection surfaces as a timeout), so the loop stops once the peer's shell read marks it as needing pairing. Managed (T3 Connect) peers are a listed follow-up.

      Sorry, I'm unable to act on this request because you do not have permissions within this repository.

      @@ -2280,0 +2531,21 @@
      2531+ private func scheduleAcceptedCommandRefresh(
      2532+ threadID: String, client: T3Client, generation: Int, refreshDetail: Bool = true
      2533+ ) {
      2534+ guard isKnownClient(client, environmentID: client.environment.id, generation: generation) else {
      2535+ return
      2536+ }
      2537+ if let current = acceptedCommandRefreshes[threadID],
      2538+ current.client === client, current.generation == generation {
      2539+ acceptedCommandRefreshes[threadID]?.pending = true
      2540+ acceptedCommandRefreshes[threadID]?.needsDetail = current.needsDetail || refreshDetail
      2541+ return
      2542+ }
      2543+ cancelAcceptedCommandRefreshes(threadID: threadID)
      2544+ let id = UUID()
      2545+ let task = Task { [weak self] in
      2546+ while self?.isCurrentAcceptedCommandRefresh(threadID: threadID, id: id) == true {
      2547+ let needsDetail = self?.acceptedCommandRefreshes[threadID]?.needsDetail == true
      2548+ self?.acceptedCommandRefreshes[threadID]?.needsDetail = false
      2549+ self?.acceptedCommandRefreshes[threadID]?.pending = false
      2550+ if needsDetail {
      2551+ try? await self?.refreshThread(id: threadID, client: client) { [weak self] in
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium App/NativeFeatureClient.swift:2551

      An accepted send can resurrect a thread deleted by another client: the in-flight refreshThread publishes .detail after the shell has removed the thread, and FeatureRootModel handles that event by upsert(value.thread). clearRemovedThreadDetail clears selection but does not cancel this task, so cancel the accepted-command refresh there or revalidate that the thread still exists before emitting .detail.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/swift-ios/App/NativeFeatureClient.swift around line 2551:
      
      An accepted send can resurrect a thread deleted by another client: the in-flight `refreshThread` publishes `.detail` after the shell has removed the thread, and `FeatureRootModel` handles that event by `upsert(value.thread)`. `clearRemovedThreadDetail` clears selection but does not cancel this task, so cancel the accepted-command refresh there or revalidate that the thread still exists before emitting `.detail`.

      Not changing in this PR: upstream awaited the same refresh inside send and has the same race with a remote delete. Cancelling accepted-command refreshes on shell removal would close it; listed as a follow-up on #10758.

      Sorry, I'm unable to act on this request because you do not have permissions within this repository.

      @@ -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: threadSnapshotTimeoutInterval
      51225943 )
      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
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium App/NativeFeatureClient.swift:5952

      Reconciliation returns without updating activeThreadPage when snapshot.thread is unchanged, so page metadata such as hasMore remains stale and the detail can continue advertising “load earlier” after older turns are deleted. Include snapshot.page in this equality check so changed pagination state is published.

      Suggested change
      5954+ if reconcile, pendingHistory == nil, let current = activeRawThread,
      5955+ snapshot.snapshotSequence >= (activeThreadSequence ?? 0),
      5956+ snapshot.thread == current,
      5957+ snapshot.page == activeThreadPage {
      5958+ return
      5959+ }
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/swift-ios/App/NativeFeatureClient.swift around lines 5952-5955:
      
      Reconciliation returns without updating `activeThreadPage` when `snapshot.thread` is unchanged, so page metadata such as `hasMore` remains stale and the detail can continue advertising “load earlier” after older turns are deleted. Include `snapshot.page` in this equality check so changed pagination state is published.

      Acknowledged: with an unchanged thread, reconciliation keeps the previous page metadata, so hasMore can stay stale until the next full load. Listed as a follow-up in the PR body.

      Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    8. @t3dotgg this is ready for your review and merge.

      Merge order: stacked chain, merge in order: #10758 → #10759 → #10761 → #10762 → #10763 → #10764 → #10765 → #10766 → #10767. #12655 (composer focus freeze) is independent and can merge at any time.

      Evidence at head 70258b6a6b:

      • CI: all checks pass on this head.
      • Full T3CodeTests at the chain top (70258b6a6b, iOS Simulator): 343 XCTest cases passed (1 skipped). Swift Testing ran 892 tests; the only 2 failures are UsageModelsTests currency formatting, which fail identically on unmodified 157476f1fb.
      • Each review fix has a focused regression test that fails without the fix, except where the description says why not.
      • An earlier build of this chain (before the review rounds) fixed the stuck-send behaviour on a physical iPhone, as confirmed by the user. The current heads have not been re-verified on a device.

      Independent review: No layer-specific Astra review. Covered by the SWE-2 Max review of the whole chain (exit 0, no blocker/high/medium findings).

      Macroscope findings on the latest heads have been verified against the source: real ones are fixed, and the rest have a written reason and are listed under Follow-ups in the description.

    9. Note

      This comment is posted by Julius' dot

      Grouping distinct tool calls into a collapsed, expandable row changes the default transcript presentation. The current thread has no linked maintainer approval for that design, as required by the prior approval rule. Please agree on the grouping and age display with maintainers, then request reconsideration.

    10. juliusmarminge closed this

Sign in to join this conversation.