Skip to content

Studio: Glass theme for the sidebar, composer and menus, glass without a background image, and drop the Classic and Minimal themes - #16333

Merged
shimmyshimmer merged 12 commits into
mainfrom
studio-glass-materials
Nov 1, 2026
Merged

shimmyshimmer merged 12 commits into
mainfrom
studio-glass-materials

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

What changed

A new Glass theme section in Settings > Appearance, just above Background image, turns the sidebar, composer, Run settings panel and (optionally) menus into translucent glass. Its switch sits in the section heading; the options appear only while it is on:

  • Style: Transparent, Frosted, Blurred, Liquid Glass (a nearly clear pane with a thin lit rim and a sheen) or Liquid Glass 3D (the same pane with a faint lit bevel, light pooling inside the edges and glass bead controls; the default). The switch remembers the last style.
  • Glass strength (0 to 100%, kept separately for light and dark mode, 40% light and 15% dark by default): blur from a fifth to twice each style's own, and every pane's opacity from about a third to nearly solid. It applies last, after the readability floor below, so it always shows.
  • Glass menus (on by default): dropdowns, selects, context menus, popovers, tooltips, toasts, hover cards and dialogs (Settings, search) take the glass too, always with some blur and a heavier tint so their text stays readable.

The Theme dropdown also lists Glass right under Standard, a submenu with every style on top of whichever colour theme is chosen.

Glass works without a background image. With no image the glass sits over the plain page colour. In light mode, where a white pane over a white page would vanish, the composer keeps a grey-tinted floor and an outline that darkens instead of brightening, and menus get a thin glass fill with a faint accent wash and a bevelled edge.

Hover and edges. Liquid menus carry a lit rim (the base dropdown shadow used to win), active composer pills keep their fill on hover, the sheen is kept faint, and Firefox redraws glass blurs once the image has painted.

Readable over any image. Studio measures the background image's tone once per image and raises the pane tint so text reads over it: darker panes over light images in dark mode, lighter ones over dark images in light mode, and a light grey shade in light mode over a light image so the sidebar stays distinct. Images that already contrast keep the plain glass.

Light mode. Light panes need more body than dark ones, so in light mode the sidebar and Run settings panel take a higher floor and a slight grey tint that sets them apart from a white chat, menus and toasts stay at least 80% solid, grey secondary text is a step darker on glass, and controls on glass (segmented toggles, filled buttons, dropdowns) are frosted white with no outline, with selected and hovered states still see-through.

Glass keeps its own image settings. While glass is on, image visibility is per mode (70% light, 40% dark by default) and Fade to background defaults to off. These are stored apart from the normal ones, so without glass an image keeps exactly the visibility and fade it had before, and turning glass on or off never changes the other set.

Glass off costs nothing at runtime. With glass off nothing writes glass variables to the page and the background image is never sampled for tone; that work starts only when glass is switched on (a test guards it).

Sign-in and change-password pages show the background under a glass card. When the install has more than one account they show only the built-in backdrop, never the last person's own image.

Under glass:

  • Borders and dividers are glass lines (a single 1px line, the text colour at 9%, fields 14%) instead of opaque greys, everywhere the glass shows, including Images and Video.
  • Hover and open fills (composer pills, sidebar rows, header icons, menu items, model picker rows) are a translucent wash with a faint rim instead of a solid grey chip, and a row that lights both its shell and its button paints one pill, not two; menus that pin their own fill (More, lifted dropdowns) are pointed at the glass instead.
  • The BETA badge is an outline on the glass rather than an opaque chip with a dark drop shadow; the titlebar strip above a pinned sidebar matches the sidebar tint.
  • Composer outline off also removes the glass ring and bevel; with Fade to background off, the solid band behind the composer is removed.
  • No glass style adds an outer shadow (a test enforces inset-only).

Classic and Minimal themes are removed. Their colours, ids (frontend, theme-boot.js and the backend palette Literal) and labels are gone; a saved Classic or Minimal falls back to Standard (the backend already drops unknown palettes, drop_unknown_palette).

Settings are per device in localStorage (unsloth_window_material).

Notes

  • The CSS minifier keeps only the last of a backdrop-filter / -webkit-backdrop-filter pair, so the glass rules put the unprefixed one last (Chromium and WebView2 ignore the prefixed one). A test guards the order.
  • Sticky sidebar section labels are cleared under glass so they do not paint solid bands.

