Skip to content

fix(mobile): let Android split screen inset the window for the keyboard - #18359

Closed
gsxdsm wants to merge 1 commit into
stablyai:mainfrom
gsxdsm:fix/android-split-screen-keyboard-inset
Closed

gsxdsm wants to merge 1 commit into
stablyai:mainfrom
gsxdsm:fix/android-split-screen-keyboard-inset

Conversation

@gsxdsm

@gsxdsm gsxdsm commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Problem

In Android split screen the keyboard covered the terminal's shortcut row and Live input bar, and nothing lifted out of the way.

Why it happens

The window is never resized there, and Android reports no keyboard to the app at all. Measured on a motorola razr fold 2026 (Android 16), keyboardDidShow arrives with:

end.height = -31.9dp   screenY = 1084.5   window = 496x1116 (identical with the IME up)

The shell owns the IME — dumpsys window shows imeControlTarget is a RemoteInsetsControlTarget — so the window gets imeInsets.bottom = 0, and RN's ReactRootView.checkForKeyboardEvents reduces that by the 31.9dp navigation bar, yielding a negative height.

It is an absent inset, not a race: re-reads of Keyboard.metrics() at +100 / +300 / +600 / +1200 / +2500ms all returned the same value, and a useAnimatedKeyboard listener never fired once. No app-side measurement of the keyboard exists in that mode, so no JS-only fix is possible.

The fix

Two separate things pin decorFitsSystemWindows = false, and undoing either alone changes nothing:

  1. Android 15+ edge-to-edge enforcement. The opt-out is a window theme attribute (android:windowOptOutEdgeToEdgeEnforcement), not a manifest attribute — the manifest form was verified to have no effect. Android 16 also ignores it above targetSdk 35, hence the expo-build-properties pin. The window is created with the splash theme and swapped to AppTheme after, so both carry the attribute.
  2. expo-modules-core's EdgeToEdgePackage calls enableEdgeToEdge() at activity create regardless of RN's isEdgeToEdgeFeatureFlagOn. MainActivity now sets decor fitting back on — only in multi-window, since full screen reports the IME normally and fitting there double-compensates with the layout's own keyboard lift (confirmed: an unconditional version left a keyboard-sized black band in full screen).

Both plugins throw during prebuild if their anchors are missing, so a template change fails the build instead of silently shipping the regression.

Verification

On a motorola razr fold 2026 (Android 16), release build:

  • Split screen + keyboard: shortcut row and Live input bar sit above the keyboard. EDGE_TO_EDGE_ENFORCED is gone from the window's private flags.
  • Full screen + keyboard: unchanged from before, edge-to-edge preserved, no blank band.

Trade-offs and follow-ups

  • targetSdk is pinned to 35. Play accepts this today, but when Google requires 36 the opt-out disappears and this approach stops working. The coupling is documented in the opt-out plugin.
  • isInMultiWindowMode is a broad proxy. Freeform and desktop-mode windows are also multi-window but do receive the ime inset, so they get a system inset they don't need. Narrowing this needs a runtime probe of the ime inset, which can't run before the first keyboard opens. Noted in the plugin comment.
  • System bars stay transparent while decor-fitting in multi-window, so the bar strips paint windowBackground rather than the themed surface. Not visible on the test device; worth a look if a seam shows up.
  • While the keyboard is open in split screen the terminal frame is shorter, so xterm reflows locally. The existing refit deferral (terminal-viewport-refit-state.ts) holds the PTY resize until the keyboard closes, at which point the resting size is reasserted.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GZq3xEtzu3nJzg1rdtyQsF

In split screen the keyboard covered the terminal's shortcut row and Live
input bar, and nothing lifted out of the way.

The window is never resized there and Android reports no keyboard at all:
`keyboardDidShow` arrives with a height of -31.9dp, because the shell owns
the IME (`imeControlTarget` is a `RemoteInsetsControlTarget`) and hands the
window `imeInsets.bottom = 0`, which RN then reduces by the navigation bar.
Re-reads at +100ms through +2500ms return the same value and reanimated's
inset listener never fires, so it is an absent inset rather than a race, and
no app-side measurement of the keyboard exists in that mode.

Two things had to be undone, neither of which works alone:

- Android 15+ edge-to-edge enforcement pins `decorFitsSystemWindows=false`.
  The opt-out is a window *theme* attribute, and Android 16 ignores it above
  targetSdk 35, hence the pin in expo-build-properties.
- expo-modules-core's `EdgeToEdgePackage` re-enables edge-to-edge at activity
  create regardless of RN's feature flag, so `MainActivity` sets decor fitting
  back on — only in multi-window, since full screen reports the IME normally
  and would otherwise double up with the layout's own lift.

Verified on a motorola razr fold 2026 (Android 16): split screen now shows the
shortcut row and input bar above the keyboard, and full screen is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZq3xEtzu3nJzg1rdtyQsF
@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Android Expo configuration now registers two prebuild plugins and targets SDK 35. One plugin sets the edge-to-edge opt-out attribute on the required application themes. The other patches MainActivity to fit system windows in multi-window mode while preserving edge-to-edge behavior in full-screen mode. It handles modern and deprecated multi-window callbacks, prevents duplicate patches, and reports missing Android anchors during prebuild.

Merge Risk: 🟡 Moderate · up to a327d

This change fixes split-screen keyboard layout on the tested configuration, but shipping with target API 35 will prevent future Google Play submissions and updates after the stated deadline. Update the implementation for target API 36 before merge or explicitly accept the release limitation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, root cause, fix, verification, and trade-offs. However, it omits required template sections, including Linked Issue, Visual Proof, Testing checkboxes and details,… Add all missing required sections. Include a linked issue after Fixes #, attach before-and-after visual proof or write N/A with a reason, document manual and automated testing, complete the required checklist items, and address Review, …
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: restoring Android split-screen keyboard insets.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, root cause, fix, verification, and trade-offs. However, it omits required template sections, including Linked Issue, Visual Proof, Testing checkboxes and details, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Add all missing required sections. Include a linked issue after Fixes #, attach before-and-after visual proof or write N/A with a reason, document manual and automated testing, complete the required checklist items, and address Review, Agent skill upstream boundary, and Notes.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 70dcf9b8-211c-446f-aa1e-35e4a4564535

📥 Commits

Reviewing files that changed from the base of the PR and between 94fcbe1 and a327d21.

