Skip to content

Studio: keep the overlay stack off a maximised Live monitor - #8190

Merged
danielhanchen merged 3 commits into
mainfrom
fix/monitor-stack-lift-clamp
Aug 9, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
fix/monitor-stack-lift-clamp

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #8082. Rebased onto current main, which now has #8210.

What is left after #8210

#8210 replaced the two-line "is it near the bottom" boolean with reachesStack, derived from stackMaxHeight, and made stackGeometry settle rather than take a single max. That is a better spine than the one this branch was written against, and this branch is now rewritten on top of it.

What #8210 did not change is the clamp:

function liftOver(frame, viewportHeight) {
  return Math.max(
    STACK_INSET,
    Math.min(viewportHeight - frame.top + STACK_GAP, viewportHeight - MIN_STACK_ROOM),
  );
}

liftOver clamps rather than refuses. For a box whose top edge is above that clamp the clamp does not clear the box, it parks the stack across the box's own top edge, which is where the monitor's collapse and Close buttons are.

The geometry

A monitor dragged to the top left and resized to fill the window, which is what tests/studio/playwright_chat_ui.py:exercise_floating_monitor_geometry does immediately before it clicks Close. Viewport 1280x900, frame {left: 16, top: 16, right: 1264, bottom: 884}. The header band, from the panel border down past the Close button, is y 16..80.

inset cap stack occupies header y 16..80 grip y 868..884
main today 780 104 y 16..120 covered clear
this branch 40 772 y 88..860 clear clear

main reaches inset 780 as viewportHeight - MIN_STACK_ROOM, and the loaded models card is the first persistent overlay in the stack, so it lands on the Close button and swallows the click. Same result at 1280x720: inset 600, cap 104, stack at y 16..120.

After

A box the lift cannot clear is sat inside rather than lifted over. The inset clears the native resize grip in the opposite corner, which is the only way back to a smaller monitor, and the cap holds the top of the stack below the header.

The predicate is asked at the inset in force rather than a fixed one, so it composes with #8210's settling loop: a box that has room at the corner on its own, but that the composer's lift walks the stack into, is sat inside too rather than clamped onto. That case is new here and was found by extending #8210's own sweep, where it showed up as bottom=530 height=600 n=2.

Constants

Both are checked against floating-monitor.tsx rather than carried over from the previous revision, which had the arithmetic slightly wrong.

  • MONITOR_HEADER = 64. The panel's 1px border, p-3, the 24px control row (size-6 Close button, per button.tsx), pb-2 plus its 1px rule, and mb-2 come to 54, rounded up.
  • MONITOR_GRIP = 16. The panel carries resize once it has been dragged or resized. Every engine that paints a grip draws it at the platform resizer's 15px; iOS Safari paints none. The previous revision said Firefox was 12px, which was wrong.

Tests

Added to monitor-stack-inset.test.ts, alongside #8210's cases rather than replacing them:

  • a monitor too tall to lift over keeps its header and grip clear
  • a monitor resized to fill the viewport keeps its header and grip clear
  • a maximised monitor keeps its header clear under a shared lift
  • a monitor too tall to lift over but clear of the bottom is sat under
  • a tall monitor that can still be cleared is lifted over

#8210's no pairing produces an overlap or an unusable cap sweep is extended with heights 600 and 814, which reach boxes that fill the column. For those the contract cannot be "no overlap", since the stack is inside the box, so it becomes "clears above, clears below, or keeps the header and the grip usable".

two obstacles are folded one at a time had a direction assertion, both.bottom < unioned.bottom, that only held under the old clamp. It is repinned on the consequence: folding clears both boxes, and the bounding box cannot clear both. That is now true whichever way the union errs, so it guards folding rather than this change.

Each new assertion was checked by breaking the fix three ways and confirming it goes red:

sabotage exit red
tooTallToClear forced false, ie. main's behaviour 1 the 3 header/grip tests plus the sweep, 1317 pass
header cap replaced by ownMargin 1 the same 4, 1317 pass
MONITOR_GRIP set to 0 1 the 2 grip tests plus the sweep, 1318 pass
restored 0 1321 pass

