Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): Stabilize thread feed layout and Markdown rendering #4036

Closedjuliusmarmingewants to merge 9 commits intomain fromrefs/pull/4036/headopened View on GitHub

juliusmarmingecommented

Extracted from #3910.

Fixes native selectable Markdown width and stale-content behavior, keeps screenshots interactive, and stabilizes floating-composer spacing, short-content positioning, and hydration layout in the thread feed. Includes the required LegendList patch and regenerated lockfile.

Validation inherited from #3910: vp check and mobile native lint passed before the split. The full typecheck is currently blocked in this workspace by unavailable mobile dependencies (expo-blur, expo-quick-actions, and @tabler/icons-react-native).

Note

Stabilize thread feed scroll layout and fix Markdown rendering in iOS

  • Fixes thread feed scroll position when content is shorter than the viewport by anchoring content under translucent headers and scrolling to end when content grows to fill the viewport.
  • Adds a fillWidth prop to SelectableMarkdownText so assistant markdown messages stretch to fill the full row width.
  • Refactors T3MarkdownTextShadowNode to derive content via buildContent and gate state updates with equality checks, preventing redundant re-renders.
  • Patches @legendapp/list to improve end-scroll maintenance, initial scroll readiness, and keyboard-aware inset handling near translucent headers.
  • Adds measured composer overlay height tracking in ThreadDetailScreen to produce a stable resting inset above the composer.
  • Behavioral Change: maintainScrollAtEnd is disabled while content underflows the viewport; scroll position is instead managed by a requestAnimationFrame loop.
Macroscope summarized 1cd97c7.

Note

Medium Risk Large changes to vendored list scroll math and native Fabric text state on a core chat screen; regressions would show as wrong scroll position, jank, or missing markdown rather than data/security issues.

Overview Thread feed and composer insets — The detail screen now tracks measured floating-composer overlay height, adds a fixed gap above the chrome, and passes that through keyboard/LegendList inset hooks (heightAdjustment, contentInsetEndEstimate). ThreadFeed detects when content is shorter than the viewport, pins scroll under the translucent header, turns off maintainScrollAtEnd in that case, and shows a loading overlay while hydrating without remounting the list on draft→thread transitions.

Native selectable markdown — iOS T3MarkdownTextShadowNode stops caching measure-time text in mutable fields; it rebuilds content from children in layout() and only updates native state when attributed text/ranges actually change, fixing dropped/stale text when Yoga layouts without remeasuring. A new optional fillWidth prop stretches assistant markdown rows so they reflow correctly in shrink-to-fit layouts.

LegendList patch — Extends the vendored @legendapp/list keyboard integration for leading inset (transparent header), safe-area end-inset compensation, short-content scroll clamping, and more reliable initial/end scroll behavior; lockfile patch hash updated.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1cd97c7a8911a639dc6608d40673adeb3e8b627b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 7bb6af15-1007-4f8d-9a16-772c36b7da18

      You can disable this status message by setting the reviews.review_status to false in 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

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. apps/mobile/src/features/threads/ThreadFeed.tsx line 1413OutdatedResolvedby juliusmarminge
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This bug fix touches native iOS C++ layout code and includes substantial patches to the @legendapp/list third-party library affecting scroll behavior calculations. While the author is the primary maintainer of these files, native code changes and third-party patches to rendering infrastructure warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. juliusmarminge added labels🚀 Mobile Continuous Deployment

    6. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1cd97c7a8911a639dc6608d40673adeb3e8b627b. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -255,3 +259,21 @@
      255259 const composerOverlapHeight = composerChrome + composerBottomInset;
      256260 const activeWorkIndicatorHeight = props.activeWorkStartedAt ? WORKING_INDICATOR_HEIGHT : 0;
      257261 const estimatedOverlayHeight = composerOverlapHeight + activeWorkIndicatorHeight;
      262+ const [composerOverlayHeight, setComposerOverlayHeight] = useState(estimatedOverlayHeight);
      263+ const estimatedOverlayHeightRef = useRef(estimatedOverlayHeight);
      264+ useEffect(() => {
      265+ estimatedOverlayHeightRef.current = estimatedOverlayHeight;
      266+ }, [estimatedOverlayHeight]);
      267+ useEffect(() => {
      268+ // A measured overlay can include approval or input cards that are not part
      269+ // of this baseline estimate. Keep that larger measurement until layout
      270+ // reports a new height, while ensuring chrome changes never under-estimate
      271+ // the composer inset.
      272+ setComposerOverlayHeight((current) => Math.max(current, estimatedOverlayHeight));
      273+ }, [estimatedOverlayHeight]);
      274+ useEffect(() => {
      275+ // Layout callbacks from the previous thread can arrive after navigation.
      276+ // Reset their larger measurement to this thread's known baseline; its own
      277+ // overlay layout will immediately replace it if it contains extra cards.
      278+ setComposerOverlayHeight(estimatedOverlayHeightRef.current);
      279+ }, [selectedThreadKey]);

      Thread switch inset desync

      Medium Severity

      On selectedThreadKey change, composerOverlayHeight resets to the new thread’s baseline, but contentInsetEndAdjustment (the keyboard hook SharedValue) is not updated. Until the new composer lays out, contentInsetEndEstimate reflects the new thread while list end-inset math and the remount reportContentInset call still use the previous thread’s larger value.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1cd97c7a8911a639dc6608d40673adeb3e8b627b. Configure [here](https://www.cursor.com/dashboard/bugbot).
    7. Note

      🤖 Codex responding on behalf of Theo

      Closing this older feed/layout branch after the mobile changes in #5986, #8793, and #9195. The native Markdown changes that rebuild content during layout to avoid stale text and enforce full width may still be useful, and are worth a smaller PR against current main. Thank you for the work on feed stability, text rendering, and the supporting native patches. If we have overlooked a remaining problem that needs this branch, please reopen it or leave a comment so we can reopen it.

Sign in to join this conversation.