Repository navigation
Replace the preview growth breaker with a 560px cap and explicit fill/content sizing - #291
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the sizing logic of the RenderedFrame component by replacing the complex runaway growth circuit breaker with a simpler, more robust mechanism based on explicit sizing modes ('fill' and 'content') and a content height cap of 560px. The 'fill' mode is used when the host has a definite height, while 'content' mode allows the frame to dynamically grow with its content. Additionally, the PR extracts catalog watchdog constants for improved testability, introduces guest simulation testing utilities, and significantly expands both unit and end-to-end test coverage to validate these sizing behaviors. I have no feedback to provide as the changes are well-implemented and thoroughly tested.
RenderedFrame's opt-in fillContainer boolean is replaced by a required `sizing: 'fill' | 'content'` input (type RenderedFrameSizing), so every host chooses a mode. The side canvas, the Dockview Rendered panel, the gallery Preview card (also the hidden default-target frame) and the hidden /demos coordinator fill their host; only the inline chat surface sizes to its content. The Dockview service sets the input with setInput before the panel's first change detection. Every validated SURFACE_RESIZE height is stored in either mode, and the mode is applied only in the computed frameHeight. A filling frame keeps its default size; a switch to content applies the last report at once. Switching to fill also ends any growth-breaker hold, so its settle timer and ceiling cannot touch the stored report. The messageStream$ subscription moves to ngOnInit. The stream is a ReplaySubject, so subscribing in the constructor handled the buffered envelope before the host had set the required input (NG0950). A replayed envelope that names a source window is ignored while the frame's own iframe does not exist yet, since it belongs to another frame. The 280px floors now apply only in content mode, keyed on a data-sizing attribute that the harness also reads. The Dockview overflow and min-height overrides on the frame are removed: Dockview gives the panel overlay a definite pixel height and the frame fills it. The gallery Preview card is a fixed 400px. Tests: RenderedFrameHarness gains getSizing, getAppliedHeightPx and simulateFrameLoad; call-site harnesses expose the child frames; a shared bridge-envelopes builder replaces hand-built envelopes. E2E: the docked preview fills its panel and the guest scrolls; the grow/shrink, tall surface and feedback-loop checks run against an inline chat surface; the gallery card is 400px; /demos and /gallery log no catalog watchdog timeout, using constants from the new Angular-free catalog-watchdog.ts.
Adds behavior tests RT-1 to RT-13 for a content-sized RenderedFrame. They assert only the applied height, read through RenderedFrameHarness after every pending timer has run, so they do not depend on how growth is bounded. They pass against the current growth breaker and are meant to run unchanged against the stateless height cap that replaces it. Every scenario ends below 560px. Runaway and transition scenarios send at least 16 consecutive growing reports, enough to engage the breaker. The scenarios cover transitions at 60Hz and 120Hz, streaming growth, expand/collapse/expand, a guest that grows with every applied height, transitions of more than 48 reports, streaming into an expansion, growth 600ms apart, a new payload, RENDERER_READY or a session reset mid-run, destruction mid-run, a burst within one tick, and a run broken by one non-growing report. New shared helpers in preview/testing/simulate-guest.ts drive a guest that reacts to the applied height (simulateGuest) or follows a script (playReports), using fake timers and the bridge-envelopes builder. Existing specs that applied raw heights above 560px now use values below it, without changing what they test. No production code changes.
A content-sized RenderedFrame now applies clampContentHeight(latest report): the report rounded up and limited to MAX_CONTENT_HEIGHT_PX (560), or no height for a non-finite or non-positive report. Both live in the new framework-free preview/content-height.ts. A guest laid out against its own viewport reports a little more than every height the host applies. Under the cap the applied height stops changing once it reaches 560px, so the guest stops reporting and the loop ends, with no timers and no state beyond the latest report. This holds for monotone growth only; oscillation below the cap remains the job of the "settles without a SURFACE_RESIZE feedback loop" e2e test. The growth breaker is removed: its constants, latch, run tracking, settle timer and probe, renderer-URL and fill-mode reset effects, the reset calls in the registration and payload paths, and its held and feedback-loop log messages. Hitting the cap is normal and logs nothing. The stored report is private and frameHeight is folded into frameHeightPx. Tests: RT-1 to RT-13 run unchanged and pass; RT-4 now also asserts that the frame stops at the cap and that nothing is logged. The breaker specs that read its internals are deleted, and their behavior is carried by the RT scenarios. New specs cover clampContentHeight and the cap in RenderedFrame (above, shrink after, rounding, fill mode), and one spec keeps a report stored while filling for a switch to content. The "settles" e2e test now asserts the settled inline frame stays below the cap, and its message bound is justified by healthy guests alone. E2E adds an inline frame resting at the cap for taller content with the guest scrolling to its last row (all renderers), a growing surface followed up to the cap, and no creep at device scale factors 1.25 and 1.5. The e2e tests import the cap from content-height.ts.
RenderedFrame tried to forward wheel events from the guest iframe to the chat history or side canvas by listening on the iframe's contentWindow. The bundled renderers are served from another origin than the shell, so that access throws a SecurityError, which the code swallowed: the forwarding never attached. A Playwright spike against all three renderers (Angular, Lit, React; Chrome, 1280x700) confirmed this. contentWindow.addEventListener threw "SecurityError: Blocked a frame with origin http://localhost:4200 from accessing a cross-origin frame" for each. The browser chains scrolling natively instead. Over a capped inline frame (560px, 656px of guest overflow) the wheel scrolled the guest to its bottom and then the chat history to its end, and back up to both tops. Over a short inline frame it scrolled the history. Neither the guests' html and body nor the chat history set overscroll-behavior; all are auto. Deletes setupIframeWheelForwarding, its call on iframe load and its fake-window unit spec. Adds an e2e test, for all three renderers, that the wheel scrolls the chat history past a capped inline frame once the frame is at its bottom or top edge.
8f6eaff to
29d7060
Compare
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
b3f0c14 to
4213265
Compare
wrenj
left a comment
There was a problem hiding this comment.
Took another look at PR #291 (4213265c). The gallery .hidden-frame collapse, URL-change reset, and contentReady === false check look good! Left one follow-up comment on the payload() effect clearing awaitingRender / hasRenderError before RENDER_SUCCESS arrives.
Resets reportedHeight on renderer URL changes, RENDER_ERROR, and empty payloads, ignores pre-render SURFACE_RESIZE reports while awaiting RENDER_SUCCESS, and collapses the hidden gallery preview frame to 0x0.
4213265 to
084fd9b
Compare
Summary
Phase 1 of simplifying preview iframe sizing:
sizing: 'fill' | 'content'mode onRenderedFrame:flexGrow: booleanwith a requiredsizinginput ('fill'for the side canvas, Dockview Rendered panel, gallery Preview card, and hidden gallery //demoscoordinator frames;'content'for inline chat).400pxheight (gallery.scss).RT-1..RT-13):simulateGuest(shell/src/app/preview/testing/simulate-guest.ts) and 13 breaker-independent growth behavior scenarios inrendered-frame.spec.tsbefore deleting the fix(shell): release the preview frame growth breaker once the renderer's reports settle #258 circuit breaker.560pxcap (MAX_CONTENT_HEIGHT_PX):hold / probe / release / confirmstate machine and its log messages in favor ofclampContentHeight(height)(shell/src/app/preview/content-height.ts, capped at560px).forwardWheelListener(which could never attach across cross-origin renderer ports3456..3458) and verifies two-way native browser scroll chaining between capped inline chat frames and.chat-history-containeracross all 3 bundled renderers.#258 Breaker Spec → Behavior Scenario Mapping
560pxwith nothing logged.describe('growth behavior')fillmode.560pxand stays stopped after all timers run.detectChanges; final report applies.MAX_CONTENT_HEIGHT_PX(RT-4).RENDERER_READYmid-run, then a smaller report applies.null, then follows new reports.