Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(swift-ios): record thread receipts and keep tool history chronological #10766

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 28 commits intot3code/rebuild-mobile-app-swift fromrefs/pull/10766/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: +807 / −330 lines across 15 files; app code +474 / −321, the rest is tests and docs.

Keep tool observations in chronological order across intervening assistant text, and record when this device last received an update for the open thread. The thread header shows that receipt time with its own connection label, so Connected is not mistaken for a new message.

Delivery: stacked. This branch contains #10758, #10759, #10761, #10762, #10763, #10764, #10765; 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).

Split (2026-09-28): this PR originally also replaced the header receipt line with the age of the last message. That change now lives in #14021, stacked directly on this PR. This PR adds the receipt line; #14021 replaces it with the message age.

Chronological tool ordering: newly captured against prerequisite #10765 at 5e0055bdc and 4434db280 (the current header/activity changes do not affect this idle, receipt-free transcript fixture). The same synthetic wire snapshot contains Read 0, assistant text, then Read 2 for the same tool call. Actual NativeFeatureClient mapping and ThreadDetailView show the baseline replacing the earlier work row with Read 2 before the text; the candidate retains all three rows in order. Both capture tests passed (1 test each, exit 0). Fixed 1 January 2026 timestamps are fixture values. This is a static snapshot comparison, not an incremental-animation or latency measurement.

Before: later update overwrites earlier work; after: both tool observations surround the assistant text

Full before screenshot · Full after screenshot · Capture and edit receipt

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 e54dd91a82.

  • Focused tests at this layer, measured before the review fixes and the split below (NativeMultiEnvironmentTests, NativeThreadCatchUpTests, NativeRetryIdentityTests, FeatureRootModelTests, iOS Simulator, per-test time limits): 119 passed.

  • 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.

  • Split check: this layer now compiles on its own; the header receipt view needed a case for the upstream Needs pairing connection state, which the removed age commits had masked by deleting that view. Full T3CodeTests at this head (e54dd91a82): 343 XCTest cases passed; Swift Testing failures only the 2 UsageModelsTests currency tests.

