Skip to content

Studio: dock the floating Live monitor beside Run settings - #11699

Merged
wasimysaid merged 17 commits into
unslothai:mainfrom
wasimysaid:mimir/rebuild-6993-monitor-dock
Sep 24, 2026
Merged

wasimysaid merged 17 commits into
unslothai:mainfrom
wasimysaid:mimir/rebuild-6993-monitor-dock

Conversation

@wasimysaid

@wasimysaid wasimysaid commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Keep Studio's floating Live monitor clear of the Run settings panel: dock it immediately to the panel's left at desktop widths, keep its right-edge placement when the panel closes, and yield to the full-screen sheet at narrow widths. Replacement for #6993, originally proposed by @Imagineer99; the original issue is #6988.

Upstream main anchors both the monitor and the settings panel to the bottom-right corner, so opening the panel paints it over the monitor and the user has to close one to read the other.

What changed

  • Placement is decided from the panel's state. A small pure rule (floating-monitor-layout.ts) returns whether the monitor is visible and whether it docks, from isOpen, isMobile, the route and settingsPanelOpen.
  • Docked, it stands beside the panel. The container's right inset becomes the panel's own live width from use-chat-settings-width, so the two never overlap at any width the panel can be dragged to (248–560 px).
  • The clearance scales with the UI font. The dock offset and the resize-handle clearance follow the shipped --ui-space-scale, so the supported 20 px interface font keeps the same 4 px gap instead of reintroducing an overlap.
  • A narrow viewport has nowhere to dock to, so the monitor yields to the mobile settings sheet instead of hiding behind it, and returns when the sheet closes.
  • A drag that ends at its own starting X is not a new placement, so a docked net-zero drag cannot latch a stale horizontal offset; the monitor falls back to the saved/rest position on undock.

Main versus replacement

Real authenticated Studio built from source at each pin, driven with real Chromium. Left is the before side, right is the head.

1280×800, Run settings open — main overlaps the monitor by 256 px; the replacement docks it with 4 px clearance and no overlap.

Studio floating monitor: overlap on main versus docked beside Run settings on the replacement

720×800, modal Run settings — main's monitor still paints over the sheet's controls even though it is aria-hidden; the replacement suppresses it and makes its grip unreachable.

Studio Run settings at narrow width: monitor overlays main but not the replacement

1280×800 at the supported 20 px UI font — main overlaps by 250.67 px; the replacement keeps 0 px, with containerRight scaling to 277.333px (= 272 + 4 × 1.3333).

Studio floating monitor at 20px UI font: overlap on main versus clear on the replacement

Verification

fact main f5109b58 original measured head 7f17c056
1280 px open: monitor x / right 1008 / 1264 748 / 1004
1280 px open: horizontal overlap 256 px 0 px
720 px sheet: monitor visible true (paints over the modal) false
20 px font open: overlap 250.672 px 0 px
20 px font: docked containerRight 16px (rest) 277.333px = 272 + 4 × 1.3333
docked net-zero drag → undock x 1008 (never docks) 1008 (right anchor restored); the superseded candidate e55c9b58 stayed at its docked 748
  • Pinned scene shared by the three original builds: scene-7f17.py, sha256 fd1fc6364d30411c54aba8cc79c9edd56cc1953861b5ad8ca289d4360bae64ee. 22 captures per variant; pair 0 (panel closed) is byte-identical between main and the measured head, so both sides start from the same frame.
  • Raw evidence, per-artifact SHA-256s and both comparison results (evidence.json, SHA256SUMS.txt); all three servers were stopped and every variant left with 0 dirty tracked files.
  • After merging current main and trimming the test to 204 lines, the updated head 8b6f29844 passes 12/12 dock tests and 8,637/8,637 frontend tests. npm run typecheck and npm run build pass; the bundle is within budget (61.3 KB transfer, 200.2 KB raw spare). No model load is needed for this layout check.
  • The merge resolved the bundle-budget comment conflict using current main's measurements; GitHub reports the PR mergeable. The screenshots above were captured against the unchanged dock implementation at the original head, not re-captured after this merge.

