Repository navigation
Studio: keep the loaded models card in the corner it is supposed to be in - #8301
Conversation
…e in The bottom-right overlay stack dodges anything that crowds its corner, and how much room it needs to sit under a box was the fixed MIN_STACK_ROOM = 120. The loaded models card is 83px tall. On a short window the centred welcome composer leaves about 83px under it, which is enough for the card and short of the constant, so the stack lifted clear over the composer's top edge and parked the card in the middle of the page with the corner beneath it empty. Measure the stack instead of guessing at it. useStackGeometry watches its own container and feeds the height back into the dodge test, so the card takes the corner when it fits there and a taller stack is still lifted over a composer it would otherwise cover. Read from scrollHeight, never clientHeight: maxHeight is this hook's own output, and measuring the clipped box would feed the placement its own answer. Reproduced at 921x500: before, the stack sat at bottom 242 with the card at y 174-258; after, bottom 16 with the card at y 401-484, clear of a composer ending at 378. A docked composer is still dodged at every measured height, so the card cannot cover Send.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 961026ca83
ℹ️ 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".
| if (node === null || typeof ResizeObserver === "undefined") return; | ||
| const measure = () => { | ||
| // An empty stack asks for nothing, so nothing is dodged for it. | ||
| const height = node.childElementCount === 0 ? 0 : node.scrollHeight; |
There was a problem hiding this comment.
Measure the stack before constraining its flex layout
When the initial 56px assumption lets the stack remain below an obstacle but the real contents are taller than that gap, maxHeight has already constrained this same flex container before this measurement runs. The overlay children explicitly use min-h-0, and components such as the update and download panels hide or scroll their inner overflow, so flexbox can shrink them to the cap and node.scrollHeight reports the constrained height rather than their natural height. neededRoom then never exceeds the available gap, reachesStack never lifts the stack, and banners or controls remain clipped in short windows; measure an unconstrained wrapper/content size instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed. The mechanism is exactly as described: with a 40px cap applied by hand, the container whose content is 83px reports scrollHeight 40, not 83.
Reproduced end to end at 921 wide, with only the loaded models card in the stack (content 83px):
| viewport | before | after |
|---|---|---|
| 470 | bottom 220.75, clientHeight 83 | unchanged |
| 460 | bottom 213.50, clientHeight 83 | unchanged |
| 450 | bottom 16, maxHeight 62, card clipped | bottom 206.25, clientHeight 83 |
| 440 | bottom 16, maxHeight 55, card clipped | bottom 199.00, clientHeight 83 |
At 450 and 440 the gap under the welcome composer is smaller than the card, and the stack settled on the gap instead of lifting, which is the loop you describe.
Fixed by taking the read with the cap off: measure() now clears maxHeight, reads scrollHeight, and restores it in one synchronous block, so the layout it measures is the unconstrained one and no observer, paint or other reader ever sees the uncapped box. A source-level test pins that ordering so it cannot regress.
The height fed the cap, and the cap was on the element being measured. The overlays are flex items with min-h-0, so under the cap they shrink to fit it rather than overflowing, and scrollHeight comes back as the cap. A stack taller than the gap under an obstacle therefore measured as exactly the gap, never asked to be lifted, and sat there clipped. Reproduced at 921 wide with the loaded models card, whose content is 83px: viewport before after 470 bottom 220.75, clientHeight 83 unchanged 460 bottom 213.50, clientHeight 83 unchanged 450 bottom 16, maxHeight 62, clipped bottom 206.25, clientHeight 83 440 bottom 16, maxHeight 55, clipped bottom 199.00, clientHeight 83 The read now drops maxHeight, reads scrollHeight, and restores it in one synchronous block, so the layout it measures is the unconstrained one and nothing else ever sees the uncapped box.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8a3815c4e
ℹ️ 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".
| const observer = new ResizeObserver(measure); | ||
| observer.observe(node); | ||
| // A 0-height stack stays 0 as children come and go, so watch the child list too. | ||
| const mutations = new MutationObserver(measure); | ||
| mutations.observe(node, { childList: true, subtree: true }); |
There was a problem hiding this comment.
Observe intrinsic descendant size changes
When capped stack content changes size without a DOM insertion—most notably when a Markdown release-note image finishes loading—the observed root remains at the same capped border-box size, while this mutation observer ignores attributes and character data. Consequently neither observer calls measure() again, neededRoom retains the pre-load height, and the expanded banner can remain clipped beneath an obstacle instead of being lifted. Observe the size-changing descendants (or otherwise remeasure on resource loads/intrinsic layout changes), rather than only the capped root and child-list mutations.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed, and fixed in #8315 since this landed after 8301 merged. The root-only ResizeObserver cannot fire for content growing inside a container already at its cap, and childList says nothing about an image finishing its load, so neededRoom kept the pre-load height. The observer now watches the container and every element inside it, the mutation callback resyncs that set before remeasuring so a banner arriving after mount is watched too, and anything leaving is unobserved.
The bug
The Loaded models card renders in the middle of the page instead of the bottom right corner, with the corner underneath it empty.
Why
The bottom-right overlay stack dodges anything that crowds its corner. How much room it needs to sit under a box was a fixed
MIN_STACK_ROOM = 120inmonitor-frame-store.ts. The card is 83px tall.On a short window the centred welcome composer ends roughly 83px above the bottom edge. That is enough room for the card and short of the constant, so
reachesStacksaid the corner was crowded,dodgeInsetlifted the whole stack clear over the composer's top edge, and the card landed mid-screen. The comment onreachesStackalready claimed the welcome layout was excluded; the derived room test did not actually exclude it, because the number it compares against was never the height of the thing it protects.The fix
Measure the stack instead of guessing at it.
useStackGeometrywatches its own container and feeds the height into the dodge test, so:Read from
scrollHeight, neverclientHeight:maxHeightis this hook's own output, so measuring the clipped box would feed the placement its own answer and settle wherever it happened to start. AMutationObservercovers overlays mounting into a stack that is currently 0-height, which aResizeObserveralone does not see.Numbers
Measured in a real Studio at 921x500, empty chat, one model loaded:
bottomThe composer ends at y 378 in both, so the card clears it.
Tests
tests/monitor-stack-inset.test.tsgains the short-window case in both directions (83px of room fits an 83px card, does not fit a 200px stack), a docked composer swept across measured heights, and a re-run of the existing no-overlap sweep at every height the stack can take.npm run typecheckandnpm test(1492 tests) pass.