Follow-ups (minor, not blocking)

  • A retained delivered message whose thread detail was evicted before the server transcript arrived keeps its text, but its attachment preview is not persisted until the transcript arrives (Macroscope).
  • Loading an older page can add work-log rows for tool activity that was still in progress in that history (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. 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.

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This is a large Swift iOS production change spanning transport synchronization, transcript rendering, navigation, and new receipt/stop behavior. Unresolved findings identify stale tool activity, lost attachment previews, and incorrect historical work-log rows, so the runtime impact warrants human review.

      Not approved because:

      • 3 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).
    5. saphid(GitHub profile, opens in a new tab) changed the title

    6. @t3dotgg Alex has approved the updated UI and media here. Please take a look at the last-message age beneath agent activity and the tool chronology changes. Current-head screenshots, GIFs, and videos are in the description. This remains chained after #10765.

    7. @@ -7354,15 +8150,8 @@
      73548150 requiresFullRebuild = true
      7355- messages.removeAll(keepingCapacity: true)
      7356- activities.removeAll(keepingCapacity: true)
      8151+ ordered.removeAll(keepingCapacity: true)
      73578152 case let .message(message):
      7358- if let index = messages.firstIndex(where: { $0.id == message.id }) {
      7359- messages[index] = message
      7360- } else {
      7361- messages.append(message)
      7362- }
      7363- case let .activity(activity):
      7364- if let index = activities.firstIndex(where: { $0.id == activity.id }) {
      7365- activities[index] = activity
      7366- } else {
      7367- activities.append(activity)
      7368- }
      8153+ if case let .message(previous) = ordered.last, previous.id == message.id {
      8154+ ordered[ordered.count - 1] = mutation
      8155+ } else { ordered.append(mutation) }
      8156+ case .activity:
      8157+ ordered.append(mutation)
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium App/NativeFeatureClient.swift:8157

      A replayed .activity with the same ID is appended instead of replacing the earlier mutation, so NativeTranscriptTimeline accepts the first event and permanently displays stale tool activity until a full rebuild. Deduplicate .activity mutations by activity ID and replace the existing entry with the latest contents, as is done for .message.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/swift-ios/App/NativeFeatureClient.swift around line 8157:
      
      A replayed `.activity` with the same ID is appended instead of replacing the earlier mutation, so `NativeTranscriptTimeline` accepts the first event and permanently displays stale tool activity until a full rebuild. Deduplicate `.activity` mutations by activity ID and replace the existing entry with the latest contents, as is done for `.message`.
    8. @@ -1823,3 +2066,6 @@
      18232066 }
      18242067 pendingCompletionSubmissionIDs.remove(submission.id)
      18252068 pendingSubmissionsByID.removeValue(forKey: submission.id)
      2069+ // A transcript that already includes it confirmed delivery; do not retain it.
      2070+ if serverMessageIDs[submission.threadID]?.contains(submission.identity.messageID) != true {
      2071+ var message = queuedMessage(for: submission)
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Root/FeatureRootModel.swift:2071

      Accepted attachments are persisted without their previewData or URL, so if the detail is evicted before the server transcript arrives, reopening the thread produces an attachment that cannot be previewed or opened. completeQueuedSubmission builds the retained row with queuedMessage(for:), which omits these fields; preserve the attachment preview/URL when creating this post-send row.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/swift-ios/Features/Root/FeatureRootModel.swift around line 2071:
      
      Accepted attachments are persisted without their `previewData` or URL, so if the detail is evicted before the server transcript arrives, reopening the thread produces an attachment that cannot be previewed or opened. `completeQueuedSubmission` builds the retained row with `queuedMessage(for:)`, which omits these fields; preserve the attachment preview/URL when creating this post-send row.
      saphid(GitHub profile, opens in a new tab)commented

      Acknowledged: an evicted, not-yet-transcribed message keeps its text but its attachment preview is not persisted until the server transcript arrives. Before this chain the message disappeared entirely. Listed as a follow-up.

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

    9. @@ -6122,11 +7055,7 @@
      61227055 let messages = thread.messages.map {
      61237056 mapMessage($0, environmentID: environmentID)
      61247057 }
      6125- let workIsLive = thread.session?.status == "starting"
      6126- || thread.session?.status == "running"
      6127- || backgroundLiveness(threadID: thread.id, environmentID: environmentID) == .working
      6128- let activities = thread.activities.compactMap {
      6129- NativeActivityNotice.message($0, createdAt: parseDate($0.createdAt))
      6130- }
      6131- + collapsedWorkLogs(thread.activities, sessionIsLive: workIsLive)
      6132- return (messages + activities).sorted { $0.createdAt < $1.createdAt }
      7058+ // Older pages contain earlier turn windows, but carry current session
      7059+ // metadata. That metadata must not revive their historical tool rows.
      7060+ return NativeTranscriptTimeline(
      7061+ messages: messages, activities: thread.activities, sessionIsLive: false
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium App/NativeFeatureClient.swift:7061

      Loading an older page adds stale work-log rows for in-progress historical tool activity. sessionIsLive: false causes NativeTranscriptTimeline to call finishActiveWork(), which materializes unfinished entries instead of discarding them; use a history-specific path that drops unfinished tool entries without reviving them.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/swift-ios/App/NativeFeatureClient.swift around line 7061:
      
      Loading an older page adds stale work-log rows for in-progress historical tool activity. `sessionIsLive: false` causes `NativeTranscriptTimeline` to call `finishActiveWork()`, which materializes unfinished entries instead of discarding them; use a history-specific path that drops unfinished tool entries without reviving them.

      Acknowledged: older pages can materialise work-log rows for tool activity that was still running in that history. Listed as a follow-up in the PR body rather than changed in this stack.

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

    10. @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 419e4ebb64:

      • 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.

    11. saphid(GitHub profile, opens in a new tab) changed the title

    12. @t3dotgg heads-up: #10766 had two concerns, so it's now split.

      • #10766 keeps thread receipts and chronological tool history (retitled).
      • #14021 (new, stacked directly on #10766) carries the last-message age on the activity row. It's the same code as #10766's last two commits squashed, plus a user-guide update. The chain top's code is unchanged; GPT-6 Astra xhigh (read-only) confirmed that, and CI is green on the new heads.

      New merge order: #10758 → #10759 → #10761 → #10762 → #10763 → #10764 → #10765 → #10766 → #14021 → #10767. #12655 stays independent.

      Each PR's GitHub diff includes the whole chain below it, so every description now starts with a link to that layer's own change:

      PROwn changeLines
      #10758layer diff+992/−29
      #10759layer diff+522/−31
      #10761layer diff+2558/−464
      #10762layer diff+123/−2
      #10763layer diff+1257/−42
      #10764layer diff+711/−56
      #10765layer diff+4060/−25
      #10766layer diff+807/−330
      #14021layer diff+90/−68
      #10767layer diff+290/−77
    13. Note

      This comment is posted by Julius' dot

      Preserving tool chronology and adding a thread receipt timestamp solve separate problems. The chronology repair does not need the new header receipt display. Under the one problem rule, please split the receipt feature from the ordering fix and establish its scope with maintainers before requesting reconsideration.

    14. juliusmarminge closed this

Sign in to join this conversation.