Stack

This is the base of a stack; each PR builds on the one before:

  1. This PR: glass materials
  2. Studio: macOS system glass on Unsloth Desktop #16334: macOS system glass on Unsloth Desktop
  3. Studio: glass on every page when the background shows on all pages #16335: glass on every page (for "All pages" in Studio: choose where the background image shows (new chat page, chats, or all pages) #16297)
  4. Studio: glass lens, and a hairline composer outline lit by what is behind it #16336: glass lens and the hairline composer outline

Screenshots

Liquid Glass with no background image (built-in backdrop), light mode:

No image

The Glass theme section, on and off:

Glass theme section

The Theme dropdown with the Glass submenu:

Theme dropdown

Dark mode over a light image: the panes darken so the text reads:

Readable over a light image

Run settings with glass dividers, dark and light:

Glass borders

Glass strength at 0, 50 and 100%:

Glass strength

Earlier screenshots of the materials:

Frosted, Liquid Glass and Liquid Glass 3D composers in light mode:

Glass materials

Frosted with Glass menus on, dark mode:

Frosted glass menu

Verification

  • npm run typecheck, npm test (0 failures), npm run i18n:check:strict, npm run build
  • pytest studio/backend/tests/test_personalization_settings.py (palette list change)
  • Isolated Studio driven with Playwright in light and dark mode: every material, with and without a background image; the Glass theme switch; the Theme dropdown Glass submenu; a scripted sweep of every page and overlay (Settings, search, model picker, menus, toasts) for opaque fills and opaque borders under glass; Glass strength measured at 0, 50 and 100%.
  • New keys translated for all 24 locale overlays.

Not tested here

  • Training and other GPU-only pages (CPU-only host); the glass is CSS over the same surfaces.

shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 31, 2026
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 31, 2026
…ground image, readable panes, glass borders, dialogs and toasts; drop the Classic and Minimal themes
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 1, 2026
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 1, 2026
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 1, 2026
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 1, 2026
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 1, 2026
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 1, 2026
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 1, 2026
@shimmyshimmer shimmyshimmer changed the title Studio: glass materials for the sidebar, composer and menus Studio: Glass theme for the sidebar, composer and menus, glass without a background image, and drop the Classic and Minimal themes Nov 1, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T11:39:23.177437Z 18b7763 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

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

sanitizeStrength,
} from "./model";

export const MATERIAL_STORAGE_KEY = "unsloth_window_material";

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 Include glass settings in the local-preferences reset

After enabling glass, using “Reset all local preferences” in Settings leaves the glass style, strength and menu setting unchanged after reload. resetAllPrefs() in studio/frontend/src/features/settings/tabs/general-tab.tsx only removes keys listed in PREFS_KEYS, which does not include this new storage key, so the persisted store immediately restores these settings. Add MATERIAL_STORAGE_KEY to that reset list so the reset also restores the new appearance preferences to their defaults.

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.

Fixed in ee4ee48: the glass storage key is now in the Reset all local preferences list, with a test that keeps them in sync.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: ee4ee4865c

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

shimmyshimmer and others added 6 commits October 31, 2026 23:10
…defaults

Light mode panes, menus and toasts take a higher readability floor and a slight grey tint, muted ink is a step darker on glass, and lines are a single thin glass hairline. Light controls on glass are frosted rather than grey or solid white, and nested row hovers no longer stack into a second pill.

The sign-in and change-password pages show the background (only the generic backdrop when the install has several accounts) under a glass card.

Glass now defaults to Liquid Glass 3D with glass menus on. Strength and image visibility are kept per mode (40% and 70% light, 15% and 40% dark), and the background fade is off under glass until the user sets it.
… while it is off

Glass keeps its own image visibility (70% light, 40% dark) and fade (off), so an image keeps the visibility and fade it had without glass, and turning glass on or off never changes the other set.

With glass off, Studio no longer writes the glass strength to the page or samples the background image's tone; both start when glass is switched on.
…one account; keep glass across account switches
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

@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: 075f87b319

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


