From 236c2d3d16ec0775ab508dc5a6bda310f5de4eb7 Mon Sep 17 00:00:00 2001 From: LHaghfoss Date: Sun, 22 Nov 2026 11:51:23 +0100 Subject: [PATCH] fix(desktop): scope Transparency to the sidebar and drop the glass Blur slider --- apps/desktop/src/App.tsx | 8 +----- apps/desktop/src/design.test.ts | 4 +-- apps/desktop/src/index.css | 6 ++--- apps/desktop/src/lib/transparency.test.ts | 12 +-------- apps/desktop/src/lib/transparency.ts | 31 +--------------------- apps/desktop/src/main.tsx | 2 -- apps/desktop/src/state/appState.ts | 11 +------- apps/desktop/src/state/settingsActions.ts | 5 ---- apps/desktop/src/state/store.ts | 2 -- apps/desktop/src/ui/SettingsAppearance.tsx | 30 +++------------------ apps/desktop/src/ui/settingsIndex.ts | 7 +---- 11 files changed, 13 insertions(+), 105 deletions(-) diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx index 709e39b6b..af4b07607 100644 --- a/apps/desktop/src/App.tsx +++ b/apps/desktop/src/App.tsx @@ -13,11 +13,7 @@ import { import { rememberFocus } from "./lib/focusAreas"; import { matchWindowTheme } from "./lib/material"; import { applyTheme, resolveTheme } from "./lib/themes"; -import { - paintBlurAfterAppStylesheet, - paintTransparency, - setUserReduceTransparency, -} from "./lib/transparency"; +import { paintTransparency, setUserReduceTransparency } from "./lib/transparency"; import { restoreZoom } from "./lib/zoom"; import { startDeepLinks } from "./state/deepLinks"; import { sessionsListed } from "./state/engine"; @@ -76,7 +72,6 @@ function useTheme() { document.documentElement.dataset.chatWidth = s.chatWidth; setUserReduceTransparency(s.reduceTransparency); paintTransparency(s.transparency); - paintBlurAfterAppStylesheet(s.glassBlur); }; paint(); media.addEventListener("change", paint); @@ -89,7 +84,6 @@ function useTheme() { s.textSize !== prev.textSize || s.reduceTransparency !== prev.reduceTransparency || s.transparency !== prev.transparency || - s.glassBlur !== prev.glassBlur || s.chatWidth !== prev.chatWidth ) paint(); diff --git a/apps/desktop/src/design.test.ts b/apps/desktop/src/design.test.ts index 8f7781769..293ec622e 100644 --- a/apps/desktop/src/design.test.ts +++ b/apps/desktop/src/design.test.ts @@ -447,7 +447,7 @@ describe("design system", () => { expect(block(':root:is([data-platform="windows"], [data-platform="linux"]) .rc-reveal')).toContain( "animation-name: rc-fade;", ); - // Only the macOS window's vibrancy shows through, behind the sidebar alone, in the shared + // Only the macOS window's vibrancy shows through, behind the sidebar alone, in its own // Transparency, and never under Reduce transparency (lib/material.ts sets the attribute). const material = ":root[data-material]:not(.reduce-transparency)"; expect(block(`${material} {`)).toContain( @@ -455,7 +455,7 @@ describe("design system", () => { ); expect(block(`${material} body {`)).toContain("background: transparent;"); expect(css.match(/\[data-material\]/g)).toHaveLength(2); - expect(css).toContain("--rc-glass-alpha: calc(100% - var(--rc-transparency));"); + expect(css).toContain("--rc-glass-alpha: 72%;"); const config = (name: string) => JSON.parse(readFileSync(join(SRC, `../src-tauri/${name}`), "utf8")).app.windows[0]; expect(config("tauri.windows.conf.json").transparent).toBe(false); diff --git a/apps/desktop/src/index.css b/apps/desktop/src/index.css index c5372310f..b4ea4b6a2 100644 --- a/apps/desktop/src/index.css +++ b/apps/desktop/src/index.css @@ -1070,9 +1070,9 @@ */ :root { /* Settings › Appearance › Transparency (lib/transparency.ts sets it on ): how much of the - sidebar and the glass shows through. 28% keeps the glass at its designed 72%. */ + window shows through the sidebar. The glass keeps its designed 72% whatever the slider says. */ --rc-transparency: 28%; - --rc-glass-alpha: calc(100% - var(--rc-transparency)); + --rc-glass-alpha: 72%; /* The composer's hue: the sidebar's, lifted by a touch of white so the box reads a step lighter than the surface it floats on, in every theme. Its glass and solid fills both take it. */ --rc-composer-hue: color-mix(in srgb, #ffffff 6%, var(--rc-sidebar)); @@ -1561,7 +1561,7 @@ * system's real blur of what is behind the window. `data-material` on (lib/material.ts) is * set only where the shell has one, so a browser, Windows and Linux keep the opaque sidebar. The * page itself stays transparent there, the main pane keeps its opaque `bg`, and the sidebar takes - * the same Transparency as the glass. Reduce transparency makes it solid again (the rule above, + * Settings › Appearance › Transparency, which applies to it alone. Reduce transparency makes it solid again (the rule above, * which this one's `:not` defers to). */ :root[data-material]:not(.reduce-transparency) { diff --git a/apps/desktop/src/lib/transparency.test.ts b/apps/desktop/src/lib/transparency.test.ts index 05b1e4613..1b7e5d6e6 100644 --- a/apps/desktop/src/lib/transparency.test.ts +++ b/apps/desktop/src/lib/transparency.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test"; -import { BLUR_MAX, blurRule, canBlur, reducesTransparency } from "./transparency"; +import { canBlur, reducesTransparency } from "./transparency"; const none = { user: false, system: false, media: false, blur: true }; @@ -23,13 +23,3 @@ test("the glass blurs only where the web view has the filter and composites it", expect(canBlur(false, true)).toBe(false); expect(canBlur(false, false)).toBe(false); }); - -test("the blur rule writes a literal filter for both properties, kept to the slider's range", () => { - const rule = blurRule(14); - expect(rule).toContain("backdrop-filter: saturate(1.15) blur(14px);"); - expect(rule).toContain("-webkit-backdrop-filter: saturate(1.15) blur(14px);"); - expect(rule).not.toContain("var("); - expect(rule).toContain(":not(.reduce-transparency"); - expect(blurRule(-3)).toContain("blur(0px)"); - expect(blurRule(999)).toContain(`blur(${BLUR_MAX}px)`); -}); diff --git a/apps/desktop/src/lib/transparency.ts b/apps/desktop/src/lib/transparency.ts index 885eae5dd..fa156e69f 100644 --- a/apps/desktop/src/lib/transparency.ts +++ b/apps/desktop/src/lib/transparency.ts @@ -88,7 +88,7 @@ export function installReduceTransparency() { .catch(() => undefined); } -/** Settings › Appearance › Transparency, in percent: how much of the sidebar and the glass shows. */ +/** Settings › Appearance › Transparency, in percent: how much of the window shows through the sidebar. */ export const TRANSPARENCY_MIN = 0; export const TRANSPARENCY_MAX = 100; @@ -98,32 +98,3 @@ export function paintTransparency(percent: number) { const value = Math.min(TRANSPARENCY_MAX, Math.max(TRANSPARENCY_MIN, Math.round(percent))); document.documentElement.style.setProperty("--rc-transparency", `${value}%`); } - -export const BLUR_MIN = 0; -export const BLUR_MAX = 40; - -const GLASS_SURFACES = - ".rc-glass, .rc-glass-faint, .rc-glass-overlay, .rc-composer, .rc-composer-card, .rc-toast, " + - ".rc-composer-footer, .rc-scrim, .rc-lightbox-scrim, .elevated, .glass-filter"; - -export function blurRule(px: number): string { - const value = Math.min(BLUR_MAX, Math.max(BLUR_MIN, Math.round(px))); - const literalFilterForWebKit = `saturate(1.15) blur(${value}px)`; - const rootUnlessSolid = - ':root:not(.reduce-transparency, [data-platform="windows"], [data-platform="linux"])'; - return ( - `${rootUnlessSolid} :is(${GLASS_SURFACES}), ${rootUnlessSolid} .rc-header-glass::before ` + - `{ backdrop-filter: ${literalFilterForWebKit}; -webkit-backdrop-filter: ${literalFilterForWebKit}; }` - ); -} - -export function paintBlurAfterAppStylesheet(px: number) { - if (typeof document === "undefined") return; - let style = document.getElementById("rc-glass-blur"); - if (!style) { - style = document.createElement("style"); - style.id = "rc-glass-blur"; - } - document.head.appendChild(style); - style.textContent = blurRule(px); -} diff --git a/apps/desktop/src/main.tsx b/apps/desktop/src/main.tsx index cb10772af..a444a3882 100644 --- a/apps/desktop/src/main.tsx +++ b/apps/desktop/src/main.tsx @@ -11,7 +11,6 @@ import { quietNativeChrome } from "./lib/quietNative"; import { applyCachedTheme } from "./lib/themes"; import { installReduceTransparency, - paintBlurAfterAppStylesheet, paintTransparency, setSystemReduceTransparency, setUserReduceTransparency, @@ -33,7 +32,6 @@ applyCachedTheme(); installReduceTransparency(); setUserReduceTransparency(store.useApp.getState().reduceTransparency); paintTransparency(store.useApp.getState().transparency); -paintBlurAfterAppStylesheet(store.useApp.getState().glassBlur); // The window's material shows through the sidebar where there is one (macOS; lib/material.ts). applyMaterial(platform); diff --git a/apps/desktop/src/state/appState.ts b/apps/desktop/src/state/appState.ts index 8a4a4be9e..898b6642b 100644 --- a/apps/desktop/src/state/appState.ts +++ b/apps/desktop/src/state/appState.ts @@ -319,10 +319,8 @@ export interface AppState { animateStreaming: boolean; /** Glass is solid on every OS (Settings › Appearance); the system's own request does the same. */ reduceTransparency: boolean; - /** How much of the sidebar and the glass shows through, in percent (Settings › Appearance). */ + /** How much of the window shows through the sidebar, in percent (Settings › Appearance). */ transparency: number; - /** How strongly the glass blurs what is behind it, in pixels (Settings › Appearance). */ - glassBlur: number; /** How wide the chat lane grows, transcript and composer alike (Settings › Chat). */ chatWidth: ChatWidth; /** A turn shows its tool calls (Settings › Chat); off, only its "Worked for" line and the reply. */ @@ -487,7 +485,6 @@ export const STORAGE = { animateStreaming: "rustcode.animateStreaming", reduceTransparency: "rustcode.reduceTransparency", transparency: "rustcode.transparency", - glassBlur: "rustcode.glassBlur", chatWidth: "rustcode.chatWidth", showToolCalls: "rustcode.showToolCalls", headerButtons: "rustcode.headerButtons", @@ -533,7 +530,6 @@ export const SETTINGS_DEFAULTS = { animateStreaming: true, reduceTransparency: false, transparency: 28, - glassBlur: 9, chatWidth: CHAT_WIDTH_DEFAULT, showToolCalls: true, headerButtons: DEFAULT_HEADER_BUTTONS, @@ -576,11 +572,6 @@ export function storedTransparency(): number { return storedNumber(STORAGE.transparency, SETTINGS_DEFAULTS.transparency, 0, 100); } -/** Settings › Appearance › Blur, kept to the slider's 0..40 pixels. */ -export function storedGlassBlur(): number { - return storedNumber(STORAGE.glassBlur, SETTINGS_DEFAULTS.glassBlur, 0, 40); -} - /** A thread's own delegate limit, kept to 2..32. */ export function storedThreadLimit(key: string, fallback: number): number { return storedNumber(key, fallback, MIN_DELEGATES_PER_THREAD, MAX_DELEGATES_PER_THREAD); diff --git a/apps/desktop/src/state/settingsActions.ts b/apps/desktop/src/state/settingsActions.ts index 5c9759706..4f4f89432 100644 --- a/apps/desktop/src/state/settingsActions.ts +++ b/apps/desktop/src/state/settingsActions.ts @@ -166,11 +166,6 @@ export function setTransparency(percent: number) { store(STORAGE.transparency, String(percent)); } -export function setGlassBlur(px: number) { - set({ glassBlur: px }); - store(STORAGE.glassBlur, String(px)); -} - export function setChatWidth(width: ChatWidth) { set({ chatWidth: width }); store(STORAGE.chatWidth, width); diff --git a/apps/desktop/src/state/store.ts b/apps/desktop/src/state/store.ts index 5019838c4..24259bf6f 100644 --- a/apps/desktop/src/state/store.ts +++ b/apps/desktop/src/state/store.ts @@ -25,7 +25,6 @@ import { store, stored, storedFlag, - storedGlassBlur, storedJson, storedThreadLimit, storedTransparency, @@ -487,7 +486,6 @@ export const useApp = create((_set, _get, api) => ({ animateStreaming: storedFlag(STORAGE.animateStreaming, SETTINGS_DEFAULTS.animateStreaming), reduceTransparency: storedFlag(STORAGE.reduceTransparency, SETTINGS_DEFAULTS.reduceTransparency), transparency: storedTransparency(), - glassBlur: storedGlassBlur(), chatWidth: parseChatWidth(stored(STORAGE.chatWidth)), showToolCalls: storedFlag(STORAGE.showToolCalls, SETTINGS_DEFAULTS.showToolCalls), headerButtons: sanitizeHeaderButtons(storedJson(STORAGE.headerButtons, null)), diff --git a/apps/desktop/src/ui/SettingsAppearance.tsx b/apps/desktop/src/ui/SettingsAppearance.tsx index 86ff98ca8..8e9f48382 100644 --- a/apps/desktop/src/ui/SettingsAppearance.tsx +++ b/apps/desktop/src/ui/SettingsAppearance.tsx @@ -4,7 +4,7 @@ import { dirname } from "../lib/paths"; import { appPlatform, paintsBlur } from "../lib/platform"; import { hasShell } from "../lib/shell"; import { BUILTIN_THEMES, cssName, type Theme, TOKENS } from "../lib/themes"; -import { BLUR_MAX, BLUR_MIN, TRANSPARENCY_MAX, TRANSPARENCY_MIN } from "../lib/transparency"; +import { TRANSPARENCY_MAX, TRANSPARENCY_MIN } from "../lib/transparency"; import { getZoom, stepZoom, subscribeZoom, ZOOM_DEFAULT, ZOOM_MAX, ZOOM_MIN, zoomLabel } from "../lib/zoom"; import { createTheme, @@ -12,7 +12,6 @@ import { setActiveTheme, setAnimateStreaming, setFont, - setGlassBlur, setReduceTransparency, setTextSize, setTheme, @@ -185,7 +184,6 @@ export function AppearancePage() { const animateStreaming = useApp((s) => s.animateStreaming); const reduceTransparency = useApp((s) => s.reduceTransparency); const transparency = useApp((s) => s.transparency); - const glassBlur = useApp((s) => s.glassBlur); const active = useApp((s) => s.themeActive); const snapshot = useApp((s) => s.themes); const supported = useApp((s) => s.features.themes); @@ -280,8 +278,8 @@ export function AppearancePage() { ? () => setTransparency(SETTINGS_DEFAULTS.transparency) : undefined } - subtitle="How much the sidebar, composer and menus let through." - hint={reduceTransparency ? "Reduce transparency is on, so everything stays solid." : undefined} + subtitle="How much of the window shows through the sidebar." + hint={reduceTransparency ? "Reduce transparency is on, so the sidebar stays solid." : undefined} > )} - {paintsBlur() && ( - setGlassBlur(SETTINGS_DEFAULTS.glassBlur) - : undefined - } - subtitle="How strongly the composer and menus blur what is behind them." - hint={reduceTransparency ? "Reduce transparency is on, so nothing is blurred." : undefined} - > - - - )} diff --git a/apps/desktop/src/ui/settingsIndex.ts b/apps/desktop/src/ui/settingsIndex.ts index e15a5469e..d8b731d09 100644 --- a/apps/desktop/src/ui/settingsIndex.ts +++ b/apps/desktop/src/ui/settingsIndex.ts @@ -385,12 +385,7 @@ export const SETTINGS_INDEX: SettingEntry[] = [ { section: "appearance", title: "Transparency", - keywords: "opacity see through translucent glass sidebar window alpha", - }, - { - section: "appearance", - title: "Blur", - keywords: "glass frosted backdrop blur radius pixels softness", + keywords: "opacity see through translucent sidebar window alpha", }, { section: "appearance",