Skip to content

fix(shell): release the preview frame growth breaker once the renderer's reports settle - #258

Merged
mikzat merged 3 commits into
a2ui-project:mainfrom
mikzat:fix/release-growth-breaker-on-settle
Oct 16, 2026
Merged

mikzat merged 3 commits into
a2ui-project:mainfrom
mikzat:fix/release-growth-breaker-on-settle

Conversation

@mikzat

@mikzat mikzat commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

The runaway growth circuit breaker latches the preview frame after 16 consecutive growing resize reports less than 500ms apart, and only a new renderer, a session reset or a RENDERER_READY handshake releases it. A CSS height transition produces exactly that pattern: Angular Material's expansion panel animates over 225ms, which the renderer reports as about a dozen per-frame growth steps at 60Hz and twice that on a 120Hz display, so expanding a panel in an inline surface can trip the breaker. Once latched the frame only accepts smaller heights, so a collapse ratchets the ceiling down and the surface ends up clipped to a fraction of its content until the renderer is reloaded. Streamed surfaces that grow quickly hit the same latch.

This matters for the inline frames in chat bubbles, which size themselves to the guest's reports and therefore need the breaker. (#257 makes the side canvas fill its panel and ignore the reports, so the canvas no longer depends on the breaker either way.)

A hold is now a probe rather than a verdict. A feedback loop only grows because the host applies each reported height, so a held guest that keeps reporting larger heights is growing on its own; the hold is released after three such reports, at most twice per growth run so a guest that answers every applied height with a burst of growth is still caught. A held guest that falls silent has its last reported height applied after 500ms, which is where a finished transition ended up; growth arriving within 500ms of that apply is the reaction a real loop produces, so the hold is kept and the loop is logged as a warning until the reports settle. Any non-growing or late report ends the run and clears the hold, so the frame no longer ratchets downward. A tentative hold logs at info level, and the settle timer is dropped when the component is destroyed.

The threshold stays at 16, and the existing resets on RENDER_SUCCESS, renderer change and session reset are kept. resetGrowthRun now keeps the last report so the next one is still judged against it: new content sent to a held guest does not end the hold by itself, but it withdraws an outstanding probe and drops a settle timer armed for the previous content, since new content is a legitimate reason to grow right after a settled height was applied. The probe is timed from when the settled height was actually applied (Date.now(), the same clock as the envelope receipt timestamps) rather than from when the settle timer was due, so a throttled timer in a background tab does not push the guest's reaction outside the window.

Verification

rendered-frame.spec.ts (48 specs) drives the breaker with a guest that only grows after the host has applied the previous report, which is what distinguishes a loop from a transition, and covers transitions of various lengths, the settle and confirmation paths, new content arriving after a probe or while a settle timer is armed, the release cap, and teardown. The breaker specs fake Date alongside the timers and move the clock to each envelope's receipt time, so the settle timer fires on the same timeline as the synthetic reports. prettier --check, eslint, and tsc -p tsconfig.json --noEmit are clean in shell/.

@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 growth circuit breaker logic in RenderedFrame to introduce a more robust hold-and-release mechanism, preventing false positives from legitimate growth (such as CSS transitions) by holding the frame temporarily and verifying if the guest settles. It also adds comprehensive unit tests to cover these new behaviors. A critical issue was identified in resetGrowthRun() where the settleTimer is not cleared, potentially leading to state corruption and incorrect loop confirmations when new content is loaded.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

Your automated preview is successfully live (commit 0a754f2):
👉 Launch PR Preview

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

@mikzat
mikzat force-pushed the fix/release-growth-breaker-on-settle branch from 27a74fd to 12a77bd Compare October 8, 2026 17:24
@mikzat
mikzat marked this pull request as ready for review October 8, 2026 17:38
mikzat added 3 commits October 8, 2026 15:26
…r's reports settle

The runaway growth circuit breaker latches the preview frame after 16 consecutive growing resize reports less than 500ms apart, and only a new renderer, a session reset or a `RENDERER_READY` handshake releases it. A CSS height transition produces exactly that pattern: Angular Material's expansion panel animates over 225ms, which the renderer reports as about a dozen per-frame growth steps at 60Hz and twice that on a 120Hz display, so expanding a panel in a Canvas can trip the breaker. Once latched the frame only accepts smaller heights, so a collapse ratchets the ceiling down and the canvas ends up clipped to a fraction of its content until the renderer is reloaded. Streamed surfaces that grow quickly hit the same latch.

A hold is now a probe rather than a verdict. A feedback loop only grows because the host applies each reported height, so a held guest that keeps reporting larger heights is growing on its own; the hold is released after three such reports, at most twice per growth run so a guest that answers every applied height with a burst of growth is still caught. A held guest that falls silent has its last reported height applied after 500ms, which is where a finished transition ended up; growth arriving within 500ms of that applied height is the reaction a real loop produces, so the hold is kept and the loop is logged as a warning until the reports settle. Any non-growing or late report ends the run and clears the hold, so the frame no longer ratchets downward. A tentative hold logs at info level, and the settle timer is dropped when the component is destroyed.

The threshold stays at 16, and the existing resets on `RENDER_SUCCESS`, renderer change and session reset are kept. `resetGrowthRun` now keeps the last report so the next one is still judged against it: new content sent to a held guest does not end the hold by itself, but it withdraws an outstanding probe, since new content is a legitimate reason to grow right after a settled height was applied.

The spec drives the breaker with a guest that only grows after the host has applied the previous report, which is what distinguishes a loop from a transition, and covers transitions of various lengths, the settle and confirmation paths, new content arriving after a probe, the release cap, and teardown.
A settle timer armed for the previous content could fire after new content was
sent, apply that content's height and arm a probe that would take the new
content's first report for a confirmed feedback loop.
…lied

The probe recorded the apply as happening one runaway interval after the
last report, which is when the settle timer was due rather than when it
fired. A throttled timer (a background tab, say) fires later, and the
guest's reaction to the apply would then fall outside the window and pass
for the start of an unrelated run. Envelope timestamps are the host's
receipt times, so Date.now() at the apply is the same clock.

The breaker specs now fake Date as well and move the clock to each
envelope's receipt time before emitting it, so the settle timer fires on
the same timeline as the synthetic reports.
@mikzat
mikzat force-pushed the fix/release-growth-breaker-on-settle branch from 12a77bd to 0a754f2 Compare October 8, 2026 22:26
@mikzat
mikzat merged commit e94361f into a2ui-project:main Oct 16, 2026
13 checks passed
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