No credentials or server logs are included in the evidence; only screenshots, geometry facts and hashes.

Credit: @Imagineer99 for the original implementation and investigation.
Codex review on fork PR #206 found no major issues at the earlier 7f17c056 head; it has not been repeated on the merged head.

Imagineer99 and others added 15 commits September 23, 2026 07:41
The Live resource monitor is anchored to the bottom-right corner, which is
exactly where the Run settings panel opens, so opening the panel covered the
monitor and the user had to close one to read the other.

Decide the monitor's placement from the panel's own state instead: dock it to
the panel's left edge while the panel is open on /chat, and yield to the sheet
on a narrow viewport, where there is no room to stand beside it. The docked
inset is the panel's live width from use-chat-settings-width, so the monitor
clears it at every width the panel can be dragged to (248-560 px).

Adapted from unslothai#6993 onto current main. The original hardcoded
an 18rem offset (correct only near the 272 px default, and fully occluded at
the 560 px maximum) and replaced the shared floating-panel z-layer with a
literal `z-40`, which puts the bottom-right notification stack back over the
monitor; both are kept on main's terms here. Its regression test also shipped
as a root-level .mjs that the configured frontend runner never collected, so it
moved to studio/frontend/tests/.

(cherry picked from commit fb9cc19)
Four follow-ups on the docking behaviour, each with a test that fails on the
previous revision:

- Follow the panel's painted width, not only the stored one. The resize handle
  paints --chat-settings-width per frame and commits to the store on pointer
  up, so the monitor trailed the panel by a whole drag.
- Yield when a pinned sidebar leaves no room to dock. At the 768 px breakpoint
  the default sidebar and panel leave less than the monitor's own width, and
  docking there covered the sidebar rather than the panel.
- Restore the position the user dragged to when the dock is removed: the
  narrowed container clamps it and place() then keeps the clamped spot.
- Keep the monitor mounted while the settings panel covers it, so opening the
  panel no longer discards the dragged position and the resize dimensions.

(cherry picked from commit 12ac921)
Codex round 3 on the previous head flagged three follow-ups:

- Suppression withholds the monitor's frame from the API monitor, but
  visibility and aria-hidden fire no ResizeObserver, so ending suppression
  never put the box back. `hidden` now feeds the existing republish effect.
- Crossing the mobile breakpoint replaces the desktop <aside> with the
  settings sheet and back while Run settings stays open, leaving the painted
  width observer attached to a disconnected node. The effect reattaches.
- Docking reserved a fixed 256 px for the monitor, but the panel is natively
  resizable, so a widened monitor could dock over the sidebar. The capacity
  check now reserves the width the panel actually renders.

(cherry picked from commit 695f9d0)
…changes

Codex round 4 on the previous head flagged two follow-ups:

- Sidebar swaps its desktop element for a sheet across the mobile breakpoint
  and back, so the painted-width observer stayed attached to a disconnected
  node and its stale width kept overriding the committed one. The effect
  reattaches on the breakpoint, as the settings-panel observer already does.
- The capacity check read window.innerWidth during render, so it only
  re-evaluated when useIsMobile crossed 768px or a width store changed. Both
  width stores saturate at their maxima, so resizing from 1600px to 1500px
  could leave a docked monitor overlapping the sidebar. It now tracks the
  viewport through its own resize subscription.

(cherry picked from commit 49b339d)
`dockedMonitorFits` floored the measured width at `FLOATING_MONITOR_WIDTH`.
Tailwind's spacing token is `calc(0.25rem * var(--ui-space-scale, 1))`, so at a
12px UI font (`--ui-space-scale: 0.8`) a `w-64` monitor renders 205px and the
floor over-reserved by 51px. An 800px desktop with the default 280px sidebar and
a 272px panel leaves 248px, which fits the real monitor but not the floor, so the
dock was suppressed and the monitor disappeared.

The constant now only supplies the pre-first-measure default; a finite measured
width is used as-is. Adds the narrow-viewport regression alongside it.

(cherry picked from commit 91cd246)
Two transitions left the dock decision or the restored position wrong:

