Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): stabilize thread composer and interactions #5986

Mergedjuliusmarmingemerged 47 commits intomain fromrefs/pull/5986/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

What changed

  • Keep the floating composer anchored after keyboard dismissal on iOS and Android.
  • Stop live-feed updates from pulling users back to the end while they are reading history.
  • Add a floating scroll-to-end control that uses the same keyboard-aware LegendList path.
  • Bound long pending-input forms to the viewport, keep their actions reachable, and preserve multi-select answers.
  • Add focused tests for live-follow, pending-input layout, and answer shaping.

This consolidates #5118 and #5915 into #5986 as the single branch to test and merge. Their original commit authorship is preserved.

Closes #5434.

Why

Several mobile thread interactions shared the same keyboard, overlay, and end-follow boundaries. Testing them together catches the real integration behavior: the composer stays attached to the keyboard, user-driven scrolling remains respected, the return-to-end affordance reflects that same state, and pending input remains usable in the remaining viewport.

Validation

  • vp test run apps/mobile/src/features/threads/thread-feed-live-follow.test.ts apps/mobile/src/features/threads/pendingUserInputLayout.test.ts apps/mobile/src/lib/threadActivity.test.ts — 24 tests passed.
  • vp run --filter @t3tools/mobile typecheck passed.
  • Targeted vp lint --report-unused-disable-directives passed for all changed TypeScript files.
  • node scripts/mobile-native-static-check.ts passed SwiftLint, ktlint, and detekt.
  • vp fmt --check passed for all changed files.
  • React Doctor scoped to the diff scored 88/100; the four remaining findings are non-blocking heuristics for the intentionally bounded question scroller, existing screen size, thread-switch reset, and a tiny normalization pass.

UI evidence

Pending input: before, after, and scroll video.

Scroll-to-end: Android interaction video.

Manual test plan

  1. Open and dismiss the keyboard repeatedly; confirm the composer returns to the bottom.
  2. Scroll upward while an agent is streaming; confirm new activity does not interrupt reading.
  3. Tap the down-arrow during and after momentum; confirm the thread returns to the end and the button disappears.
  4. Exercise a long pending-input request with single- and multi-select questions while the keyboard is open and closed.
  5. Repeat the keyboard and scrolling cases on both iOS and Android.

Model: GPT-5. Harness: Codex.

Note

Stabilize mobile thread composer, user input card, and settings navigation

  • Rewrites PendingUserInputCard as an animated collapsible overlay that replaces the composer while a user-input request is active; supports multi-select options and reports coverage via a SharedValue to drive feed inset adjustments
  • Adds event-driven resolveThreadFeedLiveFollow state machine to ThreadFeed that correctly distinguishes user-initiated from programmatic scrolls and exposes a scroll-to-end control pill when not following
  • Restructures the settings sheet navigation stack so SettingsContent is nested inside SettingsSheetStack, and removes the ClerkSettingsSheetDetent context throughout
  • On iOS, thread settings are now presented as a native context menu on the composer toolbar pill (with haptic feedback), replacing the modal sheet path
  • Patches @legendapp/list to 3.3.5 and react-native-screens with fixes for scroll-to-end fallback, anchored end space, MVCP, and header bar button caching to prevent UI glitches
  • Patches @react-native-menu/menu to support three-level submenus, keepsMenuPresented on actions, and live in-place menu updates without dismissal
  • Risk: buildPendingUserInputAnswers now returns string | ReadonlyArray<string> per question; callers that assume a single string will break
Macroscope summarized 401afe7.

Note

Medium Risk Touches core thread scrolling, keyboard overlays, and settings/Clerk navigation with vendored list patches; behavior is integration-heavy though covered by new unit tests and the PR’s manual plan.

Overview Thread experience gets the bulk of the work: live-follow now uses an explicit scroll-event resolver so streaming updates stop yanking readers off history, with a floating scroll-to-end control wired to the same follow state. While a user-input request is active, the composer slot is replaced by a collapsible questionnaire (iOS overlay + UI-thread collapse; Android in-flow), with viewport-bounded height, multi-select answers, and combined feed insets so the transcript stays aligned.

