Skip to content

Studio: center sheet header close buttons - #7957

Merged
danielhanchen merged 3 commits into
unslothai:mainfrom
oobabooga:fix/response-details-header-alignment
Aug 6, 2026
Merged

danielhanchen merged 3 commits into
unslothai:mainfrom
oobabooga:fix/response-details-header-alignment

Conversation

@oobabooga

@oobabooga oobabooga commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Summary

The close buttons in Response details and Document preview are not vertically aligned with their titles. The shared default uses a fixed 16px top offset for a 32px button, while the title lines follow Studio's adjustable UI font size.

This PR keeps both close buttons centered on their titles across the full 12px to 20px UI font-size range.

What changed

  • Add a shared SheetCloseButton that preserves the existing icon, size, style, and accessible label.
  • Position it against the title line in Response details and Document preview instead of using the sheet's fixed top offset.
  • Keep the default close-button behavior for every other sheet unchanged.
  • Add focused contract coverage for both headers and the shared control.

The header height, title position, button size, and horizontal position are unchanged.

Screenshots

Before

response-details-alignment-before

After

response-details-alignment-after

Testing

  • npm run typecheck
  • npm run build
  • npm exec eslint src/components/ui/sheet.tsx src/components/assistant-ui/message-response-details-sheet.tsx
  • python -m pytest tests/studio/test_chat_response_details_ui_contract.py -q (7 passed)
  • git diff --check

Runtime validation

Built and served Studio from this branch, then measured both rendered header structures with Playwright against the compiled application stylesheet.

At the default 15px UI font size, the old fixed offset put the Response details close button 4.750px below its title center and the Document preview close button 6.625px below its title center. Both differences are 0.000px after the change.

The centers also match exactly at the 12px, 16px, and 20px UI font sizes. The Response details sheet was additionally exercised in a live chat.

@oobabooga oobabooga changed the title Desktop: center sheet header close buttons Studio: center sheet header close buttons Aug 5, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Thanks for this. I verified the alignment claim independently and it holds up exactly.

Measured the signed delta between the close button's centre and the title's centre (positive means the button sits low), before and after, at each UI font size:

Sheet 12px 15px (default) 16px 20px
Response details, before +7.000 +4.750 +4.000 +1.000
Document preview, before +8.000 +6.625 +6.000 +3.500
Both, after 0.000 0.000 0.000 0.000

That reproduces your 4.750 and 6.625 to the digit. It holds on Chromium, Firefox and WebKit, and on ubuntu-latest, windows-latest and macos-14 runners, all within 0.02px (one LayoutUnit). Real Segoe UI and real SF Pro give identical numbers, since the line height is a unitless 1.5 ratio and so is font-metric independent. Header height, button size and the 16px right gap are all unchanged, exactly one close control renders per sheet, type="button" and the sr-only label are preserved, and Escape, Enter and Space all still work.

One thing to flag before this lands, on the desktop build only.

The close button moves up, from top: 16 to 11.25 (Response details) and 9.375 (Document preview) at the default font size. On Windows and Linux the app draws its own titlebar, absolute inset-x-0 top-0 z-[70] h-[34px] in components/tauri/window-titlebar.tsx, with a pointer-events-auto window-control toolbar at z-[80] covering roughly the rightmost 112px. SheetContent is z-50 with inset-y-0, and neither of these two sheets applies the titlebar offset that chat-settings-sheet.tsx and research-activity-panel.tsx use. So the header sits underneath those controls.

Hit-testing a 9x9 grid over the button with document.elementFromPoint, where 85.2% is a fully clear round button:

Platform before after
Windows / Linux 37.0% 12.3 to 25.9%
macOS 85.2% 85.2%

The centre of the button resolves to the window controls rather than to Close, both before and after. So the occlusion is pre-existing on main, not introduced here, but this change moves the button further into that band. macOS is unaffected because shouldUseCustomWindowTitlebar() excludes it.

There is a wrinkle if you want to address it: the sheet is portalled to document.body, so it sits outside the wrapper div in app/provider.tsx that defines --studio-custom-titlebar-height, and the variable reads as empty. Copying the chat-settings-sheet.tsx pattern alone therefore has no effect. What worked in my testing was mirroring the titlebar heights onto document.documentElement so portalled overlays can see them, then adding the usual pair to both sheets:

height: "calc(100% - var(--studio-custom-titlebar-height, 0px))",
marginTop: "var(--studio-custom-titlebar-height, 0px)",

That takes Windows and Linux to 80.2 to 87.7% reachable with the centre hitting Close, leaves macOS and the browser build untouched since the variable resolves to 0px there, and keeps your 0.000px centring intact.

Worth noting separately: research-activity-panel.tsx reads the same variable from inside a portalled sheet, so that offset is likely inert for the same reason. That one is unrelated to this PR.

Happy for the titlebar part to be a follow-up if you would rather keep this PR focused on the centring, which is correct as it stands.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 7855a7c560

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

…dow controls

The two sheets start at the top of the viewport, so on Windows and Linux their
header sits under the custom titlebar and its window-control toolbar, which
paint above at z-70/z-80. Centring the close button on the title row moves it
further into that band.

Offset both sheets below the titlebar. The variable is set on the wrapper div,
which portalled content cannot see, so mirror the titlebar heights onto <html>
as well. Resolves to 0px in the browser and on macOS, which use native chrome.
@danielhanchen

Copy link
Copy Markdown
Member

Pushed the titlebar offset in c85482a so this does not need to be a follow-up.

Two parts, because the obvious one alone does not work:

  • Both sheets now carry the height / marginTop pair against --studio-custom-titlebar-height, the same pattern chat-settings-sheet.tsx uses.
  • app/provider.tsx mirrors the titlebar heights onto <html>. The chrome styles live on a wrapper div, and these sheets are portalled into document.body, so they sat outside that subtree and read the variable as empty. Copying the pattern without this is a no-op, which is what I hit first.

Measured on the pushed branch, hit-testing a 9x9 grid over the close button, where 85.2% is a fully clear round button:

Platform before this commit after
Windows / Linux 14.8 to 37.0% 85.2%
macOS 85.2% 85.2%

The centre of the button now resolves to Close rather than to the window controls. Both sheets, at 12, 15 and 20px UI font. macOS and the browser build are untouched since the variable resolves to 0px there, and your 0.000px centring is preserved throughout.

Gates on the branch: typecheck clean, 452 frontend tests pass, npm run build clean, tests/studio/test_chat_response_details_ui_contract.py 7 passed, and eslint reports the same 8 pre-existing errors on those three files as before the change, so nothing new.

Shout if you would rather I split the provider.tsx part out into its own PR.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: c85482a8a4

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

@codex review

@oobabooga

Copy link
Copy Markdown
Member Author

The follow-up changes increase scope towards what #7954 did; worth checking if anything from the other PR is worth including here.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 5e3e53c9c4

ℹ️ 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
danielhanchen merged commit 735909b into unslothai:main Aug 6, 2026
28 of 32 checks passed
danielhanchen added a commit to oobabooga/unsloth that referenced this pull request Aug 6, 2026
unslothai#7957 merged first and carried its own compensation for the same overlap.
DesktopChromeVarsEffect mirrored the titlebar height onto <html> so the
response details and document preview sheets could offset themselves with
marginTop, since the wrapper div's CSS vars do not reach a Radix portal.

With SheetViewportInsetProvider both mechanisms apply, pushing those two
panels to 68px and leaving them 34px past the viewport bottom. Remove the
per-sheet compensation and the mirror it needed, so the context is the only
offset, and extend the contract test to pin that.
danielhanchen added a commit to oobabooga/unsloth that referenced this pull request Aug 6, 2026
…s landed

unslothai#7957 merged first and gave the response details and document preview
sheets their own compensation for the same overlap: a marginTop plus
height: calc(100% - var(--studio-custom-titlebar-height)).

With SheetViewportInsetProvider both apply, pushing those two panels to
68px and leaving them 34px past the viewport bottom. Remove the per-sheet
compensation so the context is the only offset for sheets, and extend the
contract test to pin that.

DesktopChromeVarsEffect stays: unslothai#8016 gave it a second job, mirroring
--studio-window-chrome-top for the dialogs that portal to body.
danielhanchen added a commit to oobabooga/unsloth that referenced this pull request Aug 7, 2026
…s landed

unslothai#7957 merged first and gave the response details and document preview
sheets their own compensation for the same overlap: a marginTop plus
height: calc(100% - var(--studio-custom-titlebar-height)).

With SheetViewportInsetProvider both apply, pushing those two panels to
68px and leaving them 34px past the viewport bottom. Remove the per-sheet
compensation so the context is the only offset for sheets, and extend the
contract test to pin that.

DesktopChromeVarsEffect stays: unslothai#8016 gave it a second job, mirroring
--studio-window-chrome-top for the dialogs that portal to body.
danielhanchen added a commit that referenced this pull request Aug 7, 2026
* Studio: Keep sheets below the custom titlebar

* Studio: drop the per-sheet titlebar offset now that #7957 has landed

#7957 merged first and gave the response details and document preview
sheets their own compensation for the same overlap: a marginTop plus
height: calc(100% - var(--studio-custom-titlebar-height)).

With SheetViewportInsetProvider both apply, pushing those two panels to
68px and leaving them 34px past the viewport bottom. Remove the per-sheet
compensation so the context is the only offset for sheets, and extend the
contract test to pin that.

DesktopChromeVarsEffect stays: #8016 gave it a second job, mirroring
--studio-window-chrome-top for the dialogs that portal to body.

* Tidy comment wording for PR #7954

* Inset sheets with the mirrored titlebar variable, not a React context

* Tighten the sheet inset comments for PR #7954

---------

Co-authored-by: Daniel Han <[email protected]>
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.

2 participants