export function LoginPage() {
// A shared sign-in screen never shows the last account's own image.
const personal = useLoginMode() !== "multi";

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 Wait for confirmed login mode before showing a personal image

When another browser has added an account since this browser last checked the server, opening /login directly can expose the previous user's wallpaper on a now-shared sign-in screen. initialLoginMode() defaults to single without a cached multi-user hint, and requireGuest() returns without fetching status for signed-out users. Consequently, this condition enables the personal image while AuthForm is still fetching /api/auth/status; a slow or failed request leaves it visible. Keep personal images disabled until the server has confirmed single-user mode rather than treating the initial cached/default mode as confirmation.

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.

Fixed in f612bde: the sign-in and change-password pages now show a personal image only after /api/auth/status confirms single-user mode; until then, or if the request fails, they show the generic backdrop.

sanitizeStrengths,
} from "./model";

export const MATERIAL_STORAGE_KEY = "unsloth_window_material";

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 Preserve the device-level glass preference across account switches

When signing into a different account in the same browser, transitionBrowserAccount() removes every unsloth* local-storage key not included in its preservation lists. The new unsloth_window_material key is absent from ACCOUNT_CHROME_KEYS, so switching accounts deletes the glass style, strength and menu preferences, and the subsequent reload restores solid defaults. Add this key to the chrome allowlist alongside the existing theme and palette settings so the documented per-device appearance preference survives account switches.

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.

Fixed in f612bde: unsloth_window_material is now in ACCOUNT_CHROME_KEYS, so the glass preference survives account switches like the theme.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: f612bdea69

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

Unsloth added 3 commits November 1, 2026 01:47
… steadier hovers, softer sheen

With no background image the glass sits over the plain page colour instead of a coloured backdrop. In light mode the composer keeps a grey-tinted floor, and menus over the plain page get a thin accent-washed glass fill with a bevelled edge.

Liquid menus now get their lit rim (the base dropdown shadow had always won), an active composer pill keeps its fill on hover, the light composer hover is a grey wash rather than an invisible white one, the sheen is about a quarter of its old strength, and Firefox redraws glass blurs once the background image has painted.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 18b77635dc

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

@shimmyshimmer
shimmyshimmer merged commit 65e868d into main Nov 1, 2026
@shimmyshimmer
shimmyshimmer deleted the studio-glass-materials branch November 1, 2026 12:14
shimmyshimmer added a commit that referenced this pull request Nov 1, 2026
…16335)

## What changed

