Repository navigation
Keep the two floating panels out of each other's corner - #8249
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffb226484d
ℹ️ 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".
| refugeRank: | ||
| (placed.left > viewport.width / 2 ? 2 : 0) + | ||
| (placed.top > viewport.height / 2 ? 0 : 1), |
There was a problem hiding this comment.
Classify refuge candidates by the panel's center
When a 400px panel is shown in a 768–832px-wide desktop window and the resource monitor fills the viewport, the bottom-right anchor's left coordinate is not greater than the viewport midpoint, so it receives the same refuge rank as the left anchors. Since it is the first candidate, the panel remains bottom-right and covers the resource monitor's right-side Close button and resize grip—the controls this fallback is intended to preserve. Determine the side using the panel's center/right edge or retain which semantic corner produced the candidate.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 840eddd. Each candidate now carries the corner it came from instead of the side being read back out of its left coordinate, which is what broke: a 400px panel anchored right in a 768px window sits at left=352, left of the midpoint, so the bottom-right anchor was ranked a left-hand refuge, tied with the real one and won on order. Test: 'a narrow window still sends the panel off the right edge' at 768, 800 and 832, which fails without the change. The branch is also rebased onto main, which fixes the conflict.
f6e806f to
1ec40e6
Compare
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
The Live resource monitor and the API monitor panel both default to the bottom-right corner, and #8199 moved the monitor from z-50 to z-[9999] to get it over the notification stack. The API panel stayed at z-50, so from then on the monitor painted over that panel's rows and its "Expand to full monitor" button, and a monitor resized across the viewport -- which the Windows UI smoke does on purpose -- hid the panel completely, Close button included. Raising the API panel too would only move the argument up a layer. Studio already solves this in this exact corner and does not use z-index for it: the notification stack does not outrank the monitor, it steps over it, reading the boxes the monitor and the chat composer publish to the monitor frame store. The API panel now does the same thing one rung further in. * It reads every published box but its own and takes the first free anchor: the corner it shipped in, else the same column stepped over whatever is in the way, else another corner. A free corner means nothing moves. * It publishes its own box, so the notification stack steps over it as well. That was a second collision -- a passive status card at z-[9998] sat on a panel at z-50 -- and it goes away for free. * Dragging it freezes the placement. A user who wants the panels overlapping is not argued with. The drag offset is folded back into the anchor on release, as the monitor does, so the published box stays honest and a window shrunk afterwards still pulls the panel back on screen. Neither panel keeps a position across reloads, so a panel stranded off the edge has no way back. Geometry cannot answer the case the smoke creates, because a monitor filling the viewport leaves nowhere clear. So the two panels now share one layer and the one the user touched last comes forward, with one override: a panel with no pixel showing cannot be clicked, so it cannot be raised by that rule, and it comes forward on its own. Only the API panel asks for that -- it is the one that opens and places itself. With the monitor maximised the panel lands bottom-left, which is the corner that leaves the monitor's own Close button and resize grip free. The z-indexes themselves move into studio/frontend/src/lib/z-layers.ts, which is the first place the ordering is written down rather than inferred from six files: OVERLAY_STACK 9000 < FLOATING_PANEL 9100 < FLOATING_PANEL_TOP 9101 < STARTUP_SCREEN 9999 < TOOLTIP 999999 Renumbering the top band only. Nothing else in the tree sits between 121 and 999998, so every relationship with every other surface is unchanged; the two notification stacks and the two panel containers move onto the constants, and the startup screen and tooltips keep their classes with the test pinning them to the scale. The in-page band -- dialogs, sheets, dropdowns, the Tauri titlebar, all on Tailwind's own scale at 50 to 120 -- is deliberately left alone: putting modals over the notification stack is a real question, but toasts above modals is the usual convention rather than an accident, and the titlebar half of it needs a desktop build to verify. reads z-layers.ts instead of a class literal and still asserts the panels beat the stack and stay under the startup screen and tooltips, and the Windows UI smoke's drag-resize-close on the monitor passes. Mutation-tested, sixteen, all caught: never stepping over anything; the refuge corner preferring the right-hand side; the panel climbing into the top chrome; taking the first candidate whatever it covers; dodging only the first published box; "fully covered" reading as merely overlapping, and a strip left showing on each of the four edges; a hand-placed panel not being pulled back on screen; a hidden panel staying hidden; raising notifying when nothing changed; every panel claiming the front; the stack going back over the panels; the front panel climbing two steps; a named layer dropping into the in-page band; the monitor hard-coding its z again; one notification stack drifting off the named layer; the startup screen dropping below the panels.
The refuge ranking read the side back out of the candidate's left coordinate, but a 400px panel anchored right in a 768px window sits at left=352, which is left of the midpoint. The bottom-right anchor was therefore ranked as a left-hand refuge, tied with the real one, and won on order, so with the monitor over the whole viewport the panel stayed exactly where it was: on top of the Close button and the resize grip this fallback exists to keep reachable. Each candidate carries the corner it came from now.
Two pins looked for the class string 'z-[9998] flex flex-col items-end gap-2' to find the bottom-right rails and count them. The rails read their depth from Z_LAYER now, so both counted zero and passed vacuously on one assert and failed on the next.
The two remaining pins split provider.tsx on 'fixed right-4 z-[9998]' to reach the rail's class list. The rails read their depth from Z_LAYER now, so that literal is gone and both splits found nothing.
1ec40e6 to
4c33a3e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c33a3e2f5
ℹ️ 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".
| top: FloatingPanelId | null, | ||
| hidden = false, | ||
| ): number { | ||
| return hidden || top === id |
There was a problem hiding this comment.
Allow later clicks to override the coverage rescue
When the resource monitor geometrically contains the API panel, covered remains true even after the API panel has already been rescued to the top layer. If the user subsequently clicks the resource monitor, both panels therefore receive FLOATING_PANEL_TOP; because the API overlay is rendered later in the root, it continues painting above the monitor instead of honoring the last-touch ordering. Promote the API panel into the ordering state once when it becomes covered, or otherwise stop applying the override after it is visible.
Useful? React with 👍 / 👎.
|
|
||
| function startDrag(event: PointerEvent<HTMLDivElement>): void { | ||
| event.preventDefault(); | ||
| setPlacedByUser(true); |
There was a problem hiding this comment.
Freeze placement only after an actual drag
A pointer-down on the drag handle immediately makes placement permanently user-controlled, even when the user only clicks, right-clicks, or cancels without moving the panel. If the resource monitor is then opened or moved into this corner, obstacle changes are ignored and the original overlap returns. Set this flag only once a drag actually moves or successfully ends with a changed anchor.
Useful? React with 👍 / 👎.
The collision
The Live resource monitor and the API monitor panel both default to the bottom-right corner. #8199 raised the monitor's container from
z-50toz-[9999]so it would paint over the notification stack; the API panel stayed atz-50. From then on the monitor covered that panel's request rows and its "Expand to full monitor" button, and a monitor resized across the viewport, which the Windows UI smoke does deliberately, hid the panel entirely, Close button included.Reproduced in a browser on
mainat 1440x900, both panels open:Why not another z-index
Studio already solves exactly this in exactly this corner, and not with z-index. The notification stack does not outrank the monitor, it steps over it: the monitor and the docked chat composer publish their boxes to the monitor frame store and
stackGeometryfolds them into the stack's bottom inset. The API panel now reads the same store and does the same thing one rung further in.z-[9998]sitting on a panel atz-50, and it goes away for free.finishDragdoes, so the published box stays honest and a window shrunk afterwards still pulls the panel back on screen. Neither panel keeps a position across reloads, so a panel stranded off the edge would have no way back.The case geometry cannot answer
A monitor filling the viewport leaves nowhere clear. So the two panels share one layer, the one the user touched last comes forward, and there is one override: a panel with no pixel showing cannot be clicked, so it cannot be raised by that rule, and it comes forward on its own. Only the API panel asks for it, because only it opens and places itself. With the monitor maximised the panel lands bottom-left, the corner that leaves the monitor's own Close button and resize grip free, so both windows stay operable.
The layer scale
The numbers move into
studio/frontend/src/lib/z-layers.ts, which is the first place the ordering is written down rather than inferred from six files:The top band only. Nothing else in the tree sits between 121 and 999998, so every relationship with every other surface is unchanged by the renumber. The two notification stacks and the two panel containers move onto the constants; the startup screen and tooltips keep their Tailwind classes, with the test pinning the literals to the scale so the two cannot drift.
Left alone on purpose: the in-page band, 50 to 120, holding dialogs, sheets, dropdowns, popovers and the Tauri titlebar. Putting modals over the notification stack is a real question, but toasts above modals is the usual convention rather than an accident, and the titlebar half of it needs a desktop build to verify. Renumbering 32 Radix portal call sites is exactly the change that breaks things invisibly, so it is not in here.
Verification
tests/studio/test_overlay_layering.pyrewritten to readz-layers.tsrather than a class literal. It still asserts what Let the floating monitor paint over the notification stack #8199 asserted: the panels beat the notification stack, and stay under the startup screen and tooltips.exercise_floating_monitor_geometryis the scenario Let the floating monitor paint over the notification stack #8199 unblocked. Run end to end on Linux Chromium against this build: passes, including the drag to the corner, the resize to fill the viewport and the Close click.panel-placement.test.ts,floating-panel-order.test.tsandz-layers.test.ts. Frontend suite 1405 passing, typecheck clean.