Gates

npm test 1321 pass, exit 0. npm run typecheck exit 0 on both projects. biome check exit 0 on both files.

The change is integer arithmetic on numbers already measured by the caller, with no equality comparisons against them and margins of 8px or more, so nothing in it is engine-dependent. The two browser-facing quantities are the constants above.

@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: 2d2bdd041a

ℹ️ 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".

// stack across the box's own top edge, over the controls it is dodging: a
// monitor resized to fill the viewport had its Close button swallowed by the
// loaded models card. Nothing above it is free, so stay in the corner.
if (lifted > viewportHeight - MIN_STACK_ROOM) return STACK_INSET;

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 Keep the maximised monitor's resize grip reachable

When a monitor is too tall to lift over and loaded models are present, returning the normal bottom-right inset places the persistent loaded-models card directly above the monitor's native bottom-right CSS resize grip. The overlay stack has z-[9998] and the card has pointer events enabled, while the monitor is only z-50, so after maximising the monitor the user can close it but can no longer drag the grip to shrink it again. The oversized case needs a placement that avoids both the top controls and the bottom-right resize handle.

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.

Agreed, and fixed in a192fa7. Before this PR the clamped lift left the corner free, so the grip was reachable and the header was not; returning the plain corner inset traded one for the other. Measured the grip rather than guessing at it: driving a resize: both element from the corner inwards, Chromium still resizes at 15px in and stops at 16px, Firefox stops at 13px. So the stack now clears the monitor's bottom edge by one STACK_INSET when it has to sit inside it, and a monitor too tall to lift over that still ends above the bottom edge keeps the plain corner and is capped to the room underneath instead, which clears both. Reintroducing the plain corner return turns the two maximised-monitor cases red.

// stack across the box's own top edge, over the controls it is dodging: a
// monitor resized to fill the viewport had its Close button swallowed by the
// loaded models card. Nothing above it is free, so stay in the corner.
if (lifted > viewportHeight - MIN_STACK_ROOM) return STACK_INSET;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Cap a cornered stack before it reaches the monitor header

When the stack is tall—for example, an expanded download list can use 60dvh and the loaded-models list can use another 42dvh, before banners are counted—returning the corner inset does not keep the stack away from a maximised monitor's top controls. stackMaxHeight returns nearly the full viewport height for this low frame, so the bottom-anchored stack can grow back to top: 16px; its pointer-enabled surfaces then cover the Close button again. The new test only checks the stack's bottom edge, but this case requires limiting its height or otherwise positioning the whole stack clear of the monitor header.

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.

Right, and fixed in a192fa7. stackMaxHeight took the frame.bottom > viewportHeight / 2 branch and returned ownMargin = H - 32, so the corner inset alone did not hold the top: at 1440x900 an expanded download list (60dvh) plus the loaded models card (42dvh) clamps to the cap and grows to top 16, back over the header. The cornered case is now capped below the monitor's header, and the branch is decided on the frame's own inset so the two functions cannot disagree. Reintroducing just the uncapped height turns the two maximised-monitor cases red.

Dropping the lift put the stack back in the corner, which left two gaps. Its
height was still uncapped there, so an expanded download list plus the loaded
models card grew from the bottom right back over the Close button the inset had
just moved off; and the corner itself is where the monitor's native resize grip
sits, so the card buried the only way back to a smaller monitor.

A monitor that cannot be lifted over but still ends above the bottom edge now
keeps the corner and is capped to the room underneath it. One that fills the
viewport leaves no free space at all, so the stack sits inside it, clear of the
grip at the bottom and stopping below the header at the top.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: a192fa7bd6

ℹ️ 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

Copy link
Copy Markdown
Member Author

main's CI red is three independent causes, not one, and none of the three PRs is green on its own. That is why these have all been sitting at CI_FAILING with no review items of their own.

