Skip to content

fix(mobile): the page pushes its terminal frame into the document from RN layout - #23079

Merged
Jinwoo-H merged 10 commits into
mainfrom
ota-fu-terminal-frame-push
Sep 28, 2026
Merged

Jinwoo-H merged 10 commits into
mainfrom
ota-fu-terminal-frame-push

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​302 $\color{#cf222e}{\Huge{\mathbf{−}}}$​105 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​197
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​122 $\color{#cf222e}{\Huge{\mathbf{−}}}$​59 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63

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 own ResizeObserver, which needed three guard rules in the document (fittedBox) to survive hidden screens reporting 0×0 and then their old box.

Now:

  • One mounted frame. A contentFrame View wraps every session branch and carries onLayout from the first mount, so the key is gone.
  • RN layout pushes the box. The page host's onLayout calls notifyViewport() on the mounted document, which drives the same observeViewport seam native drives from window.resize. No ResizeObserver on the page.
  • The document holds no page state. fittedBox and 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.
  • A fit asked for while hidden is held, not committed blind. That includes a text-size change too large to resize the grid at the hidden box (under the minimum column count): it holds the fit to show instead of dropping it, which the deleted fittedBox reset 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 no ResizeObserver is 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 true at 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).
  • Route-parity pin re-recorded for this change only (the key string gone, one more host node and style ref).

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

pullfrog Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Run failed. View the logs →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3cea77ba-068d-4028-82b4-695117d67ba1

📥 Commits

Reviewing files that changed from the base of the PR and between 7d59f63 and 0318ea6.

📒 Files selected for processing (4)
  • mobile/src/session/mobile-session-route-parity.test.ts
  • mobile/src/terminal/document/fit-scale.ts
  • mobile/src/terminal/document/text-scaling.ts
  • mobile/src/terminal/document/viewport-transform.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • mobile/src/terminal/document/viewport-transform.ts

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


📝 Walkthrough

Walkthrough

The 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 0318e

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 Review

Security architecture risk: 🔵 Low · up to 0318e

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — In the traced production path, the new notification is initiated by the mobile terminal host’s layout callback and reaches document geometry handling, rather than a command or authorization sink.

Trust Boundaries and Controls

  • inferred — The reviewed caller-to-document path adds no identified attacker-controlled input or privilege transition. The exported mount seam is runtime-reachable, but the observed production caller remains the in-app terminal component.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 Disclo… Add the missing template sections. Include a Linked Issue section with #22806, provide before-and-after visual proof or state N/A with a reason, complete the Testing checkboxes, address AI Disclosure as applicable, complete Review, Agent sk…
Docstring Coverage ⚠️ Warning Docstring coverage is 63.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 15 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: pushing the terminal frame into the document from React Native layout.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the 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 #22806, provide before-and-after visual proof or state N/A with a reason, complete the Testing checkboxes, address AI Disclosure as applicable, complete Review, Agent skill upstream boundary, Notes, and Checklist sections.

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

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.

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

@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 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. MobileSessionActiveContent renders every branch inside a contentFrame View that carries onLayout, replacing the keyed remount that forced react-native-web to observe the terminal frame.
  • RN layout pushes the box. The page host's onLayout calls notifyViewport(); a new pageViewport adapter seeds and updates the box, reports 'resized' vs 'shown', and answers the last laid-out size while hidden.
  • A held fit replaces fittedBox. scope.fitPending records a fit requested while hidden and runs it on show, and commitFitScale clears it; the three page-side refit guard rules and fittedBox are deleted.
  • Tests and parity pins updated, including a page-level mount suite over a grid double and re-recorded route-parity hashes.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8ad7b24e-65f7-4d2f-98b3-d80333b1b196

📥 Commits

Reviewing files that changed from the base of the PR and between 138e79e and 07e4aad.

📒 Files selected for processing (2)
  • mobile/src/terminal/document/text-scaling.ts
  • mobile/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.

@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

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 applyTextScale cannot resize the grid because the new cell size yields fewer than MIN_FIT_COLS columns while the host is hidden, it now calls applyFitScale(scope, 'text-scale'), which records fitPending under 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.ts drives a hidden host, applies set-font-scale: 2 (26px cell → 18 columns, under the floor), and asserts the show lands at 280 / (15 * 55); the assertion is exact and fails without the fix.

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

@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

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_COLS branch of applyTextScale previously called applyFitScale only 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 calls applyFitScale(scope, 'text-scale') unconditionally, and applyFitScale still holds the fit while hidden via its isViewportShown guard.
  • Test pins the visible path. terminal-web-document-mount.test.ts lays the host out at 280 px, applies set-font-scale: 2 (26 px → 18 columns, under the floor), and asserts the resulting scale is exactly 280 / (15 * 55) while the grid stays at 55 columns. The assertion fails against the prior conditional.

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

@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

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.ts now ends commitFitScale with emitKeyboardAvoidanceMetrics and reads getMeasuredCellHeight; text-scaling.ts routes a same-size text-scale change through applyFitScale and drops the transient metric emit; viewport-transform.ts gains getMeasuredCellHeight. The PR's fitPending/held-fit logic and narrow-branch applyFitScale are preserved alongside them.
  • Parity pins stay consistent. mobile-session-route-parity.test.ts keeps main's HEAD_CALLBACK_BODY_SHA256 alongside 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.

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

@Jinwoo-H
Jinwoo-H merged commit 52dc32f into main Sep 28, 2026
35 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-fu-terminal-frame-push branch September 28, 2026 04:06
Jinwoo-H added a commit that referenced this pull request Sep 28, 2026
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
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