Skip to content

fix(mobile): the page's terminal shows its last rows above the command dock (OTA phase C follow-up) - #22806

Merged
Jinwoo-H merged 9 commits into
mainfrom
ota-fu-page-terminal-rows
Sep 25, 2026
Merged

Jinwoo-H merged 9 commits into
mainfrom
ota-fu-page-terminal-rows

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​453 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​445
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​163 $\color{#cf222e}{\Huge{\mathbf{−}}}$​54 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​109

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.

  1. The page's terminal frame now reports its height. MobileSessionActiveContent renders every branch of the session content as a bare View in one slot, so the terminal frame reused the loading branch's element. react-native-web observes onLayout only 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 fired onLayout, the runtime never had a frame height, and every measure fell back to the window. Keying the frame mounts it fresh.
  2. The terminal document sizes itself to its host, not the window. Inside the native WebView the window is the terminal frame; on the page the window is the whole page, header and dock included. The document now reads one viewportSize seam (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 raw window.inner* reads out of document/.

Evidence (Pixel_API_37, Android 17, WebView 145, 1280×2856)

Cell Before After
Edge-to-edge shell (37820f9) + page, at rest PTY 63 rows, frame fits 47, 16 hidden 47, last row visible
Old shell (641a7f3) + page, at rest / after IME / reopen 58 rows, 11 hidden 47, last row visible
Page, text scale changed 39 rows vs 29 fit, 10 hidden 29, fits
Native 47, fits unchanged

Oracle: a script printing row n/N with a highlighted LAST ROW line; 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).
  • Route parity pin 529 → 530 for the key string only.

Round 2 (design review + CodeRabbit)

The document's coordinate space is its host, not only its size:

  • Origin. viewportRect replaces viewportSize (origin 0,0 plus the window in the WebView; the host's bounding box on the page). viewportPoint is the one place a clientX/Y meets that origin; cell mapping, mouse reports, the pinch anchor and selection edge-scroll all go through it. A second census allows raw clientX/Y arithmetic only as a difference of two client points.
  • Overlays. On the page the host is the containing block for the selection overlay and scroll indicator (position: absolute); the WebView keeps fixed.
  • Resize. observeViewport is a ResizeObserver on the host on the page and window resize in the WebView, so a host-only resize (dock height, docked panel) refits.
  • Zero-size host. A host hidden by react-native-screens (display: none) measures 0×0. The fit is held at the commit site while the host width is not positive, and the host observer restarts it once a box arrives: one commit, never scale 0. The refit acts only on a positive box other than the one the last fit was committed for, so hiding the session and showing it again at the same size keeps the user's pan and zoom, as native does, while a real size change still refits. A fit asked for while hidden (a resize or reflow from another client, a text-scale change the hidden grid could not apply) forgets the last fitted box, so the show refits instead of keeping a stale scale. Edge-scroll bands are pinned to the host's edges (host top 100, height 600: the down band starts at client Y 660, not 560).

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

  • With the IME up, the page's terminal shows rows 1–27 while native lifts to the last row: the page reads 0 occlusion because the shell shortens the WebView, so no lift. Separate follow-up.
  • Three config/scripts packaging tests fail in the lane rig because the shared node_modules predates feat(search): bundle ripgrep for local, WSL, and SSH search #22396's ripgrep dependency; they pass on a fresh install.

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
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 77c7d583-76c1-4da5-97c1-efba8c9454af

📥 Commits

Reviewing files that changed from the base of the PR and between 4a7c2b3 and 64d4cee.

📒 Files selected for processing (17)
  • config/scripts/mobile-web-app-terminal-render.test.mjs
  • mobile/src/session/mobile-session-route-parity.test.ts
  • mobile/src/terminal/document/document-host-seams.ts
  • mobile/src/terminal/document/document-scope.ts
  • mobile/src/terminal/document/fit-scale.ts
  • mobile/src/terminal/document/host-message-router.ts
  • mobile/src/terminal/document/host-seams.test.ts
  • mobile/src/terminal/document/mouse-report-cell.ts
  • mobile/src/terminal/document/selection-overlay.ts
  • mobile/src/terminal/document/surface-touch-gestures.ts
  • mobile/src/terminal/document/text-scaling.ts
  • mobile/src/terminal/document/viewport-cell.ts
  • mobile/src/terminal/document/viewport-frame.test.ts
  • mobile/src/terminal/document/viewport-transform.ts
  • mobile/src/terminal/document/wheel-scroll.ts
  • mobile/src/terminal/terminal-web-document-mount.test.ts
  • mobile/src/terminal/terminal-web-document-mount.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • mobile/src/terminal/document/selection-overlay.ts
  • mobile/src/session/mobile-session-route-parity.test.ts
  • mobile/src/terminal/terminal-web-document-mount.ts
  • mobile/src/terminal/document/document-scope.ts
  • mobile/src/terminal/document/document-host-seams.ts
Files not reviewed due to moderation or processing errors (12)
  • mobile/src/terminal/document/fit-scale.ts
  • mobile/src/terminal/document/host-message-router.ts
  • mobile/src/terminal/document/text-scaling.ts
  • mobile/src/terminal/document/viewport-transform.ts
  • mobile/src/terminal/document/wheel-scroll.ts
  • mobile/src/terminal/document/viewport-cell.ts
  • mobile/src/terminal/document/mouse-report-cell.ts
  • mobile/src/terminal/document/surface-touch-gestures.ts
  • mobile/src/terminal/document/host-seams.test.ts
  • mobile/src/terminal/document/viewport-frame.test.ts
  • config/scripts/mobile-web-app-terminal-render.test.mjs
  • mobile/src/terminal/terminal-web-document-mount.test.ts

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


📝 Walkthrough

Walkthrough

The 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 64d4c

The terminal sizing and coordinate changes are mergeable after normal checks. No actionable merge-blocking issue is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 64d4c

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

  • Low · reliability · inferred: A positive-width, zero-height host can pass the new refit gate and commit sizing state. If measured without a positive frame-height override, it can also report eight rows rather than the usable host height. Occurrence and recovery in production layout remain unverified.
Security review details

Security Blast Radius

  • inferred — The inspected change affects geometry and interactions within the mounted terminal. It does not establish expanded session, tenant, credential, or transport authority.

Trust Boundaries and Controls

  • observed — The default document scope keeps host transport separate from viewport measurement. Mouse reports are mapped into, and clamped within, the existing terminal grid.

Resilience and Maintainability Implications

  • inferred — Width-only validation leaves an intermediate zero-height state able to alter fit state; measurement can also advertise the minimum row count when no positive frame height is supplied. Production occurrence and downstream recovery are unknown.

Hardening Proposals

  • proposed — Require usable height as well as width before committing a host-relative fit or reporting fallback rows, and verify that measurement resumes when the host regains height.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.88% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 19 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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 iss… 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 Disclos…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the mobile terminal row-visibility fix above the command dock, which matches the main change.
Full details: Description check

Explanation

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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ 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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: c217cfa6-3aa8-4666-b407-89613fe81038

📥 Commits

Reviewing files that changed from the base of the PR and between f5d2ce5 and 4a7c2b3.

📒 Files selected for processing (15)
  • mobile/src/session/MobileSessionActiveContent.tsx
  • mobile/src/session/mobile-session-route-parity.test.ts
  • mobile/src/session/mobile-session-terminal-frame-layout.test.tsx
  • mobile/src/terminal/document/document-host-seams.ts
  • mobile/src/terminal/document/document-scope.ts
  • mobile/src/terminal/document/fit-scale.ts
  • mobile/src/terminal/document/host-message-router.ts
  • mobile/src/terminal/document/host-seams.test.ts
  • mobile/src/terminal/document/mouse-report-cell.ts
  • mobile/src/terminal/document/selection-overlay.ts
  • mobile/src/terminal/document/surface-touch-gestures.ts
  • mobile/src/terminal/document/text-scaling.ts
  • mobile/src/terminal/document/viewport-transform.ts
  • mobile/src/terminal/document/wheel-scroll.ts
  • mobile/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.

@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 new issues found.

Reviewed changes

  • The page's terminal frame reports its height again — keying the terminal-branch View makes react-native-web remount it with its onLayout, so the frame height reaches measureFitDimensions instead of falling back to the window. I confirmed against the installed [email protected] source that useElementLayout observes 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 the key.
  • The document sizes itself to its host — a new viewportSize seam replaces every raw window.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×40 vs the window's 136×51), and a source census keeping raw window reads out of document/; 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.

Pullfrog  | View workflow run | Using 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

@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 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 — viewportSize became viewportRect (origin plus size) and a single viewportPoint maps 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 observeViewport seam (ResizeObserver on the page, window resize in the WebView) now drives startFitScale, so a dock or docked-panel resize refits without a window resize.
  • Hidden-host fit hold — fittedBox/isFittedBox/hasViewportWidth keep a fit pending while a display:none host 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 absolute under a relatively-positioned host instead of fixed over 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit c9d421f into main Sep 25, 2026
32 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-fu-page-terminal-rows branch September 25, 2026 10:03
kiwidream added a commit to SwapLabsInc/orca that referenced this pull request Sep 25, 2026
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]>
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