📒 Files selected for processing (3)
  • mobile/app.json
  • mobile/plugins/android-fit-system-windows-for-ime.js
  • mobile/plugins/android-optout-edge-to-edge-enforcement.js

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread mobile/app.json
"android": {
"usesCleartextTraffic": true
"usesCleartextTraffic": true,
"targetSdkVersion": 35

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

printf '%s\n' '--- mobile/app.json ---'
sed -n '70,125p' mobile/app.json
printf '%s\n' '--- dependency manifests ---'
fd -i -t f 'package.json|app.json|app.config.*|gradle.properties|build.gradle|settings.gradle' mobile .
printf '%s\n' '--- Expo and target-SDK references ---'
rg -n 'expo-splash-screen|targetSdkVersion|windowOptOutEdgeToEdgeEnforcement|compileSdk|Expo 55|SDK 55' mobile package.json package-lock.json yarn.lock pnpm-lock.yaml 2>/dev/null || true

Repository: stablyai/orca

Length of output: 3226


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 38950


🌐 Web query:

Google Play target API level requirements August 31 2026 Android 16 API 36 targetSdkVersion

💡 Result:

Effective August 31, 2026, Google Play enforces updated target API level requirements for new apps and app updates [1][2][3]. For most apps—specifically those on phones, tablets, foldables, and Android Auto—the requirement is to target Android 16 (API level 36) or higher [1][2][3]. Other form factors have different requirements: - Wear OS and Android Automotive OS apps must target Android 15 (API level 35) or higher [1][2][3]. - Android TV and Android XR apps must target Android 14 (API level 34) or higher [1][2][3]. For existing apps that are not updated, the requirement to remain discoverable to new users on newer Android OS versions is to target Android 15 (API level 35) or higher [1][2]. Apps failing to meet this threshold will not be discoverable to users on Android OS versions newer than the app's current target API level [1][2][4]. Developers who are unable to meet these deadlines may request an app-specific extension via the Play Console, which can extend the deadline to November 1, 2026 [3][5]. Failure to meet the requirements does not delete an app or remove it from devices where it is already installed; it primarily blocks new submissions and limits discoverability for new users on newer devices [4][3][5].

Citations:


🌐 Web query:

site:developer.android.com Android 16 API 36 windowOptOutEdgeToEdgeEnforcement target SDK 36 disabled

💡 Result:

For apps targeting Android 16 (API level 36), the windowOptOutEdgeToEdgeEnforcement attribute is deprecated and disabled, meaning apps can no longer opt out of edge-to-edge enforcement [1][2]. Key details regarding this change include: - Enforcement: While Android 15 (API level 35) introduced the ability to opt out of edge-to-edge enforcement using the windowOptOutEdgeToEdgeEnforcement attribute, this option is no longer available when targeting Android 16 [1]. - Compatibility: If your app targets Android 16 but is running on an Android 15 device, the attribute will still function as an opt-out [1]. However, when running on an Android 16 device, the attribute is explicitly disabled, and the app must support edge-to-edge layouts [1]. - Migration: To ensure proper UI display, developers are advised to remove any usage of windowOptOutEdgeToEdgeEnforcement and implement edge-to-edge support by handling window insets appropriately, using established guidance for Jetpack Compose or Views [1][3][4].

Citations:


Raise the target SDK to API 36 for Google Play releases.

If this app ships through Google Play on phones or tablets, targetSdkVersion: 35 blocks new submissions and updates after August 31, 2026. Target API 36 and implement the split-screen inset fix instead of relying on windowOptOutEdgeToEdgeEnforcement, which Android 16 disables.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No blocking issues — the mechanism is sound and verified on device, but two things are worth tracking before this becomes a long-term dependency.

Reviewed changes

This run reviewed the Android split-screen keyboard-inset fix: two new config plugins that opt the theme out of Android 15+ edge-to-edge enforcement and re-enable decor fitting in multi-window, plus an app.json pin of targetSdkVersion to 35.

  • android-optout-edge-to-edge-enforcement.js — sets android:windowOptOutEdgeToEdgeEnforcement="true" on AppTheme and Theme.App.SplashScreen, throwing at prebuild if either theme is missing.
  • android-fit-system-windows-for-ime.js — injects WindowCompat.setDecorFitsSystemWindows(window, isInMultiWindowMode) plus onMultiWindowModeChanged overrides (two-arg + deprecated single-arg for API 24-25) into MainActivity, throwing at prebuild if its anchors drift.
  • app.json — registers both plugins and pins targetSdkVersion to 35.

ℹ️ Pinning targetSdkVersion to 35 is a whole-app downgrade with a hard expiry

The opt-out only works because the app targets SDK 35 — Android 16 disables windowOptOutEdgeToEdgeEnforcement for apps targeting 36, and Expo SDK 55 / RN 0.83 otherwise target 36. So this trades an app-wide targetSdk downgrade for a single split-screen edge case, and it stops working the moment Play requires targeting 36. The coupling is documented in the plugin comment but not enforced: nothing fails at prebuild if a future change bumps targetSdkVersion back to 36, so the split-screen keyboard bug would return silently.

Technical details
# Track the targetSdk 36 migration

## Affected sites
- mobile/app.json:114 — `"targetSdkVersion": 35` pins the whole app and is what makes the opt-out effective
- mobile/plugins/android-optout-edge-to-edge-enforcement.js — documents the coupling but does not enforce it

## Required outcome
- A tracked follow-up (issue) for reworking/retiring this opt-out when targetSdk 36 becomes mandatory, so the stopgap does not silently regress.
- Optionally: have the opt-out plugin assert the effective `targetSdkVersion` is <= 35 at prebuild and throw otherwise, consistent with its existing loud-failure anchors.

## Open questions for the human
- Is the whole-app targetSdk downgrade (e.g. any API 35 vs 36 runtime-behavior differences on Android 16) an acceptable cost for this fix?
- Is a narrower runtime probe of the ime inset feasible to replace the broad `isInMultiWindowMode` proxy later?

ℹ️ Nitpicks

  • The isInMultiWindowMode proxy also covers freeform/desktop-mode windows, which already receive the IME inset and will therefore double-inset (already documented in the plugin). Worth a look if a seam shows up in those window modes.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@gsxdsm

gsxdsm commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing as stale. The branch is far behind main and conflicts in mobile/app.json, and the target SDK review point is still open. I'll open a fresh PR against current main if this is still needed on current Android.

@gsxdsm gsxdsm closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant