Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions apps/desktop/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/design.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,15 @@ 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(
"--rc-sidebar-bg: color-mix(in srgb, var(--rc-sidebar) calc(100% - var(--rc-transparency)), transparent);",
);
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);
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -1070,9 +1070,9 @@
*/
:root {
/* Settings › Appearance › Transparency (lib/transparency.ts sets it on <html>): 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));
Expand Down Expand Up @@ -1561,7 +1561,7 @@
* system's real blur of what is behind the window. `data-material` on <html> (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) {
Expand Down
12 changes: 1 addition & 11 deletions apps/desktop/src/lib/transparency.test.ts
Original file line number Diff line number Diff line change
@@ -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 };

Expand All @@ -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)`);
});
31 changes: 1 addition & 30 deletions apps/desktop/src/lib/transparency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
2 changes: 0 additions & 2 deletions apps/desktop/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { quietNativeChrome } from "./lib/quietNative";
import { applyCachedTheme } from "./lib/themes";
import {
installReduceTransparency,
paintBlurAfterAppStylesheet,
paintTransparency,
setSystemReduceTransparency,
setUserReduceTransparency,
Expand All @@ -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);
Expand Down
11 changes: 1 addition & 10 deletions apps/desktop/src/state/appState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions apps/desktop/src/state/settingsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions apps/desktop/src/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
store,
stored,
storedFlag,
storedGlassBlur,
storedJson,
storedThreadLimit,
storedTransparency,
Expand Down Expand Up @@ -487,7 +486,6 @@ export const useApp = create<AppState>((_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<unknown>(STORAGE.headerButtons, null)),
Expand Down
30 changes: 3 additions & 27 deletions apps/desktop/src/ui/SettingsAppearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ 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,
SETTINGS_DEFAULTS,
setActiveTheme,
setAnimateStreaming,
setFont,
setGlassBlur,
setReduceTransparency,
setTextSize,
setTheme,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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}
>
<Slider
label="Transparency"
Expand All @@ -294,28 +292,6 @@ export function AppearancePage() {
/>
</Row>
)}
{paintsBlur() && (
<Row
title="Blur"
reset={
glassBlur !== SETTINGS_DEFAULTS.glassBlur
? () => 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}
>
<Slider
label="Blur"
value={glassBlur}
min={BLUR_MIN}
max={BLUR_MAX}
step={1}
unit="px"
onChange={setGlassBlur}
/>
</Row>
)}
<SidebarDensitySetting />
<SidebarToolbarSetting />
<SettleAfterSetting />
Expand Down
7 changes: 1 addition & 6 deletions apps/desktop/src/ui/settingsIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading