Skip to content

Studio: remeasure the overlay stack when its content resizes in place - #8315

Merged
danielhanchen merged 3 commits into
mainfrom
studio-stack-descendant-resize
Aug 10, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
studio-stack-descendant-resize

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to #8301, which landed before this came up in review.

useStackGeometry measures how much room the bottom-right overlay stack needs and observes the stack container so the measurement keeps up. That observer only fires when the container's own border box moves, and the container is capped: when its content grows inside a max-height it is already at, the border box does not change. The MutationObserver beside it watches childList only, so it says nothing either.

The case that reaches it is an expanded release note whose Markdown image finishes loading. Nothing is inserted and nothing at the root resizes, so neither observer calls measure(), neededRoom keeps the pre-load height, and the banner stays clipped under an obstacle it is now tall enough to be lifted over.

The ResizeObserver now watches the container and every element inside it, and the mutation callback resyncs that set before remeasuring so a banner arriving after mount is watched too. Elements that leave are unobserved rather than left attached.

Tests: monitor-stack-inset.test.ts gains a check that the root is not the only observed box, that the descendants are enumerated, that the observed set is resynced on mutation and that anything leaving is unobserved. The existing cap-lifted test's slice boundary moved with the code. 1525 frontend tests pass, npm run typecheck clean.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 592163039d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
for (const element of wanted) {
if (!observed.has(element)) {
observer.observe(element);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid measuring on every progress-bar width frame

When the llama.cpp update banner is applying, useSmoothedProgress updates its descendant bar's CSS width on every animation frame (llama-update-banner.tsx:34-66,204-207), and that banner is inside this observed stack (provider.tsx:682-695). Observing every descendant therefore invokes measure() at roughly 60 Hz even though the stack's height is unchanged; each invocation temporarily removes maxHeight and reads scrollHeight, forcing synchronous layout of the stack. Filter observations to height changes or limit observation to descendants whose intrinsic height can change so an update does not continuously trigger expensive remeasurement.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in c37fdee. The observer callback now compares each entry against the last height seen for that element (borderBoxSize[0].blockSize, falling back to contentRect.height) and only calls measure() when one actually moved, so the update banner animating its progress bar width no longer forces a synchronous layout every frame. Heights are held in a WeakMap so an unobserved node is not retained. Covered by a width-only animation does not remeasure the stack.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: c37fdee25e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 5a84766 into main Aug 10, 2026
43 of 44 checks passed
@danielhanchen
danielhanchen deleted the studio-stack-descendant-resize branch August 10, 2026 07:50
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.

1 participant