Repository navigation
fix(widgets): stop inline widget frames toggling their scrollbar - #20183
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check on a real Windows browser at a fractional display scale that inline frames settle and expanded frames still scroll. The 1px slack has only been run in emulation. Suggestions
[DESIGN-REVIEWED] c5f2985 Description read[DESCRIPTION-READ] 5d4db0608d66ab070482b1b3a31ddac35e76371bbead4f7e8bf319cea7a64450 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Before merge, check on real Windows that the four fixed-height hosts (expanded WidgetFrame, ArtifactBody, ArtifactThumbs, the mochi renderer) still scroll once the 300ms grace window passes. What this change shipsInventory (6 items) — 6 justifiedIntent: stop an inline widget's scrollbar from flickering and its content from reflowing in a loop on browsers that draw classic scrollbars. FIX.
[FIRST-PRINCIPLES-REVIEWED] c5f2985 Description read[DESCRIPTION-READ] e5ff0350e3f30659ef225c3157d07b9ecc43b8256af6ae222f88a51354cf6bda That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check the expanded/popout widget view on a real Windows machine: this fix was only measured in headless Chromium, and the scrollbar now appears 300ms after load. [UX-REVIEWED] c5f2985 Description read[DESCRIPTION-READ] ec8c73783fdbc304e1bc93900fb767dc214bd404c4a4bde17b5bcd90ae9c4f7c That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings that block the merge. FINDING — website/src/lib/widgetSrcdoc.ts:222 — [OPUS-REVIEWED] c5f2985 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
Replies to the review lanes:
|
|
Frontend Tests (2) on 6795422 is red on main, not from this diff: the same 5 tests in |
6795422 to
bb74da8
Compare
|
Rebased onto current main (head bb74da8); both commits are unchanged by the rebase. On the Design lane's blocker: no browser run with classic scrollbars is recorded for this change, and none is in the description. That ask stands as written. The verification that exists is deterministic:
A run in Chromium with scrollbars always shown would close the gap the lane names. Until such a run is recorded, a maintainer can either ask for it or override the Design concern. |
|
Design Review: the PR description's Manual verification section now records a real-browser run with classic scrollbars, on head bb74da8. It ran headless Chromium 145.0.7632.6 on Linux with Playwright's
No code change: the run shows the loop on the old reporter and the fix settling on classic scrollbars. |
A self-sizing widget frame a fraction of a pixel short of its content showed a classic vertical scrollbar, the narrower viewport re-wrapped the content taller, the frame grew, the scrollbar went, and the cycle repeated about twice a second. The height reporter now rounds the content height up and hides the frame's vertical overflow while the frame holds the whole document, so the content's width no longer depends on the frame's height. A frame held at a fixed height (expanded view, popout) gets its scroll back after a short grace window.
Content that keeps its aspect ratio gets shorter when a classic scrollbar narrows it. In a frame held at a fixed height, re-clipping on that fit widened the content past the viewport again and toggled the scrollbar every grace window. The scroll now stays until the viewport changes height.
bb74da8 to
c5f2985
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the inline widget height reporter rounds its measurement up and hides the frame's vertical overflow while the content fits, which stops the scrollbar resize loop; a fixed-height frame gets its scroll back after a grace window, and the reporter test covers both cases.
Problem / Motivation
Goal: A static inline widget frame stops flickering its vertical scrollbar and reflowing its content forever.
On Windows (and anywhere the browser draws a classic, space-taking scrollbar rather than an overlay one), a self-sizing inline widget frame whose content is a fraction of a pixel taller than the frame shows its own vertical scrollbar. That scrollbar narrows the viewport, the text re-wraps taller, the frame grows to the new report, the scrollbar disappears, the text re-wraps shorter, the frame shrinks back, and the scrollbar returns — a loop that runs about twice a second for as long as the widget is on screen.
Why it matters
Any user on a platform with classic scrollbars (the default on Windows) sees an inline widget's scrollbar strobe and its content jump continuously. It is distracting, makes the widget hard to read, and never settles on its own.
Not a goal
What changed (motivation → approach → change)
Root cause: a classic vertical scrollbar is the one thing that feeds the frame's height back into the content's width. When the frame is a sub-pixel short of its content, the scrollbar appears, which re-wraps the content, which changes the reported height, which removes the scrollbar — a self-sustaining oscillation. Two sub-pixel sources drive it: the height reporter measured
document.body.scrollHeight(an integer that can round down, leaving the frame short), and the frame's device-pixel-snapped viewport can be a fraction of a pixel shorter than its CSS height.Approach: break the feedback by (1) rounding the measured content height up so the frame is never sized short, and (2) hiding the frame's own vertical overflow while the frame holds the whole document, so the content's layout width no longer depends on whether a scrollbar is showing. A frame that is held at a fixed height (expanded view, popout, thumbnail) still needs to scroll, so the reporter gives the scroll back once the document stays taller than a viewport that is not resizing — a short grace window that every viewport resize restarts, so a frame still catching up to a growth is never mistaken for a fixed-height one.
Change, all in the iframe's injected height-reporter (
website/src/lib/widgetSrcdoc.ts):measure()now returnsMath.ceil(bodyTop + max(bodyRectHeight, body.scrollHeight) + bodyMarginBottom)instead ofbody.scrollHeight, so a fractional content height rounds up and the box's top offset and bottom margin are counted.htmlvertical overflow while everything fits, and restores the document's own inlineoverflow-yonce the content stays taller than the viewport past a grace window (default 300ms). A 1px fit slack absorbs device-pixel viewport snapping. The windowresizelistener restarts the grace window so a slow host growing the frame never gets its scrollbar back mid-growth.Backwards compatibility
Compatible: inline frames already auto-size to their content, so hiding the inner vertical overflow removes a scrollbar that should never have been needed there. Fixed-height frames (expanded/popout) keep their scrollbar via the grace-window path. No stored data, key, type, or public function changes.
Removes nothing: no capability, key, record, or path is removed; the inner scrollbar in inline mode was an artifact of the sub-pixel overflow, not a feature.
Tests
website/src/test/widgetSrcdocReporter.test.tsx(vitest, fake timers, no real sleeps):measure()rounds a fractional height up, counts body's top offset and bottom margin, and counts content overflowing body's box.overflow-y, stays hidden while a slow host is still growing the frame, and hides again when the frame grows back to fit.Manual verification
Recorded in a real browser with classic scrollbars: headless Chromium 145.0.7632.6 (Playwright 1.58.2) on Linux (kernel 6.12, x86_64), launched without Playwright's default
--hide-scrollbars, so it draws classic, space-taking scrollbars. Before each measurement the run asserts that a classic scrollbar has a width above 0 inside the widget frame's own document: 15px at 100% zoom, and 14px and 12px (CSS px) at 110% and 125%. Numbers only, no screenshots. No run on a Windows machine is recorded.Harness: the real
buildSrcdocoutput, bundled once from main (641b42a) and once from this branch (bb74da8), loads into a sandboxed iframe in a 640px column. A later rebase onto main (head c5f2985) leaveswidgetSrcdoc.ts, its imports,WidgetFrame.tsxandwidgetHeights.tsbyte-identical to the measured code. The host mirrorsWidgetFrame's height handling: round and clamp, apply a growth at once, apply a shrink after 250ms. Page zoom is CSSzoomon the column. ArequestAnimationFramesampler inside the frame recordsinnerWidth - documentElement.clientWidthandinnerHeight, and the host counts its iframe height writes. Each window is 10 s and starts 500ms after load.Shapes:
38 toggles in 10 s is the reported rate of about two cycles a second. At 100% zoom the card does not loop on main: its 0.47px overhang stays under the 0.5px at which this Chromium shows a scrollbar. At 110% and 125% the same card loops on main and settles on this branch. An emulated 1.25 or 1.5 device scale factor without page zoom did not start the loop in this run. The fixed-height aspect case keeps its scrollbar steady on both builds, so the scroll this branch hands back to a fixed-height frame stays put. The tall fixed-height frame keeps
overflow-y: visibleand scrolls by the same amount on both builds. At 125% the wheel moves 160 CSS px because the column is zoomed.The hosted-frame layout model test above also covers the oscillation and its fix deterministically: it reproduces the toggle on the pre-fix reporter and settles on the fixed one.
Screenshots / video
Why no screenshot: the only visual change is the absence of a strobing scrollbar on a correctly-sized inline frame — a frame that previously flickered now renders statically at the same size, so there is no new or changed rendered surface to capture, only a defect that no longer occurs.
Related Issues
N/A
Pattern harvest
Not generalizable: this is a specific layout feedback loop between a classic scrollbar's width and content re-wrapping inside a self-sizing iframe; the fix (round height up, clip inner overflow while self-sizing) is particular to the widget frame's reporter.
Checklist
Rejected / considered alternatives
overflow-y:hiddenunconditionally on inline mode (first suggestion): rejected because an inline widget that genuinely relies on an inner scroll would clip. The grace-window approach keeps the scroll for any frame held at a fixed height and only clips while the frame is actively holding the whole document.scrollbar-gutter: stableonhtmlinstead of the clip: it removes the width feedback, but it reserves an empty scrollbar-width strip on the right of every inline widget on classic-scrollbar platforms, a visible layout change for every existing inline widget (centred content shifts off-centre). The clip keeps the inline layout unchanged.