feat(desktop): back window glass with Windows 11 system materials

Glass was macOS-only because it rode setVibrancy. Windows 11 22H2 has a
first-party equivalent in setBackgroundMaterial, so the mode now resolves
its backing per platform instead of per-OS-check: macOS keeps vibrancy,
Windows 11 gets DWM acrylic / tabbed / mica, and everything older stays on
Clear. No third-party native addon.

Two Windows-specific details the mapping has to respect. DWM only paints
the client area of a transparent window (electron#49443), so glass-capable
Windows chat windows are born transparent with the opaque themed
backgroundColor covering them while glass is off — a live Clear/Glass
toggle then needs no window recreate. And Windows exposes three backdrops
for four frost rungs, so the two heaviest both resolve to mica; the mapping
stays total so a frost saved on a Mac still renders.

Glass support is computed once from os.release() and shared: main uses it
for the persisted default and every window, preload publishes it to the
renderer so the UI can't offer a mode the window can't back.
This commit is contained in:
Brooklyn Nicholson
2026-08-19 02:09:58 -05:00
parent b5455fdd16
commit eb52328857
17 changed files with 476 additions and 93 deletions
+17 -15
View File
@@ -551,23 +551,25 @@
}
/* ── Window glass (Settings → Appearance → Window Translucency: Glass) ──
Set on <html> by store/translucency.ts; macOS chat windows only. Every
chat window already carries an NSVisualEffectView (`vibrancy: 'sidebar'`
in electron/main.ts) that WindowServer composites BELOW the web contents;
the page normally buries it under fully opaque surfaces.
Set on <html> by store/translucency.ts; chat windows on a glass-capable
OS (macOS vibrancy, Windows 11 DWM acrylic/mica). The native material
composites BELOW the web contents; the page normally buries it under
fully opaque surfaces.
ONE PAINTER: <body> paints the glass tint exactly once, at
`--translucency-glass-keep` (set inline from the intensity slider, floor
30%), and the field tokens (chat / sidebar / editor surface) go fully
transparent. The field surfaces NEST — body > pane container > chat
section > transcript wrapper all wear these tokens — so thinning the
tokens themselves stacks the tint once per layer and a session pane ends
up near-opaque (~0.93 at 60%) while the landing page, with fewer layers,
reads far clearer. With a single painter the field alpha is the same
number on every route. Raised content (cards, popovers, bubbles, the
composer) keeps its own opaque fills over full-contrast text; regions
still read distinct through their borders and the material itself.
Unlike Clear, nothing on the page fades.
`--translucency-glass-keep` (set inline from the Tint slider, linear to
zero — the top of the lever is bare material), and the field tokens
(chat / sidebar / editor surface) go fully transparent. The field
surfaces NEST — body > pane container > chat section > transcript
wrapper all wear these tokens — so thinning the tokens themselves stacks
the tint once per layer and a session pane ends up near-opaque (~0.93 at
60%) while the landing page, with fewer layers, reads far clearer. With a
single painter the field alpha is the same number on every route. Raised
content (cards, popovers, bubbles, the composer) keeps its own opaque
fills over full-contrast text; regions still read distinct through their
borders and the material itself. Unlike Clear, nothing on the page fades
— the separate Fade lever does that natively, at the window level, and
defaults to off.
The boot script in index.html pins an opaque inline background on <html>
before first paint; it has to go transparent here or it sits behind the