Repository navigation
MUL-8700: HTML viewer Fit scales a wider document down to fit - #10055
Merged
Merged
Conversation
…o fit (MUL-8700) Fit laid the document out at the stage's width and stopped there, so a page built for a wider screen (a fixed-width table, a grid of min-width cards) ran past the right edge and scrolled sideways; only Desktop, which lays out at 1440 and scales, showed the whole page. A width bridge appended to the document reports how wide it needs to be (the iframe is an opaque origin, so the parent cannot read scrollWidth). When that is wider than the stage, Fit lays the document out at its own width and scales it down, with the size and scale in the caption like the device widths. Pages that fit, and pages that clip their own overflow, stay at 100%. The learned width only grows for the same document, resets for a new one, and is capped at twice the desktop width. Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…rgets it off Fit (MUL-8700) Review on #10055 found two feedback loops in the learned Fit width: - A document whose overflow grows with its viewport (a width: 100% box with padding) overflowed again at every widened width, so Fit chased it up to the 2880 cap and scaled the page to 35%. - Reports measured at a device width fed Fit too: past a desktop breakpoint a responsive page reported 1600, and back in Fit it stayed at 1600 / 63% instead of its own 100% layout. Fit now makes one attempt per document and stage width, started only by an overflow measured at the stage's own width and settled only by a report at the attempt's width. If the document still overflows there, widening cannot settle it and Fit fills the stage as before this change. A document wider than the cap fills the stage too. Leaving Fit forgets the attempt, and on return the frame asks the bridge for a fresh measurement, since a frame already at the stage's width gets no resize. Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
In the attachment viewer, Fit on an HTML file did not fit. It laid the document out at the stage's width and stopped there, so a page built for a wider screen (a wide comparison table, a grid of min-width cards: the kind of report agents produce) ran past the right edge and scrolled sideways. Only Desktop, which lays out at 1440px and scales down, showed the whole page.
Now Fit lays an over-wide document out at its own width and scales it down so the whole width is visible. The caption shows the size and scale, the same as for the device widths. Pages that already fit stay at 100%, exactly as before.
How
utils/iframe-width-bridge.ts: a small script appended to the document (like the fragment-nav shim). The iframe is an opaque origin, so the parent cannot readscrollWidth; the script posts{doc, viewport, needed}on load, resize, fonts-ready and ResizeObserver, and on ameasurerequest from the parent. Theneededwidth counts a classic scrollbar's gutter. A document that clips its own overflow (overflow-x: hidden/clip) reports no overflow. The parent validates every message.HtmlViewportFrame/nextFitAttemptmake one attempt per document and stage width:width: 100%box with padding, or a breakpoint that jumps wider), so Fit falls back to filling the stage, exactly as before this PR.Verification
measure),nextFitAttempt, and the component: scale, keep, fail back to fill, new document, cap, device isolation, re-measure on return, and other-window messages ignored.editor/andattachments/suites: 1739 passed.tscclean; lint clean on the changed files.width:100%; padding:24pxCloses MUL-8700.