Repository navigation
fix(mobile): the page pushes its terminal frame into the document from RN layout - #23079
Conversation
The frame was keyed so react-native-web would attach its onLayout: a View that gains onLayout after mount is never observed, and unkeyed the frame reused the loading branch's View. One contentFrame View now wraps every branch and carries the handler from the first mount, so no key is needed. terminalFrame stays on the terminal branch, so nothing else is clipped. The parity pin moves: the key string leaves, one View and one style reference arrive. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ayout The page's document sized itself through a ResizeObserver on its host, which duplicated RN layout and needed three rules in fit-scale: skip a 0-wide box, skip the last fitted box, and forget that box on any fit request. The host View's onLayout now pushes into the mount, which is the page's counterpart of the WebView's window resize. react-native-web still lays a display:none screen out as 0x0 and its return as the old box, so the mount treats neither as a change and keeps answering the last real box while hidden, as a WebView keeps its size. A fit asked for while hidden therefore lands at once, and fittedBox and all three rules go. The zero-width wait in applyFitScale stays for a host that mounts under a hidden screen before its first layout. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
A fit asked for under a covering screen read the last box, but where xterm cannot measure cells on a display:none host (its DOM measure, with no OffscreenCanvas) the retry loop ran out and committed scale 1, and the show that followed was not a change, so 1 stuck. The page's rect now says when the host is hidden, and the document holds any fit asked for then as fitPending instead of committing. The mount reports the same box coming back as 'shown', distinct from 'resized', and the document runs a held fit on it and otherwise does nothing, so pan and zoom still survive a plain hide and show. Native's window resize reports 'resized' and is never hidden. The mount also seeds its box from the host, so a first layout that lands before the mount is not later mistaken for a resize. The hidden text-scale case now asserts the resized column count, which stale cells miss. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…cell The init render check read the grid the moment .xterm-screen existed, but xterm sizes its one-cell helper textarea only on a cursor move or resize, after the replay drains. Under full-suite load the read won that race and measured a 0-wide cell. In the failing runs the fit had committed at 390/560 on the cell-width gate, so the page was right and the read was early. It now waits for a sized cell: 8/8 under four-way parallel load, where it was 4/8. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
A held fit that lands on show must be spent: a second hide and show re-running it would reset the pan and zoom the user set in between. The case now hides and shows again and expects no new transform, which a commit that stops clearing fitPending fails. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Run failed. View the logs →
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe session content now uses a shared frame for layout measurement and terminal frame-height updates. The terminal host reports layout changes through a page viewport adapter, which distinguishes shown and resized events. Terminal fitting now tracks work deferred while the host is hidden. Tests cover session branch changes, host layout notifications, and hide/show fitting behavior. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The terminal now refits after a narrow text-scale change made while hidden. No material merge-blocking issue is established, so the PR appears ready for normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The changed behavior is confined to mobile terminal layout and fitting. The reviewed paths show no new security-sensitive entrypoint or privilege change, but security coverage is incomplete. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the change, rationale, implementation, linked follow-up issue, and test coverage. However, it omits several required template sections, including ELI5, Visual Proof, AI Disclosure, Review, Notes, Agent skill upstream boundary, and Checklist. It also does not provide the required visual proof or an explicit N/A statement. Resolution Add the missing template sections. Include a Linked Issue section with
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
Picks up #23090 (terminal-pane hook-order parity re-pin) so the desktop test shard runs on a current merge ref. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
ℹ️ No critical issues — one edge-case suggestion inline.
Reviewed changes
This run reviewed the full PR (no prior Pullfrog review): the page build of the terminal document now takes its viewport box from React Native Web's onLayout instead of a page-level ResizeObserver, and holds a fit requested while the host is hidden.
- One mounted frame.
MobileSessionActiveContentrenders every branch inside acontentFrameView that carriesonLayout, replacing the keyed remount that forced react-native-web to observe the terminal frame. - RN layout pushes the box. The page host's
onLayoutcallsnotifyViewport(); a newpageViewportadapter seeds and updates the box, reports'resized'vs'shown', and answers the last laid-out size while hidden. - A held fit replaces
fittedBox.scope.fitPendingrecords a fit requested while hidden and runs it on show, andcommitFitScaleclears it; the three page-side refit guard rules andfittedBoxare deleted. - Tests and parity pins updated, including a page-level mount suite over a grid double and re-recorded route-parity hashes.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
A text-scale change whose new cells leave fewer than MIN_FIT_COLS in the box skips the grid resize and returned before any fit. Base cleared fittedBox there so the next box refit; with that gone, a hidden host shown at the same box kept the old scale under the larger font. The branch now asks for the fit while the host is hidden, which holds it until show. A shown host, and every native one, returns as before. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Picks up #22635's render-harness rewrite so the page terminal render test runs its current form. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 8ad7b24e-65f7-4d2f-98b3-d80333b1b196
📒 Files selected for processing (2)
mobile/src/terminal/document/text-scaling.tsmobile/src/terminal/terminal-web-document-mount.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the delta since the prior Pullfrog review (138e79e) on the page build of the mobile terminal. The single follow-up commit closes the held-fit gap the previous review flagged.
- Held refit for a narrow hidden text-scale change. When
applyTextScalecannot resize the grid because the new cell size yields fewer thanMIN_FIT_COLScolumns while the host is hidden, it now callsapplyFitScale(scope, 'text-scale'), which recordsfitPendingunder the hidden check, so a same-box show refits at the new cell size instead of rendering the larger font against the old fit. - Test pins the path.
terminal-web-document-mount.test.tsdrives a hidden host, appliesset-font-scale: 2(26px cell → 18 columns, under the floor), and asserts the show lands at280 / (15 * 55); the assertion is exact and fails without the fix.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
A visible viewport too narrow for the new cells (280 px at 200%, 18 columns) skipped the resize and returned without a fit, so the larger text overflowed the fit made for the smaller cells. The branch now fits unconditionally; applyFitScale already holds the fit while hidden. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the delta since the prior Pullfrog review (07e4aad) on the page build of the mobile terminal. The single follow-up commit closes a visible-host gap adjacent to the held-fit work.
- Fits a text-scale change too large to resize the grid while visible. The
cols < MIN_FIT_COLSbranch ofapplyTextScalepreviously calledapplyFitScaleonly when the host was hidden; on a visible narrow host it returned without any fit, so the larger text rendered against the fit made for the smaller cells. The branch now callsapplyFitScale(scope, 'text-scale')unconditionally, andapplyFitScalestill holds the fit while hidden via itsisViewportShownguard. - Test pins the visible path.
terminal-web-document-mount.test.tslays the host out at 280 px, appliesset-font-scale: 2(26 px → 18 columns, under the floor), and asserts the resulting scale is exactly280 / (15 * 55)while the grid stays at 55 columns. The assertion fails against the prior conditional.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the delta since the prior Pullfrog review (7d59f63) on the page build of the mobile terminal. The only new commit is a merge of origin/main that folds main's keyboard-avoidance work (#23070) into the same files this PR touches; the reconciliation is clean and every affected mobile test passes.
- Main's #23070 folded in.
fit-scale.tsnow endscommitFitScalewithemitKeyboardAvoidanceMetricsand readsgetMeasuredCellHeight;text-scaling.tsroutes a same-size text-scale change throughapplyFitScaleand drops the transient metric emit;viewport-transform.tsgainsgetMeasuredCellHeight. The PR'sfitPending/held-fit logic and narrow-branchapplyFitScaleare preserved alongside them. - Parity pins stay consistent.
mobile-session-route-parity.test.tskeeps main'sHEAD_CALLBACK_BODY_SHA256alongside the PR's runtime-string, host-JSX and style hashes, and the parity test passes. - No behavior change for this PR. The merge introduces main's already-reviewed work only; no author-authored changes land in this delta, and 76 tests across the 8 touched test files pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Carries #23070 (row pitch emitted once, at the fit commit) and #23079 (the page pushes its frame box; one contentFrame View holds onLayout). The frame's onLayout keeps this branch's unrounded width and frame-layout subscribe; the scope keeps hostFrame beside fitPending (fittedBox left with main's fit rewrite); a text-scale change fits through the one fitDimensionsFromCell, over the viewport until a measure gives the frame, and a too-narrow fit still commits through applyFitScale. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

