Repository navigation
fix(mobile): the page's terminal shows its last rows above the command dock (OTA phase C follow-up) - #22806
Conversation
On the page every branch of the session content is a bare View in one slot, so the terminal frame reused the loading View. react-native-web observes onLayout only on a View that mounts with it, so the frame never reported its height: every measure fell back to the page's window.innerHeight and the PTY got rows the frame cannot show (63 vs 47 on a 1280x2856 screen), with the last rows under the command dock. Keying the frame makes it mount fresh. The parity pin moves for the key string. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Inside the WebView the window is the terminal frame; on the page it is the whole page, header and dock included. Every fit, pan, scroll and overlay bound in the document read window.innerWidth/innerHeight, so a measure without a container height sized the PTY to the page. The document now reads one seam, viewportSize: the window by default (native unchanged), the host element's box on the page. A census keeps raw window size reads out of document/. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (17)
🚧 Files skipped from review as they are similar to previous changes (5)
Files not reviewed due to moderation or processing errors (12)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe terminal document now receives a viewport rectangle and change notifications from its host. Sizing, fit behavior, and interaction coordinate calculations use the host viewport. The web mount positions terminal overlays within the host. The terminal frame also has a stable React key, and a test checks its height notification when the session transitions from loading to active. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The terminal sizing and coordinate changes are mergeable after normal checks. No actionable merge-blocking issue is established. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to No new terminal access or authority was identified. The remaining risk is that a briefly zero-height terminal frame could produce an incorrect fit or row measurement; whether that state occurs in normal use is unconfirmed. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the technical changes, motivation, evidence, and tests, but it omits or does not complete several required template sections, including ELI5, Why, Linked Issue with a real issue reference, Visual Proof attachments or an explicit N/A, testing checklist details, AI Disclosure, Review, Notes, and the final Checklist. Resolution Complete the required template sections. Add an ELI5 summary, a separate Why section, the linked issue in the Fixes field, before-and-after visual attachments or an explicit N/A with a reason, manual-testing status and platforms, AI Disclosure if applicable, Review, Notes, Agent skill upstream boundary, and the final checklist statuses.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Warning Review coverage is incomplete: 12 files could not be fully reviewed. Findings from completed review steps are included; see review info for details. 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: c217cfa6-3aa8-4666-b407-89613fe81038
📒 Files selected for processing (15)
mobile/src/session/MobileSessionActiveContent.tsxmobile/src/session/mobile-session-route-parity.test.tsmobile/src/session/mobile-session-terminal-frame-layout.test.tsxmobile/src/terminal/document/document-host-seams.tsmobile/src/terminal/document/document-scope.tsmobile/src/terminal/document/fit-scale.tsmobile/src/terminal/document/host-message-router.tsmobile/src/terminal/document/host-seams.test.tsmobile/src/terminal/document/mouse-report-cell.tsmobile/src/terminal/document/selection-overlay.tsmobile/src/terminal/document/surface-touch-gestures.tsmobile/src/terminal/document/text-scaling.tsmobile/src/terminal/document/viewport-transform.tsmobile/src/terminal/document/wheel-scroll.tsmobile/src/terminal/terminal-web-document-mount.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- The page's terminal frame reports its height again — keying the terminal-branch
Viewmakes react-native-web remount it with itsonLayout, so the frame height reachesmeasureFitDimensionsinstead of falling back to the window. I confirmed against the installed[email protected]source thatuseElementLayoutobserves in a mount-keyed effect and only when a handler was present at mount, and confirmed the new test is red on base by removing thekey. - The document sizes itself to its host — a new
viewportSizeseam replaces every rawwindow.inner*read across fit, pan clamp, text-scale rows, wheel, selection overlay, mouse report, and touch gestures; the page answers with the host element's box, the WebView keeps the window. - Red-first and census tests — a frame-layout test that fails on base, a read-at-call-time default test, a host-fit measure test (
390×600 → 52×40vs the window's136×51), and a source census keeping raw window reads out ofdocument/; route-parity pins refreshed.
Verification this run: src/terminal (634 tests) and src/session (1762 tests) pass, changed mobile files lint clean, and the mobile tests-typecheck ratchet is OK. Mobile tsc --noEmit exits 2 on a pre-existing tsconfig.json baseUrl deprecation under TS 6.0.3, unrelated to this PR.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Round one moved the page document's size to its host but left its origin at the window, so a tap below the session header mapped rows low (row 19 for row 11), and the selection overlay and scroll indicator, position: fixed, drew over the page. - viewportRect replaces viewportSize: the host's box on the page, the window at 0,0 in the WebView. viewportPoint is the one place a client point meets that origin; cell mapping, mouse reports, the pinch anchor and edge scroll go through it, and a census holds the rest to deltas. - observeViewport: the fit refits on a host ResizeObserver on the page, a window resize in the WebView. - A hidden host measures 0x0; the fit keeps scale 1 rather than 0. - On the page the host is the overlays' containing block. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The overlay is absolute inside the host now, and the page's refit follows the host's box, so the owed-frame case pulses the host rather than the window. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
computeFitScale answered 1 for a 0-wide host, but applyFitScale still committed that fit as soon as the cell width was known, so a display:none screen got a fit for no box. The attempt now leaves the fit pending until the host reports a positive width, and observeViewport starts it again once it does: one commit, never at scale 0. A regression test pins edge scroll to the host's edges: with the host at top 100 and height 600, the down band starts at client Y 660, not 560. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
react-native-screens hides the session with display:none when another screen covers it, so the host's observer reports 0x0. The refit still clamped pan and repainted, so coming back to the session lost the pan the user left; native never refits on navigation. The refit now does nothing until the host has a positive width, and the next real box refits once. Also untangles the seam-count sentence in document-host-seams. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Coming back to a session takes the host from 0x0 to its old box. The observer fired, the refit committed, and the user's pan and zoom were reset, where native keeps them because navigation never resizes its WebView. The fit now remembers the box it was committed for, and the refit acts only on a positive box different from that one. The frame tests wait on the document's own frames instead of a timer, and the hidden-host case asserts the zero-width read happened. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…dden The zero-width gate drops a fit requested while the host is hidden, and the same-box skip then kept the stale fit when the host came back at its old size: 80 columns at 390 px stayed at the 55-column scale, 0.945 instead of 0.65. Any fit request now forgets the last fitted box, and so does a text-scale change that could not resize a hidden grid. A plain hide and show asks for no fit, so it still keeps pan and zoom. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Round 2 (commits 394ca01..64d4cee), the coordinate-space rework on top of round 1's host sizing.
- Host-origin coordinates —
viewportSizebecameviewportRect(origin plus size) and a singleviewportPointmaps every client point into the grid's frame, so a tap, handle drag or pinch below the page's header lands where the WebView would put it. - Host-driven refit — a new
observeViewportseam (ResizeObserveron the page, windowresizein the WebView) now drivesstartFitScale, so a dock or docked-panel resize refits without a window resize. - Hidden-host fit hold —
fittedBox/isFittedBox/hasViewportWidthkeep a fit pending while adisplay:nonehost measures 0×0, preserve pan and zoom across a hide/show at the same box, and refit when the box truly changes or a fit was requested while hidden. - Overlay containing block — on the page the selection overlay and scroll indicator become
absoluteunder a relatively-positioned host instead offixedover the whole page. - Tests and pins — new
viewport-frame.test.ts, host-seams refit and client-arithmetic census tests, an overlay-position test, and the route-parity and render-e2e pin refreshes.
Verification this run: mobile/ dependencies installed; src/terminal (69 files) and src/session (188 files) pass, including every changed test file. Two independent lens reviews separately refuted the two open questions — no remaining raw-client-coordinate/grid-state conjunction, and no reachable stale-scale path — and confirmed the new guard tests each fail when the guard they name is removed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
The owed-frame case failed on every run since stablyai#22806: "the document owed a frame at the moment dispose returned: expected 0 to be greater than 0". Dispose still cancels what it owes; the case stopped provoking anything to owe. The page's refit now follows the host's box and skips a box it already fitted. The retry fits the box it finds when it runs, which the next pulse has already put back, so the observer's report of it is skipped and a frame is owed only every other frame; with 200 ms at 60 Hz the unmount always lands on the empty half. A detached host also has no box, so nothing box-driven asks for a frame between React's detach and dispose, and a frame served there (under 2 ms apart locally, about 50 ms under a 20x CPU throttle) spends the one that was owed. The case now asks for the same applyFitScale frame through the handle (reset-zoom) from each of its own frames, holding the handle past the unmount. A frame asked for after the detach has no container for the leak list to judge by, so the frames owed at dispose are named there and each is asserted never to have run. With cancelDocumentFrames removed the case fails, throttled or not; the leak list alone passes that mutation under throttle. Co-Authored-By: Claude Opus 5.5 <[email protected]>