Failing suite on main Actual failure Fixed by
Core (all 3 matrix cells) 2 in tests/test_generated_fullgraph_fallback.py (that file is unsloth_zoo's; Core clones zoo and runs its suite) unslothai/unsloth-zoo#1018
Repo tests (CPU) 6 in tests/studio/test_model_picker_contracts.py and tests/studio/test_update_release_notes.py #8197
Chat UI Tests playwright._impl._errors.TimeoutError clicking floating-monitor's Close: a menu-soft-surface inside fixed right-4 z-[9998] intercepts pointer events #8190

The two Studio PRs each cover exactly the other's failure. On #8197, Chat UI fails on the overlay intercept and Repo tests (CPU) passes. On #8190, Chat UI passes and Repo tests (CPU) fails with those same 6. Core fails on both, because its cause is in zoo.

Checked together on a staging repo rather than on the org queue: unsloth main 161a3017d with #8197 and #8190 both merged in (clean, no conflicts), and the Core job's zoo clone pinned to zoo#1018's head.

Core (HF=4.57.6 + TRL<1)      pass
Core (HF=default + TRL=default)  pass
Core (HF=latest + TRL=latest)    pass
Repo tests (CPU)                 pass
Chat UI Tests                    pass

32 checks pass, 0 fail. The zoo suite inside Core goes from 2 failed, 4242 passed, 293 skipped on main to 4269 passed, 286 skipped, 2 deselected, with both test_maybe_compile_routes_fullgraph_through_the_fallback and test_the_alias_routes_a_fullgraph_compile_through_the_fallback collected and passing, and no FAILED anywhere in the job log.

So the merge order that clears the board is zoo#1018 first, then #8197 and #8190 in either order. Once those land, #7867, #7951, #8051, #8121 and #8128 should all go green as well; every one of them has zero open review items and is red only because it inherits this.

The staging composition used #8197 at b6301786f. Its head has since moved to 1b549d96b, which is a comments and docstrings only pass with no runtime change, so the result above still stands.

@danielhanchen

Copy link
Copy Markdown
Member Author

Reconciled against #8210, which landed on the same two files while this was open.

Not redundant. #8210 rewrote the spine, and it is the better spine, so this is now written on top of it rather than against the code it replaced. But the specific thing this PR is for survived #8210 untouched: liftOver still clamps to viewportHeight - MIN_STACK_ROOM, and for a box whose top edge is above that clamp the clamp does not clear it. Evaluated on main at this moment, viewport 1280x900, monitor at {16, 16, 1264, 884}, the stack takes inset 780 and cap 104 and occupies y 16..120. The monitor's header band is y 16..80. That is the Close button, under the loaded models card, which is the Chat UI Tests red.

Rewritten to only that residual, plus one case that is genuinely new: the predicate has to be asked at the inset in force, so it composes with #8210's settling loop. A box with room at the corner on its own, that the composer's lift then walks the stack into, was being clamped onto. #8210's own sweep finds it once the sweep reaches tall enough boxes, as bottom=530 height=600 n=2.

Two things carried over from the previous revision were wrong and are corrected: the header arithmetic, now checked against floating-monitor.tsx and button.tsx, and the claim that Firefox's resize grip is 12px. It is 15px, same as the others.

Body updated with the geometry table, the sabotage results and the gates.

One thing I could not do from here: this PR's head branch is on unslothai/unsloth, and I am not pushing to it. The rebased commit is 53dcac293, on fix/monitor-stack-lift-clamp at https://github.com/danielhanchen/unsloth-staging-2. The PR branch needs a fast-forward to that before CI here reflects any of the above.

#8210 rewrote the same two functions on main while this branch was open, so
the overlap resolves in main's favour and the maximised-monitor case is
rebuilt on top of it rather than reverting the refactor.

Kept from main: reachesStack, roomBelow's bottomInset parameter, the settled
inset in stackGeometry. Its "is this box in the way" test replaces this
branch's "is it past the halfway line", and it also subsumes this branch's
second case: a box leaving MIN_STACK_ROOM underneath itself does not reach
the stack, so the corner stays free without a branch of its own.

Kept from this branch: the case main still has no answer for. Bounding the
lift to the stack's floor parks the stack across the box's own top edge, over
the controls it is dodging, which is how a monitor resized to fill the
viewport had its Close button swallowed by the loaded models card. liftOver
goes back to the unbounded lift, liftFits asks whether it fits, and dodgeInset
picks between it and a seat inside the monitor clear of its resize grip.
stackMaxHeight holds the other edge of that seat, below the header.
@danielhanchen

Copy link
Copy Markdown
Member Author

Merged main in and resolved the conflict with #8210, which rewrote the same two functions while this was open.

What main does today. A box that crowds the corner gets lifted over, and the lift is bounded so the stack keeps its 120px of room at the top of the screen. For a Live monitor resized to fill the viewport that bound is the whole problem: there is nothing above the monitor to lift into, so the stack parks itself across the monitor's own header, over the drag handle and Close button it was meant to be dodging, and the height cap that comes with it squashes the loaded models card to nothing.

What this branch adds. When the lift does not fit, seat the stack inside the monitor instead, one inset clear of its native resize grip, and cap its height below the header. The grip matters because it is the only way back to a smaller monitor.

What came from #8210 and stayed. reachesStack, roomBelow's bottomInset parameter and the settled inset in stackGeometry. Its reach test also subsumes a branch this PR used to carry on its own: a monitor that leaves room underneath itself does not reach the stack, so the corner stays free without a case of its own. Only the maximised monitor needed adding back, as liftFits plus a seat inside the box.

Same 1440x900 viewport both times, same Live monitor dragged to the corner and resized to fill the screen, one build each. The boxes are drawn on top afterwards.

Before, on main:

before

After, on this branch:

after

Measured off those two pages, monitor filling 16,16 to 1424,884:

bottom inset stack box max-height
before 780px y 16 to 120, across the header band at y 16 to 80 104px, which clips the loaded models card to nothing
after 40px y 630 to 860, below the header 364px, and 24px of clearance above the grip at y 868

monitor-stack-inset.test.ts pins both edges of that seat. Both maximised-monitor cases fail against main's implementation and pass here; the rest of the file, including #8210's own sweeps, passes either way. Full studio/frontend suite is 1429 passing, with npm run typecheck and biome check clean.

@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: 6eec7deaeb

ℹ️ 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".

Comment on lines 153 to 156
return Math.max(
STACK_INSET,
Math.min(
viewportHeight - frame.top + STACK_GAP,
viewportHeight - MIN_STACK_ROOM,
),
viewportHeight - frame.bottom + MONITOR_GRIP + STACK_GAP,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restrict the inside-frame fallback to the Live monitor

When the docked composer grows above the 128px lift threshold—for example, in a short browser viewport with the 12-row input and the 28dvh prompt queue open—this branch also handles that frame because publishers carry no obstacle type. It consequently seats the z-[9998] overlay stack inside the composer rather than above it, allowing the loaded-models/download surfaces to cover the Send controls again. Distinguish monitor frames before applying the grip/header fallback, or retain clear-above behavior for non-monitor publishers.

Useful? React with 👍 / 👎.

Comment on lines 153 to 156
return Math.max(
STACK_INSET,
Math.min(
viewportHeight - frame.top + STACK_GAP,
viewportHeight - MIN_STACK_ROOM,
),
viewportHeight - frame.bottom + MONITOR_GRIP + STACK_GAP,
);

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 Keep the seated stack above the monitor surface

When a tall monitor starts below the viewport top but still cannot be lifted over (for example top: 100px and bottom: viewportHeight - 16px), this fallback moves the stack from the remaining strip above the monitor into its frame. The monitor container is z-[9999] in floating-monitor.tsx, while both provider stacks are z-[9998], so a widened monitor then paints over the update/download/model cards and intercepts their controls; with the normal 256px monitor, the cards' right-aligned controls are still underneath it. Either preserve the usable space above the monitor or adjust the stacking order now that the geometry explicitly clears the header and resize grip.

Useful? React with 👍 / 👎.

@danielhanchen
danielhanchen merged commit fbf5eba into main Aug 9, 2026
37 of 44 checks passed
@danielhanchen
danielhanchen deleted the fix/monitor-stack-lift-clamp branch August 9, 2026 16:33
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