Keyboard and composer fixes include iOS safe-area padding keyed on composer focus (not keyboard visibility), Android resume quarantine for stale IME height, KeyboardStickyView on the new-task draft composer, and optional onEditorFocusChange hooks. On iOS, everyday thread settings can change from a native toolbar menu without dismissing the keyboard.

Settings navigation is restructured: settings screens live in a nested SettingsContent stack inside a headerless outer sheet stack so Clerk auth can own chrome without iOS 26 header jumps; ClerkSettingsSheetDetent is removed and deep links navigate through SettingsContent. Clerk Expo is patched so auth/profile back can pop the native stack first.

Dependencies: @legendapp/list moves to the catalog version with expanded patches (composer insets, transparent-header scroll clamps, anchored-end-space). App update checks skip Metro/dev-client and treat known Expo “unavailable” errors as no-ops. ControlPill gains press-in activation for snappier scroll-to-end taps.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 401afe72b0a7c6035fcbb2df1768f95a399619bf. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. 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 Plus

      Run ID: 0a6d9639-03a9-4925-9e0c-110376cd6281

      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

      Comment `@coderabbitai help` to get the list of available commands.
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/2059ed7607ddfef5685ac881395b396cee3d1684/apps/mobile/src/features/threads/ThreadFeed.tsx#L36

      handleScroll re-arms endFollowEnabled while a user drag session is still active. When the user starts a drag at the end of the list, handleScrollBeginDrag dispatches user-scroll-begin to disable follow, but the very next onScroll event — fired before the offset has left the at-end tolerance — calls transitionEndFollow with isAtEnd: true, which immediately re-enables follow. A streaming or layout update arriving in that interval can then run maintainScrollAtEnd and yank the user back to the end, defeating the purpose of the follow-breaking logic. The scroll branch in resolveThreadFeedLiveFollow should not re-arm follow while userScrollSessionActive is true — only after the session ends should an at-end scroll re-engage follow.

      ✅ Resolved in 53cdcb7100cbefb2a067d9177cc7c01df58522ec

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

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire11.3 KiB11.3 KiB−22 B (−0.2%)15.1 KiB✅
      CodexThread snapshot wire5.5 KiB5.5 KiB+3 B (+0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire5.9 KiB5.9 KiB−25 B (−0.4%)7.8 KiB✅
      CodexLive turn WebSocket decoded49.7 KiB49.7 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages16160 (0.0%)21✅
      ClaudeTotal thread wire11.3 KiB11.3 KiB+5 B (+0.0%)15.1 KiB✅
      ClaudeThread snapshot wire5.5 KiB5.5 KiB−6 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire5.8 KiB5.9 KiB+11 B (+0.2%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded50.6 KiB50.6 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages16160 (0.0%)21✅

      Baseline: f5fce74 · PR result: 401afe7 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 94.6 KiB
      • Claude decoded thread snapshot: 95.4 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. apps/mobile/src/features/threads/ThreadDetailScreen.tsx line 394OutdatedResolvedby juliusmarminge
    6. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      5 blocking correctness issues found. This PR introduces substantial new mobile capabilities including collapsible user input cards, scroll-to-end buttons with iOS 26 glass effects, native iOS menus, and complex platform-specific keyboard handling - not a simple stabilization. Five high-severity correctness issues were identified regarding viewport overflow, bar button item loss, keyboard state handling, and environment-scoped thread keys.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    7. juliusmarminge changed the title

    8. @@ -204,3 +226,4 @@
      204226 const selectedThreadFeed = props.selectedThreadFeed;
      205227 const composerChrome = composerExpanded ? COMPOSER_EXPANDED_CHROME : COMPOSER_COLLAPSED_CHROME;
      206228 const composerOverlapHeight = composerChrome + composerBottomInset;
      229+ const pendingUserInputMaxHeight = derivePendingUserInputMaxHeight({
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High threads/ThreadDetailScreen.tsx:229

      derivePendingUserInputMaxHeight clamps the computed available height to a 160px minimum, so on a short or landscape phone with the keyboard open, the card can be 160px tall even when the true available space is far smaller (or negative). Because the card is inside a bottom-anchored overlay that is not itself scrollable, the top of the form is pushed off-screen and its initial questions are unreachable. Additionally, when both activePendingApproval and activePendingUserInput are non-null, the max-height calculation does not subtract the simultaneously rendered PendingApprovalCard, so the overlay holds both cards plus its gap and overflows the viewport, pushing controls or the composer off-screen. Consider allowing the card to shrink below 160px when space is constrained, and subtract the approval card's height from the available space when both are present.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/mobile/src/features/threads/ThreadDetailScreen.tsx around line 229:
      
      `derivePendingUserInputMaxHeight` clamps the computed available height to a 160px minimum, so on a short or landscape phone with the keyboard open, the card can be 160px tall even when the true available space is far smaller (or negative). Because the card is inside a bottom-anchored overlay that is not itself scrollable, the top of the form is pushed off-screen and its initial questions are unreachable. Additionally, when both `activePendingApproval` and `activePendingUserInput` are non-null, the max-height calculation does not subtract the simultaneously rendered `PendingApprovalCard`, so the overlay holds both cards plus its gap and overflows the viewport, pushing controls or the composer off-screen. Consider allowing the card to shrink below 160px when space is constrained, and subtract the approval card's height from the available space when both are present.
    9. github-actions[bot](GitHub profile, opens in a new tab) added labels📱 Native Change

    10. @@ -239,11 +269,14 @@
      269++ navitem.leftBarButtonItems = nil;
      270++ navitem.rightBarButtonItems = nil;
      271++ } else {
      272++ navitem.leftBarButtonItems = leftBarButtonItems;
      273++ navitem.rightBarButtonItems = rightBarButtonItems;
      239274 + }
      240-+ navitem.leftBarButtonItems = nil;
      241-+ navitem.rightBarButtonItems = nil;
      242-+ } else {
      275++#else
      243276 + navitem.leftBarButtonItems = leftBarButtonItems;
      244277 + navitem.rightBarButtonItems = rightBarButtonItems;
      245-+ }
      246-+#else
      247-+ navitem.leftBarButtonItems = leftBarButtonItems;
      248-+ navitem.rightBarButtonItems = rightBarButtonItems;
      249278 +#endif
      279++ // Only dict-driven items can be reused: with subview-backed items in the
      280++ // mix the applied state depends on view identity, so clear the key to
      281++ // force a rebuild on the next pass.
      282++ objc_setAssociatedObject(
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High patches/react-native-screens@4.25.2.patch:282

      On iOS 16+, when subview-backed bar button items are present, the rebuild path copies navitem.leftBarButtonItems/rightBarButtonItems into item groups and then sets those properties to nil. On the next header update, reuseHeaderBarButtonItems is false (the associated key was cleared), so the code rebuilds from the now-empty leftBarButtonItems/rightBarButtonItems — the subview-backed items are lost and disappear from the header. The subview items should be preserved or re-derived separately instead of read from properties that this block sets to nil.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @patches/react-native-screens@4.25.2.patch around line 282:
      
      On iOS 16+, when subview-backed bar button items are present, the rebuild path copies `navitem.leftBarButtonItems`/`rightBarButtonItems` into item groups and then sets those properties to `nil`. On the next header update, `reuseHeaderBarButtonItems` is false (the associated key was cleared), so the code rebuilds from the now-empty `leftBarButtonItems`/`rightBarButtonItems` — the subview-backed items are lost and disappear from the header. The subview items should be preserved or re-derived separately instead of read from properties that this block sets to `nil`.
    11. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/2cf4d8c89a9dfded2bc9376037aedf7e7554fd82/patches/react-native-screens@4.25.2.patch#L786

      A negative index value (e.g. -1) in a searchBarPlacement config causes a crash. The code checks index.integerValue < items.count but does not reject negative values, so -1 passes the check and is converted to a huge NSUInteger by insertObject:atIndex:, triggering an out-of-bounds exception. Add a >= 0 guard alongside the upper-bound check.

      No longer relevant as of 17b38207c84ad98f72430839df0f336d77d30af4

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

      🟠 High

      https://github.com/pingdotgg/t3code/blob/1092d7ed403821f9d9a4e5a29f24cbdb32b074fa/apps/mobile/src/features/threads/ThreadDetailScreen.tsx#L402

      When switching to a thread in a different environment that happens to share the same ThreadId, ThreadFeed is not remounted (it is keyed by threadId alone), so its internal endFollowEnabled latch keeps its previous value. Meanwhile this effect unconditionally sets the parent endFollowEnabled back to true, hiding the scroll-to-end button. The result is that the feed can remain in an unfollowed state with no visible control to return to the end. Consider keying ThreadFeed by scopedThreadKey (or resetting the latch via the existing onEndFollowEnabledChange callback) so the child latch and parent state stay in sync across environment switches.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/mobile/src/features/threads/ThreadDetailScreen.tsx around line 402:
      
      When switching to a thread in a different environment that happens to share the same `ThreadId`, `ThreadFeed` is not remounted (it is keyed by `threadId` alone), so its internal `endFollowEnabled` latch keeps its previous value. Meanwhile this effect unconditionally sets the parent `endFollowEnabled` back to `true`, hiding the scroll-to-end button. The result is that the feed can remain in an unfollowed state with no visible control to return to the end. Consider keying `ThreadFeed` by `scopedThreadKey` (or resetting the latch via the existing `onEndFollowEnabledChange` callback) so the child latch and parent state stay in sync across environment switches.
    13. @@ -173,3 +210,16 @@
      173210
      174211 export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: ThreadDetailScreenProps) {
      175212 const insets = useSafeAreaInsets();
      213+ const isKeyboardVisible = useKeyboardState((state) => state.isVisible);
      214+ const liveKeyboardHeight = useKeyboardState((state) => state.height);
      215+ // Android can swallow the IME hide callbacks when the app is backgrounded
      216+ // mid keyboard-hide (the reported repro: send — which blurs and starts the
      217+ // hide — then Home within a second). The keyboard library's height AND
      218+ // visibility then stay frozen open, so gating the sticky translation on
      219+ // visibility alone still strands the composer after resume. Quarantine the
      220+ // translation on every Android resume instead; any sign of a live keyboard
      221+ // stream — an owned input gaining focus, or any visibility/height movement —
      222+ // lifts it. A healthy resume sees no visual difference (the translation is
      223+ // already zero while the keyboard is closed).
      224+ const [keyboardStateSuspect, setKeyboardStateSuspect] = useState(false);
      225+ useEffect(() => {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High threads/ThreadDetailScreen.tsx:225

      On Android, every AppState transition to active sets keyboardStateSuspect to true, even when the app was backgrounded with the keyboard genuinely open. On resume, isKeyboardVisible and liveKeyboardHeight may not change (the keyboard never closed), so the effect that clears keyboardStateSuspect never fires, and the already-focused editor does not re-emit a focus callback. KeyboardStickyView stays disabled, stranding the composer behind the still-open keyboard until the next keyboard event arrives. Consider only setting the flag when the keyboard was not visible at background time, or additionally clearing it on resume when isKeyboardVisible is already true.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/mobile/src/features/threads/ThreadDetailScreen.tsx around line 225:
      
      On Android, every `AppState` transition to `active` sets `keyboardStateSuspect` to `true`, even when the app was backgrounded with the keyboard genuinely open. On resume, `isKeyboardVisible` and `liveKeyboardHeight` may not change (the keyboard never closed), so the effect that clears `keyboardStateSuspect` never fires, and the already-focused editor does not re-emit a focus callback. `KeyboardStickyView` stays disabled, stranding the composer behind the still-open keyboard until the next keyboard event arrives. Consider only setting the flag when the keyboard was not visible at background time, or additionally clearing it on resume when `isKeyboardVisible` is already true.
    14. Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

      Fix All in Cursor Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot), but a cloud agent failed to start. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 17695d71db571948f4652f65429966d3390b2981. Configure [here](https://www.cursor.com/dashboard/bugbot).
    15. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/17b38207c84ad98f72430839df0f336d77d30af4/patches/react-native-screens@4.25.2.patch#L315

      When the mail-search toolbar's fallback UISearchTextField is being edited, any unrelated header update (title, subtitle, tint, etc.) calls updateViewController: again, which unconditionally removes the existing toolbar view and constructs a fresh UISearchTextField initialized empty. This drops the current search text and removes first responder, dismissing the keyboard mid-typing. Consider reusing the existing toolbar when its config is unchanged, or preserving the text field's text and first-responder state across rebuilds.

      No longer relevant as of 89675f29d2cf3997b1c7b71668f282821035072a

    16. juliusmarminge merged this6676f9c

    17. juliusmarminge closed this

Sign in to join this conversation.