What
On the hybrid-shell page, a terminal with more lines than fit hid its last rows under the command dock: a Claude Code session's input box was off screen, while native showed it. Two page-side fixes, native unchanged.
MobileSessionActiveContentrenders every branch of the session content as a bareViewin one slot, so the terminal frame reused the loading branch's element. react-native-web observesonLayoutonly on an element that mounts with the handler (useElementLayout: the ResizeObserver is attached in an effect keyed on the ref, and only when a handler is already set), so the frame never firedonLayout, the runtime never had a frame height, and every measure fell back to the window. Keying the frame mounts it fresh.viewportSizeseam (the window by default, the host element's box on the page) at every size bound: fit, pan clamp, text-scale rows, wheel, selection overlay, mouse report, touch gestures. A census test keeps rawwindow.inner*reads out ofdocument/.Evidence (Pixel_API_37, Android 17, WebView 145, 1280×2856)
Oracle: a script printing
row n/Nwith a highlightedLAST ROWline; page and native shots agree after the fix.Tests (red first on the base sources)
mobile-session-terminal-frame-layout.test.tsx: the frame reports its height when the session opens from the loading state (expected [] to deeply equal [ 600 ]before).host-seams.test.ts: the default seam reads the window at call time; a measure with no container height fits the host (390×600) rather than happy-dom's window (52×40 vs 136×51 before); census: every size read goes through the seam (7 raw reads before).Round 2 (design review + CodeRabbit)
The document's coordinate space is its host, not only its size:
viewportRectreplacesviewportSize(origin 0,0 plus the window in the WebView; the host's bounding box on the page).viewportPointis the one place aclientX/Ymeets that origin; cell mapping, mouse reports, the pinch anchor and selection edge-scroll all go through it. A second census allows rawclientX/Yarithmetic only as a difference of two client points.position: absolute); the WebView keepsfixed.observeViewportis aResizeObserveron the host on the page and windowresizein the WebView, so a host-only resize (dock height, docked panel) refits.Emulator (new shell + page, by logpoint): a tap on row 11 with the host top at 134 CSS px reports
viewportRow 10(the old mapping gave 19); a tap on the last row reports 46. The scroll indicator spans 138–844 inside the host's 134–848 (fixed would span 4–948); the selection menu and handles sit inside the host on the long-pressed line. Rest state unchanged: 47 rows, last row visible. Red-first: 8 new tests fail with the round-1 sources (tap below a header maps rows low, hidden host scales to 0, no host refit, overlay outside the host).Not in this PR
config/scriptspackaging tests fail in the lane rig because the sharednode_modulespredates feat(search): bundle ripgrep for local, WSL, and SSH search #22396's ripgrep dependency; they pass on a fresh install.