Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(swift-ios): recover missing completed thread replies #10759

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 250+ commits intot3code/rebuild-mobile-app-swift fromrefs/pull/10759/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: +522 / −31 lines across 2 files; app code +75 / −20, the rest is tests and docs.

A shell can report completion while the selected transcript still lacks the final reply or displays streaming text. Require an authoritative detail snapshot without closing the live subscription, preserve newer detail state against stale shell metadata, and avoid repeatedly publishing already-synchronized legacy bursts.

Pre-restack CI verification: GitHub checks passed on the original head, including contract fixtures and native tests. Skipped checks are not claimed as executed proof.

The completion tests now use observable upstream snapshot events instead of a receipt type supplied only by the later bootstrap PR. Pre-restack native CI passed.

Delivery: stacked. This branch contains #10758; 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).

Base: Theo’s t3code/rebuild-mobile-app-swift, 157476f1fb.

Historical verification scope (before this restack): Native tests passed for missing or streaming final replies, completion while required snapshots are held, newer running details against delayed shell completion, and warm cached opens. Tests assert authoritative replacement while preserving the live subscription. The native CI job linked above contains the passing receipts. The tests exercise the protocol, state, or accessibility-value boundary changed here.

Refresh onto 157476f1fb (2026-09-27)

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

  • Focused tests at this layer, measured before the review fixes below (NativeMultiEnvironmentTests, NativeThreadCatchUpTests, NativeRetryIdentityTests, FeatureRootModelTests, iOS Simulator, per-test time limits): 84 passed, 0 failures.
  • 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.
  • Rebase change: upstream efc8b08c58 (bounded catch-up batches) now publishes one legacy .live per received batch. This PR's detailWasSynchronized guard suppressed that and made upstream's testLegacyReplayPublishesOncePerReceivedBatchAndResumesAfterAppliedEvents hang, so the guard is dropped in favour of upstream's design, along with testLegacyBurstCoalescesUntilExplicitMarker and testLegacyMarkerlessFinalPublishesWhenClockReleases, which asserted the old behaviour.

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — Production Swift code adds a stateful accepted-command refresh and transcript-recovery path that changes send/stop completion, shell/detail synchronization, and local message retention across existing customer flows. An unresolved Medium finding describes a cancellation race that can republish a deleted thread, so the runtime behavior warrants human review.

      Not approved because:

      • 1 blocking correctness issue 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).
    3. @t3dotgg Could you review this SwiftUI reliability/performance fix? It will recover missing completed replies from authoritative thread detail. It does not change the visible interface. This can be reviewed independently against your SwiftUI branch.

    4. @@ -2280,0 +2314,21 @@
      2314+ guard isKnownClient(client, environmentID: client.environment.id, generation: generation) else {
      2315+ return
      2316+ }
      2317+ if let current = acceptedCommandRefreshes[threadID],
      2318+ current.client === client, current.generation == generation {
      2319+ acceptedCommandRefreshes[threadID]?.pending = true
      2320+ acceptedCommandRefreshes[threadID]?.needsDetail = current.needsDetail || refreshDetail
      2321+ return
      2322+ }
      2323+ cancelAcceptedCommandRefreshes(threadID: threadID)
      2324+ let id = UUID()
      2325+ let task = Task { [weak self] in
      2326+ while self?.isCurrentAcceptedCommandRefresh(threadID: threadID, id: id) == true {
      2327+ let needsDetail = self?.acceptedCommandRefreshes[threadID]?.needsDetail == true
      2328+ self?.acceptedCommandRefreshes[threadID]?.needsDetail = false
      2329+ self?.acceptedCommandRefreshes[threadID]?.pending = false
      2330+ 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)
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium App/NativeFeatureClient.swift:2334

      A cancelled accepted-command refresh can restore a deleted thread, causing a later emitCachedSnapshot to publish it again. refresh(client:) resumes after shellSnapshot() and assigns shellsByEnvironmentID and latestShell without checking Task.isCancelled; add a cancellation/current-client guard before those assignments.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/swift-ios/App/NativeFeatureClient.swift around line 2334:
      
      A cancelled accepted-command refresh can restore a deleted thread, causing a later `emitCachedSnapshot` to publish it again. `refresh(client:)` resumes after `shellSnapshot()` and assigns `shellsByEnvironmentID` and `latestShell` without checking `Task.isCancelled`; add a cancellation/current-client guard before those assignments.
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Root/FeatureRootModel.swift:1755

      Completed restored submissions are treated as server-confirmed even when their message exists only in the local queued detail, so a later authoritative refresh can remove the delivered message from the UI. addingPendingMessages records every incoming message ID in serverMessageIDs, including .queued optimistic messages rebuilt by restoreOutbox; exclude queued messages from this set so completeQueuedSubmission retains them in deliveredAwaitingDetail.

      No longer relevant as of ed9720a9f7dd69cfce23f414631fea9cfa15abe5

    6. saphid(GitHub profile, opens in a new tab)commented

      Fixed in #10758 (fix(swift-ios): keep accepted messages across eviction and local details): only server transcripts record confirmed message IDs now; restored-outbox and pending-creation details are stored as local. Test: startedTaskKeepsItsPromptUntilTheServerIncludesIt fails without the fix.

    7. 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 392394d4a7:

      • 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. This layer was 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. juliusmarminge added labelsmacroscope-review

    10. Note

      🤖 GPT-6.1-Sol responding on behalf of Theo

      Closing this implementation as part of the SwiftUI backlog cleanup. Missing completed replies and older shell metadata replacing newer detail are real problems. This patch adds forced snapshot recovery based on shell completion and changes stream/cache synchronization, which is broader than the small-fix scope of this pass.

      For reconsideration, submit a focused stale-shell ordering fix or a current reproduction of missing final content with a small repair. The problems remain valid; this closure is a scope decision.

      See the contribution scope guidance.

Sign in to join this conversation.