Repository navigation
Studio: remeasure the overlay stack when its content resizes in place - #8315
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Follow-up to #8301, which landed before this came up in review.
useStackGeometrymeasures 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 amax-heightit is already at, the border box does not change. TheMutationObserverbeside it watcheschildListonly, 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(),neededRoomkeeps the pre-load height, and the banner stays clipped under an obstacle it is now tall enough to be lifted over.The
ResizeObservernow 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.tsgains 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 typecheckclean.