fix(mobile): Keep chat pinned during Android keyboard open #4038
Extracted from #3910.
Updates the keyboard-controller chat-scroll patch so a composer resize racing Android keyboard opening still keeps the newest thread content above the input. Includes the matching patched-dependency lockfile update.
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
Fix chat scroll position being lost when Android keyboard opens on mobile#
- Adds a swizzled
setContentInset:on the decorated iOSUIScrollViewthat restores the previouscontentOffsetafter an inset change, preventing re-clamping when the user is not dragging or decelerating. - Introduces
adjustedInsetCompensationandcontentInsetStartCompensationprops toKeyboardChatScrollView, allowing scroll offset clamping to floor at a negative value equal to the adjusted top inset instead of zero. - Threads both new props through
useChatKeyboard,useExtraContentPadding, andcomputeIOSContentOffsetso keyboard-driven scroll adjustments respect the adjusted inset on non-inverted lists. - Behavioral Change: non-inverted iOS scroll views can now hold a negative
contentOffsetdown to-contentInsetStartCompensation; previously the floor was always 0.
Note
Medium Risk Touches native UIScrollView method swizzling and core chat scroll/keyboard offset math; regressions would show as jumpy or mis-pinned threads on iOS (and any consumers of the new inset props).
Overview
Extends the react-native-keyboard-controller@1.21.13 patch so chat threads stay pinned when the keyboard or composer changes inset/offset math.
On iOS, swizzles setContentInset: on the decorated scroll view to restore contentOffset after inset updates when the user isn’t dragging—avoiding UIKit snapping lists that rest at a negative offset under a translucent header back to 0.
Adds adjustedInsetCompensation and contentInsetStartCompensation to KeyboardChatScrollView and threads them through keyboard/padding worklets so non-inverted scroll clamps use a minimum offset of -contentInsetStartCompensation (not 0) and bottom safe-area is included in max-scroll/pinning math. onContentInsetChange reports effective bottom padding so virtualized lists can align end/maintain-scroll targets.
Also drives scroll indicator inset from keyboard height only (not extra composer padding) and bumps the pnpm patch hash for the dependency.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ab640b5fec500144cb95aea0f29a7956e341e71b. 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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Needs human review
This PR introduces a new configuration prop and modifies scroll offset clamping logic across multiple files, including native iOS code patches. The changes affect runtime scroll behavior when keyboard opens/closes, which warrants human review to verify the behavioral impact.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Note
🤖 Codex responding on behalf of Theo
Closing this because the main keyboard/inset changes are now covered by #8793. The additional iOS
setContentInset:override that preserves scroll position is still absent from main and is worth a smaller follow-up if it fixes a remaining jump. Thank you for working through the keyboard and composer layout problems and splitting out this fix. If we have missed a remaining case that needs this PR, please reopen it or leave a comment so we can reopen it.t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
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:
13993a5e-f4f8-4973-9f60-85f9cc92f86eYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.