Repository navigation
Conversation
📝 WalkthroughWalkthroughThe mobile app adds Android desktop-mode configuration and Activity display-metrics synchronization. It measures freeform window bounds and uses stable responsive window classes. Terminal WebViews now synchronize dimensions and device pixel ratio with native layout state. Session input handling detects hardware keyboards, routes Escape on back presses, and adjusts keyboard avoidance. Tests cover plugin transforms, layout behavior, viewport updates, and keyboard handling. Merge Risk: 🟡 Moderate · up to The Android windowing and layout changes improve DeX sizing and lifecycle continuity, but the current head still has edge cases that can preserve an incorrect layout, remount the app during supported transitions, or accidentally leave a session on the first hardware Escape; narrow medium windows may also render an unusable split view. Merge should wait for these fixes or explicit owner acceptance. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description covers all required template sections, including the problem, changes, rationale, linked issue, visual proof, testing, AI disclosure, review notes, compatibility considerations, and checklist status. Full details: Linked Issues checkExplanation The changes directly address the linked issue [ Full details: Out of Scope Changes checkExplanation The plugin, layout changes, terminal updates, keyboard handling, documentation, and tests all support the Samsung DeX and external-display objectives in [ Full details: Docstring CoverageExplanation Docstring coverage is 4.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 44 functions across 50 files. (4 skipped: 3 unsupported, 1 over the file limit.)
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 |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (3)
mobile/plugins/android-desktop-mode.js (1)
162-176: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFail loudly when the
super.onCreate(null)anchor is absent.
applyActivityDisplayMetricsthrows when the anchor is missing. This hook does not. If a future Expo template changes theonCreatebody,String.prototype.replacereturns the source unchanged, the plugin writes the same bytes back, and desktop orientation silently stops working. TheORCA_DESKTOP_ORIENTATIONmarker is also never written, so every prebuild repeats the no-op.Add the same guard used in
applyActivityDisplayMetrics.♻️ Proposed guard
let source = await fs.promises.readFile(mainActivityPath, 'utf8') if (source.includes('ORCA_DESKTOP_ORIENTATION')) { return cfg } + if (!source.includes('super.onCreate(null)')) { + throw new Error('MainActivity.kt is missing the expected super.onCreate(null) call') + } source = source.replace(Consider also moving this transform into a pure exported function applied through
withMainActivity, like the display-metrics transform. That removes the direct filesystem read and write, makes the ordering explicit against the otherMainActivity.ktmod, and makes the branch unit-testable.mobile/src/terminal/terminal-webview-viewport.test.ts (1)
52-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winChange the device pixel ratio before firing the listener.
The harness sets
devicePixelRatio: 1and the test never changes it. The assertiondpr: 1therefore passes even if the injected script reported a hardcoded or stale ratio. Density change is the exact condition this PR targets, so mutate the value first and assert the new one.💚 Proposed test change
it('re-fits and reports viewport state when DPR changes', () => { const harness = createViewportHarness() + harness.setDpr(2) harness.fireDprChange() expect(harness.applyFitScale).toHaveBeenCalledWith('dpr') expect(harness.notify).toHaveBeenCalledWith( - expect.objectContaining({ type: 'viewport-changed', dpr: 1 }) + expect.objectContaining({ type: 'viewport-changed', dpr: 2 }) ) })Expose the setter from the harness:
return { applyFitScale, fireDprChange: () => mediaListener(), + setDpr: (value: number) => { + context.window.devicePixelRatio = value + }, getHeight: (context as { getHeight: () => number }).getHeight,mobile/src/terminal/use-terminal-layout-refit-triggers.ts (1)
40-56: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winClarify the height-only resize guard. After the no-change return,
previous.width === windowWidthmeans onlywindowHeightchanged. Add a concise comment. Width-originated refits intentionally remain unguarded while the keyboard is visible.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e112bec2-e97b-41a9-b2ba-48e1646da427
📥 Commits
Reviewing files that changed from the base of the PR and between 063b804 and b0f5587a305568bff16f3d1caf619a5bed97f968.
⛔ Files ignored due to path filters (1)
mobile/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (54)
mobile/README.mdmobile/app.jsonmobile/app/_layout.tsxmobile/app/h/[hostId]/session/[worktreeId].tsxmobile/app/h/_layout.tsxmobile/app/mobile-onboarding.tsxmobile/docs/dex-mode-layout-design.mdmobile/plugins/android-desktop-mode.jsmobile/plugins/android-desktop-mode.test.jsmobile/src/browser/MobileBrowserPane.tsxmobile/src/browser/browser-screencast-request.test.tsmobile/src/browser/mobile-browser-frameless-stream.test.tsxmobile/src/components/RightDrawer.tsxmobile/src/components/bottom-drawer-fill-height.test.tsmobile/src/components/mounted-bottom-drawer.tsxmobile/src/components/right-drawer-panel-width.test.tsmobile/src/files/MobileFilePreviewScreen.tsxmobile/src/layout/responsive-layout-metrics.test.tsmobile/src/layout/responsive-layout-metrics.tsmobile/src/layout/responsive-layout.tsmobile/src/layout/window-bounds-state.test.tsmobile/src/layout/window-bounds-state.tsmobile/src/layout/window-bounds.tsxmobile/src/platform/hardware-keyboard.test.tsmobile/src/platform/hardware-keyboard.tsmobile/src/platform/use-pixel-ratio.tsmobile/src/session/TerminalPaneView.tsxmobile/src/session/session-back-press.test.tsmobile/src/session/session-back-press.tsmobile/src/session/use-terminal-frame-layout.tsmobile/src/terminal/TerminalWebView.tsxmobile/src/terminal/terminal-keyboard-avoidance-webview.test.tsmobile/src/terminal/terminal-live-input.test.tsmobile/src/terminal/terminal-live-input.tsmobile/src/terminal/terminal-viewport-refit-state.tsmobile/src/terminal/terminal-viewport-refit.test.tsmobile/src/terminal/terminal-viewport-refit.tsmobile/src/terminal/terminal-webview-contract.test.tsmobile/src/terminal/terminal-webview-contract.tsmobile/src/terminal/terminal-webview-handle.tsmobile/src/terminal/terminal-webview-html.tsmobile/src/terminal/terminal-webview-messages.tsmobile/src/terminal/terminal-webview-notification-dispatch.test.tsmobile/src/terminal/terminal-webview-notification-dispatch.tsmobile/src/terminal/terminal-webview-reflow.test.tsmobile/src/terminal/terminal-webview-scroll-routing.test.tsmobile/src/terminal/terminal-webview-text-zoom.test.tsmobile/src/terminal/terminal-webview-viewport-injected.tsmobile/src/terminal/terminal-webview-viewport.test.tsmobile/src/terminal/terminal-write-coalescer-boundaries.test.tsmobile/src/terminal/use-terminal-layout-refit-triggers.tsmobile/src/terminal/use-terminal-live-input-commit.tsmobile/src/terminal/use-terminal-live-input-focus.tsmobile/vitest.config.ts
💤 Files with no reviewable changes (1)
- mobile/src/terminal/terminal-keyboard-avoidance-webview.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Nitpicks from the review summary (not inline threads), all addressed in ebf8d903:
Before/after emulator screenshots (1920×1080/160 dpi overlay display, app maximized) follow in the next comment. |
|
I prepared a rebased and verified version of this PR on current
I retried updating the PR source branch with an exact force-with-lease, but GitHub rejected the push because the current identity ( The prepared branch:
Latest local verification passed:
To update this PR safely from an account with access to git fetch https://github.com/adelin-b/orca.git pr-16018-rebased-20260830
git push \
--force-with-lease=refs/heads/fix/mobile-android-dex-layout:ebf8d903e7d12bedb32dbff89ff4d618decbc548 \
https://github.com/phs2131/orca.git \
FETCH_HEAD:refs/heads/fix/mobile-android-dex-layoutThe lease pins the current PR head, so the push will fail rather than overwrite any newer author changes. PR CI will start after the source branch is updated. |
…play windows On Galaxy DeX (and any Android freeform/desktop window on a display whose density differs from the phone panel) the app rendered as a phone-sized block in the top-left corner of the window, and entering/leaving DeX or resizing the window recreated the Activity. Root causes - RN 0.83 regression (react/react-native#55659): `PixelUtil.toDIPFromPixel` now divides by `DisplayMetricsHolder.getScreenDisplayMetrics().density`, the default (phone) display read through the Application context, while the root surface and mount path use the Activity's display density. react-native-screens' `Screen` reports its size through that helper, so the Stack content is forced to `window * (d_window / d_phone)` at (0,0). - `MainActivity` lacked `resizeableActivity` and `density|smallestScreenSize` in `configChanges`, and the Samsung keep-alive metadata, so DeX transitions and window drags recreated the Activity (full React remount). - `useWindowDimensions` reports the display, not the freeform window, on Android; xterm WebView fit used `window.innerWidth` and never observed DPR changes; hardware-keyboard Esc mapped to hardwareBackPress. Changes - New `plugins/android-desktop-mode.js` config plugin: manifest attributes + Samsung meta-data, and a `withMainActivity` hook that points `DisplayMetricsHolder` at the Activity's display on create / configuration change / resume, requests a decor relayout, and emits the RN dimensions update event. Idempotent, with tests. - `WindowBoundsProvider` / `useWindowBounds` measure the real root bounds; responsive layout uses window class + hysteresis; drawers/sheets/onboarding size from measured bounds. - Terminal WebView refits on width/height/DPR changes via injected viewport observer; text-scale no longer resizes to innerWidth. - Hardware keyboard handling: Esc no longer leaves the session; focus helper no longer assumes keyboardHeight 0 means IME dismissed. - Design/investigation notes in `mobile/docs/dex-mode-layout-design.md`. Verified on a stock API 35 emulator with a 160 dpi overlay display (phone 420 dpi): fullscreen 1920x1080, freeform 412x732, live resize 1000x700 and maximize all fill the window; phone display unchanged. Confirmed on a Galaxy device in DeX. `pnpm test` (3697 passed), `typecheck`, `lint`, `oxfmt` clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- windowClass now carries the same ±24 dp hysteresis as isWideLayout so the host sidebar does not toggle on every pixel around 600/840 dp - notifyHardwareKeyboard routes through the frame-height reducer so a refit deferred behind the IME flushes instead of stranding `pending` - desktop-orientation hook is a pure withMainActivity transform that fails loudly when the super.onCreate(null) anchor is missing - viewport DPR test mutates devicePixelRatio before firing the listener - design doc: 800x600 keeps the sidebar (280+320 fits); document the first-Escape limitation of the hardware-keyboard heuristic Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ebf8d90 to
09716af
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Greptile SummaryThe PR adds Android DeX lifecycle and display-metrics handling, introduces measured window bounds for responsive mobile layouts, and updates terminal sizing and hardware-keyboard behavior.
Confidence Score: 4/5The terminal viewport notification mismatch should be fixed before merging because it can leave PTY dimensions stale in the external-display scenario this PR targets. The WebView adopts measured RN bounds but reports raw inner dimensions to a refit controller that aborts whenever those dimensions differ, preventing terminal reflow after affected DeX window changes. Files Needing Attention: mobile/src/terminal/terminal-webview-viewport-injected.ts, mobile/src/terminal/use-terminal-layout-refit-triggers.ts, mobile/src/terminal/terminal-viewport-refit.ts
|
| Filename | Overview |
|---|---|
| mobile/plugins/android-desktop-mode.js | Adds manifest and MainActivity transforms for DeX resizing, configuration changes, and activity-display metrics. |
| mobile/src/layout/window-bounds.tsx | Provides measured root bounds to layout consumers while retaining display dimensions as a pre-layout fallback. |
| mobile/src/layout/responsive-layout-metrics.ts | Adds width-class and wide-layout hysteresis for freeform-window resizing. |
| mobile/src/terminal/terminal-webview-viewport-injected.ts | Adds RN viewport and DPR observation, but reports raw browser dimensions that can permanently block refitting when they differ from RN bounds. |
| mobile/src/terminal/terminal-viewport-refit.ts | Centralizes debounced terminal refitting and guards it on WebView/frame width alignment. |
| mobile/src/platform/hardware-keyboard.ts | Infers hardware-keyboard attachment from key and IME visibility events. |
| mobile/src/session/use-session-back-handler.ts | Routes Android Back to terminal Escape when hardware input is detected and preserves dirty-draft leave confirmation. |
Sequence Diagram
sequenceDiagram
participant RN as React Native frame
participant WV as Terminal WebView
participant RF as Refit controller
participant Host as Host PTY
RN->>WV: setViewport(measured width, height)
WV->>WV: Store rnViewport and recompute fit
WV-->>RN: viewport-changed(width, height, DPR)
RN->>RF: Compare WebView and frame widths
RF->>WV: measureFitDimensions(frame bounds)
RF->>Host: terminal.updateViewport(cols, rows)
Host-->>WV: Updated terminal layout
Reviews (1): Last reviewed commit: "fix(mobile): adapt DeX layout changes to..." | Re-trigger Greptile
| function notifyViewportChanged() { | ||
| notify({ | ||
| type: 'viewport-changed', | ||
| innerWidth: window.innerWidth, | ||
| innerHeight: window.innerHeight, | ||
| dpr: window.devicePixelRatio || 1 | ||
| }); | ||
| } |
There was a problem hiding this comment.
When a DeX window's browser dimensions differ from the measured terminal frame,
viewport-changed reports the raw window.innerWidth instead of the effective RN viewport. The refit controller stores that value and rejects subsequent width-misaligned refits, leaving the host PTY incorrectly wrapped or clipped after resizing.
| function notifyViewportChanged() { | |
| notify({ | |
| type: 'viewport-changed', | |
| innerWidth: window.innerWidth, | |
| innerHeight: window.innerHeight, | |
| dpr: window.devicePixelRatio || 1 | |
| }); | |
| } | |
| function notifyViewportChanged() { | |
| notify({ | |
| type: 'viewport-changed', | |
| innerWidth: getViewportWidth(), | |
| innerHeight: getViewportHeight(), | |
| dpr: window.devicePixelRatio || 1 | |
| }); | |
| } |
Knowledge Base Used: Mobile sessions and terminal interaction
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 75aba6cf-5b5b-4e5c-b0c5-522f06846bc8
📒 Files selected for processing (55)
mobile/README.mdmobile/app.jsonmobile/app/_layout.tsxmobile/app/h/[hostId]/session/[worktreeId].tsxmobile/app/h/_layout.tsxmobile/app/mobile-onboarding.tsxmobile/docs/dex-mode-layout-design.mdmobile/plugins/android-desktop-mode.jsmobile/plugins/android-desktop-mode.test.jsmobile/src/browser/browser-screencast-request.test.tsmobile/src/browser/mobile-browser-frameless-stream.test.tsxmobile/src/browser/use-mobile-browser-stream.tsmobile/src/components/RightDrawer.tsxmobile/src/components/bottom-drawer-fill-height.test.tsmobile/src/components/mounted-bottom-drawer.tsxmobile/src/components/right-drawer-panel-width.test.tsmobile/src/files/MobileFilePreviewScreen.tsxmobile/src/layout/responsive-layout-metrics.test.tsmobile/src/layout/responsive-layout-metrics.tsmobile/src/layout/responsive-layout.tsmobile/src/layout/window-bounds-state.test.tsmobile/src/layout/window-bounds-state.tsmobile/src/layout/window-bounds.tsxmobile/src/platform/hardware-keyboard.test.tsmobile/src/platform/hardware-keyboard.tsmobile/src/platform/use-pixel-ratio.tsmobile/src/session/TerminalPaneView.tsxmobile/src/session/session-back-press.test.tsmobile/src/session/session-back-press.tsmobile/src/session/use-session-back-handler.tsmobile/src/session/use-terminal-frame-layout.tsmobile/src/terminal/TerminalWebView.tsxmobile/src/terminal/terminal-keyboard-avoidance-webview.test.tsmobile/src/terminal/terminal-live-input.test.tsmobile/src/terminal/terminal-live-input.tsmobile/src/terminal/terminal-viewport-refit-state.tsmobile/src/terminal/terminal-viewport-refit.test.tsmobile/src/terminal/terminal-viewport-refit.tsmobile/src/terminal/terminal-webview-contract.test.tsmobile/src/terminal/terminal-webview-contract.tsmobile/src/terminal/terminal-webview-handle.tsmobile/src/terminal/terminal-webview-html.tsmobile/src/terminal/terminal-webview-messages.tsmobile/src/terminal/terminal-webview-notification-dispatch.test.tsmobile/src/terminal/terminal-webview-notification-dispatch.tsmobile/src/terminal/terminal-webview-reflow.test.tsmobile/src/terminal/terminal-webview-scroll-routing.test.tsmobile/src/terminal/terminal-webview-text-zoom.test.tsmobile/src/terminal/terminal-webview-viewport-injected.tsmobile/src/terminal/terminal-webview-viewport.test.tsmobile/src/terminal/terminal-write-coalescer-boundaries.test.tsmobile/src/terminal/use-terminal-layout-refit-triggers.tsmobile/src/terminal/use-terminal-live-input-commit.tsmobile/src/terminal/use-terminal-live-input-focus.tsmobile/vitest.config.ts
💤 Files with no reviewable changes (1)
- mobile/src/terminal/terminal-keyboard-avoidance-webview.test.ts
🚧 Files skipped from review as they are similar to previous changes (48)
- mobile/src/platform/use-pixel-ratio.ts
- mobile/vitest.config.ts
- mobile/src/layout/window-bounds-state.test.ts
- mobile/app/_layout.tsx
- mobile/src/terminal/terminal-webview-messages.ts
- mobile/app.json
- mobile/src/browser/mobile-browser-frameless-stream.test.tsx
- mobile/src/session/use-terminal-frame-layout.ts
- mobile/src/layout/responsive-layout.ts
- mobile/src/components/right-drawer-panel-width.test.ts
- mobile/src/components/mounted-bottom-drawer.tsx
- mobile/src/files/MobileFilePreviewScreen.tsx
- mobile/src/browser/browser-screencast-request.test.ts
- mobile/src/terminal/use-terminal-live-input-commit.ts
- mobile/src/terminal/terminal-webview-reflow.test.ts
- mobile/src/terminal/terminal-webview-contract.ts
- mobile/src/terminal/terminal-viewport-refit-state.ts
- mobile/src/terminal/use-terminal-live-input-focus.ts
- mobile/src/terminal/terminal-webview-contract.test.ts
- mobile/src/terminal/terminal-webview-scroll-routing.test.ts
- mobile/src/components/RightDrawer.tsx
- mobile/src/platform/hardware-keyboard.test.ts
- mobile/src/terminal/terminal-webview-notification-dispatch.test.ts
- mobile/app/mobile-onboarding.tsx
- mobile/src/terminal/terminal-webview-handle.ts
- mobile/src/components/bottom-drawer-fill-height.test.ts
- mobile/README.md
- mobile/src/terminal/terminal-webview-viewport.test.ts
- mobile/src/terminal/TerminalWebView.tsx
- mobile/src/terminal/use-terminal-layout-refit-triggers.ts
- mobile/src/layout/window-bounds-state.ts
- mobile/src/platform/hardware-keyboard.ts
- mobile/src/layout/window-bounds.tsx
- mobile/app/h/[hostId]/session/[worktreeId].tsx
- mobile/src/terminal/terminal-write-coalescer-boundaries.test.ts
- mobile/src/terminal/terminal-live-input.test.ts
- mobile/src/terminal/terminal-webview-viewport-injected.ts
- mobile/src/terminal/terminal-live-input.ts
- mobile/src/terminal/terminal-viewport-refit.test.ts
- mobile/src/layout/responsive-layout-metrics.test.ts
- mobile/src/layout/responsive-layout-metrics.ts
- mobile/src/session/TerminalPaneView.tsx
- mobile/plugins/android-desktop-mode.js
- mobile/src/terminal/terminal-webview-text-zoom.test.ts
- mobile/plugins/android-desktop-mode.test.js
- mobile/src/terminal/terminal-viewport-refit.ts
- mobile/src/terminal/terminal-webview-notification-dispatch.ts
- mobile/src/terminal/terminal-webview-html.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| physical `Escape` key to `KEYCODE_ESCAPE`, which the framework delivers as a | ||
| back press when no view consumes it. `RightDrawer.tsx:114-122` does the same. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- repository knowledge scopes ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- target document context ---'
sed -n '130,175p' mobile/docs/dex-mode-layout-design.md
printf '%s\n' '--- scoped convention and architecture excerpts ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/{conventions,architecture,learnings}/*.md; do
[ -f "$f" ] || continue
case "$f" in
*mobile*|*dex*|*layout*|*input*|*keyboard*|*hardware*) printf '\n--- %s ---\n' "$f"; cat "$f";;
esac
doneRepository: stablyai/orca
Length of output: 8537
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- relevant source locations ---'
for name in '[worktreeId].tsx' RightDrawer.tsx terminal-live-input.ts use-terminal-live-input-commit.ts terminal-webview-html.ts; do
fd -i -t f "$name" mobile src 2>/dev/null || true
done
printf '%s\n' '--- Escape/back and hardware-event references ---'
rg -n -C 5 'hasReceivedHardwareKeyEvent|BackHandler|KEYCODE_ESCAPE|hardwareBackPress|onKeyPress|handleLiveInputKeyPress' mobile src --glob '*.{ts,tsx,md,java,kt}' 2>/dev/null || true
printf '%s\n' '--- session handler context ---'
sed -n '2135,2180p' mobile/app/h/[hostId]/session/[worktreeId].tsx
printf '%s\n' '--- drawer handler context ---'
drawer=$(fd -i -t f 'RightDrawer.tsx' mobile src | head -1); [ -n "$drawer" ] && sed -n '95,135p' "$drawer"Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- exact symbol matches ---'
rg -n -C 6 'hasReceivedHardwareKeyEvent|BackHandler|hardwareBackPress|onKeyPress|handleLiveInputKeyPress|KEYCODE_ESCAPE' \
'mobile/app/h/[hostId]/session/[worktreeId].tsx' \
mobile/src/components/RightDrawer.tsx \
mobile/src/terminal/terminal-live-input.ts \
mobile/src/terminal/use-terminal-live-input-commit.ts 2>/dev/null || true
printf '%s\n' '--- session back-handler context ---'
sed -n '2135,2180p' 'mobile/app/h/[hostId]/session/[worktreeId].tsx'
printf '%s\n' '--- drawer back-handler context ---'
sed -n '95,135p' mobile/src/components/RightDrawer.tsx
printf '%s\n' '--- live-input key handling ---'
sed -n '1,70p' mobile/src/terminal/terminal-live-input.ts
sed -n '135,185p' mobile/src/terminal/use-terminal-live-input-commit.tsRepository: stablyai/orca
Length of output: 20544
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- session-back-handler implementation ---'
fd -t f 'use-session-back-handler' src mobile
handler=$(fd -t f 'use-session-back-handler' src mobile | head -1)
[ -n "$handler" ] && { sed -n '1,260p' "$handler"; }
printf '%s\n' '--- back-press resolver and hardware-key state ---'
rg -n -C 8 'resolveSessionBackPress|notifyHardwareKeyEvent|hasReceivedHardwareKeyEvent|hardwareKeyboard' \
mobile/src mobile/app/h/[hostId]/session src/session src/platform 2>/dev/null | head -300
printf '%s\n' '--- document lines ---'
sed -n '145,165p' mobile/docs/dex-mode-layout-design.mdRepository: stablyai/orca
Length of output: 28402
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- session back-press contract ---'
sed -n '1,180p' mobile/src/session/session-back-press.ts
printf '%s\n' '--- all native/platform input implementation files ---'
git ls-files mobile | rg '(^|/)(android|ios)/|\.java$|\.kt$|hardware|key' | head -120
printf '%s\n' '--- BackHandler and key-event references outside the reviewed files ---'
rg -n -C 4 'BackHandler|hardwareBackPress|dispatchKeyEvent|onKeyDown|KEYCODE_ESCAPE|KEYCODE_BACK|KeyEvent' mobile --glob '*.{ts,tsx,java,kt,json}' | head -240
printf '%s\n' '--- package versions ---'
rg -n -C 2 '"react-native"|"expo"' mobile/package.json package.json 2>/dev/null | head -80Repository: stablyai/orca
Length of output: 23069
🌐 Web query:
Android KeyEvent KEYCODE_ESCAPE KEYCODE_BACK React Native BackHandler hardwareBackPress official documentation
💡 Result:
In Android development, KEYCODE_BACK (4) and KEYCODE_ESCAPE (111) are distinct key codes [1][2][3]. While both often signify a desire to dismiss or navigate back, they are handled differently by the Android OS and React Native [4][5]. React Native's BackHandler API is specifically designed to detect and manage hardware back button presses on Android via the 'hardwareBackPress' event [6][7][8]. It does not natively provide a separate event listener for 'hardwareEscapePress' [6][8]. Key points regarding their interaction in React Native: 1. BackHandler Scope: The BackHandler API exclusively tracks the system back action [6][8]. Historically, pressing the ESC key on a hardware keyboard did not trigger the same JS-level 'hardwareBackPress' event, which often led to inconsistencies where Modals would dismiss without firing the expected 'onRequestClose' callback [5][9]. 2. Recent Improvements: React Native has updated its internal handling of the ESC key, particularly for Modals [5]. The framework now routes KEYCODE_ESCAPE events through the Android onBackPressedDispatcher [5]. This ensures that when a user presses ESC on a hardware keyboard, it triggers the same underlying mechanism as the hardware back button, causing it to correctly invoke the 'onRequestClose' callback in React Native [5]. 3. Development Considerations: Because BackHandler only listens for 'hardwareBackPress', developers cannot directly register a listener for ESCAPE using that specific API [6][8]. If your application requires handling ESCAPE events distinctly from the back button (for instance, to perform a different action), you would typically need to implement a native module or use a library that exposes Android's onKeyUp or onKeyDown events to the JavaScript layer [10]. In summary, while you cannot use BackHandler to listen for ESCAPE, modern versions of React Native automatically align the behavior of the hardware ESC key with the hardware back button for components like Modals to ensure consistent application state management [5].
Citations:
- 1: https://android.googlesource.com/platform/frameworks/base/+/HEAD/core/java/android/view/KeyEvent.java
- 2: https://developer.android.com/reference/kotlin/android/view/KeyEvent
- 3: https://developer.android.com/reference/android/view/KeyEvent
- 4: GitHub pull request 183 in samsmithyeah/tapsmith (link omitted to avoid creating a cross-reference)
- 5: GitHub pull request 56631 in facebook/react-native (link omitted to avoid creating a cross-reference)
- 6: https://reactnative.dev/docs/backhandler
- 7: https://github.com/facebook/react-native-website/blob/archive/docs/backhandler.md
- 8: https://www.mintlify.com/facebook/react-native/apis/android/backhandler
- 9: GitHub pull request 31564 in facebook/react-native (link omitted to avoid creating a cross-reference)
- 10: https://stackoverflow.com/questions/73852109/jetpack-compose-handle-escape-or-back-button
🌐 Web query:
site:github.com/facebook/react-native/pull/56631 Escape key onBackPressedDispatcher React Native version
💡 Result:
In React Native, the handling of the hardware Escape key (common on external keyboards or Android emulators) via the onBackPressedDispatcher is primarily a concern for Android platform integration. Recent improvements to React Native have specifically targeted the alignment of the hardware Escape key with the standard back-button behavior for Modal components [1]. Previously, pressing the hardware Escape key on an open Modal did not consistently trigger the JavaScript onRequestClose callback, even though the hardware Back button did [1]. Key points regarding this behavior: 1. Integration with BackHandler: To manage back navigation in React Native on Android, developers typically use the BackHandler API, which hooks into the onBackPressedDispatcher under the hood. 2. Modal Behavior: As of recent updates, the hardware Escape key (mapped to KEYCODE_ESCAPE) is now routed through the onBackPressedDispatcher in ReactModalDialog [1]. This ensures that when a user presses the Escape key while a modal is open, the onRequestClose callback is triggered, consistent with the behavior of the hardware back button [1]. 3. Debugging/Testing: You can simulate this behavior using the Android Debug Bridge (ADB) with the following command to verify if your application correctly handles the event: adb shell input keyevent 111 [1] If you are implementing custom back navigation, ensure you are utilizing the BackHandler API, which remains the standard interface for handling back events in React Native applications, allowing you to register listeners that respond to both the standard back button and, effectively, the Escape key when routed through the dispatcher [1].
Citations:
- 1: GitHub pull request 56631 in facebook/react-native (link omitted to avoid creating a cross-reference)
🌐 Web query:
site:github.com/facebook/react-native React Native 0.83 BackHandler KEYCODE_ESCAPE Android source
💡 Result:
In React Native, the Android hardware ESC key (KEYCODE_ESCAPE) is intended to be handled similarly to the hardware BACK button, particularly within the Modal component, to ensure that the JS onRequestClose callback is triggered [1][2]. In versions like 0.83, the handling of hardware keys within Modals on Android has been undergoing significant architectural changes to support Android's newer Predictive Back system and the deprecation of Activity.onBackPressed [3][4]. Key points regarding the implementation: 1. Mechanism: Historically, handling for KEYCODE_ESCAPE was added to ensure that pressing ESC on a physical keyboard would properly trigger the modal's close callback, preventing the React state from becoming desynchronized [2][5]. 2. Evolution: Recent changes have moved away from direct keycode monitoring toward using the AndroidX OnBackPressedDispatcher and OnBackPressedCallback [3][4]. This ensures that both the back gesture/button and the ESC key follow the same dispatch path [1]. 3. Current Status: While there have been ongoing refinements, issues have been reported (such as in version 0.84+) where the ESC key may occasionally fail to trigger the expected callbacks, indicating that while the architecture exists to support it, it remains a subject of active maintenance and bug fixes [1][6]. If you are investigating the source code, you can find relevant logic in the React Native Android repository under the Modal host view implementation: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt [3] This file manages the lifecycle of the modal and integrates the key handling events into the Android activity dispatch system [1][3].
Citations:
- 1: GitHub pull request 56631 in facebook/react-native (link omitted to avoid creating a cross-reference)
- 2: react/react-native@f51773ecded
- 3: react/react-native@5b630d2
- 4: GitHub pull request 51096 in facebook/react-native (link omitted to avoid creating a cross-reference)
- 5: GitHub pull request 31564 in facebook/react-native (link omitted to avoid creating a cross-reference)
- 6: GitHub issue 56411 in facebook/react-native (link omitted to avoid creating a cross-reference)
🌐 Web query:
site:android.googlesource.com/platform/frameworks/base KEYCODE_ESCAPE onBackPressedDispatcher Activity dispatchKeyEvent escape back
💡 Result:
In Android, KEYCODE_ESCAPE (111) [1] is distinct from the back navigation system and does not automatically trigger the OnBackInvokedDispatcher [2][3]. Handling of these inputs differs significantly: 1. KEYCODE_BACK: This is the standard back navigation event. When the Predictive Back gesture/system is enabled, this event is intercepted by the WindowOnBackInvokedDispatcher [3][4] and routed to registered OnBackInvokedCallback instances [2]. If Predictive Back is not enabled, the system uses legacy behavior, dispatching the key event through the View tree or activity [5][6]. 2. KEYCODE_ESCAPE: This key code typically maps to the Escape key on physical keyboards. It is not intercepted by the OnBackInvokedDispatcher [3]. Instead, it is treated as a standard key event that passes through the View hierarchy's normal dispatch chain [7][8]. If you need to handle KEYCODE_ESCAPE in an Activity, you should override onKeyDown or onKeyUp [7][8]: @Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ESCAPE) { // Handle Escape key action here return true; // Return true to indicate the event was consumed } return super.onKeyUp(keyCode, event); } The system Dialog class provides a reference implementation for handling both [9]. It treats KEYCODE_BACK as a navigation event (using the dispatcher when available) and explicitly monitors KEYCODE_ESCAPE to trigger dialog cancellation or dismissal [9]. If your goal is to make KEYCODE_ESCAPE behave exactly like a back navigation, you must manually invoke the logic you have assigned to your back callback when you detect KEYCODE_ESCAPE in your key event handlers [9].
Citations:
- 1: https://android.googlesource.com/platform/frameworks/base/+/HEAD/core/java/android/view/KeyEvent.java
- 2: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/core/java/android/window/OnBackInvokedDispatcher.java
- 3: https://android.googlesource.com/platform/frameworks/base/+/a6666f2221af6972f3177296157d6b5a8b2fb4ad%5E%21/
- 4: https://android.googlesource.com/platform/frameworks/base/+/HEAD/core/java/android/window/WindowOnBackInvokedDispatcher.java
- 5: https://android.googlesource.com/platform/frameworks/base/%2B/HEAD/core/java/android/window/WindowOnBackInvokedDispatcher.java
- 6: https://android.googlesource.com/platform/frameworks/base/+/bc3bf5b044387744666fec0d917cdfc88da8c91c/core/java/android/window/WindowOnBackInvokedDispatcher.java
- 7: https://android.googlesource.com/platform/frameworks/base/+/5a50262/docs/html/training/keyboard-input/commands.jd
- 8: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/core/java/android/app/Activity.java
- 9: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/Dialog.java
🌐 Web query:
site:github.com/facebook/react-native/blob/v0.83.10 BackHandler Android hardwareBackPress ReactActivity KEYCODE_ESCAPE
💡 Result:
In React Native v0.83.10:
ReactActivitydoes not referenceKeyEvent.KEYCODE_ESCAPE; the search returns no match. (github.com)- Back handling enters through
ReactActivity.onBackPressed(), which delegates toReactActivityDelegate. (github.com) - The JS
BackHandlerevent is emitted byDeviceEventManagerModule.emitHardwareBackPressed()as"hardwareBackPress". (github.com)
Relevant files:
ReactActivity.javaDeviceEventManagerModule.kt
So KEYCODE_ESCAPE is not the Android path for BackHandler; use the activity back-dispatch mechanism instead.
Citations:
- 1: https://github.com/facebook/react-native/blob/v0.83.10/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java?plain=1
- 2: https://github.com/facebook/react-native/blob/v0.83.10/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java?plain=1
- 3: https://github.com/facebook/react-native/blob/v0.83.10/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.kt?plain=1
Handle KEYCODE_ESCAPE natively. Android treats KEYCODE_ESCAPE and KEYCODE_BACK as separate events. React Native 0.83.10 BackHandler handles only the back-dispatch path; it does not convert KEYCODE_ESCAPE for this screen. Therefore, useSessionBackHandler may never receive Escape, and any mapped first event can select leave while hardwareKeyboard is still false. Add native KeyEvent handling or establish an equivalent Galaxy/DeX event path before relying on BackHandler.
Source: MCP tools
|
|
||
| ```xml | ||
| <activity android:name=".MainActivity" | ||
| android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|uiMode|density|locale|layoutDirection|fontScale|navigation|mcc|mnc" |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
printf '%s\n' '--- applicable repository knowledge files ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- relevant convention and architecture excerpts ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/{conventions,architecture,learnings}/*.md; do
[ -f "$f" ] || continue
case "$f" in
*android*|*mobile*|*docs*|*general*|*global*) echo "### $f"; cat "$f";;
esac
done
printf '%s\n' '--- target document context ---'
sed -n '220,270p' mobile/docs/dex-mode-layout-design.md
printf '%s\n' '--- references to the manifest/activity and configuration handling ---'
rg -n -C 3 'configChanges|MainActivity|touchscreen|screenSize|smallestScreenSize|uiMode|DeX|Dex' mobile --glob '!docs/dex-mode-layout-design.md'Repository: stablyai/orca
Length of output: 50371
🌐 Web query:
site:developer.android.com/guide/topics/manifest/activity-element android:configChanges touchscreen configuration change display input device
💡 Result:
In Android development, the android:configChanges attribute is used in the activity manifest to specify configuration changes that an activity handles itself, rather than shutting down and restarting when a change occurs [1]. Specifically, the "touchscreen" value within android:configChanges indicates that the activity will handle changes to the touchscreen mode [1]. According to official Android documentation, this configuration change is triggered when the user performs actions such as connecting or disconnecting an input peripheral or moving the application between different displays [1]. When an activity includes "touchscreen" in its android:configChanges declaration, the activity remains running during these events, and the system calls the onConfigurationChanged method of the activity instead of destroying and recreating the activity instance [1]. Developers generally need to update resources or adjust the user interface within onConfigurationChanged when these changes occur [1].
Citations:
🌐 Web query:
site:developer.android.com/guide/topics/manifest/activity-element "touchscreen" "input peripheral" "different displays"
💡 Result:
When using a touchscreen input peripheral with multiple displays, the operating system must correctly map the touch coordinates from the physical touch surface to the specific display screen it controls [1]. Because operating systems identify a change in touchscreen mode when a peripheral is connected or when application windows are moved between different displays, the system must maintain an association between the input device and the intended output display [1]. In most modern operating systems, if the touch input is not mapped to the correct display by default, it requires manual configuration through the system's display or input settings. This process typically involves identifying the touchscreen peripheral and associating it with the specific monitor it covers to ensure that touch events on the physical glass translate to the correct coordinates on the corresponding screen [1]. If this mapping is not configured, touching one display might trigger input actions on a different, incorrect display.
Citations:
🌐 Web query:
site:developer.android.com/guide/topics/manifest/activity-element "\"touchscreen\"" "\"The touchscreen has changed\""
💡 Result:
In the context of software development, particularly within the Android operating system, the phrase "touchscreen" appearing in the context of "The touchscreen has changed" refers to a specific configuration change event [1]. In Android, this is documented as a system event that occurs when there is a change to the touchscreen mode, such as when a user connects or disconnects an input peripheral (like a mouse or stylus) or moves an application between different displays [1]. When an activity is configured to handle this change—often via the android:configChanges attribute in the manifest file—the system notifies the application of the change instead of automatically destroying and recreating the activity [1]. This allows developers to update their application's UI or logic dynamically in response to the altered input capabilities or display environment [1].
Citations:
Handle touchscreen configuration changes.
If a supported DeX transition changes the touchscreen configuration, line 246 omits that change and Android can recreate MainActivity, remounting the React tree. Add touchscreen or document that supported transitions cannot change it.
Source: MCP tools
| <meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true" /> | ||
| <!-- Android 12L+/16 large-screen compat opt-outs --> | ||
| <meta-data android:name="android.allow_multiple_resumed_activities" android:value="true" /> | ||
| <property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES" android:value="true" /> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- knowledge scopes ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print | sort
printf '%s\n' '--- target context ---'
cat -n mobile/docs/dex-mode-layout-design.md | sed -n '255,280p'
printf '%s\n' '--- matching repository references ---'
rg -n -C 3 'PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES|resizab|resizeab|opt.?out|compat.*override' mobile/docs mobile 2>/dev/null | head -200Repository: stablyai/orca
Length of output: 31371
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- mobile conventions ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/mobile.md
printf '%s\n' '--- repository conventions ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/repo-wide.mdRepository: stablyai/orca
Length of output: 1186
🌐 Web query:
Android WindowManager PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES true false opt out official documentation
💡 Result:
The PackageManager property PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES is an application-level tag used to opt out of device manufacturer compatibility overrides that force an app's resizability [1][2]. According to official Android documentation, the property behaves as follows: - Setting the value to false: This explicitly informs the system that the application must be opted out of these compatibility treatments, even if a device manufacturer has attempted to force them on the app [1][2]. - Setting the value to true or not setting the property at all: These have no effect [1][2]. To implement this, add the following to your AndroidManifest.xml file within the tag [1][2]: When these manufacturer overrides are active, they force packages to be either resizable or unresizable. Using this opt-out does not change whether an app can be put into multi-window mode, but it prevents the system from forcing resizability behavior (such as forcing an app to be resizable to avoid size-compatibility mode during window container changes like rotation or display size adjustments) [1][2].
Citations:
- 1: https://developer.android.com/reference/kotlin/androidx/window/WindowProperties
- 2: https://developer.android.com/reference/androidx/window/WindowProperties
Set android.window.PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES to false.
true or unset has no effect. Set false in the design and in mobile/plugins/android-desktop-mode.js to implement the opt-out.
Source: MCP tools
| `window.decorView.requestLayout()`. For the maximize/restore/drag case the | ||
| px size changes anyway so `Screen.onLayout(changed=true)` fires and | ||
| `updateState` recomputes with the corrected density. The residual case is |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- repository knowledge scopes ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print | sort
printf '%s\n' '--- relevant conventions and learnings ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/{conventions,learnings,architecture}/*.md; do
[ -f "$f" ] || continue
case "$f" in
*mobile*|*android*|*dex*|*layout*) printf '\n### %s\n' "$f"; cat "$f";;
esac
done
printf '%s\n' '--- target document context ---'
sed -n '730,810p' mobile/docs/dex-mode-layout-design.md
printf '%s\n' '--- appendix A references ---'
rg -n -C 4 'Appendix A|frameSize|requestLayout|onLayout|density|display' mobile/docs/dex-mode-layout-design.mdRepository: stablyai/orca
Length of output: 50371
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- exact target lines ---'
sed -n '760,790p' mobile/docs/dex-mode-layout-design.md
printf '%s\n' '--- tracked react-native-screens and Android layout sources ---'
git ls-files | rg '(^|/)(Screen\.kt|FabricEnabledViewGroup\.kt|View\.java|ViewGroup\.java|react-native-screens|android-desktop-mode)' | head -80
printf '%s\n' '--- relevant design assertions ---'
rg -n -C 3 'onResume|requestLayout|density-only|same.*bounds|frameSize|changed == true' mobile/docs/dex-mode-layout-design.mdRepository: stablyai/orca
Length of output: 9591
🌐 Web query:
Android View onLayout changed parameter requestLayout same bounds official documentation source
💡 Result:
In the Android View framework, the boolean parameter changed in the onLayout(boolean changed, int left, int top, int right, int bottom) method indicates whether a new size or position was assigned to the view [1][2][3]. When you call requestLayout, you are notifying the Android UI framework that the view's layout bounds may need to be changed and that a re-measurement and re-layout pass is required [2][3]. Regarding the interaction between requestLayout and the changed parameter: 1. Significance of changed: The changed parameter is true if the view's layout bounds (left, top, right, bottom) have actually changed since the last layout pass [1][2]. It is false if the layout pass was triggered but the final calculated bounds for that specific view remain the same as they were previously [1]. 2. Triggering onLayout: Calling requestLayout does not guarantee that the view's bounds will change [4]. The framework initiates a layout pass, and the view's onLayout method will eventually be called as part of this process [2][3]. If the parent layout determines that the view's size and position remain unchanged—even after you requested a layout—onLayout may still be called with changed set to false [1][4]. 3. Common Misconceptions: Developers sometimes expect that every call to requestLayout will result in onLayout being called with changed = true. However, because requestLayout essentially signals a need for a potential update, the actual layout logic (often inside a ViewGroup) determines the final position [4]. If the new constraints result in the same bounds, changed will be false [1]. In summary, requestLayout is the request to perform the layout process, while the changed parameter in onLayout is a report on the result of that process, specifically indicating whether the view's physical boundaries were modified [1][2].
Citations:
- 1: https://stackoverflow.com/questions/19227684/why-view-onlayout-is-called-repetitively-when-changed-false
- 2: https://developer.android.com/reference/android/view/View
- 3: https://developer.android.com/reference/kotlin/android/view/View
- 4: https://stackoverflow.com/questions/40450321/onmeasure-and-onlayout-of-child-views-are-not-called-after-requestlayout-on-thei
Add an explicit state refresh for density-only display moves.
If pixel bounds stay unchanged, requestLayout() can reach Screen.onLayout(changed=false). FabricEnabledViewGroup.updateState then keeps the stale frameSize, preserving the top-left scaling error. Add an explicit react-native-screens state refresh or a regression test for this case.
Source: MCP tools
| 4. JS `Dimensions`/`PixelRatio` never update on Android bridgeless (A.3). In | ||
| the same `MainActivity` hook, after the metrics override, emit the RN | ||
| dimensions event so JS sees the new scale: | ||
| `(reactHost as? ReactHostImpl)?.currentReactContext?.getNativeModule(DeviceInfoModule::class.java)?.emitUpdateDimensionsEvent()` |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- repository guidance ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- target document context ---'
sed -n '760,810p' mobile/docs/dex-mode-layout-design.md
printf '%s\n' '--- DeviceInfoModule references and generated activity context ---'
rg -n -C 4 'DeviceInfoModule|emitUpdateDimensionsEvent|ReactHostImpl|MainActivity' mobile . \
-g '*.kt' -g '*.java' -g '*.md' | head -300Repository: stablyai/orca
Length of output: 50371
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- mobile conventions ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/mobile.md
printf '%s\n' '--- relevant document sections ---'
sed -n '720,805p' mobile/docs/dex-mode-layout-design.md
printf '%s\n' '--- RN version and local patches ---'
rg -n -C 2 'react-native[^A-Za-z]|0\.83\.9|DeviceInfoModule' mobile/package.json mobile/pnpm-lock.yaml mobile/yarn.lock mobile/package-lock.json mobile/patches mobile/plugins 2>/dev/null || true
printf '%s\n' '--- tracked Android sources ---'
git ls-files mobile | rg '(^|/)(MainActivity|DeviceInfoModule|ReactHostImpl|DisplayMetricsHolder).*\\.(kt|java)$|patches/react-native'Repository: stablyai/orca
Length of output: 50370
🌐 Web query:
React Native v0.83.9 DeviceInfoModule.kt internal class emitUpdateDimensionsEvent visibility ReactHostImpl currentReactContext
💡 Result:
In React Native v0.83.9, the DeviceInfoModule class is defined as internal [1][2]. This change was implemented to reduce the public API surface of the framework [2]. Regarding the requested components: 1. DeviceInfoModule.kt: This class is marked as internal [1][2]. It is responsible for providing device display metrics (such as screen and window dimensions) and system properties to the React Native runtime [1][3]. 2. emitUpdateDimensionsEvent: This function is a public member of the internal DeviceInfoModule class [1]. It is triggered by lifecycle events (e.g., onHostResume) when changes in font scale are detected [1][3]. The function checks if there is an active React instance, compares current display metrics against cached values, and emits a didUpdateDimensions event to JavaScript via the React bridge if a change has occurred [1]. 3. ReactHostImpl and currentReactContext: ReactHostImpl is a core component in the modern React Native architecture (often associated with the Bridgeless mode) that manages the React instance lifecycle [4][5]. While DeviceInfoModule interacts with the ReactApplicationContext to access the React instance for event emission [1], ReactHostImpl is involved in the broader orchestration of these instances [4][5]. In various versions, including v0.83.x, ReactHostImpl maintains state and configuration that influences how modules like DeviceInfoModule function, ensuring that events are correctly dispatched when the React context is active and initialized [1][5]. The visibility of DeviceInfoModule as internal signifies that it is intended for use by the framework itself rather than as a public-facing API for application developers [2]. Developers needing to handle dimension changes or device information should continue to use the standard React Native Dimensions API, which consumes these native events under the hood [6][7].
Citations:
- 1: https://github.com/facebook/react-native/blob/0617accecdcb11159ba15c34885f294bc206aa89/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.kt
- 2: react/react-native@f02607b
- 3: https://deepwiki.com/facebook/react-native/8.2-networking-and-platform-modules
- 4: https://www.codefactor.io/repository/github/facebook/react-native/source/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt
- 5: react/react-native@3b185e4
- 6: GitHub issue 47080 in facebook/react-native (link omitted to avoid creating a cross-reference)
- 7: GitHub issue 47080 in react/react-native (link omitted to avoid creating a cross-reference)
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- exact React Native dependency and patch ---'
sed -n '45,62p' mobile/package.json
sed -n '1,220p' mobile/patches/react-native@0.83.10.patch
printf '%s\n' '--- all project references to the proposed call ---'
rg -n -C 3 'emitUpdateDimensionsEvent|DeviceInfoModule|currentReactContext|ReactHostImpl' mobile \
-g '!pnpm-lock.yaml' -g '*.js' -g '*.ts' -g '*.tsx' -g '*.kt' -g '*.java' -g '*.md' | head -250Repository: stablyai/orca
Length of output: 12887
🌐 Web query:
site:raw.githubusercontent.com/facebook/react-native/v0.83.10/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.kt
💡 Result:
The requested React Native v0.83.10 file is available here. It defines DeviceInfoModule, which exports display dimensions and the isEdgeToEdge flag, and emits didUpdateDimensions when metrics change. (raw.githubusercontent.com)
Citations:
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- existing Android plugin implementation ---'
sed -n '1,180p' mobile/plugins/android-desktop-mode.js
printf '%s\n' '--- exact RN 0.83.10 DeviceInfoModule declaration ---'
curl -fsSL https://raw.githubusercontent.com/facebook/react-native/v0.83.10/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.kt \
| sed -n '1,120p'
printf '%s\n' '--- exact RN 0.83.10 ReactHostImpl context member ---'
curl -fsSL https://raw.githubusercontent.com/facebook/react-native/v0.83.10/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt \
| rg -n -C 3 'currentReactContext|class ReactHostImpl'Repository: stablyai/orca
Length of output: 12883
Update the snippet to use the existing public event path.
React Native 0.83.10 declares DeviceInfoModule as internal, so generated MainActivity.kt cannot reference DeviceInfoModule::class.java across the module boundary. The plugin already emits didUpdateDimensions through reactHost?.currentReactContext?.emitDeviceEvent(...); document that path instead.
Source: MCP tools
On Samsung One UI, split-window panes are assigned a density different from fullscreen (e.g. 321 vs 420 dpi). Three measurement paths in the app convert with a density different from the one Fabric/the WebView actually paint at: 1. react-native-screens FabricEnabledViewGroup.updateState converted the measured pane px back to dp with the process-global main-display density captured at process start, collapsing all ScreenStack content into a top-left box of pane*density-ratio (upstream software-mansion/react-native-screens#4159, fixed in 4.26.0). Pin react-native-screens to 4.26.2 - the first fix line that remains compatible with react-native 0.83 codegen (4.27+ needs newer codegen), plus a pnpm patch respelling one React.ComponentRef command argument that the 0.83.10 codegen parser rejects. 2. RN's process-global DisplayMetricsHolder stays frozen at process start (seeded once from the Application context, so activity recreation does not help). Text measurement (PixelUtil.pxToDp) and all other PixelUtil conversions then disagree with the mount density by exactly the mismatch ratio, so text is laid out into boxes that are the wrong fraction of the glyphs - clipped lines, cut descenders. Add an android-multiwindow-metrics config plugin that re-seeds BOTH holders from the windowed resources on create/resume/configurationChange, emits didUpdateDimensions, requests a decorView relayout, and adds density to configChanges so the switch reaches the hook without activity recreation. Unlike the DeX variant in stablyai#16018, the screen holder also takes windowed metrics, which the text pipeline requires. 3. The Android WebView pins its CSS-px-at-construction density to the display (Chrome-side; activity recreation does not change it), while the terminal fit protocol passes an RN-dp container height the web side consumed as CSS px. xterm then overallocated rows by the density ratio and its bottom rows sat below the visible viewport - the terminal could not scroll to the last lines in split view. Pass rnPixelRatio alongside containerHeight in the measure message and convert into the WebView's CSS px in measureFitDimensions; bump the terminal payload hash canary accordingly. The plugin's exported transforms are unit-tested (idempotent injection, hook ordering before super.onCreate(null), density append without duplication, throw paths) under a new plugins/**/*.test.js vitest include. Verified on Samsung foldable hardware (One UI, Android 16): layout and text fill the pane correctly in split panes and pop-up windows across recreation-free fullscreen<->split transitions, and the terminal viewport reaches its final buffer rows in split view. Co-Authored-By: CCCha <cccha@jetd.one> via Claude Code


ELI5
On a Galaxy phone in Samsung DeX the Orca app only painted a phone-sized box in the top-left corner of its window, and "restarted" whenever the window was resized or DeX was toggled. The app now fills the window, survives resizes, and works with a hardware keyboard.
What Changed
All under
mobile/:plugins/android-desktop-mode.js(new, registered inapp.json): manifest attributes (resizeableActivity, fullconfigChangesincl.density|smallestScreenSize, Samsungkeepalive.density/multidisplay.keep_process_alivemeta-data) and awithMainActivityhook that pointsDisplayMetricsHolderat the Activity's display on create / configuration change / resume, requests a decor relayout, and emits the RNdidUpdateDimensionsevent. Pure, idempotent transforms with unit tests.src/layout/window-bounds*.ts(x):WindowBoundsProvidermeasures the real root bounds (AndroiduseWindowDimensionsreports the display, not the freeform window); responsive layout uses window class with ±24 dp hysteresis; drawers, bottom sheets, onboarding pager and file preview size from measured bounds.innerWidth; refit triggers centralised.Escno longer leaves the session once a hardware keyboard is detected; focus/keyboard-avoidance no longer assumes an IME.docs/dex-mode-layout-design.md: investigation notes, mechanism with file/line evidence, emulator reproduction recipe.No version bump;
app.jsononly gains the plugin entry.Why
PixelUtil.toDIPFromPixeldivides byDisplayMetricsHolder.getScreenDisplayMetrics().density(the default/phone display, read through the Application context) whileReactSurfaceViewconstraints and the Fabric mount path use the Activity's display density.react-native-screens'Screenreports its size through that helper, so everything under expo-router's<Stack>is forced towindow × (d_window / d_phone)anchored at (0,0). With a 420 dpi phone on a 160 dpi monitor that is 0.381 of the window per axis — the reported block. The Kotlin hook is a workaround until upstream fixes it; the manifest/layout changes stay useful regardless.resizeableActivity+density|smallestScreenSizeinconfigChangesand the Samsung keep-alive metadata, DeX transitions and window drags recreated the Activity (full React remount).Linked Issue
Fixes #8592
Visual Proof
Stock API 35 emulator (
pixel_7, 420 dpi) with a1920x1080/160overlay display, app maximized on that display:ReactSurfaceViewScreenContentWrapper(what the user sees)Before/after screenshots of that exact setup are attached in a comment below (not committed, per template). Also confirmed on a real Galaxy device in DeX (maximized window fills the monitor; DeX enter/exit no longer restarts the app).
Testing
Emulator: before → top-left block; after → fullscreen 1920×1080, freeform 412×732, live resize 1000×700 and maximize all fill the window; phone display (1080×2400) unchanged. Recipe in
docs/dex-mode-layout-design.md§A.4/§A.7.Real Galaxy device in Samsung DeX: fixed.
pnpm test3701 passed / 3 skipped,pnpm typecheck,oxlint,oxfmt --checkclean (mobile/).Platforms touched: Android only (config plugin is
android-scoped; JS changes are platform-neutral and covered by vitest).I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Investigation, implementation and emulator verification were done with Claude (Claude Code, Fable 5) and OpenAI Codex, supervised and verified on a real device by the author.
Review
CodeRabbit round 1: 5 of 8 findings fixed in ebf8d903 with regression tests; 3 rejected with rationale in the threads.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
configChangesadditions mean the Activity is no longer recreated on density/size changes — the newonConfigurationChangedhook plus the existing JSDimensionslisteners cover that path; phone behaviour verified unchanged on the emulator's built-in display.requestLayoutper configuration change.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code