fix(mobile): Stabilize the iOS app on main
Summary
- Backport the applicable v1 iOS runtime and chat reliability fixes onto
main. - Recover cached shell and thread state cleanly after reconnects, and make stalled thread-detail loading visible and retryable.
- Keep keyboard, transparent-header, floating-composer, Markdown, and screenshot layout predictable on a real iPhone.
- Harden Release Hermes crash diagnosis so fatals leave recoverable disk records without attaching a device console.
- Stop Thread catch-up re-renders from looping through
PreventRemoveProvidervia unstable native-stack options updates.
Problem and Fix
| Problem and Why it Happened | Fix |
|---|---|
| Cached shell and thread snapshots could remain marked as synchronizing after a reconnect, while thread-detail failures lost useful error information or appeared to load forever. | Restore live status when cached data is available, preserve useful failure messages, retain prior thread data during refresh failures, and retry stalled detail requests before showing an actionable error. |
| LegendList and keyboard-controller scroll math did not consistently account for UIKit's automatic top and bottom insets around a transparent header and floating composer. | Patch the inset and offset calculations, measure the composer overlay, account for the usable viewport, and correct short-content and hydrated-thread resting positions. |
| Screenshot rows could change geometry while their asset URI resolved, become non-interactive, or leave the newest content beneath the composer when a thread reopened. | Keep a fixed attachment container through loading and display, use a full-size accessible press target, preserve the presenting thread behind the image viewer, and apply a one-time end correction after hydrated overflowing content is measured. |
Composer image objects contained client-only draft fields that do not belong in startTurn payloads. |
Convert draft attachments to the upload wire shape for direct sends and outbox retries. |
| Native selectable Markdown could render at the wrong width or publish stale child content when Yoga skipped measurement on a clone. | Add explicit fill-width support and rebuild native attributed content from current children before publishing changed state. |
Release Hermes fatals were hard to diagnose after restart. A thin ErrorUtils logger often lost the race with RCTFatal abort and left empty Documents crash logs. |
Install crash capture early: JS write-first records, dual disk paths, native fsync (T3NativeControls.writeSyncText), unhandled-rejection capture, nav/outbox/stop breadcrumbs with max-wait flush, and a native RCTSetFatalHandler path (T3CrashLog + AppDelegate plugin) that writes last-crash.json / crash-native-*.json with the real JS message and stack. |
Thread catch-up and other busy re-renders rebuilt inline native-stack options every layout, so navigation.setOptions re-entered PreventRemoveProvider until React hit maximum update depth. |
Compare a structural options signature before setOptions, keep stable header-item factories via refs, and memoize Thread screen options. |
Defensive Fixes
| Problem and Why it Happened | Fix |
|---|---|
Continuous breadcrumb activity could keep resetting the trailing debounce so last-breadcrumbs.json never flushed before a kill. |
Pair the trailing debounce with a max-wait timer so breadcrumbs still land about every 400ms under continuous activity. |
| Disclosure expansion and short-to-overflow transitions could fight automatic end maintenance. | Suspend end maintenance while content underflows or a disclosure owns the visible-content anchor, then restore it through the intended transition path. |
UI Changes
This affects thread loading feedback, screenshot messages and their viewer, transparent-header scrolling, and the floating composer.
Focused Simulator layout evidence (two after-state shots only): https://github.com/pingdotgg/t3code/pull/3910#issuecomment-4953177821
Validation
vp check: passvp run typecheck: pass- Crash-logger unit tests (breadcrumbs, crash record shape, nav path helper, options signature): pass
- Release Hermes build in the iOS Simulator: pass
- Signed Release Hermes build on a physical iPhone: pass
- Reconnect state and failure-message unit coverage: pass
- Screenshot renders normally and remains tappable after asset resolution: pass
- Screenshot viewer opens without replacing the presenting thread: pass
- Reopened screenshot thread keeps the newest content above the floating composer: pass
- Screenshot top remains reachable below the transparent header: pass
- Follow-up message after a screenshot preserves complete scroll access: pass
- Device crash capture: after a real fatal, Documents includes
last-crash.jsonwithsource: "rct-fatal"and the JS exception message (verified for maximum update depth on Thread) - Thread catch-up after the stack-options fix: large active thread finished catching up without the previous
PreventRemoveProviderabort - SwiftLint
opening_bracefix forT3CrashLog(CI Mobile Native Static Analysis)
Remaining Work
- ~~Keep exercising heavy-thread catch-up and streaming on a physical iPhone for residual performance issues (memory / large projections are separate from the options-loop fatal).~~ Done: large active CTM thread finished catching up on device after the stack-options fix without the
PreventRemoveProviderabort (see Validation). - ~~Add focused Simulator layout screenshots.~~ Done in https://github.com/pingdotgg/t3code/pull/3910#issuecomment-4953177821
Checklist
- [ ] This PR is small and focused
- [x] I explained what changed and why
- [x] I included layout screenshots for UI changes (comment)
- [ ] I included a video for animation/interaction changes
[!NOTE]
Stabilize the iOS app with crash logging, scroll fixes, and reconnect recovery
- Adds a full crash logging pipeline: JS errors and unhandled rejections are intercepted, persisted to
crash-logs/via native sync I/O or Expo FS, and pruned on startup. Navigation state changes are recorded as breadcrumbs.- Fixes
ThreadFeedscroll behavior: initial and underflow states auto-scroll to the correct resting position; the floating composer inset and gap are now correctly accounted for in scroll calculations.- Fixes
StackHeader/NativeStackScreenOptionsto callnavigation.setOptionsonly when a structural signature of options changes, using stable function references for header item factories to avoid unnecessary re-renders.- Adds retry logic in
ThreadRouteScreenfor stalled thread-detail loads: retries twice after 8s/12s then surfaces a user-facing error.- Fixes
buildProjectThreadStartTurnInputanduseThreadOutboxDrainto strip client-only fields (id,previewUri) from image attachments before sending.- Fixes shell and thread sync state to restore
livestatus after reconnect when cached data exists, without requiring new stream events.- Behavioral Change:
setReadyin shell and thread state now sets status tolive(notsynchronizing) when a cached snapshot/data is present on reconnect.Macroscope summarized f347d3e.
[!NOTE] High Risk Touches startup crash hooks, AppDelegate prebuild mutation, large LegendList patches, and navigation setOptions behavior—areas that can affect Release stability and scroll correctness across thread screens.
Overview Backports iOS runtime and chat reliability fixes: durable crash diagnostics, thread feed scroll/composer layout, reconnect and detail-loading behavior, and smaller native/JS hardening.
Crash logging loads first via
installCrashLog, wrapsErrorUtilsand unhandled rejections, writes minimal then full JSON toDocuments/crash-logs/using nativewriteSyncText(fsync), and records nav/outbox/stop breadcrumbs with debounced disk flush. An Expo plugin patches AppDelegate to hookRCTFatal/ fatal exceptions into the same persistence path when JS never flushes.Thread UI tracks content height and composer overlay, adds a composer gap, corrects short-content underflow vs transparent-header insets (LegendList patch +
contentInsetStartAdjustment), shows a loading overlay while hydrating, fixes screenshot attachments (stable layout,Pressable,overFullScreenviewer), and enablesfillWidthon native markdown. T3MarkdownText rebuilds attributed content on everylayout()instead of caching measure-only state so text does not disappear when Yoga skipsmeasureContent.Navigation skips redundant
setOptionswhen a structural signature of stack options is unchanged (avoids Release “maximum update depth” loops). Thread detail retries stalled loads (8s/12s) then surfaces an error; shell/thread syncsetReadyrestoreslivewhen cached data exists after reconnect.startTurn/ outbox sends strip client-only image fields viatoUploadChatImageAttachments. SharedcauseFailureMessageimproves error text in queries and thread state.Reviewed by Cursor Bugbot for commit f347d3e05aad99b560b74496c908aaf4520c28c0. Bugbot is set up for automated code reviews on this repo. Configure here.
[!IMPORTANT]
Review skipped
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
c929b582-a5c9-460d-8044-e963727b051dYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- [ ] 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Approvability
Verdict: Needs human review
Diff is too large for automated approval analysis. A human reviewer should evaluate this PR.
You can customize Macroscope's approvability policy. Learn more.
Simulator layout evidence (Release Hermes)
1. Transparent header: first message not cut off
Scrolled to the top of a screenshot thread. The first user bubble (prompt + attached screenshot) is fully below the nav chrome; nothing is clipped under the transparent header.