- Suppressed and undocked both paint the full-width container, so leaving
  suppression resizes no observed element and the queued position restore was
  never applied; the monitor reappeared at its dock-clamped spot. The transition
  now runs the same reconcile the observers would have.
- An unpinned web sidebar still holds the 3rem icon rail as a column
  (`collapseToZero` is desktop-app only), so reserving zero let a docked monitor
  sit on the rail. The measured rail is reserved while the sidebar really is one.

(cherry picked from commit 39393e5)
Two docked-state interactions were wrong:

- The docked inset ended exactly at the aside's left edge, but the resize
  handle is a `-left-1 w-2` target, so its outer 4px sat under the monitor's
  layer and the grip lost half its width. The docked inset now clears it.
- `startDrag` cleared the saved position on pointer-down, so pressing the grip
  without moving discarded the placement the undock restore replays. The
  position is now only replaced once a move actually happens.

(cherry picked from commit 6d4c1cf)
The settings aside's resize handle is `-left-1 w-2`, and both halves resolve
through Tailwind's `--spacing: calc(0.25rem * var(--ui-space-scale, 1))`. The
docked monitor reserved a pinned 4px for the outward half, which is only right
at the 15px default UI font: at the supported 20px maximum the handle reaches
5.333px outside the aside, so the monitor's above-panel layer covered its outer
1.33px along the whole shared height.

Derive the clearance from the live `--ui-space-scale` instead, threaded from
the appearance store through `useUiSpaceScale`, and pin the pair in the dock
regression test: the shipped CSS keeps `--spacing` scaled, the clearance
tracks it at 12/15/20px, and the default still resolves to the shipped 4px.
@wasimysaid
wasimysaid merged commit 80432b8 into unslothai:main Sep 24, 2026
38 of 40 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…#11699)

* fix(studio): dock the live monitor beside the run settings panel

The Live resource monitor is anchored to the bottom-right corner, which is
exactly where the Run settings panel opens, so opening the panel covered the
monitor and the user had to close one to read the other.

Decide the monitor's placement from the panel's own state instead: dock it to
the panel's left edge while the panel is open on /chat, and yield to the sheet
on a narrow viewport, where there is no room to stand beside it. The docked
inset is the panel's live width from use-chat-settings-width, so the monitor
clears it at every width the panel can be dragged to (248-560 px).

Adapted from unslothai#6993 onto current main. The original hardcoded
an 18rem offset (correct only near the 272 px default, and fully occluded at
the 560 px maximum) and replaced the shared floating-panel z-layer with a
literal `z-40`, which puts the bottom-right notification stack back over the
monitor; both are kept on main's terms here. Its regression test also shipped
as a root-level .mjs that the configured frontend runner never collected, so it
moved to studio/frontend/tests/.

(cherry picked from commit fb9cc19)

* fix(studio): keep the docked monitor clear of the live panel width

Four follow-ups on the docking behaviour, each with a test that fails on the
previous revision:

- Follow the panel's painted width, not only the stored one. The resize handle
  paints --chat-settings-width per frame and commits to the store on pointer
  up, so the monitor trailed the panel by a whole drag.
- Yield when a pinned sidebar leaves no room to dock. At the 768 px breakpoint
  the default sidebar and panel leave less than the monitor's own width, and
  docking there covered the sidebar rather than the panel.
- Restore the position the user dragged to when the dock is removed: the
  narrowed container clamps it and place() then keeps the clamped spot.
- Keep the monitor mounted while the settings panel covers it, so opening the
  panel no longer discards the dragged position and the resize dimensions.

(cherry picked from commit 12ac921)

* fix(studio): close three gaps in the monitor's dock and yield path

Codex round 3 on the previous head flagged three follow-ups:

- Suppression withholds the monitor's frame from the API monitor, but
  visibility and aria-hidden fire no ResizeObserver, so ending suppression
  never put the box back. `hidden` now feeds the existing republish effect.
- Crossing the mobile breakpoint replaces the desktop <aside> with the
  settings sheet and back while Run settings stays open, leaving the painted
  width observer attached to a disconnected node. The effect reattaches.
