Skip to content

Replace the preview growth breaker with a 560px cap and explicit fill/content sizing - #291

Merged
jgindin merged 5 commits into
mainfrom
resizing/1-frame-sizing
Oct 26, 2026
Merged

jgindin merged 5 commits into
mainfrom
resizing/1-frame-sizing

Conversation

@jgindin

@jgindin jgindin commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack: #291 → #293 → #294 (plus independent #292)

Summary

Phase 1 of simplifying preview iframe sizing:

  1. Explicit sizing: 'fill' | 'content' mode on RenderedFrame:
    • Replaces flexGrow: boolean with a required sizing input ('fill' for the side canvas, Dockview Rendered panel, gallery Preview card, and hidden gallery / /demos coordinator frames; 'content' for inline chat).
    • Gives the gallery Preview card a fixed 400px height (gallery.scss).
  2. Behavior-level growth test suite (RT-1..RT-13):
  3. Replace the fix(shell): release the preview frame growth breaker once the renderer's reports settle #258 growth circuit breaker with a 560px cap (MAX_CONTENT_HEIGHT_PX):
    • Removes the hold / probe / release / confirm state machine and its log messages in favor of clampContentHeight(height) (shell/src/app/preview/content-height.ts, capped at 560px).
  4. Remove cross-origin wheel-forwarding dead code:
    • Removes forwardWheelListener (which could never attach across cross-origin renderer ports 3456..3458) and verifies two-way native browser scroll chaining between capped inline chat frames and .chat-history-container across all 3 bundled renderers.

#258 Breaker Spec → Behavior Scenario Mapping

# #258 spec Carried by Notes
1 holds the frame once a guest grows in response to every applied height RT-4 Guest that grows with every applied height stops at 560px with nothing logged.
2 applies no height in fill mode, even after a runaway burst settles describe('growth behavior') Harness-only test in fill mode.
3 confirms the loop when the guest grows again as soon as its settled height applies RT-4 Growth stops at 560px and stays stopped after all timers run.
4 releases the hold when the guest keeps growing while the frame is held RT-1b, RT-6 27 reports at 8ms reach their final height.
5 applies the settled height when a held guest stops reporting RT-2, RT-5 Final report applies once timers run.
6 does not take growth caused by new content for a reaction to the settled height RT-8 New payload, then smaller and larger reports, are all followed.
7 drops a settle timer armed for the previous content when new content is sent RT-8 After new payload, frame reflects new reports.
8 holds a burst delivered inside a single change detection tick RT-12 28 reports delivered before one detectChanges; final report applies.
9 keeps applying growth when reports arrive slower than the runaway window RT-7 Every report 600ms apart is applied.
10 restarts the growth run when a report does not grow RT-13 13 growing reports, one repeat, 13 more; final report applied.
11 ends the hold when the guest reports a smaller height RT-3, RT-8 Follows down after expansion, then back up.
12 ends a confirmed hold when the guest reports again after a pause RT-7, RT-3 Later reports after a pause apply cleanly.
13 keeps a confirmed hold while new content is rendered Bounded by cap Growth is bounded by MAX_CONTENT_HEIGHT_PX (RT-4).
14 holds for good within a run once the guest has been released twice RT-5 56 reports at 8ms reach final capped height.
15 clears the hold when the renderer signals that it is ready again RT-9 RENDERER_READY mid-run, then a smaller report applies.
16 resets dynamicHeight to null and clears the hold when sessionResetNonce increments RT-10 Resets applied height to null, then follows new reports.
17 drops the settle timer when the component is destroyed RT-11 Destroyed mid-run: no timer leaks or unhandled errors.

@gemini-code-assist gemini-code-assist 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.

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.
@jgindin
jgindin force-pushed the resizing/1-frame-sizing branch from 8f6eaff to 29d7060 Compare October 22, 2026 16:32
@jgindin
jgindin requested review from mikzat and wrenj October 22, 2026 16:42

@wrenj wrenj 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.

Reviewed PR #291. Left a few comments on pre-render SURFACE_RESIZE reports overriding the 280px content-sized floor, reportedHeight retention across renderer URL changes, and .preview-card sizing in the gallery.

Comment thread shell/src/app/gallery/gallery.scss Resolved
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

Your automated preview is successfully live (commit 084fd9b):
👉 Launch PR Preview

Note: This environment will be wiped automatically when the PR is merged or closed.

@jgindin
jgindin requested a review from wrenj October 23, 2026 14:03
@jgindin
jgindin force-pushed the resizing/1-frame-sizing branch from b3f0c14 to 4213265 Compare October 23, 2026 15:03

@wrenj wrenj 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.

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.
@jgindin
jgindin force-pushed the resizing/1-frame-sizing branch from 4213265 to 084fd9b Compare October 23, 2026 20:51
@jgindin
jgindin requested a review from wrenj October 26, 2026 14:38
@jgindin
jgindin merged commit ceb72e4 into main Oct 26, 2026
15 checks passed
@jgindin
jgindin deleted the resizing/1-frame-sizing branch October 26, 2026 15:20
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.

2 participants