Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: stop the overlay rail going click-through while it is scrolling (#9150)

Daniel Han571a99b72b5c
diff --git a/studio/frontend/src/features/settings/stores/monitor-frame-store.ts b/studio/frontend/src/features/settings/stores/monitor-frame-store.ts
index 2c8fef6476f..a1e8111505c 100644
--- a/studio/frontend/src/features/settings/stores/monitor-frame-store.ts
+++ b/studio/frontend/src/features/settings/stores/monitor-frame-store.ts
@@ -418,6 +418,14 @@ export function useStackGeometry(): StackPlacement {
const [neededRoom, setNeededRoom] = useState(ASSUMED_STACK_HEIGHT);
const [floorRoom, setFloorRoom] = useState(ASSUMED_STACK_HEIGHT);
const [persistentTail, setPersistentTail] = useState(0);
+ // Whether the rail is ACTUALLY scrolling, read off the node at its real cap.
+ // The derived answer below is a prediction, and a prediction can be wrong: the
+ // cards are only assumed to collapse to `floorRoom`, so whenever they stop
+ // short of it the box overflows a cap that `floorRoom > maxHeight` says it
+ // fits inside. That combination is a rail that scrolls while it is still
+ // click-through, which costs it its scrollbar and strands every card above the
+ // fold where no pointer can reach them.
+ const [domOverflowing, setDomOverflowing] = useState(false);
useEffect(() => {
const onResize = () =>
setViewport({ width: window.innerWidth, height: window.innerHeight });
@@ -502,6 +510,22 @@ export function useStackGeometry(): StackPlacement {
// hands the pending max-height change to a transition after all.
void node.scrollHeight;
node.style.transition = eased;
+ // Taken here, with the real cap back on and the layout already flushed by
+ // the line above, so it describes the box the reader has rather than
+ // either probe. After the `transition` restore, not between it and the
+ // flush: the cap change is already committed under the suppression, and
+ // `transition` is not itself a transitionable property, so no reflow this
+ // read forces can hand that cap to an animation.
+ //
+ // Read every time this runs, never latched: the observers below watch the
+ // rail AND every descendant, and a placement change moves the rail's own
+ // border box, so a cap that grows to fit clears this on the same pass that
+ // applied it. That is what the derived value was protecting against, and
+ // it is still true when the reading is refreshed rather than remembered.
+ const overflows = node.scrollHeight > node.clientHeight;
+ setDomOverflowing((current) =>
+ current === overflows ? current : overflows,
+ );
setNeededRoom((current) => (current === natural ? current : natural));
setFloorRoom((current) => (current === floor ? current : floor));
// How much of the stack, measured up from the corner, the reader cannot
@@ -591,6 +615,11 @@ export function useStackGeometry(): StackPlacement {
// height, so a cap below the floor is exactly when the rail has to scroll.
// A pixel of slack, since the floor is a rounded scrollHeight and the cap
// is not.
- overflowing: floorRoom > geometry.maxHeight + 1,
+ //
+ // Or the box is simply scrolling, whatever the prediction says. The two
+ // agree wherever the cards do collapse to the floor they measured, so this
+ // only ever adds the case the prediction misses; it cannot take pointer
+ // input away from a rail that the derived reading already claimed.
+ overflowing: floorRoom > geometry.maxHeight + 1 || domOverflowing,
};
}
diff --git a/tests/studio/playwright_update_banner_layout.py b/tests/studio/playwright_update_banner_layout.py
index b00756926fe..be1d20ad023 100644
--- a/tests/studio/playwright_update_banner_layout.py
+++ b/tests/studio/playwright_update_banner_layout.py
@@ -433,7 +433,37 @@ MEASURE = """
// on which platform it is or on whether the rail happens to be scrolling.
railGutterPx: rail ? Math.round(rail.offsetWidth - rail.clientWidth) : null,
cardWidth: card ? Math.round(card.getBoundingClientRect().width) : null,
+ // The same card, measured off the LAYOUT box instead of the painted one.
+ // offsetWidth is the border box with no transform applied (CSSOM-View), so
+ // it answers the scrollbar question the assertion below is actually asking
+ // and cannot be moved by the card's enter animation. `cardWidth` stays,
+ // reported alongside, because the gap between the two is the diagnosis.
+ cardLayoutWidth: card ? card.offsetWidth : null,
railPointerEvents: rail ? getComputedStyle(rail).pointerEvents : null,
+ // Everything needed to say WHY a card came out narrow, reported with the
+ // failure instead of being guessed at afterwards from two numbers. A card
+ // that lost width to a scrollbar and a card that lost it to an unfinished
+ // transform read identically as `cardWidth`, and the engine that reports
+ // offsetWidth === clientWidth while still taking the width out of the
+ // content box (Playwright WebKit on Linux) makes railGutterPx no help on
+ // its own. `borderBox` is the layout width with no transform applied.
+ widthWhy: card && rail ? {
+ transform: getComputedStyle(card).transform,
+ borderBox: card.offsetWidth,
+ cssWidth: getComputedStyle(card).width,
+ maxWidth: getComputedStyle(card).maxWidth,
+ innerWidth: innerWidth,
+ docClientWidth: document.documentElement.clientWidth,
+ railOffsetW: rail.offsetWidth,
+ railClientW: rail.clientWidth,
+ railContentW: rail.clientWidth
+ - parseFloat(getComputedStyle(rail).paddingLeft || '0')
+ - parseFloat(getComputedStyle(rail).paddingRight || '0'),
+ railScrollH: rail.scrollHeight,
+ railClientH: rail.clientHeight,
+ railMaxHeight: getComputedStyle(rail).maxHeight,
+ kids: [...rail.children].map((c) => Math.round(c.getBoundingClientRect().height)),
+ } : null,
// What a click on the rail's own gutter lands on when it is click-through.
gutterIsRail: rail ? (() => {
const r = rail.getBoundingClientRect();
@@ -548,21 +578,32 @@ def measure(page, label: str) -> dict:
reached and not seen["offscreen"],
f"{name}={seen}",
)
- if facts["cardWidth"] is not None:
+ if facts["cardLayoutWidth"] is not None:
# 448px is the card's max width and 2rem the viewport inset it keeps.
want = min(448, view["width"] - 32)
+ # Asked of the layout box, not the painted one. A scrollbar that takes
+ # its width out of the rail's content box shrinks the card's layout
+ # width, which is the whole subject here; the card's enter animation
+ # (opacity 0, y 12, scale .96 -- see components/*/update-banner.tsx)
+ # shrinks only the painted one, and measuring that raced the animation
+ # rather than the scrollbar. 448 * 0.96 = 430.08, which is exactly the
+ # 430 this reported on the WebKit leg while its own borderBox read 448
+ # and railGutter read 0.
check(
f"{label}: the card keeps its full width whatever the scrollbar does",
- abs(facts["cardWidth"] - want) <= 1,
- f"cardWidth={facts['cardWidth']} want={want} "
- f"railGutter={facts['railGutterPx']} scrolls={facts['railScrolls']}",
+ abs(facts["cardLayoutWidth"] - want) <= 1,
+ f"cardLayoutWidth={facts['cardLayoutWidth']} want={want} "
+ f"cardPaintedWidth={facts['cardWidth']} "
+ f"railGutter={facts['railGutterPx']} scrolls={facts['railScrolls']} "
+ f"why={json.dumps(facts['widthWhy'], sort_keys = True)}",
)
if facts["railScrolls"] is not None:
scrolls = facts["railScrolls"]
check(
f"{label}: the rail takes pointer input exactly when it scrolls",
facts["railPointerEvents"] == ("auto" if scrolls else "none"),
- f"scrolls={scrolls} pointerEvents={facts['railPointerEvents']}",
+ f"scrolls={scrolls} pointerEvents={facts['railPointerEvents']} "
+ f"why={json.dumps(facts['widthWhy'], sort_keys = True)}",
)
# Click-through is what pointer-events-none is for, and the gutter is
# the widest part of the rail that no card covers.