Makes the glass materials work on every page when the background image
is shown on all pages ("All pages" under **Show on**, added in #16297).
Before this, many pages were unreadable over the image, or kept solid
blocks that ignored the glass.

- Every other page (Model hub, Library, Images, Video, Audio, Data
Recipes, Export, API, Projects, Scheduled) reads over one tinted pane on
a frosted copy of the image. The pane tint follows Glass strength with a
floor (70% light, 60% dark) so dense pages stay readable over any image.
- Inside the pane, page canvases, headers, cards, fields and chips turn
into lighter glass, and hover fills take the glass wash.
- Sticky headers frost the rows scrolling under them instead of painting
a band.
- Without glass, other pages read over a near-solid wash (at least 86%)
whatever the image's contrast.

The image is blurred directly on those pages rather than through a
`backdrop-filter` on the pane: a pane that is a backdrop root makes
every sticky header inside re-tint it into a visible band. A test guards
that the pane has no `backdrop-filter`.

This is CSS only and keys on `data-wallpaper-route="page"`, so it has no
effect until the background can show on other pages (#16297).

Stacked on #16334.

### Screenshots

Every page with All pages on, Frosted in dark mode:

![All pages, Frosted,
dark](https://raw.githubusercontent.com/shimmyshimmer/unsloth-staging-4/pr-media/pr/16335/allpages_dark_frosted_grid-2e4a59a369a0.png)

Liquid Glass 3D in light mode:

![All pages, Liquid Glass 3D,
light](https://raw.githubusercontent.com/shimmyshimmer/unsloth-staging-4/pr-media/pr/16335/allpages_light_liquid-3d_grid-c6ad052f3860.png)


### Update

The All pages pane follows Glass strength (its opacity now scales with
it, after its floor) and the image readability floor from #16333, so a
light image in dark mode cannot wash the page out. The surface tokens it
uses moved to the base glass section in #16333, where dialogs and menus
share them.

## Verification

- `npm test` (0 failures), `npm run build`
- Isolated Studio with the background on all pages: walked every page
above in light and dark mode for Frosted, Transparent and Liquid Glass
3D, and measured the pane tint and the header bands from pixels.

---------

Co-authored-by: Unsloth <[email protected]>
shimmyshimmer added a commit that referenced this pull request Nov 1, 2026
…hind it (#16336)

## What changed

**Glass lens** (Off, Magnify, Shrink), under the Glass setting, makes
the composer act like a thick piece of glass over the background image:
the image seen through it is larger (Magnify, 1.18x) or smaller (Shrink,
0.87x) than the image around it.

It works by placing a copy of the wallpaper behind the composer's
content, lined up with the real one and scaled about the composer's
centre. `backdrop-filter` cannot scale, and SVG backdrop filters are
Chromium only, so the copy is what makes this work in the macOS app's
WebKit too. The copy follows resizes, the welcome composer docking, new
frames and adjustments of the image.

The same copy also draws the glass composer's outline: a 1px hairline of
the image right behind the edge, brightened and saturated, plus a faint
highlight along the top. The outline takes the colours behind it (pink
over pink, grey over grey) instead of a fixed grey ring. Composer
outline off hides it.

Stacked on #16335.

### Screenshots

Lens modes on Liquid Glass. Off keeps only the hairline outline; Magnify
and Shrink scale the image under the composer:

![Glass lens
modes](https://raw.githubusercontent.com/shimmyshimmer/unsloth-staging-4/pr-media/pr/16336/pr_lens_modes-c9992c6de677.png)

The outline over a pink gradient, dark mode: pink where pink is behind
it, grey elsewhere:

![Hairline outline over
pink](https://raw.githubusercontent.com/shimmyshimmer/unsloth-staging-4/pr-media/pr/16336/pr_lens_pink_dark-e9aa15b1235d.png)


### Update

The hairline is softer and more natural: blurred slightly, less
saturated, lit a little more along the top and bottom edges than the
sides, plus a faint inset bevel (light inside the top edge, a soft shade
inside the bottom). Glass lens now lives in the Glass theme section from
#16333 and shows only while glass is on; the built-in no-image backdrop
gets the lens too.

![Softer outline with a faint
bevel](https://raw.githubusercontent.com/shimmyshimmer/unsloth-staging-4/pr-media/pr/16336/bevel_outline_zoom-684e1ac1eea9.png)

## Verification

- `npm run typecheck`, `npm test` (0 failures), `npm run
i18n:check:strict`, `npm run build`
- Isolated Studio, Playwright in light and dark mode: each lens mode on
Liquid Glass and the outline on Liquid Glass and Liquid Glass 3D, over a
busy image and a gradient image.
- New keys translated for all 24 locale overlays.

---------

Co-authored-by: Unsloth <[email protected]>
shimmyshimmer added a commit that referenced this pull request Nov 1, 2026
## What changed

Adds **macOS system glass** to the Glass setting, offered only in
Unsloth Desktop on macOS. The system's translucent window material
(`NSVisualEffectView`, sidebar material) sits under the whole window, so
the desktop shows through the sidebar, composer and pages. It follows
the window's light or dark appearance and its active / inactive state
like native apps. Glass strength and Glass menus work with it as with
the other materials.

### Desktop shell

New `set_native_vibrancy` command
(`studio/src-tauri/src/native_vibrancy.rs`): on macOS it clears the main
webview's `drawsBackground` (the same KVC key the browser layer already
uses) and applies `Effect::Sidebar` with
`EffectState::FollowsWindowActiveState` through Tauri's
`Window::set_effects`; turning it off clears the effect. Other platforms
return `false`.

The page only clears its own backgrounds after the command returns
`true`. An older Desktop shell running a newer frontend has no such
command, so the page keeps the solid look and the setting shows a short
note asking to update. In a browser the option is not listed, and a
stored `macos` value falls back to Off.

Note that with macOS's Reduce transparency turned on (System Settings >
Accessibility > Display), the system draws this material opaque.

Stacked on #16333.

### Screenshot

Simulated: a blurred stand-in is painted under the page to show the page
side of the layout, since no Desktop build runs on this host.

![macOS system glass,
simulated](https://raw.githubusercontent.com/shimmyshimmer/unsloth-staging-4/pr-media/pr/16334/dark_macos_simulated-b51646d674a1.png)


### Update

macOS system glass is now one of the Glass theme **Style** options (and
in the Theme dropdown's Glass submenu) in the Desktop app on macOS. The
glass borders and BETA badge rules from #16333 also cover it, and the
built-in no-image backdrop is skipped for it, since the desktop shows
through.

## Verification

- `npm run typecheck`, `npm test` (0 failures), `npm run
i18n:check:strict`, `npm run build`
- `cargo check` on macOS for `studio/src-tauri`

## Not tested here

- The native material inside a real Unsloth Desktop window: no Desktop
build was run from this host, and Desktop signing and the updater
journey are untouched by this change.
- Windows and Linux Desktop shells never offer the option; the command
returns `false` there.

---------

Co-authored-by: Unsloth <[email protected]>
danielhanchen added a commit to NilayYadav/unsloth that referenced this pull request Nov 6, 2026
## What changed

Typing in a long, idle chat could stall in Unsloth Desktop on Windows.
The wallpaper fade rule used a descendant search inside `:has()`, so
editing the composer could trigger a costly style recalculation across
the chat. The slowdown reproduced with turn navigation disabled and no
model running.

Use direct-child selectors for the two wallpaper layouts. The plain
Glass backdrop contains the image directly, and an uploaded wallpaper
wraps it in a frame. Both keep their existing fade behavior.

## Verification

- In Windows WebView2, median keydown-to-second-frame latency in the
same synthetic 600-message chat fell from **160.1 ms to 5.0 ms**. The
same source builds passed all 16 wallpaper fade cases.
- Extended the existing thread-ancestor performance guard to check every
combinator in wallpaper paths inside `:has()`. On the original
stylesheet, the three prior checks pass and the new check fails on the
fade selector. All 28 tests across the thread-ancestor, wallpaper and
appearance suites pass with the fix.

Playwright sent the final key at 1.88 seconds in both recordings. The
full phrase appeared at 4.09 seconds before the fix and 1.88 seconds
after it. The capture compares the parent and implementation commit. The
follow-up commits only change the regression tests.

![Before and after typing in an idle 600-message chat on Windows
WebView2](https://raw.githubusercontent.com/Imagineer99/unsloth/8fd91c242dc7fc4461a96973630e1f9da4016468/pr-media/long-chat-typing.gif)



## Glass users and the latest main

The fade selector was one of four whole-thread `:has()` searches on the
workspace that holds the chat. With Glass on (stored per origin, so
Desktop can have it on while the same chat at 127.0.0.1:8888 does not),
the other three still made every keystroke re-walk the thread:

- `:not(:has(.aui-thread-welcome-center))` and
`:has([data-tour="chat-compare-view"])` on the workspace (wallpaper dim,
plus two Glass rules added in unslothai#16643)
- `.aui-thread-viewport:has(.aui-thread-welcome-center)` on the thread
scroller itself

The welcome and compare views now set `data-chat-welcome` /
`data-chat-compare` on `<html>` in a layout effect (counted, so compare
panes and remounts stay correct), and the viewport rule uses the fixed
child path to the welcome block. The branch is merged with main. The
guard test now checks every `:has()` anchored on an element that holds
the thread, including ones nested in `:not()`.

Typing into an idle 600-message chat, headless Chromium, same server, JS
and DOM, only the stylesheet differs, arms interleaved, 6 reps each,
median [min-max]:

| Glass | Arm | Style recalc per key | 88-char burst | Keydown to 2nd
frame |
|---|---|---|---|---|
| on | main (A/A: two arms) | 26.4 / 23.4 ms | 2.97 / 2.87 s | 36.7 /
33.1 ms |
| on | fade fix only | 23.4 ms [20.6-30.1] | 2.85 s | 34.0 ms |
| on | this PR | 1.4 ms [1.4-2.4] | 0.68 s | 13.7 ms |
| off | main (A/A: two arms) | 22.7 / 20.8 ms | 2.51 / 2.41 s | 31.2 /
30.0 ms |
| off | fade fix only | 1.1 ms [1.0-1.4] | 0.62 s | 15.8 ms |
| off | this PR | 1.1 ms [0.9-2.4] | 0.65 s | 13.9 ms |

No visual change: 192 wallpaper states (workspace and chat root,
backdrop / frame / crossfade, ready, fade, welcome / conversation /
compare / compare with an empty pane, Glass on and off) compute the same
display, opacity, viewport wash and composer glass values on main and on
this PR in Chromium, Firefox and WebKit (576 cells, 0 differ; dropping
the rules flips 96 of 192, so the check is live). The real app shows the
same computed values on main and on this PR for welcome, conversation
and compare, with and without Glass.

Typing a 57-character question at 80 ms per key into the same
600-message chat with Glass on (4.6 s is the floor):

![Typing into an idle 600-message chat with Glass on, main above and
this PR
below](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/16656/typing-edd898b05ecd.gif)


## Issue unslothai#16603

Fixes unslothai#16603. Bisecting the Studio frontend from `v0.1.913` to `main` on
a seeded 200-turn agent chat (about 427K tokens: reasoning, tool cards,
web sources, compaction markers, code, KaTeX), headless Chromium, same
server and data for every build:

| Build | Style work per keystroke | 88-key burst | Scroll long tasks |
| --- | --- | --- | --- |
| before unslothai#16333 | 15.6 ms | 1.29 s | 189 ms |
| unslothai#16333 (the fade `:has()` this PR bounds) | 619 ms | 58.1 s | 268 ms |
| `v0.1.914-beta` | 144 ms | 13.9 s | 280 ms |
| `main` | 136.5 ms | 11.4 s | 935 ms |
| `main` + this PR | 4.6 ms | 1.32 s | 27 ms |

unslothai#16751 (Reduce Motion default off) made scroll pay the same walk more
often (61 ms to 188 ms per wheel step); this PR removes the walk, so no
separate change is needed there, and it is why turning Reduce Motion on
did not help typing. A spoofed agent session that grows to 30 turns with
tool calls, file edits, web search and compaction rounds goes from 23.7
to 100.3 ms per key on `main` and stays near 1.2 ms per key with this
PR.

unslothai#16801 adds a CI gate that fails when selector matching per keystroke
grows with chat length; it should merge after this PR.

---------

Co-authored-by: Daniel Han <[email protected]>
danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Nov 6, 2026
…the chat grows (unslothai#16801)

Adds a browser CI gate that fails when typing in a long chat costs more
as the chat grows, the shape of unslothai#16603.

**Stacked on unslothai#16656. Please merge unslothai#16656 first**: this branch contains
its commits, and the gate fails on current `main` by design (that is the
regression it catches).

## Why

unslothai#16603 came back because nothing in CI measured per-keystroke cost
against chat length. Bisecting the Studio frontend from `v0.1.913` to
`main`:

| Build (200-turn agent chat, about 427K tokens) | Style work per
keystroke |
| --- | --- |
| before unslothai#16333 | 15.6 ms |
| unslothai#16333 (wallpaper fade `:has()`) | 619 ms |
| `v0.1.914-beta` | 144 ms |
| `main` | 136.5 ms |
| `main` + unslothai#16656 | 4.6 ms |

unslothai#16333 added a descendant `:has()` on elements that hold the whole
thread (`[data-wallpaper-workspace]`, `[data-chat-content-root]`), so
Chromium (Desktop, Chrome, Edge) walks every message on each keystroke.
Firefox is not affected, which matches the "browser is fine" reports.
unslothai#16751 (Reduce Motion default off) then made scroll pay that walk more
often (61 ms to 188 ms per wheel step), which is why turning Reduce
Motion back on did not help typing. unslothai#16300 (`d56738f40`) already removed
two other unslothai#16333 rules that restyled the whole page on every key
(real-app bisect: 563.8 to 91.2 ms per key), which is why 0.1.914 was
slow but not as slow as unslothai#16333. The fade rule stayed. unslothai#16656 removes
every such rule and adds a static guard test; this PR adds the runtime
gate so a new rule of that shape, or anything else that scales with chat
length, cannot ship again.

## What the gate does

`tests/studio/playwright_long_thread_gate.py` runs **first** in every
frontend lane, right after `npm ci`: Frontend CI (Linux, Windows),
Composer compatibility (Ubuntu, macOS, Windows, Safari) and Inline
images (Ubuntu, macOS, Windows).

1. Builds `smoke-thread-weight.html` for production
(`vite.long-thread.config.ts`) and seeds an agent-style history inside
the real app ancestors (`?shell=1`: sidebar workspace, wallpaper, chat
content root) with open reasoning, tool cards, web sources, compaction
markers, code, KaTeX and tables. The fixture shape is checked, so a
fixture that stops rendering something fails.
2. Measures the 200-turn chat first. Two untraced keys decide how much
to trace: a healthy page traces 10 keys, a slow one 2, and a page
hundreds of times slower than healthy fails on the untraced number
alone.
3. Fails if `:has()` matching costs more than 5 ms per key at 200 turns,
or if total selector matching per key grows more than 2x from 40 to 200
turns. A second repeat runs only when the ratio is near the limit. Both
checks are ratios or tiny budgets on selector matching, so a slow runner
cannot fail them.

## What a failure says

A failure prints ms per key at each size, how far over budget it is and
the top selectors with their match attempts. Selectors tried on most of
the DOM are marked as likely victims of a whole-page restyle. It then
pins down the trigger: it removes `:has()` rules from the stylesheet
text before fresh page loads (rules switched off in a page that already
rendered leave Chromium's `:has()` state behind and blame the wrong
rule) and bisects for the rule whose removal makes typing cheap, trying
rules that search an element holding the thread first. Each rule found
is mapped to its likely source with a text match, worded as a
possibility. On current `main`:

```
FAIL: :has() matching costs 63.6 ms per keystroke at 200 turns, budget 5.0 ms (12.7x over); total selector matching 358.9 ms/key
  pin-down at 60 turns, untraced style recalc per keystroke: 48.5 ms with all 262 :has() rules, 1.1 ms with none of them
  Measured: removing only this rule takes the keystroke from 48.5 to 1.8 ms (no :has() rules: 1.1 ms); this rule on its own costs 4.9 ms:
    :is([data-wallpaper-workspace], [data-chat-content-root]):has(> .chat-wallpaper[data-ready] .chat-wallpaper-image[data-fade="false"]) .thread-bottom-fade
    It is possible this section caused the issue, but we cannot be sure (a text match):
      studio/frontend/src/index.css:6210 (exact text match)
    Pattern: `:has(> .chat-wallpaper[data-ready] .chat-wallpaper-image[data-fade="false"])` on `:is([data-wallpaper-workspace], [data-chat-content-root])` searches all descendants (no leading `>`, or a space inside), so Chromium re-walks everything under that element after each DOM change, whether or not anything matches.
      `[data-wallpaper-workspace]` (first found in studio/frontend/src/app/routes/__root.tsx:720) holds the whole thread, so every keystroke walks every message.
```

`tests/studio/test_css_culprit.py` covers the source mapping and the
`:has()` shape check.

## Replay against past stylesheets

The gate on this branch, with only `index.css` swapped in from each
commit (CPU runner):

| `index.css` from | Verdict | Time | Pin-down |
| --- | --- | --- | --- |
| before unslothai#16333 (`4ce36bc3b5`) | PASS | 25 s | |
| unslothai#16333 (`65e868dcf5`) | FAIL | 104 s | fade rule: 276.0 to 1.5 ms
without it |
| unslothai#16442 (`6401ceda29`) | FAIL | 105 s | fade rule |
| `v0.1.914-beta` | FAIL | 101 s | fade rule |
| `main` | FAIL | 104 s | fade rule: 48.5 to 1.8 ms without it |
| this branch | PASS | 28 s | |

On GitHub runners a passing gate takes 30 to 77 s per lane plus 12 to 24
s for Chromium (staging run of every lane on Linux, Windows and macOS).

## Other changes

- The smoke fixture gains `rich` agent content (markdown, table, list)
and the `?shell=1` app shell.
- The gate's Chromium step installs missing Linux libraries only when
Chromium cannot launch, through `retry-with-apt-lock.sh` with
`APT_ACQUIRE_RETRIES=0` and a 10 minute step timeout, like the other
browser steps.

---------

Co-authored-by: imagineer99 <[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.

1 participant