- Docking reserved a fixed 256 px for the monitor, but the panel is natively
  resizable, so a widened monitor could dock over the sidebar. The capacity
  check now reserves the width the panel actually renders.

(cherry picked from commit 695f9d0)

* fix(studio): keep the monitor's dock decision live across responsive changes

Codex round 4 on the previous head flagged two follow-ups:

- Sidebar swaps its desktop element for a sheet across the mobile breakpoint
  and back, so the painted-width observer stayed attached to a disconnected
  node and its stale width kept overriding the committed one. The effect
  reattaches on the breakpoint, as the settings-panel observer already does.
- The capacity check read window.innerWidth during render, so it only
  re-evaluated when useIsMobile crossed 768px or a width store changed. Both
  width stores saturate at their maxima, so resizing from 1600px to 1500px
  could leave a docked monitor overlapping the sidebar. It now tracks the
  viewport through its own resize subscription.

(cherry picked from commit 49b339d)

* fix(studio): reserve the monitor's real width, not the scaled constant

`dockedMonitorFits` floored the measured width at `FLOATING_MONITOR_WIDTH`.
Tailwind's spacing token is `calc(0.25rem * var(--ui-space-scale, 1))`, so at a
12px UI font (`--ui-space-scale: 0.8`) a `w-64` monitor renders 205px and the
floor over-reserved by 51px. An 800px desktop with the default 280px sidebar and
a 272px panel leaves 248px, which fits the real monitor but not the floor, so the
dock was suppressed and the monitor disappeared.

The constant now only supplies the pre-first-measure default; a finite measured
width is used as-is. Adds the narrow-viewport regression alongside it.

(cherry picked from commit 91cd246)

* fix(studio): reserve the icon rail and reconcile when suppression ends

Two transitions left the dock decision or the restored position wrong:

- Suppressed and undocked both paint the full-width container, so leaving
  suppression resizes no observed element and the queued position restore was
  never applied; the monitor reappeared at its dock-clamped spot. The transition
  now runs the same reconcile the observers would have.
- An unpinned web sidebar still holds the 3rem icon rail as a column
  (`collapseToZero` is desktop-app only), so reserving zero let a docked monitor
  sit on the rail. The measured rail is reserved while the sidebar really is one.

(cherry picked from commit 39393e5)

* fix(studio): keep the settings grip and the saved spot usable

Two docked-state interactions were wrong:

- The docked inset ended exactly at the aside's left edge, but the resize
  handle is a `-left-1 w-2` target, so its outer 4px sat under the monitor's
  layer and the grip lost half its width. The docked inset now clears it.
- `startDrag` cleared the saved position on pointer-down, so pressing the grip
  without moving discarded the placement the undock restore replays. The
  position is now only replaced once a move actually happens.

(cherry picked from commit 6d4c1cf)

* fix(studio): scale the monitor's clearance with the UI space scale

The settings aside's resize handle is `-left-1 w-2`, and both halves resolve
through Tailwind's `--spacing: calc(0.25rem * var(--ui-space-scale, 1))`. The
docked monitor reserved a pinned 4px for the outward half, which is only right
at the 15px default UI font: at the supported 20px maximum the handle reaches
5.333px outside the aside, so the monitor's above-panel layer covered its outer
1.33px along the whole shared height.

Derive the clearance from the live `--ui-space-scale` instead, threaded from
the appearance store through `useUiSpaceScale`, and pin the pair in the dock
regression test: the shipped CSS keeps `--spacing` scaled, the clearance
tracks it at 12/15/20px, and the default still resolves to the shipped 4px.

* fix(studio): address monitor dock review findings

* fix(studio): keep dock anchor on vertical drags

* Defer floating monitor bundle until opened

* Restore eager monitor mount and align budget with current main

* Scale restored monitor inset with UI font

* Preserve saved monitor placement when docked drag returns to start

* Keep monitor anchored after net-zero dock drag

* Format overlay layering test with pinned Ruff hook

---------

Co-authored-by: imagineer99 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants