GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(mobile): Harden iOS reconnect, crash capture, and chat layout on main by mwolson · Pull Request #3910 · pingdotgg/t3code Conversation
|
| 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. |
Warm-cache afterSequence resume could skip a dropped archive upsert after later shell events advanced snapshotSequence, so archived threads stayed on Home until a full resync. |
Always HTTP-heal the shell snapshot (or force a full socket snapshot if HTTP fails) before resuming live deltas; reject non-authoritative full snapshots older than the current sequence. |
| Warm thread detail resume with an up-to-date cache can replay zero catch-up frames, so the client never got a positive "live buffer attached" signal and could stick on Syncing (especially after in-band expected-failure retry while the supervisor stayed connected). | Opt-in { kind: "synchronized" } on thread resume after catch-up: server advertises ServerConfig.threadResumeCompletionMarker, client requests requestCompletionMarker only when advertised, and status stays synchronizing until the marker (legacy servers keep warm setReady promotion). Seeded from contributor work in mwolson#2; emission corrected to subscribeThread. |
| Stale disk active membership painted into Home before the server heal on reconnect, so archived or ghost threads could flash then shrink away. | Hold the list empty or the previous server-backed snapshot until HTTP heal (or an authoritative socket snapshot); only use disk when truly offline or when heal fails and nothing else is available. |
On Android, opening the keyboard right after a thread open could grow the composer before keyboard onStart, so delta-based scroll compensation zeroed out and the last messages stayed behind the input. |
Patch react-native-keyboard-controller chat keyboard path: when the list is anchored at the end, target the live end of the scroll range (including current composer padding) each frame; re-assert the settled target after the animation ends; keep iOS platform files unchanged for this race. |
| 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. |
New server emitting { kind: "synchronized" } without opt-in would hard-fail decode on older clients; new clients against old servers would wait forever if the warm ready path were removed. |
Emit the marker only when subscribe input requests it; advertise support via optional ServerConfig.threadResumeCompletionMarker; request the marker only when advertised. |
Ordinary reconnect cleared awaitingCompletion on disconnect, then setReady could promote to live before the next marker arrived (review follow-up). |
Sticky markerMode for the life of the thread state; re-arm awaitingCompletion on every setSynchronizing and on stream errors while marker mode is active. |
Online connect often has session: None while the lease opens. Treating that as offline still painted disk into Home before heal (review follow-up on the shell hold path). |
Do not apply disk on session absence alone. Apply disk only from true disconnect (setDisconnected) or when a live session fails HTTP heal and needs a provisional list before the socket snapshot. |
This affects thread loading feedback, screenshot messages and their viewer, transparent-header scrolling, the floating composer (including Android keyboard open), and Home membership during reconnect (no stale disk flash before heal).
Focused Simulator layout evidence (two after-state shots only): #3910 (comment)
vp check: passvp run typecheck: passlast-crash.json with source: "rct-fatal" and the JS exception message (verified for maximum update depth on Thread)PreventRemoveProvider abortopening_brace fix for T3CrashLog (CI Mobile Native Static Analysis)shell-sync): passthreads-sync + server empty resume / no-request omit): passthreads-sync): passshell-sync): passcom.mwolson.t3code.main.dev)PreventRemoveProvider abort (see Validation).afterSequence from lastSequence on each resubscribe attempt (optional follow-up)Note
High Risk
Large cross-cutting change touching shell/thread sync semantics, native AppDelegate hooks, and layout-critical chat paths; incorrect heal or marker handling could strand UI in syncing or show wrong Home membership.
Overview
Hardens iOS/mobile reconnect, Release crash diagnosis, and thread chat layout in one pass.
Crash capture loads installCrashLog before the app graph, adds JS ErrorUtils + unhandled-rejection persistence with breadcrumbs (nav, outbox, thread stop), debounced disk flush, and native fsync via T3NativeControls plus an AppDelegate plugin that hooks RCTFatal so last-crash.json survives Hermes abort.
Sync protocol adds opt-in { kind: "synchronized" } on thread resume (ServerConfig.threadResumeCompletionMarker + requestCompletionMarker); client stays synchronizing until the marker. Shell sync no longer paints disk on startup—HTTP heal first, authoritative socket snapshots, reject stale full snapshots—so archived threads don’t flash on Home after dropped archive deltas.
Thread UI improves feed scroll (composer gap, underflow correction, loading overlay), screenshot tappability, stalled detail retries, fillWidth markdown, native shadow node rebuilds content on layout, and native stack setOptions only when a structural signature changes (avoids PreventRemoveProvider infinite loops). Composer images strip draft fields for startTurn wire shape.
Reviewed by Cursor Bugbot for commit 2ec85a8. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
installCrashLog) that intercepts global JS errors and unhandled rejections, persisting minimal and full crash records (including breadcrumbs) via a native sync write or Expo FS fallback; an Expo config plugin modifies AppDelegate.swift to also intercept native RN fatal handlerscrash-logs/last-breadcrumbs.json, with navigation state changes and outbox dispatches recording breadcrumbssynchronized stream marker protocol: the server emits { kind: 'synchronized' } after catch-up when requestCompletionMarker is set, and the client holds thread state as synchronizing until the marker arrives, preventing false-live status after reconnectsynchronizing without painting disk state, attempt HTTP heal first, and only use cached disk state as a provisional fallback when offline or when HTTP heal fails; rejects stale full socket snapshots unless marked authoritativeThreadFeed chat layout by measuring content height and correcting underflow via auto-scroll, adding a THREAD_FEED_COMPOSER_GAP above the floating composer, and showing a loading overlay during hydrationStackHeader.NativeStackScreenOptions to only call navigation.setOptions when the structural signature of options changes, using stable-identity wrappers for header item factoriesT3MarkdownTextShadowNode to build content fresh from children on each layout rather than relying on cached mutable members, preventing stale or dropped textsynchronizing state briefly before the HTTP heal completes where they previously saw stale cached content immediatelyMacroscope summarized 2ec85a8.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium
The onScrollBeginDrag wrapper is created inside a useMemo(..., []) that captures the initial onScrollBeginDrag prop. If a parent passes a new callback after mount, drag events continue invoking the stale closure — the prop update is silently ignored. Store the latest callback in a ref or include onScrollBeginDrag in the memo dependencies.
In file @patches/@[email protected] around line 951:
The `onScrollBeginDrag` wrapper is created inside a `useMemo(..., [])` that captures the initial `onScrollBeginDrag` prop. If a parent passes a new callback after mount, drag events continue invoking the stale closure — the prop update is silently ignored. Store the latest callback in a ref or include `onScrollBeginDrag` in the memo dependencies.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: codex <[email protected]>
366f0e0 to
bfd9ca3
Compare
There was an error while loading. Please reload this page.
|
|
||
| let cancelled = false; | ||
| let timer: ReturnType<typeof setTimeout> | null = null; | ||
| const scheduleRetry = () => { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium threads/ThreadRouteScreen.tsx:199
The stall error appears after ~40s, not the ~20s implied by THREAD_DETAIL_STALL_ERROR_DELAY_MS. After two failed retries (8s + 12s), scheduleRetry() schedules the error after an additional 20s, so a permanently empty detail doesn't show detailLoadError until roughly 40 seconds. When the retry limit is reached, set the stalled state immediately instead of scheduling another timeout.
In file @apps/mobile/src/features/threads/ThreadRouteScreen.tsx around line 199:
The stall error appears after ~40s, not the ~20s implied by `THREAD_DETAIL_STALL_ERROR_DELAY_MS`. After two failed retries (8s + 12s), `scheduleRetry()` schedules the error after an additional 20s, so a permanently empty detail doesn't show `detailLoadError` until roughly 40 seconds. When the retry limit is reached, set the stalled state immediately instead of scheduling another timeout.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| void props.listRef.current?.scrollToOffset({ | ||
| animated: false, | ||
| offset: -anchorTopInset, | ||
| }); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium threads/ThreadFeed.tsx:1439
When usesNativeAutomaticInsets is false, the underflow correction scrolls to -anchorTopInset, but that same inset is already rendered as the ListHeaderComponent spacer. This double-counts the header inset and positions a short conversation at a negative overscroll offset instead of resting at offset 0. The negative offset should only be used for native automatic-inset layouts where the header inset lives in UIKit's adjustedContentInset and is absent from contentHeight.
| void props.listRef.current?.scrollToOffset({ | |
| animated: false, | |
| offset: -anchorTopInset, | |
| }); | |
| void props.listRef.current?.scrollToOffset({ | |
| animated: false, | |
| offset: usesNativeAutomaticInsets ? -anchorTopInset : 0, | |
| }); |
In file @apps/mobile/src/features/threads/ThreadFeed.tsx around lines 1439-1442:
When `usesNativeAutomaticInsets` is false, the underflow correction scrolls to `-anchorTopInset`, but that same inset is already rendered as the `ListHeaderComponent` spacer. This double-counts the header inset and positions a short conversation at a negative overscroll offset instead of resting at offset `0`. The negative offset should only be used for native automatic-inset layouts where the header inset lives in UIKit's `adjustedContentInset` and is absent from `contentHeight`.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
ApprovabilityVerdict: 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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Capture RCTFatal message and stack to Documents via a native handler so Release Hermes aborts leave last-crash.json without a device console. Harden the JS ErrorUtils path with a minimal write-first record, durable fsync writes, breadcrumb max-wait flush, and an Expo AppDelegate plugin. Skip NativeStackScreenOptions setOptions when content is unchanged so Thread catch-up re-renders do not loop through PreventRemoveProvider and hit maximum update depth.
| return ""; | ||
| } | ||
| const record = options as Record<string, unknown>; | ||
| return stableJsonStringify({ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium native/nativeStackOptionsSignature.ts:12
buildNativeStackOptionsSignature omits fields like headerShown, headerTransparent, presentation, and gestureEnabled. When a caller changes one of these omitted options while the included fields stay the same, the signature is identical, so the skip logic suppresses setOptions and the screen keeps stale options. Consider including all NativeStackNavigationOptions fields in the signature (or documenting why only this subset is tracked).
apps/mobile/src/native/StackHeader.tsx:114
The signature cache is not scoped to
navigation: when the navigation object/context changes whileprops.optionshas the same signature, this effect reruns but returns at the signature check before calling the new navigator'ssetOptions. The replacement navigator therefore never receives this component's screen options. Reset/cache the signature per navigation object or perform the comparison only after accounting fornavigation.
In file @apps/mobile/src/native/nativeStackOptionsSignature.ts around line 12:
`buildNativeStackOptionsSignature` omits fields like `headerShown`, `headerTransparent`, `presentation`, and `gestureEnabled`. When a caller changes one of these omitted options while the included fields stay the same, the signature is identical, so the skip logic suppresses `setOptions` and the screen keeps stale options. Consider including all `NativeStackNavigationOptions` fields in the signature (or documenting why only this subset is tracked).
Also found in 1 other location(s):
- apps/mobile/src/native/StackHeader.tsx:114 -- The signature cache is not scoped to `navigation`: when the navigation object/context changes while `props.options` has the same signature, this effect reruns but returns at the signature check before calling the new navigator's `setOptions`. The replacement navigator therefore never receives this component's screen options. Reset/cache the signature per navigation object or perform the comparison only after accounting for `navigation`.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| </View> | ||
| ) : null} | ||
| {props.contentPresentation.kind === "loading" ? ( | ||
| <View pointerEvents="none" className="bg-screen" style={StyleSheet.absoluteFill}> |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium threads/ThreadFeed.tsx:1890
The loading overlay sets pointerEvents="none", so taps pass through to the still-mounted feed underneath while only the "Loading messages" placeholder is visible. Users can unknowingly activate hidden links, image viewers, or disclosure controls at the tapped coordinates. Consider removing pointerEvents="none" so the overlay intercepts input and blocks interaction with the hidden feed.
| <View pointerEvents="none" className="bg-screen" style={StyleSheet.absoluteFill}> | |
| <View className="bg-screen" style={StyleSheet.absoluteFill}> |
In file @apps/mobile/src/features/threads/ThreadFeed.tsx around line 1890:
The loading overlay sets `pointerEvents="none"`, so taps pass through to the still-mounted feed underneath while only the "Loading messages" placeholder is visible. Users can unknowingly activate hidden links, image viewers, or disclosure controls at the tapped coordinates. Consider removing `pointerEvents="none"` so the overlay intercepts input and blocks interaction with the hidden feed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
CI Mobile Native Static Analysis failed on a multi-line if where the opening brace was on the following line.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Simulator layout evidence (Release Hermes)1. Transparent header: first message not cut offScrolled 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 inputShort 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, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Warm-cache afterSequence resume can skip a dropped thread.archived delta after later events advance snapshotSequence, leaving archived threads on the home list. Always HTTP-heal (or force a full socket snapshot) before resuming live shell deltas, and reject stale full snapshots from the stream.
There was an error while loading. Please reload this page.
When HTTP shell heal fails, the full socket snapshot is the membership source of truth. Accept that first snapshot even if its sequence is behind the warm disk cache so ghost active threads cannot stick.
There was an error while loading. Please reload this page.
A prior session can arm acceptNextSocketSnapshotAuthoritatively when HTTP heal fails and then disconnect before the socket snapshot arrives. Clear the flag on a successful HTTP heal so a later reconnect does not treat stale enrichment snapshots as authoritative.
waitForJsonLogMatch only yieldNow'd between attempts, so under busy CI it could return before the ACP mock agent wrote session/cancel. Use a real wall-clock delay (not TestClock sleep) and fail explicitly on timeout.
CI Check treats setTimeout as an Effect lint error. Keep wall-clock delays via a diagnostics-scoped helper, fail with a tagged timeout, and avoid TestClock-bound Effect.sleep so ACP mock log polls still work under load.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.