From 6dd5ccefb5b7a722dc4ec5a1165f1bb6d78ae063 Mon Sep 17 00:00:00 2001 From: broisnees Date: Tue, 24 Nov 2026 04:54:22 +0000 Subject: [PATCH] Make the window and UI feel native on each OS Density: 14px base text instead of 16px, icons at their real sizes, a 6px radius, a 38px macOS title bar (36px on Windows and Linux), and 1px hairlines between the bars. Motion: no press squash, dialogs fade, plain tooltips, a spinner for the sidebar loader. Window: size, position and maximized state persist in window-state.json (window_state.rs) instead of opening maximized every launch. Windows 11 keeps its DWM shadow, uses Mica for glass and Fluent caption glyphs; Linux gets round GTK-style controls and a 1px border when windowed; macOS glass follows the window's active state. Chrome dims when the window loses focus. Alt mnemonics open the menus on Windows and Linux. Defaults: system UI font and OS smoothing, native scrolling everywhere, and trackpads always bypass eased wheel scrolling. Linux uses GPU compositing and falls back to software rendering only after a failed launch or with WEBKIT_DISABLE_DMABUF_RENDERER=1. --- .changeset/native-feel.md | 13 + index.html | 2 +- src-tauri/capabilities/default.json | 1 + src-tauri/src/commands.rs | 29 +- src-tauri/src/display_backend.rs | 13 +- src-tauri/src/lib.rs | 60 ++-- src-tauri/src/local_servers.rs | 2 +- src-tauri/src/mac_chrome.rs | 2 +- src-tauri/src/window_state.rs | 160 +++++++++ src/App.svelte | 26 +- src/app.css | 306 ++++++------------ src/lib/components/AiChat.svelte | 6 +- src/lib/components/AppLockScreen.svelte | 4 +- src/lib/components/AppMenuBar.svelte | 83 +++-- src/lib/components/DataTable.svelte | 12 +- src/lib/components/GlobalTooltip.svelte | 26 +- src/lib/components/Onboarding.svelte | 2 +- src/lib/components/SettingsDialog.svelte | 2 +- src/lib/components/Sidebar.svelte | 37 +-- src/lib/components/SignInScreen.svelte | 4 +- src/lib/components/StatusBar.svelte | 8 +- src/lib/components/StudioShell.svelte | 10 +- src/lib/components/TabBar.svelte | 4 +- src/lib/components/TitleBar.svelte | 16 +- src/lib/components/TrialExpiredScreen.svelte | 4 +- src/lib/components/WindowControls.svelte | 110 +++++-- src/lib/components/ui/button/button.svelte | 12 +- .../context-menu/context-menu-content.svelte | 2 +- .../ui/dialog/dialog-content.svelte | 6 +- .../dropdown-menu-content.svelte | 2 +- .../ui/popover/popover-content.svelte | 2 +- .../ui/select/select-content.svelte | 2 +- src/lib/fonts.js | 4 +- src/lib/fonts.test.js | 5 +- src/lib/platform.js | 65 ++++ src/lib/smooth-scroll.js | 28 ++ src/lib/smooth-scroll.test.js | 16 +- src/lib/stores/settings.js | 34 +- src/lib/type-scale.js | 21 +- 39 files changed, 700 insertions(+), 441 deletions(-) create mode 100644 .changeset/native-feel.md create mode 100644 src-tauri/src/window_state.rs diff --git a/.changeset/native-feel.md b/.changeset/native-feel.md new file mode 100644 index 00000000..0f1709f1 --- /dev/null +++ b/.changeset/native-feel.md @@ -0,0 +1,13 @@ +### Changes + +#### Look and feel +- **Desktop density** - Text, icons and bars are smaller and tighter, closer to native desktop apps. The base text size is 14px instead of 16px, icons render at their real 12, 14 and 16px sizes, corners are tighter, and the macOS title bar is 38px (36px on Windows and Linux). +- **Quieter motion** - Buttons no longer shrink when pressed, dialogs fade in instead of zooming, tooltips lose the arrow and bounce, and the sidebar loader is a spinner. +- **System font and scrolling by default** - Unless changed in Settings, Stroke uses the system UI font with the OS's own text smoothing, and native scrolling on every platform. Trackpads always scroll natively, even with eased mouse-wheel scrolling turned on. + +#### Window +- **Window size and position are remembered** - Stroke reopens where it was, at the same size, instead of opening maximized every time. +- **Native window chrome** - Windows 11 keeps its window shadow and rounded corners, uses Mica for the glass effect, and gets Fluent caption buttons. Linux gets round GTK-style window buttons and a 1px border on unmaximized windows. On macOS the glass dims with the window when another app has focus, like Finder. +- **Unfocused window** - The title bar and sidebar dim slightly when Stroke isn't the active window. +- **Menu mnemonics** - On Windows and Linux, Alt+F, E, V, T and H open the menus, and holding Alt underlines their letters. +- **Linux GPU rendering** - Stroke now uses GPU compositing on Linux, and falls back to software rendering only after a launch that failed to draw or when `WEBKIT_DISABLE_DMABUF_RENDERER=1` is set. diff --git a/index.html b/index.html index 10ca7309..20e03b11 100644 --- a/index.html +++ b/index.html @@ -64,7 +64,7 @@ if (parsed?.zoom != null) zoom = Number(parsed.zoom) else if (parsed?.fontSize != null) zoom = Number(parsed.fontSize) / 14 if (Number.isFinite(zoom) && zoom > 0) { - const fontPx = Math.round(13 * zoom) + const fontPx = Math.round(14 * zoom) const root = document.documentElement root.style.setProperty('--app-zoom', String(zoom)) root.style.setProperty('--app-font-size', fontPx + 'px') diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 29baa69f..4d39ba27 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -32,6 +32,7 @@ "core:window:allow-toggle-maximize", "core:window:allow-start-dragging", "core:window:allow-is-maximized", + "core:window:allow-is-focused", "dialog:default", "dialog:allow-save", "autostart:default" diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 47c28df7..66bd97be 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -320,7 +320,7 @@ pub async fn open_dashboard_window(app: tauri::AppHandle, dashboard_id: String, } #[cfg(not(target_os = "macos"))] { - builder = builder.decorations(false); + builder = builder.decorations(false).shadow(true); } let window = builder.build().map_err(|e| e.to_string())?; let surface = crate::surface_for_theme(window.theme().unwrap_or(tauri::Theme::Dark)); @@ -367,7 +367,7 @@ pub async fn open_new_window(app: tauri::AppHandle) -> Result<(), String> { } #[cfg(not(target_os = "macos"))] { - builder = builder.decorations(false); + builder = builder.decorations(false).shadow(true); } let window = builder.build().map_err(|e| e.to_string())?; @@ -2572,12 +2572,9 @@ pub fn set_window_glass(window: tauri::WebviewWindow, enabled: bool, dark: bool) .set_effects( EffectsBuilder::new() .effect(Effect::Sidebar) - // Always frosted. Following the window's active state - // turned the glass into flat grey whenever another app - // had focus - which read as the theme not working, most - // of all in light, where the inactive material is a - // plain pale grey. - .state(EffectState::Active) + // Follow native macOS active/inactive material dimming + // just like Finder and system windows. + .state(EffectState::FollowsWindowActiveState) .build(), ) .map_err(|e| e.to_string())?; @@ -2589,7 +2586,21 @@ pub fn set_window_glass(window: tauri::WebviewWindow, enabled: bool, dark: bool) window.set_background_color(Some(surface)).map_err(|e| e.to_string())?; } } - #[cfg(not(target_os = "macos"))] + #[cfg(target_os = "windows")] + { + use tauri::window::{Effect, EffectsBuilder}; + let theme = if dark { tauri::Theme::Dark } else { tauri::Theme::Light }; + if enabled { + let _ = window.set_theme(Some(theme)); + let _ = window.set_effects(EffectsBuilder::new().effect(Effect::Mica).build()); + } else { + let _ = window.set_effects(None); + let _ = window.set_theme(None); + let surface = crate::surface_for_theme(theme); + let _ = window.set_background_color(Some(surface)); + } + } + #[cfg(not(any(target_os = "macos", target_os = "windows")))] let _ = (window, enabled, dark); Ok(()) } diff --git a/src-tauri/src/display_backend.rs b/src-tauri/src/display_backend.rs index 9103d6ef..29c1b9b4 100644 --- a/src-tauri/src/display_backend.rs +++ b/src-tauri/src/display_backend.rs @@ -100,6 +100,12 @@ mod imp { }); } + /// True when an earlier GPU/Wayland launch failed to draw and we fell back + /// to the safe X11 path. + pub fn using_fallback() -> bool { + state_dir().map(|d| d.join(FALLBACK).exists()).unwrap_or(false) + } + /// The page drew: this backend works here. pub fn drawn() { if let Some(dir) = state_dir() { @@ -109,7 +115,7 @@ mod imp { } #[cfg(target_os = "linux")] -pub use imp::{choose, drawn, watch}; +pub use imp::{choose, drawn, using_fallback, watch}; #[cfg(not(target_os = "linux"))] pub fn choose() {} @@ -119,3 +125,8 @@ pub fn drawn() {} #[cfg(not(target_os = "linux"))] pub fn watch(_app: tauri::AppHandle) {} + +#[cfg(not(target_os = "linux"))] +pub fn using_fallback() -> bool { + false +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index c4472b3d..a797c5e3 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -42,6 +42,7 @@ mod sync; mod updates; mod quit; mod web_search; +mod window_state; use db::{ActiveConnection, DbState, TunnelState}; use mcp::McpState; @@ -437,29 +438,23 @@ pub fn run() { // Wayland or X11, before GTK starts and before any thread (display_backend.rs). display_backend::choose(); - // Linux WebKitGTK rendering fix - set before any threads spawn. + // Linux WebKitGTK GPU compositing - set before any threads spawn. #[cfg(target_os = "linux")] // SAFETY: called before any threads are spawned. unsafe { - // WEBKIT_DISABLE_DMABUF_RENDERER: WebKitGTK's DMA-buf renderer composites - // text as GPU textures that get bilinearly sampled at fractional pixel - // offsets during scroll/zoom, producing the characteristic blur on Linux. - // Disabling it falls back to a Cairo/FreeType software path that stays crisp. - // This is the only verified safe WebKitGTK rendering env var - others like - // WEBKIT_USE_LEGACY_TEXT_RENDERER are not real and can trigger SIGTRAP crashes. - // - // The cost is per-frame CPU. rAF still rides the GdkFrameClock, so the - // cadence the compositor offers is the cadence WebKit asks for - but - // rasterising in software is expensive enough that a busy frame can miss - // it, and the miss gets more likely the higher the panel's rate. Default - // to crisp, and let a high-refresh setup buy frames back with - // `WEBKIT_DISABLE_DMABUF_RENDERER=0`, which puts the webview on the GPU - // compositor. The "0" is unset rather than passed through, because WebKit - // tests some of these vars for presence and not for value. + // Keep hardware DMA-buf compositing enabled on healthy Linux GPU setups + // so scrolling, resizing and dialogs stay fluid (our type scale now + // lands on whole pixels, avoiding fractional texture resampling). Only + // fall back to Cairo software rendering if a previous launch failed to + // draw (display_backend::using_fallback()) or the user explicitly sets + // WEBKIT_DISABLE_DMABUF_RENDERER=1. match std::env::var("WEBKIT_DISABLE_DMABUF_RENDERER").as_deref() { Ok("0") | Ok("") => std::env::remove_var("WEBKIT_DISABLE_DMABUF_RENDERER"), Ok(_) => {} - Err(_) => std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1"), + Err(_) if display_backend::using_fallback() => { + std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1"); + } + Err(_) => {} } // GDK_SCALE is intentionally NOT forced here - overriding it breaks HiDPI // setups (2× displays) and can cause rendering panics on Wayland compositors. @@ -536,7 +531,8 @@ pub fn run() { // paths that need them without a State/AppHandle argument: the D1 // driver refreshing an expired Cloudflare token mid-session. cloudflare::set_app_handle(app.handle().clone()); - if let Ok(dir) = app.path().app_data_dir() { + let app_data_dir = app.path().app_data_dir().ok(); + if let Some(dir) = app_data_dir.clone() { crash::set_dir(dir.clone()); db::connection::set_data_dir(dir); } @@ -552,15 +548,10 @@ pub fn run() { .inner_size(1280.0, 800.0) .min_inner_size(960.0, 600.0) .resizable(true) - .maximized(true) // Hidden until the page has its first finished screen: revealApp() - // in src/lib/app-reveal.js shows it. A window visible from build() - // put every pre-paint layer on screen in turn - the host surface, - // the webview backdrop, the maximize resize - and on Windows that - // read as the window flickering between two blacks for half a second - // before the app appeared. tao keeps MAXIMIZED across the hide, and - // show() issues SW_SHOW then SW_MAXIMIZE, so the OS still records a - // real maximized state (minimize -> restore keeps working). + // in src/lib/app-reveal.js shows it. Window size, position, and + // maximized state are restored from window-state.json right after + // build() rather than forcing maximized on every launch. .visible(false) // Never let the default white surface show. The real theme is only // known to the frontend (localStorage), so start on the dark base - @@ -572,8 +563,8 @@ pub fn run() { // OS-drawn traffic lights via the Overlay style - they just float over // our content instead of sitting in a native title bar strip, so // clicking/hovering/dragging them stays pixel-native with no code on - // our side. Windows/Linux get no decorations at all; TitleBar.svelte - // draws its own drag region and minimize/maximize/close buttons. + // our side. Windows/Linux use frameless windows with native shadows + // enabled so DWM shadows & rounded corners stay intact on Windows 11. #[cfg(target_os = "macos")] { window_builder = window_builder @@ -593,7 +584,7 @@ pub fn run() { } #[cfg(not(target_os = "macos"))] { - window_builder = window_builder.decorations(false); + window_builder = window_builder.decorations(false).shadow(true); } let window = window_builder @@ -614,6 +605,11 @@ pub fn run() { .on_navigation(navigation_allowed) .build()?; + window_state::restore(&window, app_data_dir.as_deref()); + if let Some(dir) = app_data_dir { + window_state::attach(&window, dir); + } + // Match the surface to the OS appearance before the first frame. Both // calls land inside `setup`, i.e. before the event loop starts, so // nothing has been composited yet and there is no flash of the wrong @@ -772,12 +768,12 @@ pub fn run() { commands::cassandra_tables, commands::cassandra_describe, commands::cassandra_page, - commands::test_convex, - commands::connect_convex_db, commands::cassandra_save, commands::cassandra_delete, commands::test_firestore, commands::connect_firestore_db, + commands::test_convex, + commands::connect_convex_db, commands::test_neo4j, commands::connect_neo4j_db, commands::neo4j_labels, @@ -797,11 +793,11 @@ pub fn run() { commands::test_odbc, commands::connect_odbc_db, commands::test_snowflake, - commands::convex_call, commands::connect_snowflake_db, commands::odbc_drivers, commands::odbc_data_sources, commands::firestore_request, + commands::convex_call, commands::test_mongo, commands::connect_mongo_db, commands::doc_use_schema, diff --git a/src-tauri/src/local_servers.rs b/src-tauri/src/local_servers.rs index 673a1f72..8aa9f059 100644 --- a/src-tauri/src/local_servers.rs +++ b/src-tauri/src/local_servers.rs @@ -688,7 +688,7 @@ pub async fn open_local_servers_window(app: AppHandle, from: String) -> Result<( } #[cfg(not(target_os = "macos"))] { - builder = builder.decorations(false); + builder = builder.decorations(false).shadow(true); } let window = builder.build().map_err(|e| e.to_string())?; let surface = crate::surface_for_theme(window.theme().unwrap_or(tauri::Theme::Dark)); diff --git a/src-tauri/src/mac_chrome.rs b/src-tauri/src/mac_chrome.rs index 188b471c..cf1009b9 100644 --- a/src-tauri/src/mac_chrome.rs +++ b/src-tauri/src/mac_chrome.rs @@ -42,7 +42,7 @@ const ACCEL_EVENT: &str = "native-menu-accelerators"; /// them (19 and 17 left them high). Shared by the main window and /// `open_new_window`. pub(crate) fn traffic_light_position() -> LogicalPosition { - LogicalPosition::new(16.0, 28.0) + LogicalPosition::new(14.0, 21.0) } /// One app item: (action, label, accelerator, needs a connection). diff --git a/src-tauri/src/window_state.rs b/src-tauri/src/window_state.rs new file mode 100644 index 00000000..51cff84a --- /dev/null +++ b/src-tauri/src/window_state.rs @@ -0,0 +1,160 @@ +//! Main window geometry & state persistence (`window-state.json`). +//! +//! Native desktop apps remember the window's size, position and maximized state +//! across launches instead of forcing maximized on every boot. Bounds are +//! validated against currently connected monitors so a disconnected external +//! display can never leave the window off-screen. + +use serde::{Deserialize, Serialize}; +use std::path::{Path, PathBuf}; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; +use tauri::{PhysicalPosition, PhysicalSize, WebviewWindow, WindowEvent}; + +const STATE_FILE: &str = "window-state.json"; +const MIN_WIDTH: u32 = 960; +const MIN_HEIGHT: u32 = 600; +const SAVE_DEBOUNCE: Duration = Duration::from_millis(350); + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub(crate) struct WindowState { + pub x: i32, + pub y: i32, + pub width: u32, + pub height: u32, + pub maximized: bool, +} + +fn state_path(data_dir: &Path) -> PathBuf { + data_dir.join(STATE_FILE) +} + +pub(crate) fn load(data_dir: &Path) -> Option { + let raw = std::fs::read_to_string(state_path(data_dir)).ok()?; + let st: WindowState = serde_json::from_str(&raw).ok()?; + if st.width < MIN_WIDTH || st.height < MIN_HEIGHT { + return None; + } + Some(st) +} + +fn save(data_dir: &Path, state: &WindowState) { + let _ = std::fs::create_dir_all(data_dir); + if let Ok(json) = serde_json::to_string_pretty(state) { + let _ = std::fs::write(state_path(data_dir), json); + } +} + +/// Checks whether at least a usable portion of the saved window sits on a +/// currently available monitor so its titlebar stays reachable. +fn fits_any_monitor(window: &WebviewWindow, st: &WindowState) -> bool { + let Ok(monitors) = window.available_monitors() else { + return false; + }; + if monitors.is_empty() { + return false; + } + let w_left = st.x; + let w_top = st.y; + let w_right = st.x.saturating_add(st.width as i32); + let w_bottom = st.y.saturating_add(st.height as i32); + + monitors.iter().any(|m| { + let pos = m.position(); + let size = m.size(); + let m_left = pos.x; + let m_top = pos.y; + let m_right = pos.x.saturating_add(size.width as i32); + let m_bottom = pos.y.saturating_add(size.height as i32); + // At least 80px horizontally and 40px vertically on-screen, and titlebar not above monitor top. + let overlap_x = w_right.min(m_right) - w_left.max(m_left); + let overlap_y = w_bottom.min(m_bottom) - w_top.max(m_top); + overlap_x >= 80 && overlap_y >= 40 && w_top >= m_top - 16 + }) +} + +/// Restores saved window bounds when available and visible, otherwise centers +/// the default window rather than forcing maximized on every launch. +pub(crate) fn restore(window: &WebviewWindow, data_dir: Option<&Path>) { + let saved = data_dir.and_then(load); + if let Some(st) = saved { + let _ = window.set_size(PhysicalSize::new(st.width, st.height)); + if fits_any_monitor(window, &st) { + let _ = window.set_position(PhysicalPosition::new(st.x, st.y)); + } else { + let _ = window.center(); + } + if st.maximized { + let _ = window.maximize(); + } + } else { + let _ = window.center(); + } +} + +fn capture(window: &WebviewWindow, prev: Option<&WindowState>) -> Option { + if window.is_minimized().unwrap_or(false) { + return None; + } + let maximized = window.is_maximized().unwrap_or(false); + if maximized { + // Keep the last non-maximized bounds so un-maximizing later restores cleanly. + if let Some(p) = prev { + return Some(WindowState { + maximized: true, + ..p.clone() + }); + } + } + let size = window.inner_size().ok()?; + let pos = window.outer_position().ok()?; + if size.width < MIN_WIDTH || size.height < MIN_HEIGHT { + return None; + } + Some(WindowState { + x: pos.x, + y: pos.y, + width: size.width, + height: size.height, + maximized, + }) +} + +/// Persists window bounds on move/resize (debounced) and immediately on close. +pub(crate) fn attach(window: &WebviewWindow, data_dir: PathBuf) { + let initial = load(&data_dir); + let last_state: Arc>> = Arc::new(Mutex::new(initial)); + let last_saved: Arc> = Arc::new(Mutex::new( + Instant::now().checked_sub(SAVE_DEBOUNCE).unwrap_or_else(Instant::now), + )); + let win = window.clone(); + + window.on_window_event(move |event| match event { + WindowEvent::Moved(_) | WindowEvent::Resized(_) => { + let now = Instant::now(); + let should_write = last_saved + .lock() + .map(|t| now.duration_since(*t) >= SAVE_DEBOUNCE) + .unwrap_or(false); + let prev = last_state.lock().ok().and_then(|g| g.clone()); + if let Some(st) = capture(&win, prev.as_ref()) { + if let Ok(mut g) = last_state.lock() { + *g = Some(st.clone()); + } + if should_write { + if let Ok(mut t) = last_saved.lock() { + *t = now; + } + save(&data_dir, &st); + } + } + } + WindowEvent::CloseRequested { .. } => { + let prev = last_state.lock().ok().and_then(|g| g.clone()); + if let Some(st) = capture(&win, prev.as_ref()).or(prev) { + save(&data_dir, &st); + } + } + _ => {} + }); +} diff --git a/src/App.svelte b/src/App.svelte index e671c55e..d531a4f4 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -19,13 +19,14 @@ import GlobalTooltip from './lib/components/GlobalTooltip.svelte' import PerfOverlay from './lib/components/PerfOverlay.svelte' import { loadSettings, applySettings, installZoomShortcuts } from '$lib/stores/settings.js' - import { installPlatformClass } from '$lib/platform.js' + import { installPlatformClass, installWindowStateListeners } from '$lib/platform.js' import { installClipboardBridge } from '$lib/clipboard.js' import { installShiftWheel } from '$lib/shift-wheel.js' import { installSlashFocus } from '$lib/slash-focus.js' - onMount(async () => { + onMount(() => { installPlatformClass() + const unwatchWindow = installWindowStateListeners() applySettings(loadSettings()) installZoomShortcuts() // Shift + wheel scrolls sideways in every scroll area, whatever the webview does. @@ -39,14 +40,16 @@ // Dev-only console helpers (window.__TAURI__ isn't exposed without // withGlobalTauri, which we keep off in production). if (import.meta.env.DEV) { - const { invoke } = await import('@tauri-apps/api/core') - const { refreshLicenseStatus } = await import('$lib/stores/license.js') - // @ts-expect-error - dev-only debug surface - window.__stroke = { - status: () => invoke('check_license_status'), - refresh: () => refreshLicenseStatus(), - } - console.info('[stroke] dev helpers → window.__stroke.status() / .refresh()') + void (async () => { + const { invoke } = await import('@tauri-apps/api/core') + const { refreshLicenseStatus } = await import('$lib/stores/license.js') + // @ts-expect-error - dev-only debug surface + window.__stroke = { + status: () => invoke('check_license_status'), + refresh: () => refreshLicenseStatus(), + } + console.info('[stroke] dev helpers → window.__stroke.status() / .refresh()') + })() } // Suppress Tauri's internal "Couldn't find callback id" warning. @@ -84,6 +87,7 @@ // No fade-in here: AppLockGate has not rendered anything yet. The first // complete screen reveals the page - see $lib/app-reveal.js. + return () => unwatchWindow() }) @@ -92,7 +96,7 @@ diff --git a/src/app.css b/src/app.css index d1bca431..fb6c8d86 100644 --- a/src/app.css +++ b/src/app.css @@ -25,7 +25,7 @@ background regardless of CSS - the `.dark` block below flips it to dark for every dark theme. One declaration fixes every native dropdown at zero cost. */ color-scheme: light; - --radius: 8px; + --radius: 6px; /* Boundary of a form control (input, textarea, select trigger, combobox). `--border` is the hairline/divider role and sits at ~1.3:1 against every surface, which is fine for a divider and invisible on a field: the filter @@ -60,30 +60,30 @@ too: without it the first paint (before applySettings runs) resolves every `calc(Npx * var(--app-scale))` through the fallback instead. */ --app-scale: 1; - --app-font-size: 16px; + --app-font-size: 14px; /* UI type scale, in whole pixels. applySettings() recomputes these for the active zoom rung and writes them back to the root; these are the 100% - fallbacks (16px base) that hold for the first paint before JS runs, and they + fallbacks (14px base) that hold for the first paint before JS runs, and they must stay in step with `buildTypeScale()` in src/lib/type-scale.js. Whole pixels are the point: a fractional font-size makes WebKit rasterise glyphs off the pixel grid, which is what made UI text look soft at 100%. */ - --fs-3xl: 27px; - --lh-3xl: 34px; - --fs-2xl: 23px; - --lh-2xl: 32px; - --fs-xl: 21px; - --lh-xl: 30px; - --fs-lg: 18px; - --lh-lg: 27px; - --fs-base: 16px; - --fs-15: 17px; - --fs-sm: 15px; - --fs-xs: 14px; - --fs-2xs: 13px; - --fs-3xs: 11px; - --editor-font-size: 16px; + --fs-3xl: 24px; + --lh-3xl: 30px; + --fs-2xl: 20px; + --lh-2xl: 28px; + --fs-xl: 18px; + --lh-xl: 26px; + --fs-lg: 16px; + --lh-lg: 24px; + --fs-base: 14px; + --fs-15: 15px; + --fs-sm: 13px; + --fs-xs: 12px; + --fs-2xs: 11px; + --fs-3xs: 10px; + --editor-font-size: 13px; /* 1.5 ratio - matches VS Code / Cursor's default editor line height. */ - --editor-line-height: 24px; + --editor-line-height: 20px; /* Dedicated code font for the code editors, kept independent of the app's UI / data-grid mono (`--font-mono`) - same separation VS Code makes between its "editor font" and everything else. JetBrains Mono is a true code typeface: @@ -412,11 +412,10 @@ textarea.no-focus-ring:focus-visible { outline: none; } -/* Control radius is the same on every OS - a button that reads as "ours" on macOS - has to read the same on Windows and Linux. Only the WINDOW radius still follows - the platform, because that corner is drawn against the OS compositor and a - mismatch there shows as a seam against the desktop, not as a style choice. */ -:root { --radius: 10px; --window-radius: 10px; } /* macOS Big Sur+ system radius */ +/* Control radius is the same on every OS - tight native desktop corners (6px + controls, 4px compact, 8px containers/menus). Only the WINDOW radius follows + the platform compositor. */ +:root { --radius: 6px; --window-radius: 10px; } /* macOS Big Sur+ system radius */ html[data-os="windows"] { --window-radius: 8px; } /* Windows 11 */ html[data-os="linux"] { --window-radius: 8px; } @@ -524,12 +523,11 @@ html[data-os="linux"] { --window-radius: 8px; } /* Opaque background: the window uses native OS decorations (rectangular, no transparency), so nothing shows through behind the content. */ background: var(--background); - /* Grayscale antialiasing on every platform. On macOS the default subpixel - ('auto') renders UI text noticeably heavier; 'antialiased' gives the - crisp, lighter weight the design system targets and keeps rendering - identical to the Windows/Linux overrides below. */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; + /* Native OS text rendering by default (ClearType on Windows, macOS + default smoothing, desktop fontconfig on Linux). Users who prefer thin + grayscale strokes can pick Grayscale in Settings -> Appearance. */ + -webkit-font-smoothing: auto; + -moz-osx-font-smoothing: auto; /* optimizeLegibility: proper kerning + shaping so UI text stays smooth and crisp at every zoom level (optimizeSpeed skips shaping and looks rough, especially scaled down). The perf-sensitive data grid opts back into @@ -540,28 +538,20 @@ html[data-os="linux"] { --window-radius: 8px; } a WebKit font assertion on Linux startup; text-size-adjust is a no-op on desktop. */ } - /* Windows renders the bundled variable fonts noticeably lighter than - macOS/Linux due to DirectWrite's grayscale AA. Bump weight slightly so - strokes look consistent. The system face (Segoe UI, the Windows default) - is drawn at its own weight: it is hinted for ClearType, and 430 made it - heavier than every other window on screen. */ - html[data-os="windows"]:not([data-font="apple"]) { - font-weight: 430; - } - - /* Linux/WebKitGTK: subpixel rendering is unavailable on Wayland (the compositor - can rotate/scale windows, so subpixel direction is unknown). Without it, Geist - Variable at weight 400 produces ~1px strokes that disappear on dark backgrounds. - 'antialiased' forces consistent grayscale AA regardless of the user's fontconfig - setup; bumping weight to 450 restores stroke visibility lost without subpixels. */ - html[data-os="linux"] { + /* Appearance > Font smoothing > Grayscale: opt-in thinner grayscale AA. */ + html[data-smoothing='grayscale'] { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } - /* The bump is for the bundled faces only. The System preset is the desktop's - own font (Cantarell, Noto Sans, Ubuntu), already tuned for its renderer, - and at 450 it read heavier than every other window. */ - html[data-os="linux"]:not([data-font="apple"]) { + + /* Bundled variable fonts under grayscale AA render slightly thin on Windows + and Linux. System fonts (SF Pro, Segoe UI, desktop sans) and native OS + smoothing already render at their designed weight, so never synthesize + weights on them. */ + html[data-os="windows"][data-smoothing="grayscale"]:not([data-font="apple"]) { + font-weight: 430; + } + html[data-os="linux"][data-smoothing="grayscale"]:not([data-font="apple"]) { font-weight: 450; } /* Small UI text: let the face's own kerning and contextual forms apply on @@ -716,7 +706,7 @@ html[data-os="linux"] { --window-radius: 8px; } font-optical-sizing: auto; } - html[data-os='windows'] :is( + html[data-os='windows'][data-smoothing='grayscale']:not([data-font='apple']) :is( [data-slot='context-menu-content'], [data-slot='dropdown-menu-content'], [data-slot='select-content'], @@ -729,7 +719,7 @@ html[data-os="linux"] { --window-radius: 8px; } font-weight: 430; } - html[data-os='linux'] :is( + html[data-os='linux'][data-smoothing='grayscale']:not([data-font='apple']) :is( [data-slot='context-menu-content'], [data-slot='dropdown-menu-content'], [data-slot='select-content'], @@ -740,12 +730,23 @@ html[data-os="linux"] { --window-radius: 8px; } [role='listbox'] ) { font-weight: 450; + } + + html[data-smoothing='grayscale'] :is( + [data-slot='context-menu-content'], + [data-slot='dropdown-menu-content'], + [data-slot='select-content'], + [data-slot='dialog-content'], + [data-slot='popover-content'], + [role='dialog'], + [role='menu'], + [role='listbox'] + ) { -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } - /* Appearance > Font smoothing > System: the OS's own text rendering instead - of the thin grayscale the app uses everywhere else (on a Mac, the heavier - default macOS smoothing). After every rule above that forces grayscale. */ + /* Appearance > Font smoothing > System: explicit OS default text rendering. */ html[data-smoothing='system'], html[data-smoothing='system'] :is( [data-slot='context-menu-content'], @@ -1521,27 +1522,36 @@ label, /* A full-window viewer (diagram, fullscreen chart) covers the title bar, and on macOS the OS still draws the traffic lights over its top-left corner. Its header takes the title bar's place: the same 38px row, the lights' room on - the left (they end at ~66px), and it drags the window like the bar it hides. */ + the left (they end at ~68px), and it drags the window like the bar it hides. */ html[data-os='macos'] .window-overlay-head { - min-height: 52px; - padding-left: 92px; + min-height: 38px; + padding-left: 78px; +} + +/* ── Inactive window dimming ───────────────────────────────────────────────── + Native desktop windows subtly recede their title bar, tab strip, and status + bar when unfocused so you can tell at a glance which window owns keyboard + input. Content stays at full contrast for reading side-by-side. */ +html[data-window-focused='false'] [data-studio-region='titlebar'] > *, +html[data-window-focused='false'] [data-studio-region='statusbar'] > *, +html[data-window-focused='false'] [role='tablist'] > * { + opacity: 0.65; } -/* ── Icon scale (T3-sized) ─────────────────────────────────────────────────── - Every icon one step up: 12→14, 14→16, 16→18px. Icons read as the controls - rather than as specks beside the text. One rule, so every icon in the app - moves together; rem, so it follows the zoom. Unlayered so it wins over the - `size-*` utilities on the icons themselves. */ -svg.size-3 { width: calc(14px * var(--app-scale, 1)); height: calc(14px * var(--app-scale, 1)); } -svg.size-3\.5 { width: calc(17px * var(--app-scale, 1)); height: calc(17px * var(--app-scale, 1)); } -svg.size-4 { width: calc(19px * var(--app-scale, 1)); height: calc(19px * var(--app-scale, 1)); } +/* ── Linux frameless window edge ───────────────────────────────────────────── + Without OS decorations, a dark window blends into dark windows behind it on + Linux compositors that don't draw CSD borders. A crisp 1px inner hairline + restores the physical window edge while windowed. */ +html[data-os='linux']:not([data-maximized='true']):not([data-fullscreen='true']) #app { + box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--foreground) 14%, transparent); +} /* The sidebar's tab row, moved into the macOS title bar: it fills the bar's height and the slot's width, with no padding of its own. */ .titlebar-tabs { height: 100% !important; flex: 1 1 0%; min-width: 0; padding: 0 calc(8px * var(--app-scale, 1)) 0 calc(4px * var(--app-scale, 1)) !important; } -/* The tab strip living in the title row: fills it, no surface of its own. */ -.titlebar-tabstrip > header[role="tablist"] { flex: 1 1 0%; min-width: 0; height: 100%; background: transparent; padding-left: 0.5rem; } +/* The tab strip living in the title row: fills it, no surface or bottom border of its own. */ +.titlebar-tabstrip > header[role="tablist"] { flex: 1 1 0%; min-width: 0; height: 100%; background: transparent; border-bottom: 0; padding-left: 0.5rem; } /* The new-tab hero reads in the system face, as T3 and native Mac apps do, whatever the app font: a mono headline made it read like a terminal. */ @@ -1640,20 +1650,12 @@ pre code, --chip: var(--foreground); display: inline-flex; align-items: center; - border-radius: 0.3125rem; + border-radius: var(--radius-sm); line-height: 1; letter-spacing: 0.01em; - color: color-mix(in oklch, var(--chip) 92%, var(--foreground)); - background: linear-gradient( - to bottom, - color-mix(in oklch, var(--foreground) 11%, var(--background)), - color-mix(in oklch, var(--foreground) 4%, var(--background)) - ); - box-shadow: - inset 0 0 0 1px color-mix(in oklch, var(--foreground) 26%, transparent), - inset 0 1px 0 color-mix(in oklch, white 20%, transparent), - inset 0 -1px 0 rgb(0 0 0 / 0.22), - 0 1px 2px rgb(0 0 0 / 0.3); + color: color-mix(in oklch, var(--chip) 90%, var(--foreground)); + background: color-mix(in oklch, var(--foreground) 7%, var(--background)); + box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--foreground) 16%, transparent); } .chip-gloss.chip-warning { --chip: var(--warning); } /* ── Glossy key ────────────────────────────────────────────────────────────── @@ -1664,21 +1666,12 @@ pre code, .key-gloss { --key-dot: var(--success); position: relative; - isolation: isolate; - overflow: hidden; display: inline-flex; align-items: center; - border-radius: 7px; + border-radius: var(--radius-sm); color: var(--foreground); - background: linear-gradient( - to bottom, - color-mix(in oklch, var(--foreground) 13%, var(--background)), - color-mix(in oklch, var(--foreground) 5%, var(--background)) - ); - box-shadow: - inset 0 1px 0 color-mix(in oklch, white 16%, transparent), - inset 0 0 0 1px color-mix(in oklch, var(--foreground) 12%, transparent), - 0 1px 2px rgb(0 0 0 / 0.22); + background: color-mix(in oklch, var(--foreground) 6%, var(--background)); + box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--foreground) 14%, transparent); } .key-gloss::before, .key-gloss::after { @@ -1708,81 +1701,51 @@ pre code, box-shadow: 0 0 6px color-mix(in oklch, var(--key-dot) 70%, transparent); } .chip-gloss.chip-muted { --chip: var(--muted-foreground); } -/* ── Keycap button ──────────────────────────────────────────────────────────── - The Pro chip's dark key, at button size: the same lifted fill, hairline - ring, sheen on top and shade at the foot. A press sinks the cap 1px and - flattens its drop, the way a key goes down. Built from --foreground and - --background, so it reads as a key in every theme. */ +/* ── Native control button ─────────────────────────────────────────────────── + Clean hairline button surface with instant native press tint (no bounce). */ .keycap-btn { color: var(--foreground); - background: linear-gradient( - to bottom, - color-mix(in oklch, var(--foreground) 14%, var(--background)), - color-mix(in oklch, var(--foreground) 6%, var(--background)) - ); - box-shadow: - inset 0 0 0 1px color-mix(in oklch, var(--foreground) 22%, transparent), - inset 0 1px 0 color-mix(in oklch, white 18%, transparent), - inset 0 -2px 0 rgb(0 0 0 / 0.22), - 0 1px 2px rgb(0 0 0 / 0.3); - transition: transform 100ms cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 100ms cubic-bezier(0.165, 0.84, 0.44, 1), background 150ms ease-out; + background: color-mix(in oklch, var(--foreground) 7%, var(--background)); + box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--foreground) 16%, transparent); } @media (hover: hover) and (pointer: fine) { .keycap-btn:not(:disabled):hover { - background: linear-gradient( - to bottom, - color-mix(in oklch, var(--foreground) 18%, var(--background)), - color-mix(in oklch, var(--foreground) 9%, var(--background)) - ); + background: color-mix(in oklch, var(--foreground) 11%, var(--background)); } } .keycap-btn:not(:disabled):active { - transform: translateY(1px); - box-shadow: - inset 0 0 0 1px color-mix(in oklch, var(--foreground) 22%, transparent), - inset 0 1px 0 color-mix(in oklch, white 10%, transparent), - inset 0 -1px 0 rgb(0 0 0 / 0.18); + background: color-mix(in oklch, var(--foreground) 15%, var(--background)); } .keycap-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; } .keycap-btn:disabled { color: var(--muted-foreground); opacity: 0.6; } -/* Light themes: a white key on a pale page, with a lighter shade at its foot. */ html:not(.dark) .keycap-btn { - background: linear-gradient(to bottom, var(--background), color-mix(in oklch, var(--foreground) 5%, var(--background))); - box-shadow: - inset 0 0 0 1px color-mix(in oklch, var(--foreground) 16%, transparent), - inset 0 -2px 0 rgb(0 0 0 / 0.06), - 0 1px 2px rgb(0 0 0 / 0.08); + background: var(--background); + box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--foreground) 16%, transparent); } @media (hover: hover) and (pointer: fine) { html:not(.dark) .keycap-btn:not(:disabled):hover { - background: linear-gradient(to bottom, var(--background), color-mix(in oklch, var(--foreground) 8%, var(--background))); + background: color-mix(in oklch, var(--foreground) 4%, var(--background)); } } html:not(.dark) .keycap-btn:not(:disabled):active { - box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--foreground) 16%, transparent), inset 0 1px 1px rgb(0 0 0 / 0.06); + background: color-mix(in oklch, var(--foreground) 8%, var(--background)); } -html:not(.dark) .key-well { box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.06), inset 0 0 0 1px color-mix(in oklch, var(--foreground) 12%, transparent); } -html:not(.dark) .key-well:focus-within { box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.06), 0 0 0 2px var(--ring); } -@media (prefers-reduced-motion: reduce) { - .keycap-btn { transition: background 150ms ease-out; } - .keycap-btn:not(:disabled):active { transform: none; } -} -/* A field drawn as a well: a step darker than its surface, no border, a - faint inner shade. Focus deepens it and adds the ring. */ +html:not(.dark) .key-well { box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--foreground) 14%, transparent); } +html:not(.dark) .key-well:focus-within { box-shadow: inset 0 0 0 1px var(--ring); } +/* A field drawn as a well: a step darker than its surface, hairline edge. */ .key-well { background: color-mix(in oklch, var(--foreground) 4%, var(--background)); - box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.25), inset 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent); - transition: box-shadow 150ms ease-out, background 150ms ease-out; + box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--foreground) 12%, transparent); } .key-well:focus-within { background: color-mix(in oklch, var(--foreground) 2%, var(--background)); - box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.25), 0 0 0 2px var(--ring); + box-shadow: inset 0 0 0 1px var(--ring); } .key-well[data-invalid] { - box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.25), inset 0 0 0 1px var(--destructive); + box-shadow: inset 0 0 0 1px var(--destructive); } .chip-gloss.chip-primary { --chip: var(--primary); } .mark-grain::after { @@ -1846,70 +1809,11 @@ html:not(.dark) .key-well:focus-within { box-shadow: inset 0 1px 2px rgb(0 0 0 / .ai-gen-sweep, .ai-gen-bar, .ai-gen-node, .ai-gen-line, .ai-gen-dots i { animation: none; } } -/* Press feedback, app-wide: compact controls only. Icon buttons (sized - with a size-* utility), the shared Button and menu, popover and select - triggers shrink to 0.97 while held, so a click always answers. - - Only real - - - {#if onopenlabs}{/if} + +
+ + + + {#if onopenlabs}{/if} {#if updateState} {:else} - + {/if}
diff --git a/src/lib/components/SignInScreen.svelte b/src/lib/components/SignInScreen.svelte index eb4cc889..34917db6 100644 --- a/src/lib/components/SignInScreen.svelte +++ b/src/lib/components/SignInScreen.svelte @@ -38,14 +38,14 @@
diff --git a/src/lib/components/StatusBar.svelte b/src/lib/components/StatusBar.svelte index 58f400b2..37859d4a 100644 --- a/src/lib/components/StatusBar.svelte +++ b/src/lib/components/StatusBar.svelte @@ -409,9 +409,9 @@ }) } - const iconBtn = 'inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-[color,background-color,scale] duration-[120ms] ease-[var(--ease-out)] active:scale-[0.97] hover:bg-sidebar-accent/60 hover:text-foreground' + const iconBtn = 'inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground' /** Shared label+icon button */ - const labelBtn = 'flex h-7 items-center gap-2 rounded-md px-2.5 text-ui-xs hover:bg-sidebar-accent/60 hover:text-foreground data-[state=open]:bg-sidebar-accent/60 data-[state=open]:text-foreground' + const labelBtn = 'flex h-6 items-center gap-1.5 rounded-md px-2 text-ui-2xs hover:bg-sidebar-accent/60 hover:text-foreground data-[state=open]:bg-sidebar-accent/60 data-[state=open]:text-foreground' let aiModelMenuOpen = $state(false) @@ -492,7 +492,7 @@ {/snippet}
@@ -975,7 +975,7 @@ - - -
+ {#if isLinux} +
+ + + +
+ {:else} +
+ + + +
+ {/if} {/if} diff --git a/src/lib/components/ui/button/button.svelte b/src/lib/components/ui/button/button.svelte index 9c3314c2..f6fc2ce7 100644 --- a/src/lib/components/ui/button/button.svelte +++ b/src/lib/components/ui/button/button.svelte @@ -2,14 +2,14 @@ import { cn, tv } from "$lib/utils.js"; export const buttonVariants = tv({ - base: "focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-ring aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-[var(--radius-field)] border-[length:var(--field-border-width)] border-transparent bg-clip-padding text-ui-sm font-medium active:not-aria-[haspopup]:translate-y-px [&_svg:not([class*='size-'])]:size-4 group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-[transform,scale,color,background-color,border-color,box-shadow] duration-[120ms] ease-[var(--ease-out)] outline-none select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0", + base: "focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-ring aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-[var(--radius-field)] border-[length:var(--field-border-width)] border-transparent bg-clip-padding text-ui-sm font-medium [&_svg:not([class*='size-'])]:size-4 group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap outline-none select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0", variants: { variant: { - default: "bg-primary text-primary-foreground hover:bg-primary/90 active:scale-[0.97]", - outline: "field-surface bg-transparent hover:bg-muted/50 hover:text-foreground aria-expanded:bg-muted/50 aria-expanded:text-foreground active:scale-[0.97]", - secondary: "field-surface bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-foreground active:scale-[0.97]", - ghost: "hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground active:scale-[0.97]", - destructive: "bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30 active:scale-[0.97]", + default: "bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80", + outline: "field-surface bg-transparent hover:bg-muted/50 hover:text-foreground active:bg-muted/80 aria-expanded:bg-muted/50 aria-expanded:text-foreground", + secondary: "field-surface bg-secondary text-secondary-foreground hover:bg-secondary/80 active:bg-secondary/70 aria-expanded:bg-secondary aria-expanded:text-foreground", + ghost: "hover:bg-muted hover:text-foreground active:bg-muted/80 dark:hover:bg-muted/50 dark:active:bg-muted/70 aria-expanded:bg-muted aria-expanded:text-foreground", + destructive: "bg-destructive/10 hover:bg-destructive/20 active:bg-destructive/25 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30", link: "text-primary underline-offset-4 hover:underline", }, size: { diff --git a/src/lib/components/ui/context-menu/context-menu-content.svelte b/src/lib/components/ui/context-menu/context-menu-content.svelte index 0be8bfa7..79697a13 100644 --- a/src/lib/components/ui/context-menu/context-menu-content.svelte +++ b/src/lib/components/ui/context-menu/context-menu-content.svelte @@ -28,7 +28,7 @@ // there, so a 100ms slide meant the panel was still moving into place // when the eye had already arrived: that is what reads as "the menu // lagged", and nothing about it was actually slow. - "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 border border-border/60 bg-popover text-popover-foreground min-w-36 max-w-(--menu-max-w) rounded-[10px] p-1 elevate-2-rim duration-75 z-50 overflow-x-hidden overflow-y-auto outline-none", + "data-closed:animate-out data-closed:fade-out-0 border border-border/70 bg-popover text-popover-foreground min-w-36 max-w-(--menu-max-w) rounded-lg p-1 elevate-2-rim duration-75 z-50 overflow-x-hidden overflow-y-auto outline-none", className )} {...restProps} diff --git a/src/lib/components/ui/dialog/dialog-content.svelte b/src/lib/components/ui/dialog/dialog-content.svelte index 6d6bf5bf..1570cfd9 100644 --- a/src/lib/components/ui/dialog/dialog-content.svelte +++ b/src/lib/components/ui/dialog/dialog-content.svelte @@ -57,10 +57,8 @@ data-slot="dialog-content" onCloseAutoFocus={handleCloseAutoFocus} class={cn( - "bg-background text-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 ease-out flex flex-col gap-4 rounded-2xl border border-border/60 p-5 text-ui-sm elevate-3-rim w-full max-w-[calc(100%-2rem)] h-fit fixed inset-0 m-auto z-50 outline-none", - motion === 'pop' - ? "data-closed:zoom-out-[0.96] data-open:zoom-in-[0.96] data-open:slide-in-from-bottom-1 duration-200" - : "duration-150", + "bg-background text-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 ease-out flex flex-col gap-4 rounded-xl border border-border/70 p-5 text-ui-sm elevate-3-rim w-full max-w-[calc(100%-2rem)] h-fit fixed inset-0 m-auto z-50 outline-none", + motion === 'pop' ? "duration-100" : "duration-75", className )} {...restProps} diff --git a/src/lib/components/ui/dropdown-menu/dropdown-menu-content.svelte b/src/lib/components/ui/dropdown-menu/dropdown-menu-content.svelte index 0dc928d7..3e44c58c 100644 --- a/src/lib/components/ui/dropdown-menu/dropdown-menu-content.svelte +++ b/src/lib/components/ui/dropdown-menu/dropdown-menu-content.svelte @@ -19,7 +19,7 @@ {sideOffset} {align} class={cn( - " data-closed:animate-out data-closed:fade-out-0 [transform-origin:var(--bits-floating-transform-origin)] ease-out duration-100 border border-border/60 bg-popover text-popover-foreground min-w-[max(9rem,var(--bits-dropdown-menu-anchor-width,0px))] max-w-(--menu-max-w) rounded-[10px] p-1 elevate-2-rim z-50 overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", + "data-closed:animate-out data-closed:fade-out-0 ease-out duration-75 border border-border/70 bg-popover text-popover-foreground min-w-[max(9rem,var(--bits-dropdown-menu-anchor-width,0px))] max-w-(--menu-max-w) rounded-lg p-1 elevate-2-rim z-50 overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", className )} {...restProps} diff --git a/src/lib/components/ui/popover/popover-content.svelte b/src/lib/components/ui/popover/popover-content.svelte index da777485..2879ed33 100644 --- a/src/lib/components/ui/popover/popover-content.svelte +++ b/src/lib/components/ui/popover/popover-content.svelte @@ -18,7 +18,7 @@ {sideOffset} {align} class={cn( - " data-closed:animate-out data-closed:fade-out-0 [transform-origin:var(--bits-floating-transform-origin)] ease-out duration-100 z-50 rounded-[10px] border border-border/60 bg-popover p-0 elevate-2-rim outline-none", + "data-closed:animate-out data-closed:fade-out-0 ease-out duration-75 z-50 rounded-lg border border-border/70 bg-popover p-0 elevate-2-rim outline-none", className )} {...restProps} diff --git a/src/lib/components/ui/select/select-content.svelte b/src/lib/components/ui/select/select-content.svelte index 7f644c12..295d1736 100644 --- a/src/lib/components/ui/select/select-content.svelte +++ b/src/lib/components/ui/select/select-content.svelte @@ -27,7 +27,7 @@ {preventScroll} data-slot="select-content" class={cn( - "bg-popover text-popover-foreground data-closed:animate-out data-closed:fade-out-0 [transform-origin:var(--bits-floating-transform-origin)] ease-out data-closed:duration-100 border border-border/60 min-w-36 max-w-(--menu-max-w) rounded-[10px] elevate-2-rim relative isolate z-50 overflow-x-hidden overflow-y-auto", + "bg-popover text-popover-foreground data-closed:animate-out data-closed:fade-out-0 ease-out data-closed:duration-75 border border-border/70 min-w-36 max-w-(--menu-max-w) rounded-lg elevate-2-rim relative isolate z-50 overflow-x-hidden overflow-y-auto", className )} {...restProps} diff --git a/src/lib/fonts.js b/src/lib/fonts.js index 1dee3070..2de5c9e0 100644 --- a/src/lib/fonts.js +++ b/src/lib/fonts.js @@ -106,7 +106,7 @@ export const FONT_SURFACES = /** @type {const} */ ([ /** @typedef {{ separate: boolean, ui: string, code: string, grid: string, chat: string, terminal: string, smoothing: 'grayscale' | 'system' }} FontSettings */ /** @type {FontSettings} */ -export const DEFAULT_FONT_SETTINGS = { separate: false, ui: '', code: '', grid: '', chat: '', terminal: '', smoothing: 'grayscale' } +export const DEFAULT_FONT_SETTINGS = { separate: false, ui: '', code: '', grid: '', chat: '', terminal: '', smoothing: 'system' } /** @param {unknown} v @returns {FontSettings} */ export function normalizeFontSettings(v) { @@ -119,6 +119,6 @@ export function normalizeFontSettings(v) { grid: face(o.grid), chat: face(o.chat), terminal: face(o.terminal), - smoothing: o.smoothing === 'system' ? 'system' : 'grayscale', + smoothing: o.smoothing === 'grayscale' ? 'grayscale' : 'system', } } diff --git a/src/lib/fonts.test.js b/src/lib/fonts.test.js index 7b3f6ebc..3a33b7a7 100644 --- a/src/lib/fonts.test.js +++ b/src/lib/fonts.test.js @@ -27,8 +27,9 @@ describe('facesFor', () => { describe('normalizeFontSettings', () => { it('defaults, and drops unknown faces', () => { expect(normalizeFontSettings(undefined)).toEqual(DEFAULT_FONT_SETTINGS) - const n = normalizeFontSettings({ separate: true, ui: 'inter', code: 'comic-sans', smoothing: 'system' }) - expect(n).toMatchObject({ separate: true, ui: 'inter', code: '', smoothing: 'system' }) + const n = normalizeFontSettings({ separate: true, ui: 'inter', code: 'comic-sans', smoothing: 'grayscale' }) + expect(n).toMatchObject({ separate: true, ui: 'inter', code: '', smoothing: 'grayscale' }) + expect(normalizeFontSettings({ smoothing: 'system' }).smoothing).toBe('system') }) it('stacks for known faces only', () => { expect(faceStack('menlo')).toBe('Menlo, monospace') diff --git a/src/lib/platform.js b/src/lib/platform.js index 1c7c4959..1545a55e 100644 --- a/src/lib/platform.js +++ b/src/lib/platform.js @@ -15,3 +15,68 @@ export function installPlatformClass() { if (typeof document === 'undefined') return document.documentElement.dataset.os = detectOs() } + +/** + * Syncs native window focus, maximized, and fullscreen state onto `` + * (`data-window-focused`, `data-maximized`, `data-fullscreen`) so chrome dims + * subtly when unfocused and adapts borders when maximized/windowed. + * @returns {() => void} cleanup + */ +export function installWindowStateListeners() { + if (typeof window === 'undefined' || typeof document === 'undefined') return () => {} + const root = document.documentElement + + const setFocused = (/** @type {boolean} */ focused) => { + root.dataset.windowFocused = focused ? 'true' : 'false' + } + setFocused(document.hasFocus()) + + const onFocus = () => setFocused(true) + const onBlur = () => setFocused(false) + window.addEventListener('focus', onFocus) + window.addEventListener('blur', onBlur) + + let disposed = false + /** @type {(() => void)[]} */ + const unsubs = [] + + if ('__TAURI_INTERNALS__' in window) { + void (async () => { + try { + const { getCurrentWindow } = await import('@tauri-apps/api/window') + const win = getCurrentWindow() + const syncLayout = async () => { + try { + if (disposed) return + const [max, fs] = await Promise.all([win.isMaximized(), win.isFullscreen()]) + if (disposed) return + root.dataset.maximized = max ? 'true' : 'false' + root.dataset.fullscreen = fs ? 'true' : 'false' + } catch { /* window gone */ } + } + try { + const focused = await win.isFocused() + if (!disposed) setFocused(focused) + } catch { /* fallback to document.hasFocus */ } + await syncLayout() + const offFocus = await win.onFocusChanged(({ payload }) => { + if (!disposed) setFocused(!!payload) + }) + const offResize = await win.onResized(() => void syncLayout()) + if (disposed) { + offFocus() + offResize() + } else { + unsubs.push(offFocus, offResize) + } + } catch { /* not running under Tauri */ } + })() + } + + return () => { + disposed = true + window.removeEventListener('focus', onFocus) + window.removeEventListener('blur', onBlur) + for (const off of unsubs) off() + } +} diff --git a/src/lib/smooth-scroll.js b/src/lib/smooth-scroll.js index 422cfefb..d473d972 100644 --- a/src/lib/smooth-scroll.js +++ b/src/lib/smooth-scroll.js @@ -32,6 +32,27 @@ const LINE_PX = 16 /** Ceiling on the queued distance, so spinning the wheel can't wind up seconds of travel. */ const MAX_PENDING_SCREENS = 3 +/** + * True when a wheel event looks like a smooth trackpad / Precision Touchpad + * gesture rather than a discrete notched mouse wheel. Trackpads already apply + * OS momentum and inertia, so double-easing them in JS feels floaty/laggy. + * @param {WheelEvent} e + */ +export function isTrackpadWheel(e) { + // Line-mode (1) and page-mode (2) come from notched wheels / scroll wheels. + if (e.deltaMode !== 0) return false + const ax = Math.abs(e.deltaX) + const ay = Math.abs(e.deltaY) + // Diagonal two-axis movement is a trackpad gesture. + if (ax > 0 && ay > 0) return true + const primary = ay || ax + if (primary === 0) return false + // Fractional pixel deltas or small (<40px) pixel deltas come from high-res + // trackpads / precision touchpads; classic mouse notches are 48/53/100/120px. + if (!Number.isInteger(primary) || primary < 40) return true + return false +} + /** * Wheel delta in CSS pixels. Wheel events arrive in pixels, lines or pages * depending on the browser and device; a scroller that assumes pixels moves by a @@ -189,6 +210,13 @@ export function smoothScroll(node, params = {}) { function onWheel(e) { // Ctrl+wheel is a zoom gesture (app zoom / trackpad pinch), never a scroll. if (e.ctrlKey || e.metaKey) return + // Trackpads / Precision Touchpads already have native OS momentum; never + // double-ease them in JS. + if (isTrackpadWheel(e)) { + scroller.stop() + scroller.sync() + return + } // Let a nested scroller that can actually move have the event. const inner = e.target instanceof Element ? e.target.closest('[data-native-scroll]') : null if (inner && inner !== node) return diff --git a/src/lib/smooth-scroll.test.js b/src/lib/smooth-scroll.test.js index 910787f4..0daea059 100644 --- a/src/lib/smooth-scroll.test.js +++ b/src/lib/smooth-scroll.test.js @@ -1,5 +1,5 @@ import { afterEach, describe, expect, it, vi } from 'vitest' -import { createSmoothScroll, wheelPixels } from './smooth-scroll.js' +import { createSmoothScroll, isTrackpadWheel, wheelPixels } from './smooth-scroll.js' /** * A scroll container that QUANTIZES its offset, the way a real element does. @@ -161,3 +161,17 @@ describe('createSmoothScroll - horizontal', () => { expect(el.scrollLeft).toBe(300) // scrollWidth 800 - clientWidth 500 }) }) + +describe('isTrackpadWheel', () => { + it('treats smooth small, fractional, or diagonal deltas as trackpad gestures', () => { + expect(isTrackpadWheel(wheel({ deltaY: 12 }))).toBe(true) + expect(isTrackpadWheel(wheel({ deltaY: 53.5 }))).toBe(true) + expect(isTrackpadWheel(wheel({ deltaX: 40, deltaY: 40 }))).toBe(true) + }) + + it('treats line-mode or large notched integer wheel ticks as discrete mouse wheels', () => { + expect(isTrackpadWheel(wheel({ deltaMode: 1, deltaY: 3 }))).toBe(false) + expect(isTrackpadWheel(wheel({ deltaMode: 0, deltaY: 100 }))).toBe(false) + expect(isTrackpadWheel(wheel({ deltaMode: 0, deltaY: -120 }))).toBe(false) + }) +}) diff --git a/src/lib/stores/settings.js b/src/lib/stores/settings.js index b3dd9e20..39ebc610 100644 --- a/src/lib/stores/settings.js +++ b/src/lib/stores/settings.js @@ -30,28 +30,18 @@ import { DEFAULT_EDITOR_THEME, normalizeEditorTheme } from '$lib/themes/editor-t const STORAGE_KEY = 'stroke:settings' /** - * Whether the OS should own scrolling, when the user has expressed no preference. - * - * Eased scrolling is ours: wheel deltas are accumulated and `scrollTop` is walked - * toward the target one frame at a time. That is a real improvement over a - * discrete mouse wheel, which otherwise jumps a fixed notch with no motion at all. - * - * It is the wrong thing on macOS. The OS has ALREADY applied momentum and rubber - * banding to a trackpad's deltas by the time they reach us, so easing them again - * is a second filter on top of a filter: every gesture trails its fingers by the - * length of our ease, which is exactly what "the scrolling feels laggy" describes. - * It also costs a non-passive wheel listener, which puts the main thread in front - * of every tick on the one platform whose compositor did not need it. - * - * So: OS-owned on macOS, eased elsewhere. Either way Settings → Appearance → - * Native scrolling is the override, and an explicit choice always wins over this. + * Native OS scrolling by default on every platform (macOS, Windows, Linux). + * Modern desktops and Precision Touchpads already apply native momentum and + * scroll physics; intercepting wheel events with a non-passive JS listener + * feels floaty and adds latency. Users with a notched desktop mouse who prefer + * JS easing can still opt in via Settings -> Appearance -> Native scrolling. */ export function defaultNativeScroll() { - return detectOs() === 'macos' + return true } /** One-shot marker for the migration in `loadSettings` (see there for why). */ -const SCROLL_DEFAULT_KEY = 'stroke:scroll-default-v2' +const SCROLL_DEFAULT_KEY = 'stroke:scroll-default-v3' const scrollDefaultApplied = () => { try { return localStorage.getItem(SCROLL_DEFAULT_KEY) === '1' } catch { return true } } @@ -277,7 +267,7 @@ export const FONT_PRESETS = { // UI here, each hinted for its platform's renderer. Geist, a web font, drew // thin and soft on Windows next to everything else on screen. Linux keeps // Geist, since its system UI font varies by desktop. -export const DEFAULT_FONT = IS_MAC || IS_WINDOWS ? 'apple' : 'geist' +export const DEFAULT_FONT = 'apple' /** @returns {FontId} */ function normalizeFont(/** @type {unknown} */ id) { return FONT_PRESETS[/** @type {FontId} */ (id)] ? /** @type {FontId} */ (id) : DEFAULT_FONT @@ -979,12 +969,16 @@ export function loadSettings() { if (font === 'claude' || font === 'mono') { font = DEFAULT_FONT; settingsMigrated = true } markFontGeistDefaultApplied() } - // Windows moves to its system face once, from the Geist default it had. + // Windows & Linux move to the OS system face once, from the Geist default they had. try { if (IS_WINDOWS && localStorage.getItem('stroke:font-windows-system-v1') !== '1') { if (font === 'geist') { font = DEFAULT_FONT; settingsMigrated = true } localStorage.setItem('stroke:font-windows-system-v1', '1') } + if (!IS_MAC && !IS_WINDOWS && localStorage.getItem('stroke:font-linux-system-v1') !== '1') { + if (font === 'geist') { font = DEFAULT_FONT; settingsMigrated = true } + localStorage.setItem('stroke:font-linux-system-v1', '1') + } } catch {} const iconStyle = normalizeIconStyle(parsed.iconStyle) const iconSet = normalizeIconSet(parsed.iconSet) @@ -1138,7 +1132,7 @@ function applyFontSurfaces(root, fonts, preset) { setOrClearVar(root, '--editor-font-family', pick(fonts.code)) setOrClearVar(root, '--grid-font', pick(fonts.grid)) setOrClearVar(root, '--terminal-font', pick(fonts.terminal)) - setAttr(root, 'data-smoothing', fonts.smoothing === 'system' ? 'system' : null) + setAttr(root, 'data-smoothing', fonts.smoothing === 'grayscale' ? 'grayscale' : 'system') } /** @param {HTMLElement} el @param {string} prop @param {string | null} value */ diff --git a/src/lib/type-scale.js b/src/lib/type-scale.js index ec20d612..cf070143 100644 --- a/src/lib/type-scale.js +++ b/src/lib/type-scale.js @@ -9,25 +9,20 @@ /** * Root font size at 100%, on every platform. * - * It used to be per-OS - 14px on macOS, 18px elsewhere - which shipped the same - * screen at two different sizes. 14px was also too small to hold the scale - * together: below 100% the ten steps could not stay distinct on a whole-pixel - * grid, so captions and labels collapsed onto one size. 16px keeps the smallest - * step above 9px at the lowest rung, and is the web's own default reading size. + * 14px matches native desktop UI density (DESIGN_SYSTEM.md: text-ui = 14px, + * text-ui-sm = 13px, text-ui-xs = 12px, text-ui-2xs = 11px, text-ui-3xs = 10px) + * while keeping every rung distinct on a whole-pixel grid down to 90%. */ -export const ROOT_BASE_PX = 16 +export const ROOT_BASE_PX = 14 /** * UI zoom scale (font + layout). 1 = 100%. * - * Rungs are spaced so each one lands on its own whole-pixel root at that base. - * 5% rungs could not: 5% of 16px is 0.8px, so half of them rounded onto the rung - * next door and rendered identically. The old code worked around that by - * stepping one pixel per rung INDEX, which made every label but 100% a lie - - * "150%" rendered at 136%. Coarser rungs that each mean what they say are worth - * more than ten rungs where only some of them move. + * Rungs are spaced so each one lands on its own whole-pixel root at 14px + * within 3pp of its advertised label, and the lowest rung (90%, 13px) keeps + * the smallest step at 9px with every step strictly ordered. */ -export const ZOOM_STEPS = [0.8, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2] +export const ZOOM_STEPS = [0.9, 1, 1.1, 1.2, 1.35, 1.5, 1.7, 2] /** Root size for a zoom rung. Whole pixels: WebKit rasterises fractional text soft. */ export const rootPxFor = (zoom) => Math.max(1, Math.round(ROOT_BASE_PX * zoom))