2. Floating composer: content stays above the input
Short screenshot thread after send. Message body and reply sit above the floating composer with clear gap; content is not trapped under the input bar.

All captures: iPhone Simulator, Release + Hermes, ios-fixes-main validation.
I hit the same persistent “Syncing messages…” state on a physical iPhone with a warm cached thread and no new events after reconnect.
Your reconnect work is directly relevant. In our trace, the server had attached the catch-up + live subscription successfully, but emitted zero frames because the cache was current, so the client had no positive completion signal. We validated a small protocol-level completion marker emitted once the live subscription is attached; it lets a cached thread transition to live without retransmitting its full body. Happy to contribute that as a focused follow-up if it remains useful after this PR lands.
I hit the same persistent “Syncing messages…” state on a physical iPhone with a warm cached thread and no new events after reconnect.
Your reconnect work is directly relevant. In our trace, the server had attached the catch-up + live subscription successfully, but emitted zero frames because the cache was current, so the client had no positive completion signal. We validated a small protocol-level completion marker emitted once the live subscription is attached; it lets a cached thread transition to live without retransmitting its full body. Happy to contribute that as a focused follow-up if it remains useful after this PR lands.
Hi, if you have time I'd be interested to see a PR with this one as a base branch, which includes the steps to repro it consistently. I haven't come across it yet organically myself. If this PR gets merged first, GitHub should automatically change base to master.
I hit the same persistent “Syncing messages…” state on a physical iPhone with a warm cached thread and no new events after reconnect. Your reconnect work is directly relevant. In our trace, the server had attached the catch-up + live subscription successfully, but emitted zero frames because the cache was current, so the client had no positive completion signal. We validated a small protocol-level completion marker emitted once the live subscription is attached; it lets a cached thread transition to live without retransmitting its full body. Happy to contribute that as a focused follow-up if it remains useful after this PR lands.
Hi, if you have time I'd be interested to see a PR with this one as a base branch, which includes the steps to repro it consistently. I haven't come across it yet organically myself. If this PR gets merged first, GitHub should automatically change base to master.
Will do Mike. Let me get back to you shortly.
@twistedgrim Thanks for filing this and for the PR. I squash-merged your branch onto ios-fixes-main as mwolson/t3code#2 (Confirm resumed thread subscriptions (#2)), then landed two follow-ups on the same branch so the protocol idea is production-safe and so a separate Home-list flash does not get mixed into that change.
Gate commit (your thread-sync idea, hardened)
fix(orchestration): Gate thread resume sync marker after catch-up
Your diagnosis still holds: a warm resume with empty catch-up can attach the live subscription and emit zero frames, so the client has no positive "caught up" signal.
On top of your marker, this commit:
- Emits
{ kind: "synchronized" }on thread resume (afterSequence), not shell. - Orders the stream as catch-up → synchronized → live, so the UI can stay on "Syncing…" until catch-up is applied, then flip to live once (better for short 1–5s catch-up than going live first and rewriting rows as events arrive).
- Uses two-way expand/contract:
- Server advertises
threadResumeCompletionMarkeronServerConfig. - Client only requests
requestCompletionMarkerwhen that is present. - Server only emits the marker when requested (old clients never see an unknown
kindand hard-fail decode).
- Server advertises
- Keeps the warm-cache ready fallback when the server does not advertise the marker, so a new client against an old serve does not stick on Syncing forever.
- While the marker is expected, catch-up snapshots/events update data but keep status
synchronizinguntil the marker arrives. - Covers the residual path where an in-band expected-failure retry leaves the supervisor connected, demotes to
cached, and empty resubscribe would otherwise never go live.
I also hit a real bug in the original tip: the marker was only wired on the shell resume path while the contracts/client/test targeted thread resume (the server test timed out with empty replay). That is fixed here.
Shell-hold commit (separate Home UX; not part of your PR)
fix(client-runtime): Hold shell list until server heal on reconnect
This is unrelated to the thread-detail marker. While retesting on device I saw Home briefly balloon with many more threads, then shrink after the HTTP shell heal. That came from painting a stale warm disk shell snapshot (often inflated active membership after a dropped archive delta) before the authoritative heal.
This commit:
- Does not paint disk shell into the visible list when online before heal.
- Holds any existing server-backed list while reconciling.
- Still uses disk as offline / heal-failure fallback only.
Kept as its own commit so your protocol work stays reviewable on its own.
Happy to take further notes if you still see sticky Syncing on a build that includes both the squash and the gate commit.