What
Follow-up to #22806. That PR made the page's terminal document read its box from its host element, but two parts were workarounds: the terminal frame was keyed to force a remount so react-native-web would attach
onLayout, and the page watched the host with its ownResizeObserver, which needed three guard rules in the document (fittedBox) to survive hidden screens reporting 0×0 and then their old box.Now:
contentFrameView wraps every session branch and carriesonLayoutfrom the first mount, so the key is gone.onLayoutcallsnotifyViewport()on the mounted document, which drives the sameobserveViewportseam native drives fromwindow.resize. NoResizeObserveron the page.fittedBoxand the three refit rules are deleted. The page's viewport adapter ignores a 0×0 box and a repeat of the last box, and answers the last laid-out size while hidden, as a WebView keeps its size under a covering screen. It reports a show separately from a resize.fittedBoxreset used to cover. A visible host that narrow gets the same fit at once, so the larger text never overflows the fit made for the smaller cells. Where xterm cannot measure a hidden element, the old retry loop timed out and committed scale 1. The document now keeps the fit pending and runs it when the host is shown; a plain hide and show with nothing pending changes nothing, so pan and zoom survive.Behaviour on the emulator is unchanged from main: 47 rows with the last row visible, taps map to the right cell, overlays inside the host, navigate away and back keeps pan and zoom, rotation refits, text-size change refits, keyboard open/close keeps 47 rows. Native path unchanged.
Tests (red first)
mobile-session-terminal-frame-layout.test.tsx: the frame reports its height from the loading state without a key (expected [600, 600] to deeply equal [600]on base).terminal-web-document-mount.test.ts: a pushed box refits the document and noResizeObserveris constructed; hide/show keeps pan and zoom; a fit asked for while hidden lands on show (expected 0.65 to be 0.945); a blind fit is never committed while the grid cannot be measured; the host seeds the box when RN laid it out before the mount existed; a text-scale change while hidden lands at 67 columns; a text scale too large to resize a visible 280 px grid still fits it (expected false to be trueat the fit wait).config/scripts/mobile-web-app-session-terminal-init.test.mjs: the init check now waits for xterm to size a cell instead of reading the grid as soon as the screen element exists (a load race; the exact cols/rows assertion is unchanged).